Browse Source

ubl_state no longer needed

Scott Lahteine 7 years ago
parent
commit
b8ddae61e2
5 changed files with 23 additions and 28 deletions
  1. 3
    3
      Marlin/Marlin_main.cpp
  2. 9
    9
      Marlin/configuration_store.cpp
  3. 2
    2
      Marlin/ubl.cpp
  4. 1
    6
      Marlin/ubl.h
  5. 8
    8
      Marlin/ubl_G29.cpp

+ 3
- 3
Marlin/Marlin_main.cpp View File

@@ -9335,7 +9335,7 @@ void quickstop_stepper() {
9335 9335
       if (parser.seen('L')) {
9336 9336
 
9337 9337
         #if ENABLED(EEPROM_SETTINGS)
9338
-          const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot;
9338
+          const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
9339 9339
           const int16_t a = settings.calc_num_meshes();
9340 9340
 
9341 9341
           if (!a) {
@@ -9350,7 +9350,7 @@ void quickstop_stepper() {
9350 9350
           }
9351 9351
 
9352 9352
           settings.load_mesh(storage_slot);
9353
-          ubl.state.storage_slot = storage_slot;
9353
+          ubl.storage_slot = storage_slot;
9354 9354
 
9355 9355
         #else
9356 9356
 
@@ -9364,7 +9364,7 @@ void quickstop_stepper() {
9364 9364
       if (parser.seen('L') || parser.seen('V')) {
9365 9365
         ubl.display_map(0);  // Currently only supports one map type
9366 9366
         SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
9367
-        SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
9367
+        SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
9368 9368
       }
9369 9369
 
9370 9370
     #endif // AUTO_BED_LEVELING_UBL

+ 9
- 9
Marlin/configuration_store.cpp View File

@@ -89,7 +89,7 @@
89 89
  *
90 90
  * AUTO_BED_LEVELING_UBL:                           6 bytes
91 91
  *  324  G29 A     planner.leveling_active          (bool)
92
- *  325  G29 S     ubl.state.storage_slot           (int8_t)
92
+ *  325  G29 S     ubl.storage_slot                 (int8_t)
93 93
  *
94 94
  * DELTA:                                           48 bytes
95 95
  *  348  M666 XYZ  endstop_adj                      (float x3)
@@ -440,7 +440,7 @@ void MarlinSettings::postprocess() {
440 440
 
441 441
     #if ENABLED(AUTO_BED_LEVELING_UBL)
442 442
       EEPROM_WRITE(planner.leveling_active);
443
-      EEPROM_WRITE(ubl.state.storage_slot);
443
+      EEPROM_WRITE(ubl.storage_slot);
444 444
     #else
445 445
       const bool ubl_active = false;
446 446
       const int8_t storage_slot = -1;
@@ -665,8 +665,8 @@ void MarlinSettings::postprocess() {
665 665
     }
666 666
 
667 667
     #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
668
-      if (ubl.state.storage_slot >= 0)
669
-        store_mesh(ubl.state.storage_slot);
668
+      if (ubl.storage_slot >= 0)
669
+        store_mesh(ubl.storage_slot);
670 670
     #endif
671 671
 
672 672
     return !eeprom_error;
@@ -829,7 +829,7 @@ void MarlinSettings::postprocess() {
829 829
 
830 830
       #if ENABLED(AUTO_BED_LEVELING_UBL)
831 831
         EEPROM_READ(planner.leveling_active);
832
-        EEPROM_READ(ubl.state.storage_slot);
832
+        EEPROM_READ(ubl.storage_slot);
833 833
       #else
834 834
         uint8_t dummyui8;
835 835
         EEPROM_READ(dummyb);
@@ -1046,10 +1046,10 @@ void MarlinSettings::postprocess() {
1046 1046
           ubl.reset();
1047 1047
         }
1048 1048
 
1049
-        if (ubl.state.storage_slot >= 0) {
1050
-          load_mesh(ubl.state.storage_slot);
1049
+        if (ubl.storage_slot >= 0) {
1050
+          load_mesh(ubl.storage_slot);
1051 1051
           #if ENABLED(EEPROM_CHITCHAT)
1052
-            SERIAL_ECHOPAIR("Mesh ", ubl.state.storage_slot);
1052
+            SERIAL_ECHOPAIR("Mesh ", ubl.storage_slot);
1053 1053
             SERIAL_ECHOLNPGM(" loaded from storage.");
1054 1054
           #endif
1055 1055
         }
@@ -1624,7 +1624,7 @@ void MarlinSettings::reset() {
1624 1624
         if (!forReplay) {
1625 1625
           SERIAL_EOL();
1626 1626
           ubl.report_state();
1627
-          SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1627
+          SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
1628 1628
           SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1629 1629
           SERIAL_ECHOLNPGM(" meshes.\n");
1630 1630
         }

+ 2
- 2
Marlin/ubl.cpp View File

@@ -61,7 +61,7 @@
61 61
     safe_delay(10);
62 62
   }
63 63
 
64
-  ubl_state unified_bed_leveling::state;
64
+  int8_t unified_bed_leveling::storage_slot;
65 65
 
66 66
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
67 67
 
@@ -82,7 +82,7 @@
82 82
 
83 83
   void unified_bed_leveling::reset() {
84 84
     set_bed_leveling_enabled(false);
85
-    state.storage_slot = -1;
85
+    storage_slot = -1;
86 86
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
87 87
       planner.set_z_fade_height(10.0);
88 88
     #endif

+ 1
- 6
Marlin/ubl.h View File

@@ -76,11 +76,6 @@
76 76
   #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
77 77
   #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
78 78
 
79
-  typedef struct {
80
-    bool active = false;
81
-    int8_t storage_slot = -1;
82
-  } ubl_state;
83
-
84 79
   class unified_bed_leveling {
85 80
     private:
86 81
 
@@ -165,7 +160,7 @@
165 160
         static void G26();
166 161
       #endif
167 162
 
168
-      static ubl_state state;
163
+      static int8_t storage_slot;
169 164
 
170 165
       static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
171 166
 

+ 8
- 8
Marlin/ubl_G29.cpp View File

@@ -423,8 +423,8 @@
423 423
     #endif // HAS_BED_PROBE
424 424
 
425 425
     if (parser.seen('P')) {
426
-      if (WITHIN(g29_phase_value, 0, 1) && state.storage_slot == -1) {
427
-        state.storage_slot = 0;
426
+      if (WITHIN(g29_phase_value, 0, 1) && storage_slot == -1) {
427
+        storage_slot = 0;
428 428
         SERIAL_PROTOCOLLNPGM("Default storage slot 0 selected.");
429 429
       }
430 430
 
@@ -603,7 +603,7 @@
603 603
     //
604 604
 
605 605
     if (parser.seen('L')) {     // Load Current Mesh Data
606
-      g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot;
606
+      g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
607 607
 
608 608
       int16_t a = settings.calc_num_meshes();
609 609
 
@@ -619,7 +619,7 @@
619 619
       }
620 620
 
621 621
       settings.load_mesh(g29_storage_slot);
622
-      state.storage_slot = g29_storage_slot;
622
+      storage_slot = g29_storage_slot;
623 623
 
624 624
       SERIAL_PROTOCOLLNPGM("Done.");
625 625
     }
@@ -629,7 +629,7 @@
629 629
     //
630 630
 
631 631
     if (parser.seen('S')) {     // Store (or Save) Current Mesh Data
632
-      g29_storage_slot = parser.has_value() ? parser.value_int() : state.storage_slot;
632
+      g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
633 633
 
634 634
       if (g29_storage_slot == -1) {                     // Special case, we are going to 'Export' the mesh to the
635 635
         SERIAL_ECHOLNPGM("G29 I 999");              // host in a form it can be reconstructed on a different machine
@@ -661,7 +661,7 @@
661 661
       }
662 662
 
663 663
       settings.store_mesh(g29_storage_slot);
664
-      state.storage_slot = g29_storage_slot;
664
+      storage_slot = g29_storage_slot;
665 665
 
666 666
       SERIAL_PROTOCOLLNPGM("Done.");
667 667
     }
@@ -1190,10 +1190,10 @@
1190 1190
   void unified_bed_leveling::g29_what_command() {
1191 1191
     report_state();
1192 1192
 
1193
-    if (state.storage_slot == -1)
1193
+    if (storage_slot == -1)
1194 1194
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1195 1195
     else {
1196
-      SERIAL_PROTOCOLPAIR("Mesh ", state.storage_slot);
1196
+      SERIAL_PROTOCOLPAIR("Mesh ", storage_slot);
1197 1197
       SERIAL_PROTOCOLPGM(" Loaded.");
1198 1198
     }
1199 1199
     SERIAL_EOL();

Loading…
Cancel
Save