added support for silently upgrading from old settings record w/o accelleration parameters
This commit is contained in:
parent
bf4f75d632
commit
9b292ffe3c
47
config.c
47
config.c
@ -28,6 +28,17 @@
|
||||
|
||||
settings_t settings;
|
||||
|
||||
// Version 1 outdated settings record
|
||||
typedef struct {
|
||||
double steps_per_mm[3];
|
||||
uint8_t microsteps;
|
||||
uint8_t pulse_microseconds;
|
||||
double default_feed_rate;
|
||||
double default_seek_rate;
|
||||
uint8_t invert_mask;
|
||||
double mm_per_arc_segment;
|
||||
} settings_v1_t;
|
||||
|
||||
void reset_settings() {
|
||||
settings.steps_per_mm[0] = X_STEPS_PER_MM;
|
||||
settings.steps_per_mm[1] = Y_STEPS_PER_MM;
|
||||
@ -37,7 +48,7 @@ void reset_settings() {
|
||||
settings.default_seek_rate = RAPID_FEEDRATE;
|
||||
settings.acceleration = DEFAULT_ACCELERATION;
|
||||
settings.mm_per_arc_segment = MM_PER_ARC_SEGMENT;
|
||||
settings.invert_mask = STEPPING_INVERT_MASK;
|
||||
settings.invert_mask = DEFAULT_STEPPING_INVERT_MASK;
|
||||
settings.max_jerk = DEFAULT_MAX_JERK;
|
||||
}
|
||||
|
||||
@ -57,22 +68,33 @@ void dump_settings() {
|
||||
printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
|
||||
}
|
||||
|
||||
int read_settings() {
|
||||
// Check version-byte of eeprom
|
||||
uint8_t version = eeprom_get_char(0);
|
||||
if (version != SETTINGS_VERSION) { return(FALSE); }
|
||||
// Read settings-record and check checksum
|
||||
if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void write_settings() {
|
||||
eeprom_put_char(0, SETTINGS_VERSION);
|
||||
memcpy_to_eeprom_with_checksum(1, (char*)&settings, sizeof(settings_t));
|
||||
}
|
||||
|
||||
int read_settings() {
|
||||
// Check version-byte of eeprom
|
||||
uint8_t version = eeprom_get_char(0);
|
||||
|
||||
if (version == SETTINGS_VERSION) {
|
||||
// Read settings-record and check checksum
|
||||
if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
|
||||
return(FALSE);
|
||||
}
|
||||
} else if (version == 1) {
|
||||
// Migrate from old settings version
|
||||
if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) {
|
||||
return(FALSE);
|
||||
}
|
||||
settings.acceleration = DEFAULT_ACCELERATION;
|
||||
settings.max_jerk = DEFAULT_MAX_JERK;
|
||||
} else {
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
// A helper method to set settings from command line
|
||||
void store_setting(int parameter, double value) {
|
||||
switch(parameter) {
|
||||
@ -93,6 +115,7 @@ void store_setting(int parameter, double value) {
|
||||
printPgmString(PSTR("Stored new setting\r\n"));
|
||||
}
|
||||
|
||||
// Initialize the config subsystem
|
||||
void config_init() {
|
||||
if(read_settings()) {
|
||||
printPgmString(PSTR("'$' to dump current settings\r\n"));
|
||||
|
19
config.h
19
config.h
@ -85,37 +85,20 @@ void dump_settings();
|
||||
// A helper method to set new settings from command line
|
||||
void store_setting(int parameter, double value);
|
||||
|
||||
|
||||
// Default settings (used when resetting eeprom-settings)
|
||||
#define MICROSTEPS 8
|
||||
#define X_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
#define Y_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
#define Z_STEPS_PER_MM (94.488188976378*MICROSTEPS)
|
||||
#define STEP_PULSE_MICROSECONDS 30
|
||||
|
||||
#define MM_PER_ARC_SEGMENT 0.1
|
||||
|
||||
#define RAPID_FEEDRATE 480.0 // in millimeters per minute
|
||||
#define DEFAULT_FEEDRATE 480.0
|
||||
#define DEFAULT_ACCELERATION (DEFAULT_FEEDRATE/100.0)
|
||||
#define DEFAULT_MAX_JERK 50.0
|
||||
|
||||
// Use this line for default operation (step-pulses high)
|
||||
#define STEPPING_INVERT_MASK 0
|
||||
// Uncomment this line for inverted stepping (step-pulses low, rest high)
|
||||
// #define STEPPING_INVERT_MASK (STEP_MASK)
|
||||
// Uncomment this line to invert all step- and direction bits
|
||||
// #define STEPPING_INVERT_MASK (STEPPING_MASK)
|
||||
// Or bake your own like this adding any step-bits or directions you want to invert:
|
||||
// #define STEPPING_INVERT_MASK (STEP_MASK | (1<<X_DIRECTION_BIT) | (1<<Y_DIRECTION_BIT))
|
||||
#define DEFAULT_STEPPING_INVERT_MASK 0
|
||||
|
||||
// The temporal resolution of the acceleration management subsystem
|
||||
#define ACCELERATION_TICKS_PER_SECOND 10L
|
||||
|
||||
// Some useful constants
|
||||
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
|
||||
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
|
||||
#define STEPPING_MASK (STEP_MASK | DIRECTION_MASK) // All stepping-related bits (step/direction)
|
||||
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user