EEPROM read code grouping
This commit is contained in:
parent
f2adb4b9cc
commit
946cf8b453
@ -1008,10 +1008,6 @@ void MarlinSettings::postprocess() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float dummy = 0;
|
float dummy = 0;
|
||||||
#if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || DISABLED(FWRETRACT_AUTORETRACT) || ENABLED(NO_VOLUMETRICS)
|
|
||||||
bool dummyb;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
|
working_crc = 0; // Init to 0. Accumulated by EEPROM_READ
|
||||||
|
|
||||||
_FIELD_TEST(esteppers);
|
_FIELD_TEST(esteppers);
|
||||||
@ -1023,223 +1019,241 @@ void MarlinSettings::postprocess() {
|
|||||||
//
|
//
|
||||||
// Planner Motion
|
// Planner Motion
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
// Get only the number of E stepper parameters previously stored
|
||||||
|
// Any steppers added later are set to their defaults
|
||||||
|
const uint32_t def1[] = DEFAULT_MAX_ACCELERATION;
|
||||||
|
const float def2[] = DEFAULT_AXIS_STEPS_PER_UNIT, def3[] = DEFAULT_MAX_FEEDRATE;
|
||||||
|
|
||||||
// Get only the number of E stepper parameters previously stored
|
uint32_t tmp1[XYZ + esteppers];
|
||||||
// Any steppers added later are set to their defaults
|
EEPROM_READ(tmp1); // max_acceleration_mm_per_s2
|
||||||
const uint32_t def1[] = DEFAULT_MAX_ACCELERATION;
|
EEPROM_READ(planner.settings.min_segment_time_us);
|
||||||
const float def2[] = DEFAULT_AXIS_STEPS_PER_UNIT, def3[] = DEFAULT_MAX_FEEDRATE;
|
|
||||||
|
|
||||||
uint32_t tmp1[XYZ + esteppers];
|
float tmp2[XYZ + esteppers], tmp3[XYZ + esteppers];
|
||||||
EEPROM_READ(tmp1); // max_acceleration_mm_per_s2
|
EEPROM_READ(tmp2); // axis_steps_per_mm
|
||||||
EEPROM_READ(planner.settings.min_segment_time_us);
|
EEPROM_READ(tmp3); // max_feedrate_mm_s
|
||||||
|
if (!validating) LOOP_XYZE_N(i) {
|
||||||
|
const bool in = (i < esteppers + XYZ);
|
||||||
|
planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : def1[ALIM(i, def1)];
|
||||||
|
planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : def2[ALIM(i, def2)];
|
||||||
|
planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : def3[ALIM(i, def3)];
|
||||||
|
}
|
||||||
|
|
||||||
float tmp2[XYZ + esteppers], tmp3[XYZ + esteppers];
|
EEPROM_READ(planner.settings.acceleration);
|
||||||
EEPROM_READ(tmp2); // axis_steps_per_mm
|
EEPROM_READ(planner.settings.retract_acceleration);
|
||||||
EEPROM_READ(tmp3); // max_feedrate_mm_s
|
EEPROM_READ(planner.settings.travel_acceleration);
|
||||||
if (!validating) LOOP_XYZE_N(i) {
|
EEPROM_READ(planner.settings.min_feedrate_mm_s);
|
||||||
const bool in = (i < esteppers + XYZ);
|
EEPROM_READ(planner.settings.min_travel_feedrate_mm_s);
|
||||||
planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : def1[ALIM(i, def1)];
|
|
||||||
planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : def2[ALIM(i, def2)];
|
|
||||||
planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : def3[ALIM(i, def3)];
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM_READ(planner.settings.acceleration);
|
#if HAS_CLASSIC_JERK
|
||||||
EEPROM_READ(planner.settings.retract_acceleration);
|
EEPROM_READ(planner.max_jerk);
|
||||||
EEPROM_READ(planner.settings.travel_acceleration);
|
#if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE)
|
||||||
EEPROM_READ(planner.settings.min_feedrate_mm_s);
|
EEPROM_READ(dummy);
|
||||||
EEPROM_READ(planner.settings.min_travel_feedrate_mm_s);
|
#endif
|
||||||
|
#else
|
||||||
|
for (uint8_t q = 4; q--;) EEPROM_READ(dummy);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_CLASSIC_JERK
|
#if ENABLED(JUNCTION_DEVIATION)
|
||||||
EEPROM_READ(planner.max_jerk);
|
EEPROM_READ(planner.junction_deviation_mm);
|
||||||
#if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE)
|
#else
|
||||||
EEPROM_READ(dummy);
|
EEPROM_READ(dummy);
|
||||||
#endif
|
#endif
|
||||||
#else
|
}
|
||||||
for (uint8_t q = 4; q--;) EEPROM_READ(dummy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(JUNCTION_DEVIATION)
|
|
||||||
EEPROM_READ(planner.junction_deviation_mm);
|
|
||||||
#else
|
|
||||||
EEPROM_READ(dummy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Home Offset (M206)
|
// Home Offset (M206)
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
_FIELD_TEST(home_offset);
|
||||||
|
|
||||||
_FIELD_TEST(home_offset);
|
#if !HAS_HOME_OFFSET
|
||||||
|
float home_offset[XYZ];
|
||||||
#if !HAS_HOME_OFFSET
|
#endif
|
||||||
float home_offset[XYZ];
|
EEPROM_READ(home_offset);
|
||||||
#endif
|
}
|
||||||
EEPROM_READ(home_offset);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hotend Offsets, if any
|
// Hotend Offsets, if any
|
||||||
//
|
//
|
||||||
|
{
|
||||||
#if HAS_HOTEND_OFFSET
|
#if HAS_HOTEND_OFFSET
|
||||||
// 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++)
|
||||||
LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
|
LOOP_XYZ(i) EEPROM_READ(hotend_offset[i][e]);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Global Leveling
|
// Global Leveling
|
||||||
//
|
//
|
||||||
|
{
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
EEPROM_READ(new_z_fade_height);
|
EEPROM_READ(new_z_fade_height);
|
||||||
#else
|
#else
|
||||||
EEPROM_READ(dummy);
|
EEPROM_READ(dummy);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Mesh (Manual) Bed Leveling
|
// Mesh (Manual) Bed Leveling
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
uint8_t mesh_num_x, mesh_num_y;
|
||||||
|
EEPROM_READ(dummy);
|
||||||
|
EEPROM_READ_ALWAYS(mesh_num_x);
|
||||||
|
EEPROM_READ_ALWAYS(mesh_num_y);
|
||||||
|
|
||||||
uint8_t mesh_num_x, mesh_num_y;
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
EEPROM_READ(dummy);
|
if (!validating) mbl.z_offset = dummy;
|
||||||
EEPROM_READ_ALWAYS(mesh_num_x);
|
if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
|
||||||
EEPROM_READ_ALWAYS(mesh_num_y);
|
// EEPROM data fits the current mesh
|
||||||
|
EEPROM_READ(mbl.z_values);
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
}
|
||||||
if (!validating) mbl.z_offset = dummy;
|
else {
|
||||||
if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
|
// EEPROM data is stale
|
||||||
// EEPROM data fits the current mesh
|
if (!validating) mbl.reset();
|
||||||
EEPROM_READ(mbl.z_values);
|
for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
|
||||||
}
|
}
|
||||||
else {
|
#else
|
||||||
// EEPROM data is stale
|
// MBL is disabled - skip the stored data
|
||||||
if (!validating) mbl.reset();
|
|
||||||
for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
|
for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
|
||||||
}
|
#endif // MESH_BED_LEVELING
|
||||||
#else
|
}
|
||||||
// MBL is disabled - skip the stored data
|
|
||||||
for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummy);
|
|
||||||
#endif // MESH_BED_LEVELING
|
|
||||||
|
|
||||||
_FIELD_TEST(zprobe_zoffset);
|
//
|
||||||
|
// Probe Z Offset
|
||||||
|
//
|
||||||
|
{
|
||||||
|
_FIELD_TEST(zprobe_zoffset);
|
||||||
|
|
||||||
#if !HAS_BED_PROBE
|
#if !HAS_BED_PROBE
|
||||||
float zprobe_zoffset;
|
float zprobe_zoffset;
|
||||||
#endif
|
#endif
|
||||||
EEPROM_READ(zprobe_zoffset);
|
EEPROM_READ(zprobe_zoffset);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Planar Bed Leveling matrix
|
// Planar Bed Leveling matrix
|
||||||
//
|
//
|
||||||
|
{
|
||||||
#if ABL_PLANAR
|
#if ABL_PLANAR
|
||||||
EEPROM_READ(planner.bed_level_matrix);
|
EEPROM_READ(planner.bed_level_matrix);
|
||||||
#else
|
#else
|
||||||
for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
|
for (uint8_t q = 9; q--;) EEPROM_READ(dummy);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bilinear Auto Bed Leveling
|
// Bilinear Auto Bed Leveling
|
||||||
//
|
//
|
||||||
|
{
|
||||||
uint8_t grid_max_x, grid_max_y;
|
uint8_t grid_max_x, grid_max_y;
|
||||||
EEPROM_READ_ALWAYS(grid_max_x); // 1 byte
|
EEPROM_READ_ALWAYS(grid_max_x); // 1 byte
|
||||||
EEPROM_READ_ALWAYS(grid_max_y); // 1 byte
|
EEPROM_READ_ALWAYS(grid_max_y); // 1 byte
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
|
if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) {
|
||||||
if (!validating) set_bed_leveling_enabled(false);
|
if (!validating) set_bed_leveling_enabled(false);
|
||||||
EEPROM_READ(bilinear_grid_spacing); // 2 ints
|
EEPROM_READ(bilinear_grid_spacing); // 2 ints
|
||||||
EEPROM_READ(bilinear_start); // 2 ints
|
EEPROM_READ(bilinear_start); // 2 ints
|
||||||
EEPROM_READ(z_values); // 9 to 256 floats
|
EEPROM_READ(z_values); // 9 to 256 floats
|
||||||
}
|
}
|
||||||
else // EEPROM data is stale
|
else // EEPROM data is stale
|
||||||
#endif // AUTO_BED_LEVELING_BILINEAR
|
#endif // AUTO_BED_LEVELING_BILINEAR
|
||||||
{
|
{
|
||||||
// Skip past disabled (or stale) Bilinear Grid data
|
// Skip past disabled (or stale) Bilinear Grid data
|
||||||
int bgs[2], bs[2];
|
int bgs[2], bs[2];
|
||||||
EEPROM_READ(bgs);
|
EEPROM_READ(bgs);
|
||||||
EEPROM_READ(bs);
|
EEPROM_READ(bs);
|
||||||
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
|
// Unified Bed Leveling active state
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
_FIELD_TEST(planner_leveling_active);
|
||||||
|
|
||||||
_FIELD_TEST(planner_leveling_active);
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
|
EEPROM_READ(planner.leveling_active);
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
EEPROM_READ(ubl.storage_slot);
|
||||||
EEPROM_READ(planner.leveling_active);
|
#else
|
||||||
EEPROM_READ(ubl.storage_slot);
|
bool planner_leveling_active;
|
||||||
#else
|
uint8_t ubl_storage_slot;
|
||||||
uint8_t dummyui8;
|
EEPROM_READ(planner_leveling_active);
|
||||||
EEPROM_READ(dummyb);
|
EEPROM_READ(ubl_storage_slot);
|
||||||
EEPROM_READ(dummyui8);
|
#endif
|
||||||
#endif // AUTO_BED_LEVELING_UBL
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// SERVO_ANGLES
|
// SERVO_ANGLES
|
||||||
//
|
//
|
||||||
#if !HAS_SERVOS || DISABLED(EDITABLE_SERVO_ANGLES)
|
{
|
||||||
uint16_t servo_angles[NUM_SERVOS][2];
|
#if !HAS_SERVOS || DISABLED(EDITABLE_SERVO_ANGLES)
|
||||||
#endif
|
uint16_t servo_angles[NUM_SERVOS][2];
|
||||||
EEPROM_READ(servo_angles);
|
#endif
|
||||||
|
EEPROM_READ(servo_angles);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DELTA Geometry or Dual Endstops offsets
|
// DELTA Geometry or Dual Endstops offsets
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
#if ENABLED(DELTA)
|
||||||
|
|
||||||
#if ENABLED(DELTA)
|
_FIELD_TEST(delta_height);
|
||||||
|
|
||||||
_FIELD_TEST(delta_height);
|
EEPROM_READ(delta_height); // 1 float
|
||||||
|
EEPROM_READ(delta_endstop_adj); // 3 floats
|
||||||
|
EEPROM_READ(delta_radius); // 1 float
|
||||||
|
EEPROM_READ(delta_diagonal_rod); // 1 float
|
||||||
|
EEPROM_READ(delta_segments_per_second); // 1 float
|
||||||
|
EEPROM_READ(delta_calibration_radius); // 1 float
|
||||||
|
EEPROM_READ(delta_tower_angle_trim); // 3 floats
|
||||||
|
|
||||||
EEPROM_READ(delta_height); // 1 float
|
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||||
EEPROM_READ(delta_endstop_adj); // 3 floats
|
|
||||||
EEPROM_READ(delta_radius); // 1 float
|
|
||||||
EEPROM_READ(delta_diagonal_rod); // 1 float
|
|
||||||
EEPROM_READ(delta_segments_per_second); // 1 float
|
|
||||||
EEPROM_READ(delta_calibration_radius); // 1 float
|
|
||||||
EEPROM_READ(delta_tower_angle_trim); // 3 floats
|
|
||||||
|
|
||||||
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
_FIELD_TEST(x2_endstop_adj);
|
||||||
|
|
||||||
_FIELD_TEST(x2_endstop_adj);
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||||
|
EEPROM_READ(endstops.x2_endstop_adj); // 1 float
|
||||||
|
#else
|
||||||
|
EEPROM_READ(dummy);
|
||||||
|
#endif
|
||||||
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||||
|
EEPROM_READ(endstops.y2_endstop_adj); // 1 float
|
||||||
|
#else
|
||||||
|
EEPROM_READ(dummy);
|
||||||
|
#endif
|
||||||
|
#if Z_MULTI_ENDSTOPS
|
||||||
|
EEPROM_READ(endstops.z2_endstop_adj); // 1 float
|
||||||
|
#else
|
||||||
|
EEPROM_READ(dummy);
|
||||||
|
#endif
|
||||||
|
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||||
|
EEPROM_READ(endstops.z3_endstop_adj); // 1 float
|
||||||
|
#else
|
||||||
|
EEPROM_READ(dummy);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
|
||||||
EEPROM_READ(endstops.x2_endstop_adj); // 1 float
|
|
||||||
#else
|
|
||||||
EEPROM_READ(dummy);
|
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
}
|
||||||
EEPROM_READ(endstops.y2_endstop_adj); // 1 float
|
|
||||||
#else
|
|
||||||
EEPROM_READ(dummy);
|
|
||||||
#endif
|
|
||||||
#if Z_MULTI_ENDSTOPS
|
|
||||||
EEPROM_READ(endstops.z2_endstop_adj); // 1 float
|
|
||||||
#else
|
|
||||||
EEPROM_READ(dummy);
|
|
||||||
#endif
|
|
||||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
|
||||||
EEPROM_READ(endstops.z3_endstop_adj); // 1 float
|
|
||||||
#else
|
|
||||||
EEPROM_READ(dummy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// LCD Preheat settings
|
// LCD Preheat settings
|
||||||
//
|
//
|
||||||
|
{
|
||||||
|
_FIELD_TEST(lcd_preheat_hotend_temp);
|
||||||
|
|
||||||
_FIELD_TEST(lcd_preheat_hotend_temp);
|
#if DISABLED(ULTIPANEL)
|
||||||
|
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
|
||||||
#if DISABLED(ULTIPANEL)
|
uint8_t lcd_preheat_fan_speed[2];
|
||||||
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
|
#endif
|
||||||
uint8_t lcd_preheat_fan_speed[2];
|
EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
|
||||||
#endif
|
EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
|
||||||
EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
|
EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
|
||||||
EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
|
}
|
||||||
EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hotend PID
|
// Hotend PID
|
||||||
|
Loading…
Reference in New Issue
Block a user