Ver código fonte

Set and check main parameter values, report all errors

Scott Lahteine 8 anos atrás
pai
commit
3729510b1e
1 arquivos alterados com 18 adições e 21 exclusões
  1. 18
    21
      Marlin/ubl_G29.cpp

+ 18
- 21
Marlin/ubl_G29.cpp Ver arquivo

1001
       lcd_quick_feedback();
1001
       lcd_quick_feedback();
1002
     #endif
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
     g29_verbose_level = code_seen('V') ? code_value_int() : 0;
1012
     g29_verbose_level = code_seen('V') ? code_value_int() : 0;
1011
     if (!WITHIN(g29_verbose_level, 0, 4)) {
1013
     if (!WITHIN(g29_verbose_level, 0, 4)) {
1012
       SERIAL_PROTOCOLLNPGM("Invalid Verbose Level specified. (0-4)\n");
1014
       SERIAL_PROTOCOLLNPGM("Invalid Verbose Level specified. (0-4)\n");
1013
-      return UBL_ERR;
1015
+      err_flag = true;
1014
     }
1016
     }
1015
 
1017
 
1016
     if (code_seen('G')) {
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
       if (!WITHIN(grid_size_G, 2, 10)) {
1020
       if (!WITHIN(grid_size_G, 2, 10)) {
1021
         SERIAL_PROTOCOLLNPGM("Invalid grid probe points specified.\n");
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
     if (!WITHIN(RAW_X_POSITION(x_pos), X_MIN_POS, X_MAX_POS)) {
1031
     if (!WITHIN(RAW_X_POSITION(x_pos), X_MIN_POS, X_MAX_POS)) {
1029
       SERIAL_PROTOCOLLNPGM("Invalid X location specified.\n");
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
     if (!WITHIN(RAW_Y_POSITION(y_pos), Y_MIN_POS, Y_MAX_POS)) {
1036
     if (!WITHIN(RAW_Y_POSITION(y_pos), Y_MIN_POS, Y_MAX_POS)) {
1036
       SERIAL_PROTOCOLLNPGM("Invalid Y location specified.\n");
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
     if (code_seen('A')) {     // Activate the Unified Bed Leveling System
1043
     if (code_seen('A')) {     // Activate the Unified Bed Leveling System
1046
       ubl.state.active = 1;
1044
       ubl.state.active = 1;
1069
       }
1067
       }
1070
     #endif
1068
     #endif
1071
 
1069
 
1072
-    repeat_flag = code_seen('R');
1073
     repetition_cnt = repeat_flag ? (code_has_value() ? code_value_int() : 9999) : 1;
1070
     repetition_cnt = repeat_flag ? (code_has_value() ? code_value_int() : 9999) : 1;
1074
     if (repetition_cnt < 1) {
1071
     if (repetition_cnt < 1) {
1075
       SERIAL_PROTOCOLLNPGM("Invalid Repetition count.\n");
1072
       SERIAL_PROTOCOLLNPGM("Invalid Repetition count.\n");

Carregando…
Cancelar
Salvar