Browse Source

Merge pull request #6277 from thinkyhead/pr_roxy3d_rcbugfix

Unify UBL Command Parsing
Scott Lahteine 8 years ago
parent
commit
d3b4d84586
1 changed files with 26 additions and 33 deletions
  1. 26
    33
      Marlin/ubl_G29.cpp

+ 26
- 33
Marlin/ubl_G29.cpp View File

@@ -674,7 +674,7 @@
674 674
           if (ELAPSED(millis(), nxt)) {
675 675
             SERIAL_PROTOCOLLNPGM("\nZ-Offset Adjustment Stopped.");
676 676
             do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
677
-            lcd_setstatuspgm(PSTR("Z-Offset Stopped"));
677
+            LCD_MESSAGEPGM("Z-Offset Stopped");
678 678
             restore_ubl_active_state_and_leave();
679 679
             goto LEAVE;
680 680
           }
@@ -693,7 +693,7 @@
693 693
 
694 694
     #if ENABLED(ULTRA_LCD)
695 695
       lcd_reset_alert_level();
696
-      lcd_setstatuspgm(PSTR(""));
696
+      LCD_MESSAGEPGM("");
697 697
       lcd_quick_feedback();
698 698
     #endif
699 699
 
@@ -997,50 +997,48 @@
997 997
 
998 998
   bool g29_parameter_parsing() {
999 999
     #if ENABLED(ULTRA_LCD)
1000
-      lcd_setstatuspgm(PSTR("Doing G29 UBL!"));
1000
+      LCD_MESSAGEPGM("Doing G29 UBL!");
1001 1001
       lcd_quick_feedback();
1002 1002
     #endif
1003 1003
 
1004
-    x_pos = current_position[X_AXIS];
1005
-    y_pos = current_position[Y_AXIS];
1006
-    x_flag = 0;
1007
-    y_flag = 0;
1008
-    repeat_flag = 0;
1004
+    x_flag = code_seen('X') && code_has_value();
1005
+    y_flag = code_seen('Y') && code_has_value();
1006
+    x_pos = x_flag ? code_value_float() : current_position[X_AXIS];
1007
+    y_pos = y_flag ? code_value_float() : current_position[Y_AXIS];
1008
+    repeat_flag = code_seen('R') ? code_value_bool() : false;
1009
+
1010
+    bool err_flag = false;
1009 1011
 
1010 1012
     g29_verbose_level = code_seen('V') ? code_value_int() : 0;
1011 1013
     if (!WITHIN(g29_verbose_level, 0, 4)) {
1012 1014
       SERIAL_PROTOCOLLNPGM("Invalid Verbose Level specified. (0-4)\n");
1013
-      return UBL_ERR;
1015
+      err_flag = true;
1014 1016
     }
1015 1017
 
1016 1018
     if (code_seen('G')) {
1017
-      grid_size_G = 3;
1018
-      if (code_has_value())
1019
-        grid_size_G = code_value_int();
1019
+      grid_size_G = code_has_value() ? code_value_int() : 3;
1020 1020
       if (!WITHIN(grid_size_G, 2, 10)) {
1021 1021
         SERIAL_PROTOCOLLNPGM("Invalid grid probe points specified.\n");
1022
-        return UBL_ERR;
1022
+        err_flag = true;
1023 1023
       }
1024 1024
     }
1025 1025
 
1026
-    x_flag = code_seen('X') && code_has_value();
1027
-    x_pos = x_flag ? code_value_float() : current_position[X_AXIS];
1026
+    if (x_flag != y_flag) {
1027
+      SERIAL_PROTOCOLLNPGM("Both X & Y locations must be specified.\n");
1028
+      err_flag = true;
1029
+    }
1030
+
1028 1031
     if (!WITHIN(RAW_X_POSITION(x_pos), X_MIN_POS, X_MAX_POS)) {
1029 1032
       SERIAL_PROTOCOLLNPGM("Invalid X location specified.\n");
1030
-      return UBL_ERR;
1033
+      err_flag = true;
1031 1034
     }
1032 1035
 
1033
-    y_flag = code_seen('Y') && code_has_value();
1034
-    y_pos = y_flag ? code_value_float() : current_position[Y_AXIS];
1035 1036
     if (!WITHIN(RAW_Y_POSITION(y_pos), Y_MIN_POS, Y_MAX_POS)) {
1036 1037
       SERIAL_PROTOCOLLNPGM("Invalid Y location specified.\n");
1037
-      return UBL_ERR;
1038
+      err_flag = true;
1038 1039
     }
1039 1040
 
1040
-    if (x_flag != y_flag) {
1041
-      SERIAL_PROTOCOLLNPGM("Both X & Y locations must be specified.\n");
1042
-      return UBL_ERR;
1043
-    }
1041
+    if (err_flag) return UBL_ERR;
1044 1042
 
1045 1043
     if (code_seen('A')) {     // Activate the Unified Bed Leveling System
1046 1044
       ubl.state.active = 1;
@@ -1069,7 +1067,6 @@
1069 1067
       }
1070 1068
     #endif
1071 1069
 
1072
-    repeat_flag = code_seen('R');
1073 1070
     repetition_cnt = repeat_flag ? (code_has_value() ? code_value_int() : 9999) : 1;
1074 1071
     if (repetition_cnt < 1) {
1075 1072
       SERIAL_PROTOCOLLNPGM("Invalid Repetition count.\n");
@@ -1124,7 +1121,7 @@
1124 1121
     ubl_state_recursion_chk++;
1125 1122
     if (ubl_state_recursion_chk != 1) {
1126 1123
       SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
1127
-      lcd_setstatuspgm(PSTR("save_UBL_active() error"));
1124
+      LCD_MESSAGEPGM("save_UBL_active() error");
1128 1125
       lcd_quick_feedback();
1129 1126
       return;
1130 1127
     }
@@ -1135,7 +1132,7 @@
1135 1132
   void restore_ubl_active_state_and_leave() {
1136 1133
     if (--ubl_state_recursion_chk) {
1137 1134
       SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
1138
-      lcd_setstatuspgm(PSTR("restore_UBL_active() error"));
1135
+      LCD_MESSAGEPGM("restore_UBL_active() error");
1139 1136
       lcd_quick_feedback();
1140 1137
       return;
1141 1138
     }
@@ -1374,9 +1371,7 @@
1374 1371
     save_ubl_active_state_and_disable();
1375 1372
     memset(not_done, 0xFF, sizeof(not_done));
1376 1373
 
1377
-    #if ENABLED(ULTRA_LCD)
1378
-      lcd_setstatuspgm(PSTR("Fine Tuning Mesh"));
1379
-    #endif
1374
+    LCD_MESSAGEPGM("Fine Tuning Mesh");
1380 1375
 
1381 1376
     do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1382 1377
     do_blocking_move_to_xy(lx, ly);
@@ -1434,7 +1429,7 @@
1434 1429
           lcd_return_to_status();
1435 1430
           //SERIAL_PROTOCOLLNPGM("\nFine Tuning of Mesh Stopped.");
1436 1431
           do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
1437
-          lcd_setstatuspgm(PSTR("Mesh Editing Stopped"));
1432
+          LCD_MESSAGEPGM("Mesh Editing Stopped");
1438 1433
 
1439 1434
           while (ubl_lcd_clicked()) idle();
1440 1435
 
@@ -1461,9 +1456,7 @@
1461 1456
 
1462 1457
     do_blocking_move_to_xy(lx, ly);
1463 1458
 
1464
-    #if ENABLED(ULTRA_LCD)
1465
-      lcd_setstatuspgm(PSTR("Done Editing Mesh"));
1466
-    #endif
1459
+    LCD_MESSAGEPGM("Done Editing Mesh");
1467 1460
     SERIAL_ECHOLNPGM("Done Editing Mesh");
1468 1461
   }
1469 1462
 

Loading…
Cancel
Save