Homing direction pin bits fixed. Lite refactoring of settings.
This commit is contained in:
parent
4c6f5bec48
commit
32963289fe
5
limits.c
5
limits.c
@ -80,9 +80,8 @@ static void homing_cycle(bool x_axis, bool y_axis, bool z_axis, int8_t pos_dir,
|
|||||||
uint32_t dt_min = lround(1000000*60/(ds*homing_rate)); // Cruising (usec/step)
|
uint32_t dt_min = lround(1000000*60/(ds*homing_rate)); // Cruising (usec/step)
|
||||||
uint32_t dt = 1000000*60/MINIMUM_STEPS_PER_MINUTE; // Initial (usec/step)
|
uint32_t dt = 1000000*60/MINIMUM_STEPS_PER_MINUTE; // Initial (usec/step)
|
||||||
|
|
||||||
// Determine default out_bits set. Direction fixed and step pin inverted
|
// Set default out_bits.
|
||||||
uint8_t out_bits0 = DIRECTION_MASK;
|
uint8_t out_bits0 = settings.invert_mask;
|
||||||
out_bits0 ^= settings.invert_mask; // Apply the global step and direction invert mask
|
|
||||||
if (!pos_dir) { out_bits0 ^= DIRECTION_MASK; } // Invert bits, if negative dir.
|
if (!pos_dir) { out_bits0 ^= DIRECTION_MASK; } // Invert bits, if negative dir.
|
||||||
|
|
||||||
// Initialize stepping variables
|
// Initialize stepping variables
|
||||||
|
41
settings.c
41
settings.c
@ -75,9 +75,12 @@ typedef struct {
|
|||||||
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
#define DEFAULT_HOMING_DEBOUNCE_DELAY 100 // msec (0-65k)
|
||||||
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
|
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-255)
|
||||||
// #define DEFAULT_AUTO_START 1 // true
|
// #define DEFAULT_AUTO_START 1 // true
|
||||||
|
// #define DEFAULT_INCHES_MODE 1 // true
|
||||||
// #define DEFAULT_BLOCK_DELETE 0 // false
|
// #define DEFAULT_BLOCK_DELETE 0 // false
|
||||||
|
|
||||||
void settings_reset() {
|
void settings_reset(bool reset_all) {
|
||||||
|
// Reset all settings or only the migration settings to the new version.
|
||||||
|
if (reset_all) {
|
||||||
settings.steps_per_mm[X_AXIS] = DEFAULT_X_STEPS_PER_MM;
|
settings.steps_per_mm[X_AXIS] = DEFAULT_X_STEPS_PER_MM;
|
||||||
settings.steps_per_mm[Y_AXIS] = DEFAULT_Y_STEPS_PER_MM;
|
settings.steps_per_mm[Y_AXIS] = DEFAULT_Y_STEPS_PER_MM;
|
||||||
settings.steps_per_mm[Z_AXIS] = DEFAULT_Z_STEPS_PER_MM;
|
settings.steps_per_mm[Z_AXIS] = DEFAULT_Z_STEPS_PER_MM;
|
||||||
@ -88,6 +91,16 @@ void settings_reset() {
|
|||||||
settings.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT;
|
settings.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT;
|
||||||
settings.invert_mask = DEFAULT_STEPPING_INVERT_MASK;
|
settings.invert_mask = DEFAULT_STEPPING_INVERT_MASK;
|
||||||
settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION;
|
settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION;
|
||||||
|
}
|
||||||
|
// New settings since last version
|
||||||
|
settings.flags = 0;
|
||||||
|
// if (DEFAULT_AUTO_START) { settings.flags |= FLAG_BIT_AUTO_START; }
|
||||||
|
// if (DEFAULT_INCHES_MODE) { settings.flags |= FLAG_BIT_INCHES_MODE; }
|
||||||
|
if (DEFAULT_HOMING_ENABLE) { settings.flags |= FLAG_BIT_HOMING_ENABLE; }
|
||||||
|
settings.homing_feed_rate = DEFAULT_HOMING_FEEDRATE;
|
||||||
|
settings.homing_seek_rate = DEFAULT_HOMING_RAPID_FEEDRATE;
|
||||||
|
settings.homing_debounce_delay = DEFAULT_HOMING_DEBOUNCE_DELAY;
|
||||||
|
settings.stepper_idle_lock_time = DEFAULT_STEPPER_IDLE_LOCK_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_dump() {
|
void settings_dump() {
|
||||||
@ -107,7 +120,7 @@ void settings_dump() {
|
|||||||
printPgmString(PSTR(" (mm/min homing feed rate)\r\n$12 = ")); printFloat(settings.homing_seek_rate);
|
printPgmString(PSTR(" (mm/min homing feed rate)\r\n$12 = ")); printFloat(settings.homing_seek_rate);
|
||||||
printPgmString(PSTR(" (mm/min homing seek rate)\r\n$13 = ")); printInteger(settings.homing_debounce_delay);
|
printPgmString(PSTR(" (mm/min homing seek rate)\r\n$13 = ")); printInteger(settings.homing_debounce_delay);
|
||||||
printPgmString(PSTR(" (milliseconds homing debounce delay)\r\n$14 = ")); printInteger(settings.stepper_idle_lock_time);
|
printPgmString(PSTR(" (milliseconds homing debounce delay)\r\n$14 = ")); printInteger(settings.stepper_idle_lock_time);
|
||||||
printPgmString(PSTR(" (milliseconds stepper idle lock time)\r\n"));
|
printPgmString(PSTR(" (milliseconds stepper idle lock time)"));
|
||||||
printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
|
printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,17 +186,8 @@ int read_settings() {
|
|||||||
if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v2_v4_t)))) {
|
if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v2_v4_t)))) {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
settings_reset(false);
|
||||||
settings.flags = 0;
|
|
||||||
// if (DEFAULT_AUTO_START) { settings.flags |= FLAG_BIT_AUTO_START; }
|
|
||||||
if (DEFAULT_HOMING_ENABLE) { settings.flags |= FLAG_BIT_HOMING_ENABLE; }
|
|
||||||
settings.homing_feed_rate = DEFAULT_HOMING_FEEDRATE;
|
|
||||||
settings.homing_seek_rate = DEFAULT_HOMING_RAPID_FEEDRATE;
|
|
||||||
settings.homing_debounce_delay = DEFAULT_HOMING_DEBOUNCE_DELAY;
|
|
||||||
settings.stepper_idle_lock_time = DEFAULT_STEPPER_IDLE_LOCK_TIME;
|
|
||||||
|
|
||||||
write_settings();
|
write_settings();
|
||||||
|
|
||||||
} else if (version >= 50) {
|
} else if (version >= 50) {
|
||||||
// Developmental settings. Version numbers greater than or equal to 50 are temporary.
|
// Developmental settings. Version numbers greater than or equal to 50 are temporary.
|
||||||
// Currently, this will update the user settings to v4 and the remainder of the settings
|
// Currently, this will update the user settings to v4 and the remainder of the settings
|
||||||
@ -191,17 +195,8 @@ int read_settings() {
|
|||||||
|
|
||||||
// Grab settings regardless of error.
|
// Grab settings regardless of error.
|
||||||
memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t));
|
memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t));
|
||||||
|
settings_reset(false);
|
||||||
settings.flags = 0;
|
|
||||||
// if (DEFAULT_AUTO_START) { settings.flags |= FLAG_BIT_AUTO_START; }
|
|
||||||
if (DEFAULT_HOMING_ENABLE) { settings.flags |= FLAG_BIT_HOMING_ENABLE; }
|
|
||||||
settings.homing_feed_rate = DEFAULT_HOMING_FEEDRATE;
|
|
||||||
settings.homing_seek_rate = DEFAULT_HOMING_RAPID_FEEDRATE;
|
|
||||||
settings.homing_debounce_delay = DEFAULT_HOMING_DEBOUNCE_DELAY;
|
|
||||||
settings.stepper_idle_lock_time = DEFAULT_STEPPER_IDLE_LOCK_TIME;
|
|
||||||
|
|
||||||
write_settings();
|
write_settings();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@ -252,7 +247,7 @@ void settings_store_setting(int parameter, float value) {
|
|||||||
void settings_init() {
|
void settings_init() {
|
||||||
if(!read_settings()) {
|
if(!read_settings()) {
|
||||||
printPgmString(PSTR("Warning: Failed to read EEPROM settings. Using defaults.\r\n"));
|
printPgmString(PSTR("Warning: Failed to read EEPROM settings. Using defaults.\r\n"));
|
||||||
settings_reset();
|
settings_reset(true);
|
||||||
write_settings();
|
write_settings();
|
||||||
settings_dump();
|
settings_dump();
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,12 @@
|
|||||||
|
|
||||||
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
|
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
|
||||||
// when firmware is upgraded. Always stored in byte 0 of eeprom
|
// when firmware is upgraded. Always stored in byte 0 of eeprom
|
||||||
#define SETTINGS_VERSION 50
|
#define SETTINGS_VERSION 51
|
||||||
|
|
||||||
// Define bit flag masks in settings.flag.
|
// Define bit flag masks in settings.flag.
|
||||||
#define FLAG_BIT_HOMING_ENABLE bit(0)
|
#define FLAG_BIT_HOMING_ENABLE bit(0)
|
||||||
//#define FLAG_BIT_AUTO_START bit(1)
|
//#define FLAG_BIT_AUTO_START bit(1)
|
||||||
|
//#define FLAG_BIT_INCHES_MODE bit(2)
|
||||||
|
|
||||||
// Current global settings (persisted in EEPROM from byte 1 onwards)
|
// Current global settings (persisted in EEPROM from byte 1 onwards)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user