Browse Source

Reduce UBL RAM usage by making G26/G29 optional

Bob-the-Kuhn 8 years ago
parent
commit
f3618c3337

+ 2
- 2
Marlin/G26_Mesh_Validation_Tool.cpp View File

113
    *   Y #  Y coordinate  Specify the starting location of the drawing activity.
113
    *   Y #  Y coordinate  Specify the starting location of the drawing activity.
114
    */
114
    */
115
 
115
 
116
+  extern bool g26_debug_flag;
116
   extern bool ubl_has_control_of_lcd_panel;
117
   extern bool ubl_has_control_of_lcd_panel;
117
   extern float feedrate;
118
   extern float feedrate;
118
   //extern bool relative_mode;
119
   //extern bool relative_mode;
171
 
172
 
172
   int8_t prime_flag = 0;
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
    * G26: Mesh Validation Pattern generation.
178
    * G26: Mesh Validation Pattern generation.

+ 53
- 29
Marlin/Marlin_main.cpp View File

299
 #if ENABLED(AUTO_BED_LEVELING_UBL)
299
 #if ENABLED(AUTO_BED_LEVELING_UBL)
300
   #include "UBL.h"
300
   #include "UBL.h"
301
   unified_bed_leveling ubl;
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
 #endif
309
 #endif
308
 
310
 
309
 bool Running = true;
311
 bool Running = true;
7213
    *       S[bool]   Turns leveling on or off
7215
    *       S[bool]   Turns leveling on or off
7214
    *       Z[height] Sets the Z fade height (0 or none to disable)
7216
    *       Z[height] Sets the Z fade height (0 or none to disable)
7215
    *       V[bool]   Verbose - Print the leveling grid
7217
    *       V[bool]   Verbose - Print the leveling grid
7218
+   *
7219
+   *       L[index]  Load UBL mesh from index (0 is default)
7216
    */
7220
    */
7217
   inline void gcode_M420() {
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
     if (code_seen('S')) {
7266
     if (code_seen('S')) {
7221
       to_enable = code_value_bool();
7267
       to_enable = code_value_bool();
7222
       set_bed_leveling_enabled(to_enable);
7268
       set_bed_leveling_enabled(to_enable);
7243
 
7289
 
7244
     SERIAL_ECHO_START;
7290
     SERIAL_ECHO_START;
7245
     SERIAL_ECHOLNPAIR("Bed Leveling ", new_status ? MSG_ON : MSG_OFF);
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
 #endif
7293
 #endif
7270
 
7294
 
8595
         gcode_G28();
8619
         gcode_G28();
8596
         break;
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
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8623
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
8600
                  // or provides access to the UBL System if enabled.
8624
                  // or provides access to the UBL System if enabled.
8601
           gcode_G29();
8625
           gcode_G29();

+ 0
- 6
Marlin/UBL.h View File

81
     #define MESH_X_DIST ((float(UBL_MESH_MAX_X) - float(UBL_MESH_MIN_X)) / (float(UBL_MESH_NUM_X_POINTS) - 1.0))
81
     #define MESH_X_DIST ((float(UBL_MESH_MAX_X) - float(UBL_MESH_MIN_X)) / (float(UBL_MESH_NUM_X_POINTS) - 1.0))
82
     #define MESH_Y_DIST ((float(UBL_MESH_MAX_Y) - float(UBL_MESH_MIN_Y)) / (float(UBL_MESH_NUM_Y_POINTS) - 1.0))
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
     extern float last_specified_z;
84
     extern float last_specified_z;
90
     extern float fade_scaling_factor_for_current_height;
85
     extern float fade_scaling_factor_for_current_height;
91
     extern float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
86
     extern float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
339
     }; // class unified_bed_leveling
334
     }; // class unified_bed_leveling
340
 
335
 
341
     extern unified_bed_leveling ubl;
336
     extern unified_bed_leveling ubl;
342
-    extern int ubl_eeprom_start;
343
 
337
 
344
     #define UBL_LAST_EEPROM_INDEX (E2END - sizeof(unified_bed_leveling::state))
338
     #define UBL_LAST_EEPROM_INDEX (E2END - sizeof(unified_bed_leveling::state))
345
 
339
 

+ 1
- 0
Marlin/UBL_Bed_Leveling.cpp View File

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

+ 7
- 2
Marlin/UBL_G29.cpp View File

22
 
22
 
23
 #include "MarlinConfig.h"
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
   //#include "vector_3.h"
26
   //#include "vector_3.h"
27
   //#include "qr_solve.h"
27
   //#include "qr_solve.h"
28
 
28
 
39
   void lcd_return_to_status();
39
   void lcd_return_to_status();
40
   bool lcd_clicked();
40
   bool lcd_clicked();
41
   void lcd_implementation_clear();
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
   extern float meshedit_done;
46
   extern float meshedit_done;
44
   extern long babysteps_done;
47
   extern long babysteps_done;
45
   extern float code_value_float();
48
   extern float code_value_float();
62
   #define SIZE_OF_LITTLE_RAISE 0
65
   #define SIZE_OF_LITTLE_RAISE 0
63
   #define BIG_RAISE_NOT_NEEDED 0
66
   #define BIG_RAISE_NOT_NEEDED 0
64
   extern void lcd_quick_feedback();
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
    *   G29: Unified Bed Leveling by Roxy
72
    *   G29: Unified Bed Leveling by Roxy

+ 3
- 2
Marlin/UBL_line_to_destination.cpp View File

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

+ 1
- 0
Marlin/configuration_store.cpp View File

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

Loading…
Cancel
Save