Generalize Bed Leveling flag in EEPROM

2.0.x
Scott Lahteine 8 years ago
parent e42fd7813a
commit e2429a9da1

@ -65,11 +65,11 @@
* 207 M218 XYZ hotend_offset (float x3 per additional hotend) * 207 M218 XYZ hotend_offset (float x3 per additional hotend)
* *
* Mesh bed leveling: * Mesh bed leveling:
* 219 M420 S status (uint8) * 219 M420 S from mbl.status (bool)
* 220 z_offset (float) * 220 mbl.z_offset (float)
* 224 mesh_num_x (uint8 as set in firmware) * 224 MESH_NUM_X_POINTS (uint8 as set in firmware)
* 225 mesh_num_y (uint8 as set in firmware) * 225 MESH_NUM_Y_POINTS (uint8 as set in firmware)
* 226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81) * 226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81) +288
* *
* AUTO BED LEVELING * AUTO BED LEVELING
* 262 M851 zprobe_zoffset (float) * 262 M851 zprobe_zoffset (float)
@ -263,21 +263,19 @@ void Config_Postprocess() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
// Compile time test that sizeof(mbl.z_values) is as expected // Compile time test that sizeof(mbl.z_values) is as expected
typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1]; typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
uint8_t mesh_num_x = MESH_NUM_X_POINTS, const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
mesh_num_y = MESH_NUM_Y_POINTS, const uint8_t mesh_num_x = MESH_NUM_X_POINTS, mesh_num_y = MESH_NUM_Y_POINTS;
dummy_uint8 = mbl.status & _BV(MBL_STATUS_HAS_MESH_BIT); EEPROM_WRITE(leveling_is_on);
EEPROM_WRITE(dummy_uint8);
EEPROM_WRITE(mbl.z_offset); EEPROM_WRITE(mbl.z_offset);
EEPROM_WRITE(mesh_num_x); EEPROM_WRITE(mesh_num_x);
EEPROM_WRITE(mesh_num_y); EEPROM_WRITE(mesh_num_y);
EEPROM_WRITE(mbl.z_values); EEPROM_WRITE(mbl.z_values);
#else #else
// For disabled MBL write a default mesh // For disabled MBL write a default mesh
uint8_t mesh_num_x = 3, const bool leveling_is_on = false;
mesh_num_y = 3,
mbl_status = 0;
dummy = 0.0f; dummy = 0.0f;
EEPROM_WRITE(mbl_status); const uint8_t mesh_num_x = 3, mesh_num_y = 3;
EEPROM_WRITE(leveling_is_on);
EEPROM_WRITE(dummy); // z_offset EEPROM_WRITE(dummy); // z_offset
EEPROM_WRITE(mesh_num_x); EEPROM_WRITE(mesh_num_x);
EEPROM_WRITE(mesh_num_y); EEPROM_WRITE(mesh_num_y);
@ -498,13 +496,15 @@ void Config_Postprocess() {
// Mesh (Manual) Bed Leveling // Mesh (Manual) Bed Leveling
// //
uint8_t dummy_uint8, mesh_num_x, mesh_num_y; bool leveling_is_on;
EEPROM_READ(dummy_uint8); uint8_t mesh_num_x, mesh_num_y;
EEPROM_READ(leveling_is_on);
EEPROM_READ(dummy); EEPROM_READ(dummy);
EEPROM_READ(mesh_num_x); EEPROM_READ(mesh_num_x);
EEPROM_READ(mesh_num_y); EEPROM_READ(mesh_num_y);
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
mbl.status = dummy_uint8; mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
mbl.z_offset = dummy; mbl.z_offset = dummy;
if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) { if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
// EEPROM data fits the current mesh // EEPROM data fits the current mesh
@ -721,6 +721,7 @@ void Config_ResetDefault() {
LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e]; LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
#endif #endif
// Applies to all MBL and ABL
#if PLANNER_LEVELING #if PLANNER_LEVELING
reset_bed_level(); reset_bed_level();
#endif #endif

Loading…
Cancel
Save