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
       if (parser.seen('L')) {
9335
       if (parser.seen('L')) {
9336
 
9336
 
9337
         #if ENABLED(EEPROM_SETTINGS)
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
           const int16_t a = settings.calc_num_meshes();
9339
           const int16_t a = settings.calc_num_meshes();
9340
 
9340
 
9341
           if (!a) {
9341
           if (!a) {
9350
           }
9350
           }
9351
 
9351
 
9352
           settings.load_mesh(storage_slot);
9352
           settings.load_mesh(storage_slot);
9353
-          ubl.state.storage_slot = storage_slot;
9353
+          ubl.storage_slot = storage_slot;
9354
 
9354
 
9355
         #else
9355
         #else
9356
 
9356
 
9364
       if (parser.seen('L') || parser.seen('V')) {
9364
       if (parser.seen('L') || parser.seen('V')) {
9365
         ubl.display_map(0);  // Currently only supports one map type
9365
         ubl.display_map(0);  // Currently only supports one map type
9366
         SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
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
     #endif // AUTO_BED_LEVELING_UBL
9370
     #endif // AUTO_BED_LEVELING_UBL

+ 9
- 9
Marlin/configuration_store.cpp View File

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

+ 2
- 2
Marlin/ubl.cpp View File

61
     safe_delay(10);
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
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
66
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
67
 
67
 
82
 
82
 
83
   void unified_bed_leveling::reset() {
83
   void unified_bed_leveling::reset() {
84
     set_bed_leveling_enabled(false);
84
     set_bed_leveling_enabled(false);
85
-    state.storage_slot = -1;
85
+    storage_slot = -1;
86
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
86
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
87
       planner.set_z_fade_height(10.0);
87
       planner.set_z_fade_height(10.0);
88
     #endif
88
     #endif

+ 1
- 6
Marlin/ubl.h View File

76
   #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
76
   #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
77
   #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
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
   class unified_bed_leveling {
79
   class unified_bed_leveling {
85
     private:
80
     private:
86
 
81
 
165
         static void G26();
160
         static void G26();
166
       #endif
161
       #endif
167
 
162
 
168
-      static ubl_state state;
163
+      static int8_t storage_slot;
169
 
164
 
170
       static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
165
       static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
171
 
166
 

+ 8
- 8
Marlin/ubl_G29.cpp View File

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

Loading…
Cancel
Save