Преглед на файлове

Generalize Bed Leveling flag in EEPROM

Scott Lahteine преди 8 години
родител
ревизия
e2429a9da1
променени са 1 файла, в които са добавени 17 реда и са изтрити 16 реда
  1. 17
    16
      Marlin/configuration_store.cpp

+ 17
- 16
Marlin/configuration_store.cpp Целия файл

@@ -65,11 +65,11 @@
65 65
  *  207  M218 XYZ  hotend_offset (float x3 per additional hotend)
66 66
  *
67 67
  * Mesh bed leveling:
68
- *  219  M420 S    status (uint8)
69
- *  220            z_offset (float)
70
- *  224            mesh_num_x (uint8 as set in firmware)
71
- *  225            mesh_num_y (uint8 as set in firmware)
72
- *  226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81)
68
+ *  219  M420 S    from mbl.status (bool)
69
+ *  220            mbl.z_offset (float)
70
+ *  224            MESH_NUM_X_POINTS (uint8 as set in firmware)
71
+ *  225            MESH_NUM_Y_POINTS (uint8 as set in firmware)
72
+ *  226 G29 S3 XYZ z_values[][] (float x9, by default, up to float x 81) +288
73 73
  *
74 74
  * AUTO BED LEVELING
75 75
  *  262  M851      zprobe_zoffset (float)
@@ -263,21 +263,19 @@ void Config_Postprocess() {
263 263
     #if ENABLED(MESH_BED_LEVELING)
264 264
       // Compile time test that sizeof(mbl.z_values) is as expected
265 265
       typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1];
266
-      uint8_t mesh_num_x = MESH_NUM_X_POINTS,
267
-              mesh_num_y = MESH_NUM_Y_POINTS,
268
-              dummy_uint8 = mbl.status & _BV(MBL_STATUS_HAS_MESH_BIT);
269
-      EEPROM_WRITE(dummy_uint8);
266
+      const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
267
+      const uint8_t mesh_num_x = MESH_NUM_X_POINTS, mesh_num_y = MESH_NUM_Y_POINTS;
268
+      EEPROM_WRITE(leveling_is_on);
270 269
       EEPROM_WRITE(mbl.z_offset);
271 270
       EEPROM_WRITE(mesh_num_x);
272 271
       EEPROM_WRITE(mesh_num_y);
273 272
       EEPROM_WRITE(mbl.z_values);
274 273
     #else
275 274
       // For disabled MBL write a default mesh
276
-      uint8_t mesh_num_x = 3,
277
-              mesh_num_y = 3,
278
-              mbl_status = 0;
275
+      const bool leveling_is_on = false;
279 276
       dummy = 0.0f;
280
-      EEPROM_WRITE(mbl_status);
277
+      const uint8_t mesh_num_x = 3, mesh_num_y = 3;
278
+      EEPROM_WRITE(leveling_is_on);
281 279
       EEPROM_WRITE(dummy); // z_offset
282 280
       EEPROM_WRITE(mesh_num_x);
283 281
       EEPROM_WRITE(mesh_num_y);
@@ -498,13 +496,15 @@ void Config_Postprocess() {
498 496
       // Mesh (Manual) Bed Leveling
499 497
       //
500 498
 
501
-      uint8_t dummy_uint8, mesh_num_x, mesh_num_y;
502
-      EEPROM_READ(dummy_uint8);
499
+      bool leveling_is_on;
500
+      uint8_t mesh_num_x, mesh_num_y;
501
+      EEPROM_READ(leveling_is_on);
503 502
       EEPROM_READ(dummy);
504 503
       EEPROM_READ(mesh_num_x);
505 504
       EEPROM_READ(mesh_num_y);
505
+
506 506
       #if ENABLED(MESH_BED_LEVELING)
507
-        mbl.status = dummy_uint8;
507
+        mbl.status = leveling_is_on ? _BV(MBL_STATUS_HAS_MESH_BIT) : 0;
508 508
         mbl.z_offset = dummy;
509 509
         if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
510 510
           // EEPROM data fits the current mesh
@@ -721,6 +721,7 @@ void Config_ResetDefault() {
721 721
     LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
722 722
   #endif
723 723
 
724
+  // Applies to all MBL and ABL
724 725
   #if PLANNER_LEVELING
725 726
     reset_bed_level();
726 727
   #endif

Loading…
Отказ
Запис