Browse Source

Further repairs to UBL, comments, spacing

Scott Lahteine 8 years ago
parent
commit
9e4bd6b3b5

+ 22
- 27
Marlin/G26_Mesh_Validation_Tool.cpp View File

38
 
38
 
39
   #define EXTRUSION_MULTIPLIER 1.0    // This is too much clutter for the main Configuration.h file  But
39
   #define EXTRUSION_MULTIPLIER 1.0    // This is too much clutter for the main Configuration.h file  But
40
   #define RETRACTION_MULTIPLIER 1.0   // some user have expressed an interest in being able to customize
40
   #define RETRACTION_MULTIPLIER 1.0   // some user have expressed an interest in being able to customize
41
-  #define NOZZLE 0.3                  // these numbers for thier printer so they don't need to type all
41
+  #define NOZZLE 0.3                  // these numbers for their printer so they don't need to type all
42
   #define FILAMENT 1.75               // the options every time they do a Mesh Validation Print.
42
   #define FILAMENT 1.75               // the options every time they do a Mesh Validation Print.
43
   #define LAYER_HEIGHT 0.2
43
   #define LAYER_HEIGHT 0.2
44
   #define PRIME_LENGTH 10.0           // So, we put these number in an easy to find and change place.
44
   #define PRIME_LENGTH 10.0           // So, we put these number in an easy to find and change place.
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;
117
-  extern bool ubl_has_control_of_lcd_panel;
118
   extern float feedrate;
116
   extern float feedrate;
119
-  //extern bool relative_mode;
120
   extern Planner planner;
117
   extern Planner planner;
121
   //#if ENABLED(ULTRA_LCD)
118
   //#if ENABLED(ULTRA_LCD)
122
     extern char lcd_status_message[];
119
     extern char lcd_status_message[];
197
       set_current_to_destination();
194
       set_current_to_destination();
198
     }
195
     }
199
 
196
 
200
-    ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
197
+    ubl.has_control_of_lcd_panel = true; // Take control of the LCD Panel!
201
     if (turn_on_heaters())     // Turn on the heaters, leave the command if anything
198
     if (turn_on_heaters())     // Turn on the heaters, leave the command if anything
202
       goto LEAVE;              // has gone wrong.
199
       goto LEAVE;              // has gone wrong.
203
 
200
 
204
-    axis_relative_modes[E_AXIS] = false;    // Get things setup so we can take control of the
205
-    //relative_mode = false;                  // planner and stepper motors!
206
     current_position[E_AXIS] = 0.0;
201
     current_position[E_AXIS] = 0.0;
207
     sync_plan_position_e();
202
     sync_plan_position_e();
208
 
203
 
232
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
227
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
233
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
228
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
234
 
229
 
235
-    ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
230
+    ubl.has_control_of_lcd_panel = true; // Take control of the LCD Panel!
236
     //debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
231
     //debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
237
 
232
 
238
     /**
233
     /**
292
         xi = location.x_index;  // Just to shrink the next few lines and make them easier to understand
287
         xi = location.x_index;  // Just to shrink the next few lines and make them easier to understand
293
         yi = location.y_index;
288
         yi = location.y_index;
294
 
289
 
295
-        if (g26_debug_flag) {
290
+        if (ubl.g26_debug_flag) {
296
           SERIAL_ECHOPAIR("   Doing circle at: (xi=", xi);
291
           SERIAL_ECHOPAIR("   Doing circle at: (xi=", xi);
297
           SERIAL_ECHOPAIR(", yi=", yi);
292
           SERIAL_ECHOPAIR(", yi=", yi);
298
           SERIAL_CHAR(')');
293
           SERIAL_CHAR(')');
346
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
341
             ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
347
           #endif
342
           #endif
348
 
343
 
349
-          //if (g26_debug_flag) {
344
+          //if (ubl.g26_debug_flag) {
350
           //  char ccc, *cptr, seg_msg[50], seg_num[10];
345
           //  char ccc, *cptr, seg_msg[50], seg_num[10];
351
           //  strcpy(seg_msg, "   segment: ");
346
           //  strcpy(seg_msg, "   segment: ");
352
           //  strcpy(seg_num, "    \n");
347
           //  strcpy(seg_num, "    \n");
364
         //if (lcd_init_counter > 10) {
359
         //if (lcd_init_counter > 10) {
365
         //  lcd_init_counter = 0;
360
         //  lcd_init_counter = 0;
366
         //  lcd_init(); // Some people's LCD Displays are locking up.  This might help them
361
         //  lcd_init(); // Some people's LCD Displays are locking up.  This might help them
367
-        //  ubl_has_control_of_lcd_panel = true;     // Make sure UBL still is controlling the LCD Panel
362
+        //  ubl.has_control_of_lcd_panel = true;     // Make sure UBL still is controlling the LCD Panel
368
         //}
363
         //}
369
 
364
 
370
         //debug_current_and_destination((char*)"Looking for lines to connect.");
365
         //debug_current_and_destination((char*)"Looking for lines to connect.");
394
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
389
     move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Move back to the starting position
395
     //debug_current_and_destination((char*)"done doing X/Y move.");
390
     //debug_current_and_destination((char*)"done doing X/Y move.");
396
 
391
 
397
-    ubl_has_control_of_lcd_panel = false;     // Give back control of the LCD Panel!
392
+    ubl.has_control_of_lcd_panel = false;     // Give back control of the LCD Panel!
398
 
393
 
399
     if (!keep_heaters_on) {
394
     if (!keep_heaters_on) {
400
       #if HAS_TEMP_BED
395
       #if HAS_TEMP_BED
479
               ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
474
               ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
480
               ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
475
               ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
481
 
476
 
482
-              if (g26_debug_flag) {
477
+              if (ubl.g26_debug_flag) {
483
                 SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
478
                 SERIAL_ECHOPAIR(" Connecting with horizontal line (sx=", sx);
484
                 SERIAL_ECHOPAIR(", sy=", sy);
479
                 SERIAL_ECHOPAIR(", sy=", sy);
485
                 SERIAL_ECHOPAIR(") -> (ex=", ex);
480
                 SERIAL_ECHOPAIR(") -> (ex=", ex);
516
                 ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
511
                 ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
517
                 ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
512
                 ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
518
 
513
 
519
-                if (g26_debug_flag) {
514
+                if (ubl.g26_debug_flag) {
520
                   SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
515
                   SERIAL_ECHOPAIR(" Connecting with vertical line (sx=", sx);
521
                   SERIAL_ECHOPAIR(", sy=", sy);
516
                   SERIAL_ECHOPAIR(", sy=", sy);
522
                   SERIAL_ECHOPAIR(") -> (ex=", ex);
517
                   SERIAL_ECHOPAIR(") -> (ex=", ex);
541
 
536
 
542
     bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
537
     bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
543
 
538
 
544
-    //if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to()  has_xy_component:", (int)has_xy_component);
539
+    //if (ubl.g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to()  has_xy_component:", (int)has_xy_component);
545
 
540
 
546
     if (z != last_z) {
541
     if (z != last_z) {
547
-      //if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to()  changing Z to ", (int)z);
542
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to()  changing Z to ", (int)z);
548
 
543
 
549
       last_z = z;
544
       last_z = z;
550
       feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
545
       feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
559
       stepper.synchronize();
554
       stepper.synchronize();
560
       set_destination_to_current();
555
       set_destination_to_current();
561
 
556
 
562
-      //if (g26_debug_flag) debug_current_and_destination((char*)" in move_to() done with Z move");
557
+      //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() done with Z move");
563
     }
558
     }
564
 
559
 
565
     // Check if X or Y is involved in the movement.
560
     // Check if X or Y is involved in the movement.
566
     // Yes: a 'normal' movement. No: a retract() or un_retract()
561
     // Yes: a 'normal' movement. No: a retract() or un_retract()
567
     feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
562
     feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
568
 
563
 
569
-    if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
564
+    if (ubl.g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
570
 
565
 
571
     destination[X_AXIS] = x;
566
     destination[X_AXIS] = x;
572
     destination[Y_AXIS] = y;
567
     destination[Y_AXIS] = y;
573
     destination[E_AXIS] += e_delta;
568
     destination[E_AXIS] += e_delta;
574
 
569
 
575
-    //if (g26_debug_flag) debug_current_and_destination((char*)" in move_to() doing last move");
570
+    //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() doing last move");
576
 
571
 
577
     ubl_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
572
     ubl_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
578
 
573
 
579
-    //if (g26_debug_flag) debug_current_and_destination((char*)" in move_to() after last move");
574
+    //if (ubl.g26_debug_flag) debug_current_and_destination((char*)" in move_to() after last move");
580
 
575
 
581
     stepper.synchronize();
576
     stepper.synchronize();
582
     set_destination_to_current();
577
     set_destination_to_current();
586
   void retract_filament() {
581
   void retract_filament() {
587
     if (!g26_retracted) { // Only retract if we are not already retracted!
582
     if (!g26_retracted) { // Only retract if we are not already retracted!
588
       g26_retracted = true;
583
       g26_retracted = true;
589
-      //if (g26_debug_flag) SERIAL_ECHOLNPGM(" Decided to do retract.");
584
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM(" Decided to do retract.");
590
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], -1.0 * retraction_multiplier);
585
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], -1.0 * retraction_multiplier);
591
-      //if (g26_debug_flag) SERIAL_ECHOLNPGM(" Retraction done.");
586
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM(" Retraction done.");
592
     }
587
     }
593
   }
588
   }
594
 
589
 
596
     if (g26_retracted) { // Only un-retract if we are retracted.
591
     if (g26_retracted) { // Only un-retract if we are retracted.
597
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * retraction_multiplier);
592
       move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * retraction_multiplier);
598
       g26_retracted = false;
593
       g26_retracted = false;
599
-      //if (g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
594
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
600
     }
595
     }
601
   }
596
   }
602
 
597
 
633
     // On very small lines we don't do the optimization because it just isn't worth it.
628
     // On very small lines we don't do the optimization because it just isn't worth it.
634
     //
629
     //
635
     if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < abs(line_length)) {
630
     if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < abs(line_length)) {
636
-      //if (g26_debug_flag) SERIAL_ECHOLNPGM("  Reversing start and end of print_line_from_here_to_there()");
631
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM("  Reversing start and end of print_line_from_here_to_there()");
637
       print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
632
       print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
638
       return;
633
       return;
639
     }
634
     }
642
 
637
 
643
     if (dist_start > 2.0) {
638
     if (dist_start > 2.0) {
644
       retract_filament();
639
       retract_filament();
645
-      //if (g26_debug_flag) SERIAL_ECHOLNPGM("  filament retracted.");
640
+      //if (ubl.g26_debug_flag) SERIAL_ECHOLNPGM("  filament retracted.");
646
     }
641
     }
647
     move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
642
     move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
648
 
643
 
650
 
645
 
651
     un_retract_filament();
646
     un_retract_filament();
652
 
647
 
653
-    //if (g26_debug_flag) {
648
+    //if (ubl.g26_debug_flag) {
654
     //  SERIAL_ECHOLNPGM("  doing printing move.");
649
     //  SERIAL_ECHOLNPGM("  doing printing move.");
655
     //  debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
650
     //  debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
656
     //}
651
     //}
810
           lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
805
           lcd_setstatuspgm(PSTR("G26 Heating Bed."), 99);
811
           lcd_quick_feedback();
806
           lcd_quick_feedback();
812
       #endif
807
       #endif
813
-          ubl_has_control_of_lcd_panel = true;
808
+          ubl.has_control_of_lcd_panel = true;
814
           thermalManager.setTargetBed(bed_temp);
809
           thermalManager.setTargetBed(bed_temp);
815
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
810
           while (abs(thermalManager.degBed() - bed_temp) > 3) {
816
             if (ubl_lcd_clicked()) return exit_from_g26();
811
             if (ubl_lcd_clicked()) return exit_from_g26();

+ 2
- 2
Marlin/M100_Free_Mem_Chk.cpp View File

76
       // We want to start and end the dump on a nice 16 byte boundry even though
76
       // We want to start and end the dump on a nice 16 byte boundry even though
77
       // the values we are using are not 16 byte aligned.
77
       // the values we are using are not 16 byte aligned.
78
       //
78
       //
79
-      SERIAL_ECHOPAIR("\nbss_end : ", hex_word((uint16_t)ptr));
79
+      SERIAL_ECHOPAIR("\nbss_end : 0x", hex_word((uint16_t)ptr));
80
       ptr = (char*)((uint32_t)ptr & 0xfff0);
80
       ptr = (char*)((uint32_t)ptr & 0xfff0);
81
       sp = top_of_stack();
81
       sp = top_of_stack();
82
-      SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_word((uint16_t)sp));
82
+      SERIAL_ECHOLNPAIR("\nStack Pointer : 0x", hex_word((uint16_t)sp));
83
       sp = (char*)((uint32_t)sp | 0x000f);
83
       sp = (char*)((uint32_t)sp | 0x000f);
84
       n = sp - ptr;
84
       n = sp - ptr;
85
       //
85
       //

+ 19
- 21
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]))
307
-  extern bool g26_debug_flag;
308
-  extern int ubl_eeprom_start;
302
+  #define UBL_MESH_VALID !( ( ubl.z_values[0][0] == ubl.z_values[0][1] && ubl.z_values[0][1] == ubl.z_values[0][2] \
303
+                           && ubl.z_values[1][0] == ubl.z_values[1][1] && ubl.z_values[1][1] == ubl.z_values[1][2] \
304
+                           && ubl.z_values[2][0] == ubl.z_values[2][1] && ubl.z_values[2][1] == ubl.z_values[2][2] \
305
+                           && ubl.z_values[0][0] == 0 && ubl.z_values[1][0] == 0 && ubl.z_values[2][0] == 0 )  \
306
+                           || isnan(ubl.z_values[0][0]))
309
 #endif
307
 #endif
310
 
308
 
311
 bool Running = true;
309
 bool Running = true;
5349
 #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
5347
 #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
5350
 
5348
 
5351
   inline void gcode_M49() {
5349
   inline void gcode_M49() {
5350
+    ubl.g26_debug_flag = !ubl.g26_debug_flag;
5352
     SERIAL_PROTOCOLPGM("UBL Debug Flag turned ");
5351
     SERIAL_PROTOCOLPGM("UBL Debug Flag turned ");
5353
-    if ((g26_debug_flag = !g26_debug_flag))
5354
-      SERIAL_PROTOCOLLNPGM("on.");
5355
-    else
5356
-      SERIAL_PROTOCOLLNPGM("off.");
5352
+    serialprintPGM(ubl.g26_debug_flag ? PSTR("on.") : PSTR("off."));
5357
   }
5353
   }
5358
 
5354
 
5359
 #endif // AUTO_BED_LEVELING_UBL && UBL_MESH_EDIT_ENABLED
5355
 #endif // AUTO_BED_LEVELING_UBL && UBL_MESH_EDIT_ENABLED
7212
   /**
7208
   /**
7213
    * M420: Enable/Disable Bed Leveling and/or set the Z fade height.
7209
    * M420: Enable/Disable Bed Leveling and/or set the Z fade height.
7214
    *
7210
    *
7215
-   *       S[bool]   Turns leveling on or off
7216
-   *       Z[height] Sets the Z fade height (0 or none to disable)
7217
-   *       V[bool]   Verbose - Print the leveling grid
7211
+   *   S[bool]   Turns leveling on or off
7212
+   *   Z[height] Sets the Z fade height (0 or none to disable)
7213
+   *   V[bool]   Verbose - Print the leveling grid
7214
+   *
7215
+   *   With AUTO_BED_LEVELING_UBL only:
7218
    *
7216
    *
7219
-   *       L[index]  Load UBL mesh from index (0 is default)
7217
+   *     L[index]  Load UBL mesh from index (0 is default)
7220
    */
7218
    */
7221
   inline void gcode_M420() {
7219
   inline void gcode_M420() {
7222
 
7220
 
7224
       // L to load a mesh from the EEPROM
7222
       // L to load a mesh from the EEPROM
7225
       if (code_seen('L')) {
7223
       if (code_seen('L')) {
7226
         const int8_t storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
7224
         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);
7225
+        const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
7228
         if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
7226
         if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
7229
           SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
7227
           SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
7230
           return;
7228
           return;
7231
         }
7229
         }
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();
7230
+
7231
+        ubl.load_mesh(storage_slot);
7232
+        if (storage_slot != ubl.state.eeprom_storage_slot) ubl.store_state();
7233
+        ubl.state.eeprom_storage_slot = storage_slot;
7236
         ubl.display_map(0);  // Right now, we only support one type of map
7234
         ubl.display_map(0);  // Right now, we only support one type of map
7237
         SERIAL_ECHOLNPAIR("UBL_MESH_VALID =  ", UBL_MESH_VALID);
7235
         SERIAL_ECHOLNPAIR("UBL_MESH_VALID =  ", UBL_MESH_VALID);
7238
         SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
7236
         SERIAL_ECHOLNPAIR("eeprom_storage_slot = ", ubl.state.eeprom_storage_slot);
8736
       #endif // Z_MIN_PROBE_REPEATABILITY_TEST
8734
       #endif // Z_MIN_PROBE_REPEATABILITY_TEST
8737
 
8735
 
8738
       #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
8736
       #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(UBL_MESH_EDIT_ENABLED)
8739
-        case 49: // M49: Turn on or off g26_debug_flag for verbose output
8737
+        case 49: // M49: Turn on or off G26 debug flag for verbose output
8740
           gcode_M49();
8738
           gcode_M49();
8741
           break;
8739
           break;
8742
       #endif // AUTO_BED_LEVELING_UBL && UBL_MESH_EDIT_ENABLED
8740
       #endif // AUTO_BED_LEVELING_UBL && UBL_MESH_EDIT_ENABLED

+ 42
- 25
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
-    extern float last_specified_z;
85
-    extern float fade_scaling_factor_for_current_height;
86
-    extern float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
87
     extern float mesh_index_to_x_location[UBL_MESH_NUM_X_POINTS + 1]; // +1 just because of paranoia that we might end up on the
84
     extern float mesh_index_to_x_location[UBL_MESH_NUM_X_POINTS + 1]; // +1 just because of paranoia that we might end up on the
88
     extern float mesh_index_to_y_location[UBL_MESH_NUM_Y_POINTS + 1]; // the last Mesh Line and that is the start of a whole new cell
85
     extern float mesh_index_to_y_location[UBL_MESH_NUM_Y_POINTS + 1]; // the last Mesh Line and that is the start of a whole new cell
89
 
86
 
90
     class unified_bed_leveling {
87
     class unified_bed_leveling {
88
+      private:
89
+
90
+      float last_specified_z,
91
+            fade_scaling_factor_for_current_height;
92
+
91
       public:
93
       public:
94
+
95
+      float z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS];
96
+
97
+      bool g26_debug_flag = false,
98
+           has_control_of_lcd_panel = false;
99
+
100
+      int8_t eeprom_start = -1;
101
+
102
+      volatile int encoder_diff; // Volatile because it's changed at interrupt time.
103
+
92
       struct ubl_state {
104
       struct ubl_state {
93
         bool active = false;
105
         bool active = false;
94
         float z_offset = 0.0;
106
         float z_offset = 0.0;
95
-        int eeprom_storage_slot = -1,
96
-            n_x = UBL_MESH_NUM_X_POINTS,
97
-            n_y = UBL_MESH_NUM_Y_POINTS;
107
+        int8_t eeprom_storage_slot = -1,
108
+               n_x = UBL_MESH_NUM_X_POINTS,
109
+               n_y = UBL_MESH_NUM_Y_POINTS;
110
+
98
         float mesh_x_min = UBL_MESH_MIN_X,
111
         float mesh_x_min = UBL_MESH_MIN_X,
99
               mesh_y_min = UBL_MESH_MIN_Y,
112
               mesh_y_min = UBL_MESH_MIN_Y,
100
               mesh_x_max = UBL_MESH_MAX_X,
113
               mesh_x_max = UBL_MESH_MAX_X,
104
 
117
 
105
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
118
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
106
           float g29_correction_fade_height = 10.0,
119
           float g29_correction_fade_height = 10.0,
107
-                g29_fade_height_multiplier = 1.0 / 10.0; // It is cheaper to do a floating point multiply than a floating
108
-                                                         // point divide. So, we keep this number in both forms. The first
109
-                                                         // is for the user. The second one is the one that is actually used
110
-                                                         // again and again and again during the correction calculations.
120
+                g29_fade_height_multiplier = 1.0 / 10.0; // It's cheaper to do a floating point multiply than divide,
121
+                                                         // so keep this value and its reciprocal.
122
+        #else
123
+          const float g29_correction_fade_height = 10.0,
124
+                      g29_fade_height_multiplier = 1.0 / 10.0;
111
         #endif
125
         #endif
112
 
126
 
113
-        unsigned char padding[24];  // This is just to allow room to add state variables without
114
-                                    // changing the location of data structures in the EEPROM.
115
-                                    // This is for compatability with future versions to keep
116
-                                    // people from having to regenerate thier mesh data.
117
-                                    //
118
-                                    // If you change the contents of this struct, please adjust
119
-                                    // the padding[] to keep the size the same!
127
+        // If you change this struct, adjust TOTAL_STRUCT_SIZE
128
+
129
+        #define TOTAL_STRUCT_SIZE 43 // Total size of the above fields
130
+
131
+        // padding provides space to add state variables without
132
+        // changing the location of data structures in the EEPROM.
133
+        // This is for compatibility with future versions to keep
134
+        // users from having to regenerate their mesh data.
135
+        unsigned char padding[64 - TOTAL_STRUCT_SIZE];
136
+
120
       } state, pre_initialized;
137
       } state, pre_initialized;
121
 
138
 
122
       unified_bed_leveling();
139
       unified_bed_leveling();
123
-      //  ~unified_bed_leveling();  // No destructor because this object never goes away!
124
 
140
 
125
       void display_map(const int);
141
       void display_map(const int);
126
 
142
 
269
         #if ENABLED(DEBUG_LEVELING_FEATURE)
285
         #if ENABLED(DEBUG_LEVELING_FEATURE)
270
           if (DEBUGGING(MESH_ADJUST)) {
286
           if (DEBUGGING(MESH_ADJUST)) {
271
             SERIAL_ECHOPAIR(" raw get_z_correction(", x0);
287
             SERIAL_ECHOPAIR(" raw get_z_correction(", x0);
272
-            SERIAL_ECHOPAIR(",", y0);
273
-            SERIAL_ECHOPGM(")=");
288
+            SERIAL_CHAR(',')
289
+            SERIAL_ECHO(y0);
290
+            SERIAL_ECHOPGM(") = ");
274
             SERIAL_ECHO_F(z0, 6);
291
             SERIAL_ECHO_F(z0, 6);
275
           }
292
           }
276
         #endif
293
         #endif
291
 
308
 
292
           #if ENABLED(DEBUG_LEVELING_FEATURE)
309
           #if ENABLED(DEBUG_LEVELING_FEATURE)
293
             if (DEBUGGING(MESH_ADJUST)) {
310
             if (DEBUGGING(MESH_ADJUST)) {
294
-              SERIAL_ECHOPGM("??? Yikes!  NAN in get_z_correction( ");
295
-              SERIAL_ECHO(x0);
296
-              SERIAL_ECHOPGM(", ");
311
+              SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", x0);
312
+              SERIAL_CHAR(',');
297
               SERIAL_ECHO(y0);
313
               SERIAL_ECHO(y0);
298
-              SERIAL_ECHOLNPGM(" )");
314
+              SERIAL_CHAR(')');
315
+              SERIAL_EOL;
299
             }
316
             }
300
           #endif
317
           #endif
301
         }
318
         }
313
        */
330
        */
314
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
331
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
315
 
332
 
316
-        FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) const {
333
+        FORCE_INLINE float fade_scaling_factor_for_z(const float &lz) {
317
           const float rz = RAW_Z_POSITION(lz);
334
           const float rz = RAW_Z_POSITION(lz);
318
           if (last_specified_z != rz) {
335
           if (last_specified_z != rz) {
319
             last_specified_z = rz;
336
             last_specified_z = rz;

+ 19
- 32
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;
31
 
30
 
32
   /**
31
   /**
33
    * These support functions allow the use of large bit arrays of flags that take very
32
    * These support functions allow the use of large bit arrays of flags that take very
65
    * 'member data'. So, in the interest of speed, we do it this way. On a 32-bit CPU they can be
64
    * 'member data'. So, in the interest of speed, we do it this way. On a 32-bit CPU they can be
66
    * moved back inside the bed leveling class.
65
    * moved back inside the bed leveling class.
67
    */
66
    */
68
-  float last_specified_z,
69
-        fade_scaling_factor_for_current_height,
70
-        z_values[UBL_MESH_NUM_X_POINTS][UBL_MESH_NUM_Y_POINTS],
71
-        mesh_index_to_x_location[UBL_MESH_NUM_X_POINTS + 1], // +1 just because of paranoia that we might end up on the
67
+  float mesh_index_to_x_location[UBL_MESH_NUM_X_POINTS + 1], // +1 just because of paranoia that we might end up on the
72
         mesh_index_to_y_location[UBL_MESH_NUM_Y_POINTS + 1]; // the last Mesh Line and that is the start of a whole new cell
68
         mesh_index_to_y_location[UBL_MESH_NUM_Y_POINTS + 1]; // the last Mesh Line and that is the start of a whole new cell
73
 
69
 
74
   unified_bed_leveling::unified_bed_leveling() {
70
   unified_bed_leveling::unified_bed_leveling() {
96
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
92
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
97
       /**
93
       /**
98
        * These lines can go away in a few weeks.  They are just
94
        * These lines can go away in a few weeks.  They are just
99
-       * to make sure people updating thier firmware won't be using
95
+       * to make sure people updating their firmware won't be using
100
        * an incomplete Bed_Leveling.state structure. For speed
96
        * an incomplete Bed_Leveling.state structure. For speed
101
        * we now multiply by the inverse of the Fade Height instead of
97
        * we now multiply by the inverse of the Fade Height instead of
102
        * dividing by it. Soon... all of the old structures will be
98
        * dividing by it. Soon... all of the old structures will be
111
   }
107
   }
112
 
108
 
113
   void unified_bed_leveling::load_mesh(const int16_t m) {
109
   void unified_bed_leveling::load_mesh(const int16_t m) {
114
-    int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
110
+    int16_t j = (UBL_LAST_EEPROM_INDEX - eeprom_start) / sizeof(z_values);
115
 
111
 
116
     if (m == -1) {
112
     if (m == -1) {
117
       SERIAL_PROTOCOLLNPGM("?No mesh saved in EEPROM. Zeroing mesh in memory.\n");
113
       SERIAL_PROTOCOLLNPGM("?No mesh saved in EEPROM. Zeroing mesh in memory.\n");
119
       return;
115
       return;
120
     }
116
     }
121
 
117
 
122
-    if (m < 0 || m >= j || ubl_eeprom_start <= 0) {
118
+    if (m < 0 || m >= j || eeprom_start <= 0) {
123
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available to load mesh.\n");
119
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available to load mesh.\n");
124
       return;
120
       return;
125
     }
121
     }
132
   }
128
   }
133
 
129
 
134
   void unified_bed_leveling::store_mesh(const int16_t m) {
130
   void unified_bed_leveling::store_mesh(const int16_t m) {
135
-    int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
131
+    int16_t j = (UBL_LAST_EEPROM_INDEX - eeprom_start) / sizeof(z_values);
136
 
132
 
137
-    if (m < 0 || m >= j || ubl_eeprom_start <= 0) {
133
+    if (m < 0 || m >= j || eeprom_start <= 0) {
138
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available to load mesh.\n");
134
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available to load mesh.\n");
139
       SERIAL_PROTOCOL(m);
135
       SERIAL_PROTOCOL(m);
140
       SERIAL_PROTOCOLLNPGM(" mesh slots available.\n");
136
       SERIAL_PROTOCOLLNPGM(" mesh slots available.\n");
202
       for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
198
       for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
203
         const bool is_current = i == current_xi && j == current_yi;
199
         const bool is_current = i == current_xi && j == current_yi;
204
 
200
 
205
-        // is the nozzle here?  if so, mark the number
206
-        if (map0)
207
-          SERIAL_CHAR(is_current ? '[' : ' ');
201
+        // is the nozzle here? then mark the number
202
+        if (map0) SERIAL_CHAR(is_current ? '[' : ' ');
208
 
203
 
209
         const float f = z_values[i][j];
204
         const float f = z_values[i][j];
210
         if (isnan(f)) {
205
         if (isnan(f)) {
212
         }
207
         }
213
         else {
208
         else {
214
           // if we don't do this, the columns won't line up nicely
209
           // if we don't do this, the columns won't line up nicely
215
-          if (f >= 0.0 && map0) SERIAL_CHAR(' ');
210
+          if (map0 && f >= 0.0) SERIAL_CHAR(' ');
216
           SERIAL_PROTOCOL_F(f, 3);
211
           SERIAL_PROTOCOL_F(f, 3);
217
           idle();
212
           idle();
218
         }
213
         }
219
-        if (!map0 && i < UBL_MESH_NUM_X_POINTS - 1)
220
-         SERIAL_CHAR(',');
214
+        if (!map0 && i < UBL_MESH_NUM_X_POINTS - 1) SERIAL_CHAR(',');
221
 
215
 
222
         #if TX_BUFFER_SIZE > 0
216
         #if TX_BUFFER_SIZE > 0
223
           MYSERIAL.flushTX();
217
           MYSERIAL.flushTX();
252
   bool unified_bed_leveling::sanity_check() {
246
   bool unified_bed_leveling::sanity_check() {
253
     uint8_t error_flag = 0;
247
     uint8_t error_flag = 0;
254
 
248
 
255
-    if (state.n_x !=  UBL_MESH_NUM_X_POINTS) {
249
+    if (state.n_x != UBL_MESH_NUM_X_POINTS) {
256
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_NUM_X_POINTS set wrong\n");
250
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_NUM_X_POINTS set wrong\n");
257
       error_flag++;
251
       error_flag++;
258
     }
252
     }
259
-
260
-    if (state.n_y !=  UBL_MESH_NUM_Y_POINTS) {
253
+    if (state.n_y != UBL_MESH_NUM_Y_POINTS) {
261
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_NUM_Y_POINTS set wrong\n");
254
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_NUM_Y_POINTS set wrong\n");
262
       error_flag++;
255
       error_flag++;
263
     }
256
     }
264
-
265
-    if (state.mesh_x_min !=  UBL_MESH_MIN_X) {
257
+    if (state.mesh_x_min != UBL_MESH_MIN_X) {
266
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MIN_X set wrong\n");
258
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MIN_X set wrong\n");
267
       error_flag++;
259
       error_flag++;
268
     }
260
     }
269
-
270
-    if (state.mesh_y_min !=  UBL_MESH_MIN_Y) {
261
+    if (state.mesh_y_min != UBL_MESH_MIN_Y) {
271
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MIN_Y set wrong\n");
262
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MIN_Y set wrong\n");
272
       error_flag++;
263
       error_flag++;
273
     }
264
     }
274
-
275
-    if (state.mesh_x_max !=  UBL_MESH_MAX_X) {
265
+    if (state.mesh_x_max != UBL_MESH_MAX_X) {
276
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MAX_X set wrong\n");
266
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MAX_X set wrong\n");
277
       error_flag++;
267
       error_flag++;
278
     }
268
     }
279
-
280
-    if (state.mesh_y_max !=  UBL_MESH_MAX_Y) {
269
+    if (state.mesh_y_max != UBL_MESH_MAX_Y) {
281
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MAX_Y set wrong\n");
270
       SERIAL_PROTOCOLLNPGM("?UBL_MESH_MAX_Y set wrong\n");
282
       error_flag++;
271
       error_flag++;
283
     }
272
     }
284
-
285
-    if (state.mesh_x_dist !=  MESH_X_DIST) {
273
+    if (state.mesh_x_dist != MESH_X_DIST) {
286
       SERIAL_PROTOCOLLNPGM("?MESH_X_DIST set wrong\n");
274
       SERIAL_PROTOCOLLNPGM("?MESH_X_DIST set wrong\n");
287
       error_flag++;
275
       error_flag++;
288
     }
276
     }
289
-
290
-    if (state.mesh_y_dist !=  MESH_Y_DIST) {
277
+    if (state.mesh_y_dist != MESH_Y_DIST) {
291
       SERIAL_PROTOCOLLNPGM("?MESH_Y_DIST set wrong\n");
278
       SERIAL_PROTOCOLLNPGM("?MESH_Y_DIST set wrong\n");
292
       error_flag++;
279
       error_flag++;
293
     }
280
     }
294
 
281
 
295
-    const int j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
282
+    const int j = (UBL_LAST_EEPROM_INDEX - eeprom_start) / sizeof(z_values);
296
     if (j < 1) {
283
     if (j < 1) {
297
       SERIAL_PROTOCOLLNPGM("?No EEPROM storage available for a mesh of this size.\n");
284
       SERIAL_PROTOCOLLNPGM("?No EEPROM storage available for a mesh of this size.\n");
298
       error_flag++;
285
       error_flag++;

+ 90
- 94
Marlin/UBL_G29.cpp View File

65
   #define SIZE_OF_LITTLE_RAISE 0
65
   #define SIZE_OF_LITTLE_RAISE 0
66
   #define BIG_RAISE_NOT_NEEDED 0
66
   #define BIG_RAISE_NOT_NEEDED 0
67
   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.
70
 
68
 
71
   /**
69
   /**
72
    *   G29: Unified Bed Leveling by Roxy
70
    *   G29: Unified Bed Leveling by Roxy
146
    *   P0    Phase 0    Zero Mesh Data and turn off the Mesh Compensation System. This reverts the
144
    *   P0    Phase 0    Zero Mesh Data and turn off the Mesh Compensation System. This reverts the
147
    *                    3D Printer to the same state it was in before the Unified Bed Leveling Compensation
145
    *                    3D Printer to the same state it was in before the Unified Bed Leveling Compensation
148
    *                    was turned on. Setting the entire Mesh to Zero is a special case that allows
146
    *                    was turned on. Setting the entire Mesh to Zero is a special case that allows
149
-   *                    a subsequent G or T leveling operation for backward compatability.
147
+   *                    a subsequent G or T leveling operation for backward compatibility.
150
    *
148
    *
151
    *   P1    Phase 1    Invalidate entire Mesh and continue with automatic generation of the Mesh data using
149
    *   P1    Phase 1    Invalidate entire Mesh and continue with automatic generation of the Mesh data using
152
    *                    the Z-Probe. Depending upon the values of DELTA_PROBEABLE_RADIUS and
150
    *                    the Z-Probe. Depending upon the values of DELTA_PROBEABLE_RADIUS and
299
    *   this is going to be helpful to the users!)
297
    *   this is going to be helpful to the users!)
300
    *
298
    *
301
    *   The foundation of this Bed Leveling System is built on Epatel's Mesh Bed Leveling code. A big
299
    *   The foundation of this Bed Leveling System is built on Epatel's Mesh Bed Leveling code. A big
302
-   *   'Thanks!' to him and the creators of 3-Point and Grid Based leveling. Combining thier contributions
300
+   *   'Thanks!' to him and the creators of 3-Point and Grid Based leveling. Combining their contributions
303
    *   we now have the functionality and features of all three systems combined.
301
    *   we now have the functionality and features of all three systems combined.
304
    */
302
    */
305
 
303
 
306
-  int ubl_eeprom_start = -1;
307
-  bool ubl_has_control_of_lcd_panel = false;
308
-  volatile int8_t ubl_encoderDiff = 0; // Volatile because it's changed by Temperature ISR button update
309
-
310
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
304
   // The simple parameter flags and values are 'static' so parameter parsing can be in a support routine.
311
   static int g29_verbose_level, phase_value = -1, repetition_cnt,
305
   static int g29_verbose_level, phase_value = -1, repetition_cnt,
312
              storage_slot = 0, map_type; //unlevel_value = -1;
306
              storage_slot = 0, map_type; //unlevel_value = -1;
318
   #endif
312
   #endif
319
 
313
 
320
   void gcode_G29() {
314
   void gcode_G29() {
321
-    SERIAL_PROTOCOLLNPAIR("ubl_eeprom_start=", ubl_eeprom_start);
322
-    if (ubl_eeprom_start < 0) {
315
+    SERIAL_PROTOCOLLNPAIR("ubl.eeprom_start=", ubl.eeprom_start);
316
+    if (ubl.eeprom_start < 0) {
323
       SERIAL_PROTOCOLLNPGM("?You need to enable your EEPROM and initialize it");
317
       SERIAL_PROTOCOLLNPGM("?You need to enable your EEPROM and initialize it");
324
       SERIAL_PROTOCOLLNPGM("with M502, M500, M501 in that order.\n");
318
       SERIAL_PROTOCOLLNPGM("with M502, M500, M501 in that order.\n");
325
       return;
319
       return;
340
           SERIAL_PROTOCOLLNPGM("Entire Mesh invalidated.\n");
334
           SERIAL_PROTOCOLLNPGM("Entire Mesh invalidated.\n");
341
           break;            // No more invalid Mesh Points to populate
335
           break;            // No more invalid Mesh Points to populate
342
         }
336
         }
343
-        z_values[location.x_index][location.y_index] = NAN;
337
+        ubl.z_values[location.x_index][location.y_index] = NAN;
344
       }
338
       }
345
       SERIAL_PROTOCOLLNPGM("Locations invalidated.\n");
339
       SERIAL_PROTOCOLLNPGM("Locations invalidated.\n");
346
     }
340
     }
359
             for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++) { // a poorly calibrated Delta.
353
             for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++) { // a poorly calibrated Delta.
360
               const float p1 = 0.5 * (UBL_MESH_NUM_X_POINTS) - x,
354
               const float p1 = 0.5 * (UBL_MESH_NUM_X_POINTS) - x,
361
                           p2 = 0.5 * (UBL_MESH_NUM_Y_POINTS) - y;
355
                           p2 = 0.5 * (UBL_MESH_NUM_Y_POINTS) - y;
362
-              z_values[x][y] += 2.0 * HYPOT(p1, p2);
356
+              ubl.z_values[x][y] += 2.0 * HYPOT(p1, p2);
363
             }
357
             }
364
           }
358
           }
365
           break;
359
           break;
366
         case 1:
360
         case 1:
367
           for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++) {  // Create a diagonal line several Mesh cells thick that is raised
361
           for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++) {  // Create a diagonal line several Mesh cells thick that is raised
368
-            z_values[x][x] += 9.999;
369
-            z_values[x][x + (x < UBL_MESH_NUM_Y_POINTS - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
362
+            ubl.z_values[x][x] += 9.999;
363
+            ubl.z_values[x][x + (x < UBL_MESH_NUM_Y_POINTS - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
370
           }
364
           }
371
           break;
365
           break;
372
         case 2:
366
         case 2:
373
           // Allow the user to specify the height because 10mm is a little extreme in some cases.
367
           // Allow the user to specify the height because 10mm is a little extreme in some cases.
374
           for (uint8_t x = (UBL_MESH_NUM_X_POINTS) / 3; x < 2 * (UBL_MESH_NUM_X_POINTS) / 3; x++)   // Create a rectangular raised area in
368
           for (uint8_t x = (UBL_MESH_NUM_X_POINTS) / 3; x < 2 * (UBL_MESH_NUM_X_POINTS) / 3; x++)   // Create a rectangular raised area in
375
             for (uint8_t y = (UBL_MESH_NUM_Y_POINTS) / 3; y < 2 * (UBL_MESH_NUM_Y_POINTS) / 3; y++) // the center of the bed
369
             for (uint8_t y = (UBL_MESH_NUM_Y_POINTS) / 3; y < 2 * (UBL_MESH_NUM_Y_POINTS) / 3; y++) // the center of the bed
376
-              z_values[x][y] += code_seen('C') ? ubl_constant : 9.99;
370
+              ubl.z_values[x][y] += code_seen('C') ? ubl_constant : 9.99;
377
           break;
371
           break;
378
       }
372
       }
379
     }
373
     }
395
         return;
389
         return;
396
       }
390
       }
397
       switch (phase_value) {
391
       switch (phase_value) {
398
-        //
399
-        // Zero Mesh Data
400
-        //
401
         case 0:
392
         case 0:
393
+          //
394
+          // Zero Mesh Data
395
+          //
402
           ubl.reset();
396
           ubl.reset();
403
           SERIAL_PROTOCOLLNPGM("Mesh zeroed.\n");
397
           SERIAL_PROTOCOLLNPGM("Mesh zeroed.\n");
404
           break;
398
           break;
405
-        //
406
-        // Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
407
-        //
399
+
408
         case 1:
400
         case 1:
401
+          //
402
+          // Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
403
+          //
409
           if (!code_seen('C') ) {
404
           if (!code_seen('C') ) {
410
             ubl.invalidate();
405
             ubl.invalidate();
411
             SERIAL_PROTOCOLLNPGM("Mesh invalidated. Probing mesh.\n");
406
             SERIAL_PROTOCOLLNPGM("Mesh invalidated. Probing mesh.\n");
419
           probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
414
           probe_entire_mesh(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER,
420
                             code_seen('O') || code_seen('M'), code_seen('E'), code_seen('U'));
415
                             code_seen('O') || code_seen('M'), code_seen('E'), code_seen('U'));
421
           break;
416
           break;
422
-        //
423
-        // Manually Probe Mesh in areas that can't be reached by the probe
424
-        //
417
+
425
         case 2: {
418
         case 2: {
419
+          //
420
+          // Manually Probe Mesh in areas that can't be reached by the probe
421
+          //
426
           SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.\n");
422
           SERIAL_PROTOCOLLNPGM("Manually probing unreachable mesh locations.\n");
427
           do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
423
           do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
428
           if (!x_flag && !y_flag) {      // use a good default location for the path
424
           if (!x_flag && !y_flag) {      // use a good default location for the path
455
 
451
 
456
         } break;
452
         } break;
457
 
453
 
458
-        //
459
-        // Populate invalid Mesh areas with a constant
460
-        //
461
         case 3: {
454
         case 3: {
455
+          //
456
+          // Populate invalid Mesh areas with a constant
457
+          //
462
           const float height = code_seen('C') ? ubl_constant : 0.0;
458
           const float height = code_seen('C') ? ubl_constant : 0.0;
463
           // If no repetition is specified, do the whole Mesh
459
           // If no repetition is specified, do the whole Mesh
464
           if (!repeat_flag) repetition_cnt = 9999;
460
           if (!repeat_flag) repetition_cnt = 9999;
465
           while (repetition_cnt--) {
461
           while (repetition_cnt--) {
466
             const mesh_index_pair location = find_closest_mesh_point_of_type(INVALID, x_pos, y_pos, 0, NULL, false); // The '0' says we want to use the nozzle's position
462
             const mesh_index_pair location = find_closest_mesh_point_of_type(INVALID, x_pos, y_pos, 0, NULL, false); // The '0' says we want to use the nozzle's position
467
             if (location.x_index < 0) break; // No more invalid Mesh Points to populate
463
             if (location.x_index < 0) break; // No more invalid Mesh Points to populate
468
-            z_values[location.x_index][location.y_index] = height;
464
+            ubl.z_values[location.x_index][location.y_index] = height;
469
           }
465
           }
470
         } break;
466
         } break;
471
 
467
 
472
-        //
473
-        // Fine Tune (Or Edit) the Mesh
474
-        //
475
         case 4:
468
         case 4:
469
+          //
470
+          // Fine Tune (i.e., Edit) the Mesh
471
+          //
476
           fine_tune_mesh(x_pos, y_pos, code_seen('O') || code_seen('M'));
472
           fine_tune_mesh(x_pos, y_pos, code_seen('O') || code_seen('M'));
477
           break;
473
           break;
478
         case 5:
474
         case 5:
487
           SERIAL_ECHO_START;
483
           SERIAL_ECHO_START;
488
           SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
484
           SERIAL_ECHOLNPGM("Checking G29 has control of LCD Panel:");
489
           KEEPALIVE_STATE(PAUSED_FOR_USER);
485
           KEEPALIVE_STATE(PAUSED_FOR_USER);
490
-          ubl_has_control_of_lcd_panel++;
486
+          ubl.has_control_of_lcd_panel++;
491
           while (!ubl_lcd_clicked()) {
487
           while (!ubl_lcd_clicked()) {
492
             safe_delay(250);
488
             safe_delay(250);
493
-            if (ubl_encoderDiff) {
494
-              SERIAL_ECHOLN((int)ubl_encoderDiff);
495
-              ubl_encoderDiff = 0;
489
+            if (ubl.encoder_diff) {
490
+              SERIAL_ECHOLN((int)ubl.encoder_diff);
491
+              ubl.encoder_diff = 0;
496
             }
492
             }
497
           }
493
           }
498
           SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
494
           SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
499
-          ubl_has_control_of_lcd_panel = false;
495
+          ubl.has_control_of_lcd_panel = false;
500
           KEEPALIVE_STATE(IN_HANDLER);
496
           KEEPALIVE_STATE(IN_HANDLER);
501
           break;
497
           break;
502
 
498
 
508
           wait_for_user = true;
504
           wait_for_user = true;
509
           while (wait_for_user) {
505
           while (wait_for_user) {
510
             safe_delay(250);
506
             safe_delay(250);
511
-            if (ubl_encoderDiff) {
512
-              SERIAL_ECHOLN((int)ubl_encoderDiff);
513
-              ubl_encoderDiff = 0;
507
+            if (ubl.encoder_diff) {
508
+              SERIAL_ECHOLN((int)ubl.encoder_diff);
509
+              ubl.encoder_diff = 0;
514
             }
510
             }
515
           }
511
           }
516
           SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
512
           SERIAL_ECHOLNPGM("G29 giving back control of LCD Panel.");
562
     if (code_seen('L')) {     // Load Current Mesh Data
558
     if (code_seen('L')) {     // Load Current Mesh Data
563
       storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
559
       storage_slot = code_has_value() ? code_value_int() : ubl.state.eeprom_storage_slot;
564
 
560
 
565
-      const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
561
+      const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
566
 
562
 
567
-      if (storage_slot < 0 || storage_slot >= j || ubl_eeprom_start <= 0) {
563
+      if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
568
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
564
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
569
         return;
565
         return;
570
       }
566
       }
586
         SERIAL_ECHOLNPGM("G29 I 999");              // host in a form it can be reconstructed on a different machine
582
         SERIAL_ECHOLNPGM("G29 I 999");              // host in a form it can be reconstructed on a different machine
587
         for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
583
         for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
588
           for (uint8_t y = 0;  y < UBL_MESH_NUM_Y_POINTS; y++)
584
           for (uint8_t y = 0;  y < UBL_MESH_NUM_Y_POINTS; y++)
589
-            if (!isnan(z_values[x][y])) {
585
+            if (!isnan(ubl.z_values[x][y])) {
590
               SERIAL_ECHOPAIR("M421 I ", x);
586
               SERIAL_ECHOPAIR("M421 I ", x);
591
               SERIAL_ECHOPAIR(" J ", y);
587
               SERIAL_ECHOPAIR(" J ", y);
592
               SERIAL_ECHOPGM(" Z ");
588
               SERIAL_ECHOPGM(" Z ");
593
-              SERIAL_ECHO_F(z_values[x][y], 6);
589
+              SERIAL_ECHO_F(ubl.z_values[x][y], 6);
594
               SERIAL_EOL;
590
               SERIAL_EOL;
595
             }
591
             }
596
         return;
592
         return;
597
       }
593
       }
598
 
594
 
599
-      const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values);
595
+      const int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values);
600
 
596
 
601
-      if (storage_slot < 0 || storage_slot >= j || ubl_eeprom_start <= 0) {
597
+      if (storage_slot < 0 || storage_slot >= j || ubl.eeprom_start <= 0) {
602
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
598
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
603
         SERIAL_PROTOCOLLNPAIR("?Use 0 to ", j - 1);
599
         SERIAL_PROTOCOLLNPAIR("?Use 0 to ", j - 1);
604
         goto LEAVE;
600
         goto LEAVE;
622
         save_ubl_active_state_and_disable();
618
         save_ubl_active_state_and_disable();
623
         //measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
619
         //measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
624
 
620
 
625
-        ubl_has_control_of_lcd_panel++;     // Grab the LCD Hardware
621
+        ubl.has_control_of_lcd_panel++;     // Grab the LCD Hardware
626
         measured_z = 1.5;
622
         measured_z = 1.5;
627
         do_blocking_move_to_z(measured_z);  // Get close to the bed, but leave some space so we don't damage anything
623
         do_blocking_move_to_z(measured_z);  // Get close to the bed, but leave some space so we don't damage anything
628
                                             // The user is not going to be locking in a new Z-Offset very often so
624
                                             // The user is not going to be locking in a new Z-Offset very often so
638
           do_blocking_move_to_z(measured_z);
634
           do_blocking_move_to_z(measured_z);
639
         } while (!ubl_lcd_clicked());
635
         } while (!ubl_lcd_clicked());
640
 
636
 
641
-        ubl_has_control_of_lcd_panel++;   // There is a race condition for the Encoder Wheel getting clicked.
637
+        ubl.has_control_of_lcd_panel++;   // There is a race condition for the Encoder Wheel getting clicked.
642
                                           // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
638
                                           // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
643
                                           // or here. So, until we are done looking for a long Encoder Wheel Press,
639
                                           // or here. So, until we are done looking for a long Encoder Wheel Press,
644
                                           // we need to take control of the panel
640
                                           // we need to take control of the panel
658
             goto LEAVE;
654
             goto LEAVE;
659
           }
655
           }
660
         }
656
         }
661
-        ubl_has_control_of_lcd_panel = false;
657
+        ubl.has_control_of_lcd_panel = false;
662
         safe_delay(20); // We don't want any switch noise.
658
         safe_delay(20); // We don't want any switch noise.
663
 
659
 
664
         ubl.state.z_offset = measured_z;
660
         ubl.state.z_offset = measured_z;
675
       lcd_quick_feedback();
671
       lcd_quick_feedback();
676
     #endif
672
     #endif
677
 
673
 
678
-    ubl_has_control_of_lcd_panel = false;
674
+    ubl.has_control_of_lcd_panel = false;
679
   }
675
   }
680
 
676
 
681
   void find_mean_mesh_height() {
677
   void find_mean_mesh_height() {
687
     n = 0;
683
     n = 0;
688
     for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
684
     for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
689
       for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
685
       for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
690
-        if (!isnan(z_values[x][y])) {
691
-          sum += z_values[x][y];
686
+        if (!isnan(ubl.z_values[x][y])) {
687
+          sum += ubl.z_values[x][y];
692
           n++;
688
           n++;
693
         }
689
         }
694
 
690
 
699
     //
695
     //
700
     for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
696
     for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
701
       for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
697
       for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
702
-        if (!isnan(z_values[x][y])) {
703
-          difference = (z_values[x][y] - mean);
698
+        if (!isnan(ubl.z_values[x][y])) {
699
+          difference = (ubl.z_values[x][y] - mean);
704
           sum_of_diff_squared += difference * difference;
700
           sum_of_diff_squared += difference * difference;
705
         }
701
         }
706
 
702
 
717
     if (c_flag)
713
     if (c_flag)
718
       for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
714
       for (x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
719
         for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
715
         for (y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
720
-          if (!isnan(z_values[x][y]))
721
-            z_values[x][y] -= mean + ubl_constant;
716
+          if (!isnan(ubl.z_values[x][y]))
717
+            ubl.z_values[x][y] -= mean + ubl_constant;
722
   }
718
   }
723
 
719
 
724
   void shift_mesh_height() {
720
   void shift_mesh_height() {
725
     for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
721
     for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
726
       for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
722
       for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
727
-        if (!isnan(z_values[x][y]))
728
-          z_values[x][y] += ubl_constant;
723
+        if (!isnan(ubl.z_values[x][y]))
724
+          ubl.z_values[x][y] += ubl_constant;
729
   }
725
   }
730
 
726
 
731
   /**
727
   /**
735
   void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest) {
731
   void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest) {
736
     mesh_index_pair location;
732
     mesh_index_pair location;
737
 
733
 
738
-    ubl_has_control_of_lcd_panel++;
734
+    ubl.has_control_of_lcd_panel++;
739
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
735
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
740
     DEPLOY_PROBE();
736
     DEPLOY_PROBE();
741
 
737
 
745
         lcd_quick_feedback();
741
         lcd_quick_feedback();
746
         STOW_PROBE();
742
         STOW_PROBE();
747
         while (ubl_lcd_clicked()) idle();
743
         while (ubl_lcd_clicked()) idle();
748
-        ubl_has_control_of_lcd_panel = false;
744
+        ubl.has_control_of_lcd_panel = false;
749
         restore_ubl_active_state_and_leave();
745
         restore_ubl_active_state_and_leave();
750
         safe_delay(50);  // Debounce the Encoder wheel
746
         safe_delay(50);  // Debounce the Encoder wheel
751
         return;
747
         return;
761
         if (rawx < (MIN_PROBE_X) || rawx > (MAX_PROBE_X) || rawy < (MIN_PROBE_Y) || rawy > (MAX_PROBE_Y)) {
757
         if (rawx < (MIN_PROBE_X) || rawx > (MAX_PROBE_X) || rawy < (MIN_PROBE_Y) || rawy > (MAX_PROBE_Y)) {
762
           SERIAL_ERROR_START;
758
           SERIAL_ERROR_START;
763
           SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
759
           SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
764
-          ubl_has_control_of_lcd_panel = false;
760
+          ubl.has_control_of_lcd_panel = false;
765
           goto LEAVE;
761
           goto LEAVE;
766
         }
762
         }
767
         const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level);
763
         const float measured_z = probe_pt(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy), stow_probe, g29_verbose_level);
768
-        z_values[location.x_index][location.y_index] = measured_z + zprobe_zoffset;
764
+        ubl.z_values[location.x_index][location.y_index] = measured_z + zprobe_zoffset;
769
       }
765
       }
770
 
766
 
771
       if (do_ubl_mesh_map) ubl.display_map(map_type);
767
       if (do_ubl_mesh_map) ubl.display_map(map_type);
842
     for (i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
838
     for (i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
843
       for (j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
839
       for (j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
844
         c = -((normal.x * (UBL_MESH_MIN_X + i * (MESH_X_DIST)) + normal.y * (UBL_MESH_MIN_Y + j * (MESH_Y_DIST))) - d);
840
         c = -((normal.x * (UBL_MESH_MIN_X + i * (MESH_X_DIST)) + normal.y * (UBL_MESH_MIN_Y + j * (MESH_Y_DIST))) - d);
845
-        z_values[i][j] += c;
841
+        ubl.z_values[i][j] += c;
846
       }
842
       }
847
     }
843
     }
848
     return normal;
844
     return normal;
852
     KEEPALIVE_STATE(PAUSED_FOR_USER);
848
     KEEPALIVE_STATE(PAUSED_FOR_USER);
853
     while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
849
     while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
854
       idle();
850
       idle();
855
-      if (ubl_encoderDiff) {
856
-        do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl_encoderDiff));
857
-        ubl_encoderDiff = 0;
851
+      if (ubl.encoder_diff) {
852
+        do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl.encoder_diff));
853
+        ubl.encoder_diff = 0;
858
       }
854
       }
859
     }
855
     }
860
     KEEPALIVE_STATE(IN_HANDLER);
856
     KEEPALIVE_STATE(IN_HANDLER);
863
 
859
 
864
   float measure_business_card_thickness(const float &in_height) {
860
   float measure_business_card_thickness(const float &in_height) {
865
 
861
 
866
-    ubl_has_control_of_lcd_panel++;
862
+    ubl.has_control_of_lcd_panel++;
867
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
863
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
868
 
864
 
869
     SERIAL_PROTOCOLLNPGM("Place Shim Under Nozzle and Perform Measurement.");
865
     SERIAL_PROTOCOLLNPGM("Place Shim Under Nozzle and Perform Measurement.");
873
 
869
 
874
     const float z1 = use_encoder_wheel_to_measure_point();
870
     const float z1 = use_encoder_wheel_to_measure_point();
875
     do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
871
     do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
876
-    ubl_has_control_of_lcd_panel = false;
872
+    ubl.has_control_of_lcd_panel = false;
877
 
873
 
878
     SERIAL_PROTOCOLLNPGM("Remove Shim and Measure Bed Height.");
874
     SERIAL_PROTOCOLLNPGM("Remove Shim and Measure Bed Height.");
879
     const float z2 = use_encoder_wheel_to_measure_point();
875
     const float z2 = use_encoder_wheel_to_measure_point();
890
 
886
 
891
   void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) {
887
   void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) {
892
 
888
 
893
-    ubl_has_control_of_lcd_panel++;
889
+    ubl.has_control_of_lcd_panel++;
894
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
890
     save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
895
     do_blocking_move_to_z(z_clearance);
891
     do_blocking_move_to_z(z_clearance);
896
     do_blocking_move_to_xy(lx, ly);
892
     do_blocking_move_to_xy(lx, ly);
911
       if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) {
907
       if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) {
912
         SERIAL_ERROR_START;
908
         SERIAL_ERROR_START;
913
         SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
909
         SERIAL_ERRORLNPGM("Attempt to probe off the bed.");
914
-        ubl_has_control_of_lcd_panel = false;
910
+        ubl.has_control_of_lcd_panel = false;
915
         goto LEAVE;
911
         goto LEAVE;
916
       }
912
       }
917
 
913
 
931
       last_y = yProbe;
927
       last_y = yProbe;
932
 
928
 
933
       KEEPALIVE_STATE(PAUSED_FOR_USER);
929
       KEEPALIVE_STATE(PAUSED_FOR_USER);
934
-      ubl_has_control_of_lcd_panel = true;
930
+      ubl.has_control_of_lcd_panel = true;
935
 
931
 
936
       while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
932
       while (!ubl_lcd_clicked()) {     // we need the loop to move the nozzle based on the encoder wheel here!
937
         idle();
933
         idle();
938
-        if (ubl_encoderDiff) {
939
-          do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl_encoderDiff) / 100.0);
940
-          ubl_encoderDiff = 0;
934
+        if (ubl.encoder_diff) {
935
+          do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl.encoder_diff) / 100.0);
936
+          ubl.encoder_diff = 0;
941
         }
937
         }
942
       }
938
       }
943
 
939
 
949
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
945
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
950
           lcd_quick_feedback();
946
           lcd_quick_feedback();
951
           while (ubl_lcd_clicked()) idle();
947
           while (ubl_lcd_clicked()) idle();
952
-          ubl_has_control_of_lcd_panel = false;
948
+          ubl.has_control_of_lcd_panel = false;
953
           KEEPALIVE_STATE(IN_HANDLER);
949
           KEEPALIVE_STATE(IN_HANDLER);
954
           restore_ubl_active_state_and_leave();
950
           restore_ubl_active_state_and_leave();
955
           return;
951
           return;
956
         }
952
         }
957
       }
953
       }
958
 
954
 
959
-      z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - card_thickness;
955
+      ubl.z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - card_thickness;
960
       if (g29_verbose_level > 2) {
956
       if (g29_verbose_level > 2) {
961
         SERIAL_PROTOCOLPGM("Mesh Point Measured at: ");
957
         SERIAL_PROTOCOLPGM("Mesh Point Measured at: ");
962
-        SERIAL_PROTOCOL_F(z_values[location.x_index][location.y_index], 6);
958
+        SERIAL_PROTOCOL_F(ubl.z_values[location.x_index][location.y_index], 6);
963
         SERIAL_EOL;
959
         SERIAL_EOL;
964
       }
960
       }
965
     } while (location.x_index >= 0 && location.y_index >= 0);
961
     } while (location.x_index >= 0 && location.y_index >= 0);
1110
    * good to have the extra information. Soon... we prune this to just a few items
1106
    * good to have the extra information. Soon... we prune this to just a few items
1111
    */
1107
    */
1112
   void g29_what_command() {
1108
   void g29_what_command() {
1113
-    const uint16_t k = E2END - ubl_eeprom_start;
1109
+    const uint16_t k = E2END - ubl.eeprom_start;
1114
 
1110
 
1115
     SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
1111
     SERIAL_PROTOCOLPGM("Unified Bed Leveling System Version 1.00 ");
1116
     if (ubl.state.active)  
1112
     if (ubl.state.active)  
1167
     SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1163
     SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1168
     SERIAL_EOL;
1164
     SERIAL_EOL;
1169
     safe_delay(50);
1165
     safe_delay(50);
1170
-    SERIAL_PROTOCOLLNPAIR("Free EEPROM space starts at: 0x", hex_word(ubl_eeprom_start));
1166
+    SERIAL_PROTOCOLLNPAIR("Free EEPROM space starts at: 0x", hex_word(ubl.eeprom_start));
1171
 
1167
 
1172
-    SERIAL_PROTOCOLLNPAIR("end of EEPROM              : ", hex_word(E2END));
1168
+    SERIAL_PROTOCOLLNPAIR("end of EEPROM              : 0x", hex_word(E2END));
1173
     safe_delay(50);
1169
     safe_delay(50);
1174
 
1170
 
1175
     SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1171
     SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1176
     SERIAL_EOL;
1172
     SERIAL_EOL;
1177
-    SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1173
+    SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(ubl.z_values));
1178
     SERIAL_EOL;
1174
     SERIAL_EOL;
1179
     safe_delay(50);
1175
     safe_delay(50);
1180
 
1176
 
1181
     SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: 0x", hex_word(k));
1177
     SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: 0x", hex_word(k));
1182
     safe_delay(50);
1178
     safe_delay(50);
1183
 
1179
 
1184
-    SERIAL_PROTOCOLPAIR("EEPROM can hold ", k / sizeof(z_values));
1180
+    SERIAL_PROTOCOLPAIR("EEPROM can hold ", k / sizeof(ubl.z_values));
1185
     SERIAL_PROTOCOLLNPGM(" meshes.\n");
1181
     SERIAL_PROTOCOLLNPGM(" meshes.\n");
1186
     safe_delay(50);
1182
     safe_delay(50);
1187
 
1183
 
1245
     }
1241
     }
1246
     storage_slot = code_value_int();
1242
     storage_slot = code_value_int();
1247
 
1243
 
1248
-    int16_t j = (UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(tmp_z_values);
1244
+    int16_t j = (UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(tmp_z_values);
1249
 
1245
 
1250
-    if (storage_slot < 0 || storage_slot > j || ubl_eeprom_start <= 0) {
1246
+    if (storage_slot < 0 || storage_slot > j || ubl.eeprom_start <= 0) {
1251
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
1247
       SERIAL_PROTOCOLLNPGM("?EEPROM storage not available for use.\n");
1252
       return;
1248
       return;
1253
     }
1249
     }
1256
     eeprom_read_block((void *)&tmp_z_values, (void *)j, sizeof(tmp_z_values));
1252
     eeprom_read_block((void *)&tmp_z_values, (void *)j, sizeof(tmp_z_values));
1257
 
1253
 
1258
     SERIAL_ECHOPAIR("Subtracting Mesh ", storage_slot);
1254
     SERIAL_ECHOPAIR("Subtracting Mesh ", storage_slot);
1259
-    SERIAL_PROTOCOLLNPAIR(" loaded from EEPROM address ", hex_word(j)); // Soon, we can remove the extra clutter of printing
1255
+    SERIAL_PROTOCOLLNPAIR(" loaded from EEPROM address 0x", hex_word(j)); // Soon, we can remove the extra clutter of printing
1260
                                                                         // the address in the EEPROM where the Mesh is stored.
1256
                                                                         // the address in the EEPROM where the Mesh is stored.
1261
 
1257
 
1262
     for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
1258
     for (uint8_t x = 0; x < UBL_MESH_NUM_X_POINTS; x++)
1263
       for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
1259
       for (uint8_t y = 0; y < UBL_MESH_NUM_Y_POINTS; y++)
1264
-        z_values[x][y] = z_values[x][y] - tmp_z_values[x][y];
1260
+        ubl.z_values[x][y] -= tmp_z_values[x][y];
1265
   }
1261
   }
1266
 
1262
 
1267
   mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, unsigned int bits[16], bool far_flag) {
1263
   mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, unsigned int bits[16], bool far_flag) {
1280
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
1276
     for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
1281
       for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
1277
       for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
1282
 
1278
 
1283
-        if ( (type == INVALID && isnan(z_values[i][j]))  // Check to see if this location holds the right thing
1284
-          || (type == REAL && !isnan(z_values[i][j]))
1279
+        if ( (type == INVALID && isnan(ubl.z_values[i][j]))  // Check to see if this location holds the right thing
1280
+          || (type == REAL && !isnan(ubl.z_values[i][j]))
1285
           || (type == SET_IN_BITMAP && is_bit_set(bits, i, j))
1281
           || (type == SET_IN_BITMAP && is_bit_set(bits, i, j))
1286
         ) {
1282
         ) {
1287
 
1283
 
1308
           if (far_flag) {                                           // If doing the far_flag action, we want to be as far as possible
1304
           if (far_flag) {                                           // If doing the far_flag action, we want to be as far as possible
1309
             for (uint8_t k = 0; k < UBL_MESH_NUM_X_POINTS; k++) {   // from the starting point and from any other probed points.  We
1305
             for (uint8_t k = 0; k < UBL_MESH_NUM_X_POINTS; k++) {   // from the starting point and from any other probed points.  We
1310
               for (uint8_t l = 0; l < UBL_MESH_NUM_Y_POINTS; l++) { // want the next point spread out and filling in any blank spaces
1306
               for (uint8_t l = 0; l < UBL_MESH_NUM_Y_POINTS; l++) { // want the next point spread out and filling in any blank spaces
1311
-                if (!isnan(z_values[k][l])) {                       // in the mesh. So we add in some of the distance to every probed
1307
+                if (!isnan(ubl.z_values[k][l])) {                       // in the mesh. So we add in some of the distance to every probed
1312
                   distance += sq(i - k) * (MESH_X_DIST) * .05       // point we can find.
1308
                   distance += sq(i - k) * (MESH_X_DIST) * .05       // point we can find.
1313
                             + sq(j - l) * (MESH_Y_DIST) * .05;
1309
                             + sq(j - l) * (MESH_Y_DIST) * .05;
1314
                 }
1310
                 }
1361
       if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) { // In theory, we don't need this check.
1357
       if (rawx < (X_MIN_POS) || rawx > (X_MAX_POS) || rawy < (Y_MIN_POS) || rawy > (Y_MAX_POS)) { // In theory, we don't need this check.
1362
         SERIAL_ERROR_START;
1358
         SERIAL_ERROR_START;
1363
         SERIAL_ERRORLNPGM("Attempt to edit off the bed."); // This really can't happen, but do the check for now
1359
         SERIAL_ERRORLNPGM("Attempt to edit off the bed."); // This really can't happen, but do the check for now
1364
-        ubl_has_control_of_lcd_panel = false;
1360
+        ubl.has_control_of_lcd_panel = false;
1365
         goto FINE_TUNE_EXIT;
1361
         goto FINE_TUNE_EXIT;
1366
       }
1362
       }
1367
 
1363
 
1368
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1364
       do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1369
       do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
1365
       do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
1370
-      float new_z = z_values[location.x_index][location.y_index];
1366
+      float new_z = ubl.z_values[location.x_index][location.y_index];
1371
       
1367
       
1372
       round_off = (int32_t)(new_z * 1000.0);    // we chop off the last digits just to be clean. We are rounding to the
1368
       round_off = (int32_t)(new_z * 1000.0);    // we chop off the last digits just to be clean. We are rounding to the
1373
       new_z = float(round_off) / 1000.0;
1369
       new_z = float(round_off) / 1000.0;
1374
 
1370
 
1375
       KEEPALIVE_STATE(PAUSED_FOR_USER);
1371
       KEEPALIVE_STATE(PAUSED_FOR_USER);
1376
-      ubl_has_control_of_lcd_panel = true;
1372
+      ubl.has_control_of_lcd_panel = true;
1377
 
1373
 
1378
       lcd_implementation_clear();
1374
       lcd_implementation_clear();
1379
       lcd_mesh_edit_setup(new_z);
1375
       lcd_mesh_edit_setup(new_z);
1385
 
1381
 
1386
       lcd_return_to_status();
1382
       lcd_return_to_status();
1387
 
1383
 
1388
-      ubl_has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked.
1384
+      ubl.has_control_of_lcd_panel = true; // There is a race condition for the Encoder Wheel getting clicked.
1389
                                            // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
1385
                                            // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
1390
                                            // or here.
1386
                                            // or here.
1391
 
1387
 
1406
 
1402
 
1407
       safe_delay(20);                       // We don't want any switch noise.
1403
       safe_delay(20);                       // We don't want any switch noise.
1408
 
1404
 
1409
-      z_values[location.x_index][location.y_index] = new_z;
1405
+      ubl.z_values[location.x_index][location.y_index] = new_z;
1410
 
1406
 
1411
       lcd_implementation_clear();
1407
       lcd_implementation_clear();
1412
 
1408
 
1414
 
1410
 
1415
     FINE_TUNE_EXIT:
1411
     FINE_TUNE_EXIT:
1416
 
1412
 
1417
-    ubl_has_control_of_lcd_panel = false;
1413
+    ubl.has_control_of_lcd_panel = false;
1418
     KEEPALIVE_STATE(IN_HANDLER);
1414
     KEEPALIVE_STATE(IN_HANDLER);
1419
 
1415
 
1420
     if (do_ubl_mesh_map) ubl.display_map(map_type);
1416
     if (do_ubl_mesh_map) ubl.display_map(map_type);

+ 7
- 8
Marlin/UBL_line_to_destination.cpp View File

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
   extern float destination[];
34
   extern float destination[];
35
-  bool g26_debug_flag = false;
36
   void debug_current_and_destination(char *title) {
35
   void debug_current_and_destination(char *title) {
37
 
36
 
38
     // if the title message starts with a '!' it is so important, we are going to
37
     // if the title message starts with a '!' it is so important, we are going to
39
     // ignore the status of the g26_debug_flag
38
     // ignore the status of the g26_debug_flag
40
-    if (*title != '!' && !g26_debug_flag) return;
39
+    if (*title != '!' && !ubl.g26_debug_flag) return;
41
 
40
 
42
     const float de = destination[E_AXIS] - current_position[E_AXIS];
41
     const float de = destination[E_AXIS] - current_position[E_AXIS];
43
 
42
 
122
               cell_dest_xi  = ubl.get_cell_index_x(RAW_X_POSITION(x_end)),
121
               cell_dest_xi  = ubl.get_cell_index_x(RAW_X_POSITION(x_end)),
123
               cell_dest_yi  = ubl.get_cell_index_y(RAW_Y_POSITION(y_end));
122
               cell_dest_yi  = ubl.get_cell_index_y(RAW_Y_POSITION(y_end));
124
 
123
 
125
-    if (g26_debug_flag) {
124
+    if (ubl.g26_debug_flag) {
126
       SERIAL_ECHOPGM(" ubl_line_to_destination(xe=");
125
       SERIAL_ECHOPGM(" ubl_line_to_destination(xe=");
127
       SERIAL_ECHO(x_end);
126
       SERIAL_ECHO(x_end);
128
       SERIAL_ECHOPGM(", ye=");
127
       SERIAL_ECHOPGM(", ye=");
151
         planner.buffer_line(x_end, y_end, z_end + ubl.state.z_offset, e_end, feed_rate, extruder);
150
         planner.buffer_line(x_end, y_end, z_end + ubl.state.z_offset, e_end, feed_rate, extruder);
152
         set_current_to_destination();
151
         set_current_to_destination();
153
 
152
 
154
-        if (g26_debug_flag)
153
+        if (ubl.g26_debug_flag)
155
           debug_current_and_destination((char*)"out of bounds in ubl_line_to_destination()");
154
           debug_current_and_destination((char*)"out of bounds in ubl_line_to_destination()");
156
 
155
 
157
         return;
156
         return;
213
 
212
 
214
       planner.buffer_line(x_end, y_end, z_end + z0 + ubl.state.z_offset, e_end, feed_rate, extruder);
213
       planner.buffer_line(x_end, y_end, z_end + z0 + ubl.state.z_offset, e_end, feed_rate, extruder);
215
 
214
 
216
-      if (g26_debug_flag)
215
+      if (ubl.g26_debug_flag)
217
         debug_current_and_destination((char*)"FINAL_MOVE in ubl_line_to_destination()");
216
         debug_current_and_destination((char*)"FINAL_MOVE in ubl_line_to_destination()");
218
 
217
 
219
       set_current_to_destination();
218
       set_current_to_destination();
340
         } //else printf("FIRST MOVE PRUNED  ");
339
         } //else printf("FIRST MOVE PRUNED  ");
341
       }
340
       }
342
 
341
 
343
-      if (g26_debug_flag)
342
+      if (ubl.g26_debug_flag)
344
         debug_current_and_destination((char*)"vertical move done in ubl_line_to_destination()");
343
         debug_current_and_destination((char*)"vertical move done in ubl_line_to_destination()");
345
 
344
 
346
       //
345
       //
425
         } //else printf("FIRST MOVE PRUNED  ");
424
         } //else printf("FIRST MOVE PRUNED  ");
426
       }
425
       }
427
 
426
 
428
-      if (g26_debug_flag)
427
+      if (ubl.g26_debug_flag)
429
         debug_current_and_destination((char*)"horizontal move done in ubl_line_to_destination()");
428
         debug_current_and_destination((char*)"horizontal move done in ubl_line_to_destination()");
430
 
429
 
431
       if (current_position[X_AXIS] != x_end || current_position[Y_AXIS] != y_end)
430
       if (current_position[X_AXIS] != x_end || current_position[Y_AXIS] != y_end)
564
       }
563
       }
565
     }
564
     }
566
 
565
 
567
-    if (g26_debug_flag)
566
+    if (ubl.g26_debug_flag)
568
       debug_current_and_destination((char*)"generic move done in ubl_line_to_destination()");
567
       debug_current_and_destination((char*)"generic move done in ubl_line_to_destination()");
569
 
568
 
570
     if (current_position[0] != x_end || current_position[1] != y_end)
569
     if (current_position[0] != x_end || current_position[1] != y_end)

+ 2
- 3
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;
170
 #endif
169
 #endif
171
 
170
 
172
 #if ENABLED(ABL_BILINEAR_SUBDIVISION)
171
 #if ENABLED(ABL_BILINEAR_SUBDIVISION)
847
       }
846
       }
848
 
847
 
849
       #if ENABLED(AUTO_BED_LEVELING_UBL)
848
       #if ENABLED(AUTO_BED_LEVELING_UBL)
850
-        ubl_eeprom_start = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
849
+        ubl.eeprom_start = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it
851
                                                          // can float up or down a little bit without
850
                                                          // can float up or down a little bit without
852
                                                          // disrupting the Unified Bed Leveling data
851
                                                          // disrupting the Unified Bed Leveling data
853
         ubl.load_state();
852
         ubl.load_state();
1233
         SERIAL_ECHO_F(ubl.state.z_offset, 6);
1232
         SERIAL_ECHO_F(ubl.state.z_offset, 6);
1234
         SERIAL_EOL;
1233
         SERIAL_EOL;
1235
 
1234
 
1236
-        SERIAL_ECHOPAIR("EEPROM can hold ", (int)((UBL_LAST_EEPROM_INDEX - ubl_eeprom_start) / sizeof(z_values)));
1235
+        SERIAL_ECHOPAIR("EEPROM can hold ", (int)((UBL_LAST_EEPROM_INDEX - ubl.eeprom_start) / sizeof(ubl.z_values)));
1237
         SERIAL_ECHOLNPGM(" meshes.\n");
1236
         SERIAL_ECHOLNPGM(" meshes.\n");
1238
 
1237
 
1239
         SERIAL_ECHOLNPGM("UBL_MESH_NUM_X_POINTS  " STRINGIFY(UBL_MESH_NUM_X_POINTS));
1238
         SERIAL_ECHOLNPGM("UBL_MESH_NUM_X_POINTS  " STRINGIFY(UBL_MESH_NUM_X_POINTS));

+ 7
- 8
Marlin/ultralcd.cpp View File

124
   int32_t lastEncoderMovementMillis;
124
   int32_t lastEncoderMovementMillis;
125
 
125
 
126
   #if ENABLED(AUTO_BED_LEVELING_UBL)
126
   #if ENABLED(AUTO_BED_LEVELING_UBL)
127
-    extern bool ubl_has_control_of_lcd_panel;
128
-    extern int8_t ubl_encoderDiff;
127
+    #include "UBL.h"
129
   #endif
128
   #endif
130
 
129
 
131
   #if HAS_POWER_SWITCH
130
   #if HAS_POWER_SWITCH
860
 
859
 
861
     static void _lcd_mesh_fine_tune(const char* msg) {
860
     static void _lcd_mesh_fine_tune(const char* msg) {
862
       defer_return_to_status = true;
861
       defer_return_to_status = true;
863
-      if (ubl_encoderDiff) {
864
-        ubl_encoderPosition = (ubl_encoderDiff > 0) ? 1 : -1;
865
-        ubl_encoderDiff = 0;
862
+      if (ubl.encoder_diff) {
863
+        ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
864
+        ubl.encoder_diff = 0;
866
 
865
 
867
         mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005 / 2.0;
866
         mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005 / 2.0;
868
         mesh_edit_value = mesh_edit_accumulator;
867
         mesh_edit_value = mesh_edit_accumulator;
3206
     lcd_buttons_update();
3205
     lcd_buttons_update();
3207
 
3206
 
3208
     #if ENABLED(AUTO_BED_LEVELING_UBL)
3207
     #if ENABLED(AUTO_BED_LEVELING_UBL)
3209
-      const bool UBL_CONDITION = !ubl_has_control_of_lcd_panel;
3208
+      const bool UBL_CONDITION = !ubl.has_control_of_lcd_panel;
3210
     #else
3209
     #else
3211
       constexpr bool UBL_CONDITION = true;
3210
       constexpr bool UBL_CONDITION = true;
3212
     #endif
3211
     #endif
3622
         case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
3621
         case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
3623
       }
3622
       }
3624
       #if ENABLED(AUTO_BED_LEVELING_UBL)
3623
       #if ENABLED(AUTO_BED_LEVELING_UBL)
3625
-        if (ubl_has_control_of_lcd_panel) {
3626
-          ubl_encoderDiff = encoderDiff;    // Make the encoder's rotation available to G29's Mesh Editor
3624
+        if (ubl.has_control_of_lcd_panel) {
3625
+          ubl.encoder_diff = encoderDiff;    // Make the encoder's rotation available to G29's Mesh Editor
3627
           encoderDiff = 0;                  // We are going to lie to the LCD Panel and claim the encoder
3626
           encoderDiff = 0;                  // We are going to lie to the LCD Panel and claim the encoder
3628
                                             // wheel has not turned.
3627
                                             // wheel has not turned.
3629
         }
3628
         }

Loading…
Cancel
Save