Browse Source

UBL no longer needs ubl_state

Scott Lahteine 7 years ago
parent
commit
1344ca4b2f

+ 3
- 5
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

@@ -65,10 +65,9 @@
65 65
     safe_delay(10);
66 66
   }
67 67
 
68
-  ubl_state unified_bed_leveling::state;
68
+  int8_t unified_bed_leveling::storage_slot;
69 69
 
70
-  float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
71
-        unified_bed_leveling::last_specified_z;
70
+  float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
72 71
 
73 72
   // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
74 73
   // until determinism prevails
@@ -91,12 +90,11 @@
91 90
 
92 91
   void unified_bed_leveling::reset() {
93 92
     set_bed_leveling_enabled(false);
94
-    state.storage_slot = -1;
93
+    storage_slot = -1;
95 94
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
96 95
       planner.set_z_fade_height(10.0);
97 96
     #endif
98 97
     ZERO(z_values);
99
-    last_specified_z = -999.9;
100 98
   }
101 99
 
102 100
   void unified_bed_leveling::invalidate() {

+ 1
- 8
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -70,16 +70,9 @@ extern uint8_t ubl_cnt;
70 70
 #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
71 71
 #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
72 72
 
73
-typedef struct {
74
-  bool active = false;
75
-  int8_t storage_slot = -1;
76
-} ubl_state;
77
-
78 73
 class unified_bed_leveling {
79 74
   private:
80 75
 
81
-    static float last_specified_z;
82
-
83 76
     static int    g29_verbose_level,
84 77
                   g29_phase_value,
85 78
                   g29_repetition_cnt,
@@ -161,7 +154,7 @@ class unified_bed_leveling {
161 154
       static void G26();
162 155
     #endif
163 156
 
164
-    static ubl_state state;
157
+    static int8_t storage_slot;
165 158
 
166 159
     static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
167 160
 

+ 8
- 8
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

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

+ 3
- 3
Marlin/src/gcode/bedlevel/M420.cpp View File

@@ -51,7 +51,7 @@ void GcodeSuite::M420() {
51 51
     if (parser.seen('L')) {
52 52
 
53 53
       #if ENABLED(EEPROM_SETTINGS)
54
-        const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot;
54
+        const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
55 55
         const int16_t a = settings.calc_num_meshes();
56 56
 
57 57
         if (!a) {
@@ -66,7 +66,7 @@ void GcodeSuite::M420() {
66 66
         }
67 67
 
68 68
         settings.load_mesh(storage_slot);
69
-        ubl.state.storage_slot = storage_slot;
69
+        ubl.storage_slot = storage_slot;
70 70
 
71 71
       #else
72 72
 
@@ -80,7 +80,7 @@ void GcodeSuite::M420() {
80 80
     if (parser.seen('L') || parser.seen('V')) {
81 81
       ubl.display_map(0);  // Currently only supports one map type
82 82
       SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
83
-      SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
83
+      SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
84 84
     }
85 85
 
86 86
   #endif // AUTO_BED_LEVELING_UBL

+ 9
- 9
Marlin/src/module/configuration_store.cpp View File

@@ -89,7 +89,7 @@
89 89
  *
90 90
  * AUTO_BED_LEVELING_UBL:                           2 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
  *  344  M666 XYZ  delta_endstop_adj                (float x3)
@@ -411,7 +411,7 @@ void MarlinSettings::postprocess() {
411 411
 
412 412
     #if ENABLED(AUTO_BED_LEVELING_UBL)
413 413
       EEPROM_WRITE(planner.leveling_active);
414
-      EEPROM_WRITE(ubl.state.storage_slot);
414
+      EEPROM_WRITE(ubl.storage_slot);
415 415
     #else
416 416
       const bool ubl_active = false;
417 417
       const int8_t storage_slot = -1;
@@ -634,8 +634,8 @@ void MarlinSettings::postprocess() {
634 634
     }
635 635
 
636 636
     #if ENABLED(UBL_SAVE_ACTIVE_ON_M500)
637
-      if (ubl.state.storage_slot >= 0)
638
-        store_mesh(ubl.state.storage_slot);
637
+      if (ubl.storage_slot >= 0)
638
+        store_mesh(ubl.storage_slot);
639 639
     #endif
640 640
     EEPROM_FINISH();
641 641
     return !eeprom_error;
@@ -798,7 +798,7 @@ void MarlinSettings::postprocess() {
798 798
 
799 799
       #if ENABLED(AUTO_BED_LEVELING_UBL)
800 800
         EEPROM_READ(planner.leveling_active);
801
-        EEPROM_READ(ubl.state.storage_slot);
801
+        EEPROM_READ(ubl.storage_slot);
802 802
       #else
803 803
         uint8_t dummyui8;
804 804
         EEPROM_READ(dummyb);
@@ -1015,10 +1015,10 @@ void MarlinSettings::postprocess() {
1015 1015
           ubl.reset();
1016 1016
         }
1017 1017
 
1018
-        if (ubl.state.storage_slot >= 0) {
1019
-          load_mesh(ubl.state.storage_slot);
1018
+        if (ubl.storage_slot >= 0) {
1019
+          load_mesh(ubl.storage_slot);
1020 1020
           #if ENABLED(EEPROM_CHITCHAT)
1021
-            SERIAL_ECHOPAIR("Mesh ", ubl.state.storage_slot);
1021
+            SERIAL_ECHOPAIR("Mesh ", ubl.storage_slot);
1022 1022
             SERIAL_ECHOLNPGM(" loaded from storage.");
1023 1023
           #endif
1024 1024
         }
@@ -1570,7 +1570,7 @@ void MarlinSettings::reset() {
1570 1570
         SERIAL_EOL();
1571 1571
         ubl.report_state();
1572 1572
 
1573
-        SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1573
+        SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.storage_slot);
1574 1574
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1575 1575
         SERIAL_ECHOLNPGM(" meshes.\n");
1576 1576
       }

Loading…
Cancel
Save