Prettify some EEPROM code

master
Scott Lahteine 7 years ago
parent 64f077fd2a
commit e642a64b68

@ -723,12 +723,16 @@ void MarlinSettings::postprocess() {
float dummy = 0; float dummy = 0;
bool dummyb; bool dummyb;
working_crc = 0; //clear before reading first "real data" working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
// Number of esteppers may change // Number of esteppers may change
uint8_t esteppers; uint8_t esteppers;
EEPROM_READ(esteppers); EEPROM_READ(esteppers);
//
// Planner Motion
//
// Get only the number of E stepper parameters previously stored // Get only the number of E stepper parameters previously stored
// Any steppers added later are set to their defaults // Any steppers added later are set to their defaults
const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE; const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
@ -752,6 +756,10 @@ void MarlinSettings::postprocess() {
EEPROM_READ(planner.min_segment_time_us); EEPROM_READ(planner.min_segment_time_us);
EEPROM_READ(planner.max_jerk); EEPROM_READ(planner.max_jerk);
//
// Home Offset (M206)
//
#if !HAS_HOME_OFFSET #if !HAS_HOME_OFFSET
float home_offset[XYZ]; float home_offset[XYZ];
#endif #endif
@ -763,6 +771,10 @@ void MarlinSettings::postprocess() {
home_offset[Z_AXIS] -= DELTA_HEIGHT; home_offset[Z_AXIS] -= DELTA_HEIGHT;
#endif #endif
//
// Hotend Offsets, if any
//
#if HOTENDS > 1 #if HOTENDS > 1
// Skip hotend 0 which must be 0 // Skip hotend 0 which must be 0
for (uint8_t e = 1; e < HOTENDS; e++) for (uint8_t e = 1; e < HOTENDS; e++)
@ -846,6 +858,10 @@ void MarlinSettings::postprocess() {
for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy); for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
} }
//
// Unified Bed Leveling active state
//
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
EEPROM_READ(planner.leveling_active); EEPROM_READ(planner.leveling_active);
EEPROM_READ(ubl.storage_slot); EEPROM_READ(ubl.storage_slot);
@ -855,6 +871,10 @@ void MarlinSettings::postprocess() {
EEPROM_READ(dummyui8); EEPROM_READ(dummyui8);
#endif // AUTO_BED_LEVELING_UBL #endif // AUTO_BED_LEVELING_UBL
//
// DELTA Geometry or Dual Endstops offsets
//
#if ENABLED(DELTA) #if ENABLED(DELTA)
EEPROM_READ(delta_endstop_adj); // 3 floats EEPROM_READ(delta_endstop_adj); // 3 floats
EEPROM_READ(delta_radius); // 1 float EEPROM_READ(delta_radius); // 1 float
@ -891,19 +911,26 @@ void MarlinSettings::postprocess() {
#endif #endif
//
// LCD Preheat settings
//
#if DISABLED(ULTIPANEL) #if DISABLED(ULTIPANEL)
int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2]; int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
#endif #endif
EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
EEPROM_READ(lcd_preheat_hotend_temp); EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
EEPROM_READ(lcd_preheat_bed_temp); EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
EEPROM_READ(lcd_preheat_fan_speed);
//EEPROM_ASSERT( //EEPROM_ASSERT(
// WITHIN(lcd_preheat_fan_speed, 0, 255), // WITHIN(lcd_preheat_fan_speed, 0, 255),
// "lcd_preheat_fan_speed out of range" // "lcd_preheat_fan_speed out of range"
//); //);
//
// Hotend PID
//
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) { for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
EEPROM_READ(dummy); // Kp EEPROM_READ(dummy); // Kp
@ -927,11 +954,19 @@ void MarlinSettings::postprocess() {
for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
#endif // !PIDTEMP #endif // !PIDTEMP
//
// PID Extrusion Scaling
//
#if DISABLED(PID_EXTRUSION_SCALING) #if DISABLED(PID_EXTRUSION_SCALING)
int lpq_len; int lpq_len;
#endif #endif
EEPROM_READ(lpq_len); EEPROM_READ(lpq_len);
//
// Heated Bed PID
//
#if ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPBED)
EEPROM_READ(dummy); // bedKp EEPROM_READ(dummy); // bedKp
if (dummy != DUMMY_PID_VALUE) { if (dummy != DUMMY_PID_VALUE) {
@ -943,11 +978,19 @@ void MarlinSettings::postprocess() {
for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
#endif #endif
//
// LCD Contrast
//
#if !HAS_LCD_CONTRAST #if !HAS_LCD_CONTRAST
uint16_t lcd_contrast; uint16_t lcd_contrast;
#endif #endif
EEPROM_READ(lcd_contrast); EEPROM_READ(lcd_contrast);
//
// Firmware Retraction
//
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
EEPROM_READ(autoretract_enabled); EEPROM_READ(autoretract_enabled);
EEPROM_READ(retract_length); EEPROM_READ(retract_length);
@ -963,13 +1006,20 @@ void MarlinSettings::postprocess() {
for (uint8_t q=8; q--;) EEPROM_READ(dummy); for (uint8_t q=8; q--;) EEPROM_READ(dummy);
#endif #endif
EEPROM_READ(volumetric_enabled); //
// Volumetric & Filament Size
//
EEPROM_READ(volumetric_enabled);
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) { for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
EEPROM_READ(dummy); EEPROM_READ(dummy);
if (q < COUNT(filament_size)) filament_size[q] = dummy; if (q < COUNT(filament_size)) filament_size[q] = dummy;
} }
//
// TMC2130 Stepper Current
//
uint16_t val; uint16_t val;
#if ENABLED(HAVE_TMC2130) #if ENABLED(HAVE_TMC2130)
EEPROM_READ(val); EEPROM_READ(val);
@ -1017,7 +1067,7 @@ void MarlinSettings::postprocess() {
stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER); stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
#endif #endif
#else #else
for (uint8_t q = 0; q < 11; q++) EEPROM_READ(val); for (uint8_t q = 11; --q;) EEPROM_READ(val);
#endif #endif
// //
@ -1032,6 +1082,10 @@ void MarlinSettings::postprocess() {
EEPROM_READ(dummy); EEPROM_READ(dummy);
#endif #endif
//
// Motor Current PWM
//
#if HAS_MOTOR_CURRENT_PWM #if HAS_MOTOR_CURRENT_PWM
for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]); for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
#else #else

Loading…
Cancel
Save