Bladeren bron

General UBL/G26 code cleanup

Scott Lahteine 6 jaren geleden
bovenliggende
commit
7b6ad28a5d
3 gewijzigde bestanden met toevoegingen van 54 en 50 verwijderingen
  1. 3
    3
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 48
    45
      Marlin/ubl_G29.cpp
  3. 3
    2
      Marlin/ultralcd.cpp

+ 3
- 3
Marlin/G26_Mesh_Validation_Tool.cpp Bestand weergeven

@@ -168,15 +168,15 @@
168 168
      * Detect is_lcd_clicked, debounce it, and return true for cancel
169 169
      */
170 170
     bool user_canceled() {
171
-      if (!is_lcd_clicked()) return false;
172
-      safe_delay(10);                       // Wait for click to settle
171
+      if (!is_lcd_clicked()) return false; // Return if the button isn't pressed
173 172
 
174 173
       #if ENABLED(ULTRA_LCD)
175 174
         lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
176 175
         lcd_quick_feedback();
177 176
       #endif
178 177
 
179
-      while (!is_lcd_clicked()) idle();    // Wait for button release
178
+      safe_delay(10);                      // Wait for click to settle
179
+      while (!is_lcd_clicked()) idle();    // Wait for button press again?
180 180
 
181 181
       // If the button is suddenly pressed again,
182 182
       // ask the user to resolve the issue

+ 48
- 45
Marlin/ubl_G29.cpp Bestand weergeven

@@ -24,6 +24,8 @@
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_UBL)
26 26
 
27
+  //#define UBL_DEVEL_DEBUGGING
28
+
27 29
   #include "ubl.h"
28 30
   #include "Marlin.h"
29 31
   #include "hex_print_routines.h"
@@ -1152,21 +1154,24 @@
1152 1154
     return UBL_OK;
1153 1155
   }
1154 1156
 
1155
-  static int ubl_state_at_invocation = 0,
1156
-             ubl_state_recursion_chk = 0;
1157
-
1158
-  void unified_bed_leveling::save_ubl_active_state_and_disable() {
1159
-    ubl_state_recursion_chk++;
1160
-    if (ubl_state_recursion_chk != 1) {
1161
-      SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1157
+  static uint8_t ubl_state_at_invocation = 0;
1162 1158
 
1163
-      #if ENABLED(NEWPANEL)
1164
-        LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
1165
-        lcd_quick_feedback();
1166
-      #endif
1159
+  #ifdef UBL_DEVEL_DEBUGGING
1160
+    static uint8_t ubl_state_recursion_chk = 0;
1161
+  #endif
1167 1162
 
1168
-      return;
1169
-    }
1163
+  void unified_bed_leveling::save_ubl_active_state_and_disable() {
1164
+    #ifdef UBL_DEVEL_DEBUGGING
1165
+      ubl_state_recursion_chk++;
1166
+      if (ubl_state_recursion_chk != 1) {
1167
+        SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1168
+        #if ENABLED(NEWPANEL)
1169
+          LCD_MESSAGEPGM(MSG_UBL_SAVE_ERROR);
1170
+          lcd_quick_feedback();
1171
+        #endif
1172
+        return;
1173
+      }
1174
+    #endif
1170 1175
     ubl_state_at_invocation = planner.leveling_active;
1171 1176
     set_bed_leveling_enabled(false);
1172 1177
   }
@@ -1253,28 +1258,30 @@
1253 1258
     SERIAL_EOL();
1254 1259
     safe_delay(50);
1255 1260
 
1256
-    SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1257
-    SERIAL_EOL();
1258
-    SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1259
-    SERIAL_EOL();
1260
-    safe_delay(50);
1261
+    #ifdef UBL_DEVEL_DEBUGGING
1262
+      SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
1263
+      SERIAL_EOL();
1264
+      SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
1265
+      SERIAL_EOL();
1266
+      safe_delay(50);
1261 1267
 
1262
-    SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
1263
-    SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
1264
-    safe_delay(50);
1268
+      SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
1269
+      SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
1270
+      safe_delay(50);
1265 1271
 
1266
-    SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1267
-    SERIAL_EOL();
1268
-    SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1269
-    SERIAL_EOL();
1270
-    safe_delay(25);
1272
+      SERIAL_PROTOCOLLNPAIR("sizeof(ubl) :  ", (int)sizeof(ubl));
1273
+      SERIAL_EOL();
1274
+      SERIAL_PROTOCOLLNPAIR("z_value[][] size: ", (int)sizeof(z_values));
1275
+      SERIAL_EOL();
1276
+      safe_delay(25);
1271 1277
 
1272
-    SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
1273
-    safe_delay(50);
1278
+      SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
1279
+      safe_delay(50);
1274 1280
 
1275
-    SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1276
-    SERIAL_PROTOCOLLNPGM(" meshes.\n");
1277
-    safe_delay(25);
1281
+      SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
1282
+      SERIAL_PROTOCOLLNPGM(" meshes.\n");
1283
+      safe_delay(25);
1284
+    #endif // UBL_DEVEL_DEBUGGING
1278 1285
 
1279 1286
     if (!sanity_check()) {
1280 1287
       echo_name();
@@ -1344,11 +1351,10 @@
1344 1351
         z_values[x][y] -= tmp_z_values[x][y];
1345 1352
   }
1346 1353
 
1347
-
1348 1354
   mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1349 1355
 
1350
-    bool found_a_NAN  = false;
1351
-    bool found_a_real = false;
1356
+    bool found_a_NAN  = false, found_a_real = false;
1357
+
1352 1358
     mesh_index_pair out_mesh;
1353 1359
     out_mesh.x_index = out_mesh.y_index = -1;
1354 1360
     out_mesh.distance = -99999.99;
@@ -1356,12 +1362,12 @@
1356 1362
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1357 1363
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1358 1364
 
1359
-        if ( isnan(z_values[i][j])) { // Check to see if this location holds an invalid mesh point
1365
+        if (isnan(z_values[i][j])) { // Check to see if this location holds an invalid mesh point
1360 1366
 
1361 1367
           const float mx = mesh_index_to_xpos(i),
1362 1368
                       my = mesh_index_to_ypos(j);
1363 1369
 
1364
-          if ( !position_is_reachable_by_probe(mx, my))  // make sure the probe can get to the mesh point
1370
+          if (!position_is_reachable_by_probe(mx, my))  // make sure the probe can get to the mesh point
1365 1371
             continue;
1366 1372
 
1367 1373
           found_a_NAN = true;
@@ -1504,15 +1510,8 @@
1504 1510
         if (!position_is_reachable(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1505 1511
           break;
1506 1512
 
1507
-        float new_z = z_values[location.x_index][location.y_index];
1508
-
1509
-        if (isnan(new_z)) // if the mesh point is invalid, set it to 0.0 so it can be edited
1510
-          new_z = 0.0;
1511
-
1512 1513
         do_blocking_move_to(rawx, rawy, Z_CLEARANCE_BETWEEN_PROBES); // Move the nozzle to the edit point
1513 1514
 
1514
-        new_z = FLOOR(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1515
-
1516 1515
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1517 1516
         lcd_external_control = true;
1518 1517
 
@@ -1520,15 +1519,19 @@
1520 1519
 
1521 1520
         lcd_refresh();
1522 1521
 
1522
+        float new_z = z_values[location.x_index][location.y_index];
1523
+        if (isnan(new_z)) new_z = 0.0;          // Set invalid mesh points to 0.0 so they can be edited
1524
+        new_z = FLOOR(new_z * 1000.0) * 0.001;  // Chop off digits after the 1000ths place
1525
+
1523 1526
         lcd_mesh_edit_setup(new_z);
1524 1527
 
1525
-        do {
1528
+        while (!is_lcd_clicked()) {
1526 1529
           new_z = lcd_mesh_edit();
1527 1530
           #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1528 1531
             do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1529 1532
           #endif
1530 1533
           idle();
1531
-        } while (!is_lcd_clicked());
1534
+        }
1532 1535
 
1533 1536
         if (!lcd_map_control) lcd_return_to_status();
1534 1537
 

+ 3
- 2
Marlin/ultralcd.cpp Bestand weergeven

@@ -2306,11 +2306,12 @@ void kill_screen(const char* lcd_msg) {
2306 2306
 
2307 2307
     void _lcd_ubl_map_homing() {
2308 2308
       defer_return_to_status = true;
2309
-      ubl.lcd_map_control = true; // Return to the map screen
2310 2309
       if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT < 3 ? 0 : (LCD_HEIGHT > 4 ? 2 : 1), PSTR(MSG_LEVEL_BED_HOMING));
2311 2310
       lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
2312
-      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
2311
+      if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
2312
+        ubl.lcd_map_control = true; // Return to the map screen
2313 2313
         lcd_goto_screen(_lcd_ubl_output_map_lcd);
2314
+      }
2314 2315
     }
2315 2316
 
2316 2317
     /**

Laden…
Annuleren
Opslaan