瀏覽代碼

Reduce UBL RAM usage by making G26/G29 optional

Bob-the-Kuhn 8 年之前
父節點
當前提交
f3618c3337

+ 2
- 2
Marlin/G26_Mesh_Validation_Tool.cpp 查看文件

@@ -113,6 +113,7 @@
113 113
    *   Y #  Y coordinate  Specify the starting location of the drawing activity.
114 114
    */
115 115
 
116
+  extern bool g26_debug_flag;
116 117
   extern bool ubl_has_control_of_lcd_panel;
117 118
   extern float feedrate;
118 119
   //extern bool relative_mode;
@@ -171,8 +172,7 @@
171 172
 
172 173
   int8_t prime_flag = 0;
173 174
 
174
-  bool keep_heaters_on = false,
175
-       g26_debug_flag = false;
175
+  bool keep_heaters_on = false;
176 176
 
177 177
   /**
178 178
    * G26: Mesh Validation Pattern generation.

+ 53
- 29
Marlin/Marlin_main.cpp 查看文件

@@ -299,11 +299,13 @@
299 299
 #if ENABLED(AUTO_BED_LEVELING_UBL)
300 300
   #include "UBL.h"
301 301
   unified_bed_leveling ubl;
302
-#define UBL_MESH_VALID !(   z_values[0][0] == z_values[0][1] && z_values[0][1] == z_values[0][2] \
303
-                         && z_values[1][0] == z_values[1][1] && z_values[1][1] == z_values[1][2] \
304
-                         && z_values[2][0] == z_values[2][1] && z_values[2][1] == z_values[2][2] \
305
-                         && z_values[0][0] == 0 && z_values[1][0] == 0 && z_values[2][0] == 0    \
306
-                         || isnan(z_values[0][0]))
302
+  #define UBL_MESH_VALID !( ( z_values[0][0] == z_values[0][1] && z_values[0][1] == z_values[0][2] \
303
+                           && z_values[1][0] == z_values[1][1] && z_values[1][1] == z_values[1][2] \
304
+                           && z_values[2][0] == z_values[2][1] && z_values[2][1] == z_values[2][2] \
305
+                           && z_values[0][0] == 0 && z_values[1][0] == 0 && z_values[2][0] == 0 )  \
306
+                           || isnan(z_values[0][0]))
307
+  extern bool g26_debug_flag;
308
+  extern int ubl_eeprom_start;
307 309
 #endif
308 310
 
309 311
 bool Running = true;
@@ -7213,10 +7215,54 @@ void quickstop_stepper() {
7213 7215
    *       S[bool]   Turns leveling on or off
7214 7216
    *       Z[height] Sets the Z fade height (0 or none to disable)
7215 7217
    *       V[bool]   Verbose - Print the leveling grid
7218
+   *
7219
+   *       L[index]  Load UBL mesh from index (0 is default)
7216 7220
    */
7217 7221
   inline void gcode_M420() {
7218
-    bool to_enable = false;
7219 7222
 
7223
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
7224
+      // L to load a mesh from the EEPROM
7225
+      if (code_seen('L')) {
7226
+        const int8_t storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
7227
+        const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(z_values);
7228
+        if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
7229
+          SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
7230
+          return;
7231
+        }
7232
+        ubl.load_mesh(Storage_Slot);
7233
+        ubl.state.eeprom_storage_slot = Storage_Slot;
7234
+        if (Storage_Slot != ubl.state.eeprom_storage_slot)
7235
+          ubl.store_state();
7236
+        ubl.display_map(0);  // Right now, we only support one type of map
7237
+        SERIAL_ECHOLNPAIR("UBL_MESH_VALID =  ", UBL_MESH_VALID);
7238
+        SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
7239
+      }
7240
+    #endif // AUTO_BED_LEVELING_UBL
7241
+
7242
+    // V to print the matrix or mesh
7243
+    if (code_seen('V')) {
7244
+      #if ABL_PLANAR
7245
+        planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
7246
+      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7247
+        if (bilinear_grid_spacing[X_AXIS]) {
7248
+          print_bilinear_leveling_grid();
7249
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7250
+            bed_level_virt_print();
7251
+          #endif
7252
+        }
7253
+      #elif ENABLED(AUTO_BED_LEVELING_UBL)
7254
+        ubl.display_map(0);  // Currently only supports one map type
7255
+        SERIAL_ECHOLNPAIR("UBL_MESH_VALID =  ", UBL_MESH_VALID);
7256
+        SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
7257
+      #elif ENABLED(MESH_BED_LEVELING)
7258
+        if (mbl.has_mesh()) {
7259
+          SERIAL_ECHOLNPGM("Mesh Bed Level data:");
7260
+          mbl_mesh_report();
7261
+        }
7262
+      #endif
7263
+    }
7264
+
7265
+    bool to_enable = false;
7220 7266
     if (code_seen('S')) {
7221 7267
       to_enable = code_value_bool();
7222 7268
       set_bed_leveling_enabled(to_enable);
@@ -7243,28 +7289,6 @@ void quickstop_stepper() {
7243 7289
 
7244 7290
     SERIAL_ECHO_START;
7245 7291
     SERIAL_ECHOLNPAIR("Bed Leveling ", new_status ? MSG_ON : MSG_OFF);
7246
-
7247
-    // V to print the matrix or mesh
7248
-    if (code_seen('V')) {
7249
-      #if ABL_PLANAR
7250
-        planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
7251
-      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7252
-        if (bilinear_grid_spacing[X_AXIS]) {
7253
-          print_bilinear_leveling_grid();
7254
-          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7255
-            bed_level_virt_print();
7256
-          #endif
7257
-        }
7258
-      #elif ENABLED(AUTO_BED_LEVELING_UBL)
7259
-        ubl.display_map(0);  // Right now, we only support one type of map
7260
-      #elif ENABLED(MESH_BED_LEVELING)
7261
-        if (mbl.has_mesh()) {
7262
-          SERIAL_ECHOLNPGM("Mesh Bed Level data:");
7263
-          mbl_mesh_report();
7264
-        }
7265
-      #endif
7266
-    }
7267
-
7268 7292
   }
7269 7293
 #endif
7270 7294
 
@@ -8595,7 +8619,7 @@ void process_next_command() {
8595 8619
         gcode_G28();
8596 8620
         break;
8597 8621
 
8598
-      #if PLANNER_LEVELING
8622
+      #if PLANNER_LEVELING && !ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
8599 8623
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8600 8624
                  // or provides access to the UBL System if enabled.
8601 8625
           gcode_G29();

+ 0
- 6
Marlin/UBL.h 查看文件

@@ -81,11 +81,6 @@
81 81
     #define MESH_X_DIST ((float(UBL_MESH_MAX_X) - float(UBL_MESH_MIN_X)) / (float(UBL_MESH_NUM_X_POINTS) - 1.0))
82 82
     #define MESH_Y_DIST ((float(UBL_MESH_MAX_Y) - float(UBL_MESH_MIN_Y)) / (float(UBL_MESH_NUM_Y_POINTS) - 1.0))
83 83
 
84
-    #if ENABLED(UBL_MESH_EDIT_ENABLED)
85
-      extern bool g26_debug_flag;
86
-    #else
87
-      constexpr bool g26_debug_flag = false;
88
-    #endif
89 84
     extern float last_specified_z;
90 85
     extern float fade_scaling_factor_for_current_height;
91 86
     extern float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
@@ -339,7 +334,6 @@
339 334
     }; // class unified_bed_leveling
340 335
 
341 336
     extern unified_bed_leveling ubl;
342
-    extern int ubl_eeprom_start;
343 337
 
344 338
     #define UBL_LAST_EEPROM_INDEX (E2END - sizeof(unified_bed_leveling::state))
345 339
 

+ 1
- 0
Marlin/UBL_Bed_Leveling.cpp 查看文件

@@ -27,6 +27,7 @@
27 27
 
28 28
   #include "UBL.h"
29 29
   #include "hex_print_routines.h"
30
+  extern int ubl_eeprom_start;
30 31
 
31 32
   /**
32 33
    * These support functions allow the use of large bit arrays of flags that take very

+ 7
- 2
Marlin/UBL_G29.cpp 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "MarlinConfig.h"
24 24
 
25
-#if ENABLED(AUTO_BED_LEVELING_UBL)
25
+#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
26 26
   //#include "vector_3.h"
27 27
   //#include "qr_solve.h"
28 28
 
@@ -39,7 +39,10 @@
39 39
   void lcd_return_to_status();
40 40
   bool lcd_clicked();
41 41
   void lcd_implementation_clear();
42
-
42
+  void lcd_mesh_edit_setup(float initial);
43
+  float lcd_mesh_edit();
44
+  void lcd_z_offset_edit_setup(float);
45
+  float lcd_z_offset_edit();
43 46
   extern float meshedit_done;
44 47
   extern long babysteps_done;
45 48
   extern float code_value_float();
@@ -62,6 +65,8 @@
62 65
   #define SIZE_OF_LITTLE_RAISE 0
63 66
   #define BIG_RAISE_NOT_NEEDED 0
64 67
   extern void lcd_quick_feedback();
68
+  extern int ubl_eeprom_start;
69
+  extern volatile int ubl_encoderDiff; // This is volatile because it is getting changed at interrupt time.
65 70
 
66 71
   /**
67 72
    *   G29: Unified Bed Leveling by Roxy

+ 3
- 2
Marlin/UBL_line_to_destination.cpp 查看文件

@@ -31,7 +31,8 @@
31 31
 
32 32
   extern float destination[XYZE];
33 33
   extern void set_current_to_destination();
34
-
34
+  extern float destination[];
35
+  bool g26_debug_flag = false;
35 36
   void debug_current_and_destination(char *title) {
36 37
 
37 38
     // if the title message starts with a '!' it is so important, we are going to
@@ -314,7 +315,7 @@
314 315
          * because part of the Mesh is undefined and we don't have the
315 316
          * information we need to complete the height correction.
316 317
          */
317
-        if (isnan(z0)) z0 = 0.0;     
318
+        if (isnan(z0)) z0 = 0.0;
318 319
 
319 320
         const float y = LOGICAL_Y_POSITION(mesh_index_to_y_location[current_yi]);
320 321
 

+ 1
- 0
Marlin/configuration_store.cpp 查看文件

@@ -166,6 +166,7 @@
166 166
 
167 167
 #if ENABLED(AUTO_BED_LEVELING_UBL)
168 168
   #include "UBL.h"
169
+  int ubl_eeprom_start = -1;
169 170
 #endif
170 171
 
171 172
 #if ENABLED(ABL_BILINEAR_SUBDIVISION)

Loading…
取消
儲存