Pārlūkot izejas kodu

Optimize G-code flag parameters (#21849)

Scott Lahteine 3 gadus atpakaļ
vecāks
revīzija
49548c343d
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 20
- 20
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Parādīt failu

@@ -306,7 +306,7 @@ void unified_bed_leveling::G29() {
306 306
   if (G29_parse_parameters()) return; // Abort on parameter error
307 307
 
308 308
   const int8_t p_val = parser.intval('P', -1);
309
-  const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J');
309
+  const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
310 310
   #if ENABLED(HAS_MULTI_HOTEND)
311 311
     const uint8_t old_tool_index = active_extruder;
312 312
   #endif
@@ -315,7 +315,7 @@ void unified_bed_leveling::G29() {
315 315
   if (may_move) {
316 316
     planner.synchronize();
317 317
     // Send 'N' to force homing before G29 (internal only)
318
-    if (axes_should_home() || parser.seen('N')) gcode.home_all_axes();
318
+    if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
319 319
     TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
320 320
   }
321 321
 
@@ -380,7 +380,7 @@ void unified_bed_leveling::G29() {
380 380
         // Allow the user to specify the height because 10mm is a little extreme in some cases.
381 381
         for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)     // Create a rectangular raised area in
382 382
           for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed
383
-            z_values[x][y] += parser.seen('C') ? param.C_constant : 9.99f;
383
+            z_values[x][y] += parser.seen_test('C') ? param.C_constant : 9.99f;
384 384
             TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
385 385
           }
386 386
         break;
@@ -389,7 +389,7 @@ void unified_bed_leveling::G29() {
389 389
 
390 390
   #if HAS_BED_PROBE
391 391
 
392
-    if (parser.seen('J')) {
392
+    if (parser.seen_test('J')) {
393 393
       save_ubl_active_state_and_disable();
394 394
       tilt_mesh_based_on_probed_grid(param.J_grid_size == 0); // Zero size does 3-Point
395 395
       restore_ubl_active_state_and_leave();
@@ -402,7 +402,7 @@ void unified_bed_leveling::G29() {
402 402
 
403 403
   #endif // HAS_BED_PROBE
404 404
 
405
-  if (parser.seen('P')) {
405
+  if (parser.seen_test('P')) {
406 406
     if (WITHIN(param.P_phase, 0, 1) && storage_slot == -1) {
407 407
       storage_slot = 0;
408 408
       SERIAL_ECHOLNPGM("Default storage slot 0 selected.");
@@ -423,7 +423,7 @@ void unified_bed_leveling::G29() {
423 423
           //
424 424
           // Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
425 425
           //
426
-          if (!parser.seen('C')) {
426
+          if (!parser.seen_test('C')) {
427 427
             invalidate();
428 428
             SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
429 429
           }
@@ -433,7 +433,7 @@ void unified_bed_leveling::G29() {
433 433
             SERIAL_DECIMAL(param.XY_pos.y);
434 434
             SERIAL_ECHOLNPGM(").\n");
435 435
           }
436
-          probe_entire_mesh(param.XY_pos, parser.seen('T'), parser.seen('E'), parser.seen('U'));
436
+          probe_entire_mesh(param.XY_pos, parser.seen_test('T'), parser.seen_test('E'), parser.seen_test('U'));
437 437
 
438 438
           report_current_position();
439 439
           probe_deployed = true;
@@ -449,7 +449,7 @@ void unified_bed_leveling::G29() {
449 449
           SERIAL_ECHOLNPGM("Manually probing unreachable points.");
450 450
           do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
451 451
 
452
-          if (parser.seen('C') && !param.XY_seen) {
452
+          if (parser.seen_test('C') && !param.XY_seen) {
453 453
 
454 454
             /**
455 455
              * Use a good default location for the path.
@@ -483,7 +483,7 @@ void unified_bed_leveling::G29() {
483 483
           }
484 484
 
485 485
           const float height = parser.floatval('H', Z_CLEARANCE_BETWEEN_PROBES);
486
-          manually_probe_remaining_mesh(param.XY_pos, height, param.B_shim_thickness, parser.seen('T'));
486
+          manually_probe_remaining_mesh(param.XY_pos, height, param.B_shim_thickness, parser.seen_test('T'));
487 487
 
488 488
           SERIAL_ECHOLNPGM("G29 P2 finished.");
489 489
 
@@ -555,7 +555,7 @@ void unified_bed_leveling::G29() {
555 555
 
556 556
       case 4: // Fine Tune (i.e., Edit) the Mesh
557 557
         #if HAS_LCD_MENU
558
-          fine_tune_mesh(param.XY_pos, parser.seen('T'));
558
+          fine_tune_mesh(param.XY_pos, parser.seen_test('T'));
559 559
         #else
560 560
           SERIAL_ECHOLNPGM("?P4 is only available when an LCD is present.");
561 561
           return;
@@ -574,14 +574,14 @@ void unified_bed_leveling::G29() {
574 574
     // Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
575 575
     // good to have the extra information. Soon... we prune this to just a few items
576 576
     //
577
-    if (parser.seen('W')) g29_what_command();
577
+    if (parser.seen_test('W')) g29_what_command();
578 578
 
579 579
     //
580 580
     // When we are fully debugged, this may go away. But there are some valid
581 581
     // use cases for the users. So we can wait and see what to do with it.
582 582
     //
583 583
 
584
-    if (parser.seen('K')) // Kompare Current Mesh Data to Specified Stored Mesh
584
+    if (parser.seen_test('K')) // Kompare Current Mesh Data to Specified Stored Mesh
585 585
       g29_compare_current_mesh_to_stored_mesh();
586 586
 
587 587
   #endif // UBL_DEVEL_DEBUGGING
@@ -640,7 +640,7 @@ void unified_bed_leveling::G29() {
640 640
     SERIAL_ECHOLNPGM("Done.");
641 641
   }
642 642
 
643
-  if (parser.seen('T'))
643
+  if (parser.seen_test('T'))
644 644
     display_map(param.T_map_type);
645 645
 
646 646
   LEAVE:
@@ -915,7 +915,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
915 915
 
916 916
       if (do_ubl_mesh_map) display_map(param.T_map_type);   // Show user where we're probing
917 917
 
918
-      if (parser.seen('B')) {
918
+      if (parser.seen_test('B')) {
919 919
         SERIAL_ECHOPGM_P(GET_TEXT(MSG_UBL_BC_INSERT));
920 920
         LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
921 921
       }
@@ -954,7 +954,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
954 954
    *          NOTE: Blocks the G-code queue and captures Marlin UI during use.
955 955
    */
956 956
   void unified_bed_leveling::fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) {
957
-    if (!parser.seen('R'))        // fine_tune_mesh() is special. If no repetition count flag is specified
957
+    if (!parser.seen_test('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
958 958
       param.R_repetition = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
959 959
 
960 960
     #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
@@ -1091,7 +1091,7 @@ bool unified_bed_leveling::G29_parse_parameters() {
1091 1091
     }
1092 1092
   }
1093 1093
 
1094
-  param.V_verbosity = parser.seen('V') ? parser.value_int() : 0;
1094
+  param.V_verbosity = parser.intval('V');
1095 1095
   if (!WITHIN(param.V_verbosity, 0, 4)) {
1096 1096
     SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n");
1097 1097
     err_flag = true;
@@ -1153,15 +1153,15 @@ bool unified_bed_leveling::G29_parse_parameters() {
1153 1153
    *       Leveling is being enabled here with old data, possibly
1154 1154
    *       none. Error handling should disable for safety...
1155 1155
    */
1156
-  if (parser.seen('A')) {
1157
-    if (parser.seen('D')) {
1156
+  if (parser.seen_test('A')) {
1157
+    if (parser.seen_test('D')) {
1158 1158
       SERIAL_ECHOLNPGM("?Can't activate and deactivate at the same time.\n");
1159 1159
       return UBL_ERR;
1160 1160
     }
1161 1161
     set_bed_leveling_enabled(true);
1162 1162
     report_state();
1163 1163
   }
1164
-  else if (parser.seen('D')) {
1164
+  else if (parser.seen_test('D')) {
1165 1165
     set_bed_leveling_enabled(false);
1166 1166
     report_state();
1167 1167
   }
@@ -1520,7 +1520,7 @@ void unified_bed_leveling::smart_fill_mesh() {
1520 1520
             SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
1521 1521
             TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
1522 1522
 
1523
-            measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
1523
+            measured_z = probe.probe_at_point(rpos, parser.seen_test('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
1524 1524
 
1525 1525
             abort_flag = isnan(measured_z);
1526 1526
 

+ 7
- 7
Marlin/src/feature/encoder_i2c.cpp Parādīt failu

@@ -819,11 +819,11 @@ int8_t I2CPositionEncodersMgr::parse() {
819 819
 void I2CPositionEncodersMgr::M860() {
820 820
   if (parse()) return;
821 821
 
822
-  const bool hasU = parser.seen('U'), hasO = parser.seen('O');
822
+  const bool hasU = parser.seen_test('U'), hasO = parser.seen_test('O');
823 823
 
824 824
   if (I2CPE_idx == 0xFF) {
825 825
     LOOP_XYZE(i) {
826
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
826
+      if (!I2CPE_anyaxis || parser.seen_test(axis_codes[i])) {
827 827
         const uint8_t idx = idx_from_axis(AxisEnum(i));
828 828
         if ((int8_t)idx >= 0) report_position(idx, hasU, hasO);
829 829
       }
@@ -956,10 +956,10 @@ void I2CPositionEncodersMgr::M864() {
956 956
     return;
957 957
   }
958 958
   else {
959
-         if (parser.seen('X')) newAddress = I2CPE_PRESET_ADDR_X;
960
-    else if (parser.seen('Y')) newAddress = I2CPE_PRESET_ADDR_Y;
961
-    else if (parser.seen('Z')) newAddress = I2CPE_PRESET_ADDR_Z;
962
-    else if (parser.seen('E')) newAddress = I2CPE_PRESET_ADDR_E;
959
+         if (parser.seen_test('X')) newAddress = I2CPE_PRESET_ADDR_X;
960
+    else if (parser.seen_test('Y')) newAddress = I2CPE_PRESET_ADDR_Y;
961
+    else if (parser.seen_test('Z')) newAddress = I2CPE_PRESET_ADDR_Z;
962
+    else if (parser.seen_test('E')) newAddress = I2CPE_PRESET_ADDR_E;
963 963
     else return;
964 964
   }
965 965
 
@@ -1012,7 +1012,7 @@ void I2CPositionEncodersMgr::M865() {
1012 1012
 void I2CPositionEncodersMgr::M866() {
1013 1013
   if (parse()) return;
1014 1014
 
1015
-  const bool hasR = parser.seen('R');
1015
+  const bool hasR = parser.seen_test('R');
1016 1016
 
1017 1017
   if (I2CPE_idx == 0xFF) {
1018 1018
     LOOP_XYZE(i) {

+ 7
- 7
Marlin/src/feature/fwretract.cpp Parādīt failu

@@ -212,10 +212,10 @@ void FWRetract::retract(const bool retracting
212 212
  */
213 213
 void FWRetract::M207() {
214 214
   if (!parser.seen("FSWZ")) return M207_report();
215
-  if (parser.seen('S')) settings.retract_length = parser.value_axis_units(E_AXIS);
216
-  if (parser.seen('F')) settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
217
-  if (parser.seen('Z')) settings.retract_zraise = parser.value_linear_units();
218
-  if (parser.seen('W')) settings.swap_retract_length = parser.value_axis_units(E_AXIS);
215
+  if (parser.seenval('S')) settings.retract_length        = parser.value_axis_units(E_AXIS);
216
+  if (parser.seenval('F')) settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
217
+  if (parser.seenval('Z')) settings.retract_zraise        = parser.value_linear_units();
218
+  if (parser.seenval('W')) settings.swap_retract_length   = parser.value_axis_units(E_AXIS);
219 219
 }
220 220
 
221 221
 void FWRetract::M207_report(const bool forReplay/*=false*/) {
@@ -238,10 +238,10 @@ void FWRetract::M207_report(const bool forReplay/*=false*/) {
238 238
  */
239 239
 void FWRetract::M208() {
240 240
   if (!parser.seen("FSRW")) return M208_report();
241
-  if (parser.seen('S')) settings.retract_recover_extra = parser.value_axis_units(E_AXIS);
242
-  if (parser.seen('F')) settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
241
+  if (parser.seen('S')) settings.retract_recover_extra              = parser.value_axis_units(E_AXIS);
242
+  if (parser.seen('F')) settings.retract_recover_feedrate_mm_s      = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
243 243
   if (parser.seen('R')) settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
244
-  if (parser.seen('W')) settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS);
244
+  if (parser.seen('W')) settings.swap_retract_recover_extra         = parser.value_axis_units(E_AXIS);
245 245
 }
246 246
 
247 247
 void FWRetract::M208_report(const bool forReplay/*=false*/) {

+ 4
- 4
Marlin/src/gcode/bedlevel/G26.cpp Parādīt failu

@@ -648,12 +648,12 @@ void GcodeSuite::G26() {
648 648
   #if HAS_LCD_MENU
649 649
     g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
650 650
   #else
651
-    if (!parser.seen('R')) {
651
+    if (parser.seen('R'))
652
+      g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
653
+    else {
652 654
       SERIAL_ECHOLNPGM("?(R)epeat must be specified when not using an LCD.");
653 655
       return;
654 656
     }
655
-    else
656
-      g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
657 657
   #endif
658 658
   if (g26_repeats < 1) {
659 659
     SERIAL_ECHOLNPGM("?(R)epeat value not plausible; must be at least 1.");
@@ -671,7 +671,7 @@ void GcodeSuite::G26() {
671 671
   /**
672 672
    * Wait until all parameters are verified before altering the state!
673 673
    */
674
-  set_bed_leveling_enabled(!parser.seen('D'));
674
+  set_bed_leveling_enabled(!parser.seen_test('D'));
675 675
 
676 676
   do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
677 677
 

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp Parādīt failu

@@ -133,7 +133,7 @@ void GcodeSuite::M420() {
133 133
 
134 134
   #endif // AUTO_BED_LEVELING_UBL
135 135
 
136
-  const bool seenV = parser.seen('V');
136
+  const bool seenV = parser.seen_test('V');
137 137
 
138 138
   #if HAS_MESH
139 139
 

+ 6
- 6
Marlin/src/gcode/bedlevel/abl/G29.cpp Parādīt failu

@@ -223,7 +223,7 @@ G29_TYPE GcodeSuite::G29() {
223 223
 
224 224
   reset_stepper_timeout();
225 225
 
226
-  const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q');
226
+  const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen_test('Q');
227 227
 
228 228
   // G29 Q is also available if debugging
229 229
   #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -235,7 +235,7 @@ G29_TYPE GcodeSuite::G29() {
235 235
     if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
236 236
   #endif
237 237
 
238
-  const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')),
238
+  const bool seenA = TERN0(PROBE_MANUALLY, parser.seen_test('A')),
239 239
          no_action = seenA || seenQ,
240 240
               faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
241 241
 
@@ -245,7 +245,7 @@ G29_TYPE GcodeSuite::G29() {
245 245
   }
246 246
 
247 247
   // Send 'N' to force homing before G29 (internal only)
248
-  if (parser.seen('N'))
248
+  if (parser.seen_test('N'))
249 249
     process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
250 250
 
251 251
   // Don't allow auto-leveling without homing first
@@ -275,7 +275,7 @@ G29_TYPE GcodeSuite::G29() {
275 275
 
276 276
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
277 277
 
278
-      const bool seen_w = parser.seen('W');
278
+      const bool seen_w = parser.seen_test('W');
279 279
       if (seen_w) {
280 280
         if (!leveling_is_valid()) {
281 281
           SERIAL_ERROR_MSG("No bilinear grid");
@@ -308,7 +308,7 @@ G29_TYPE GcodeSuite::G29() {
308 308
           if (abl.reenable) report_current_position();
309 309
         }
310 310
         G29_RETURN(false);
311
-      } // parser.seen('W')
311
+      } // parser.seen_test('W')
312 312
 
313 313
     #else
314 314
 
@@ -317,7 +317,7 @@ G29_TYPE GcodeSuite::G29() {
317 317
     #endif
318 318
 
319 319
     // Jettison bed leveling data
320
-    if (!seen_w && parser.seen('J')) {
320
+    if (!seen_w && parser.seen_test('J')) {
321 321
       reset_bed_level();
322 322
       G29_RETURN(false);
323 323
     }

+ 1
- 1
Marlin/src/gcode/bedlevel/mbl/G29.cpp Parādīt failu

@@ -87,7 +87,7 @@ void GcodeSuite::G29() {
87 87
       mbl.reset();
88 88
       mbl_probe_index = 0;
89 89
       if (!ui.wait_for_move) {
90
-        queue.inject_P(parser.seen('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
90
+        queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
91 91
         return;
92 92
       }
93 93
       state = MeshNext;

+ 14
- 11
Marlin/src/gcode/bedlevel/ubl/M421.cpp Parādīt failu

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * unified.cpp - Unified Bed Leveling
24
+ * M421.cpp - Unified Bed Leveling
25 25
  */
26 26
 
27 27
 #include "../../../inc/MarlinConfig.h"
@@ -39,31 +39,34 @@
39 39
  * M421: Set a single Mesh Bed Leveling Z coordinate
40 40
  *
41 41
  * Usage:
42
- *   M421 I<xindex> J<yindex> Z<linear>
43
- *   M421 I<xindex> J<yindex> Q<offset>
44
- *   M421 I<xindex> J<yindex> N
45
- *   M421 C Z<linear>
46
- *   M421 C Q<offset>
42
+ *   M421 I<xindex> J<yindex> Z<linear>  : Set the Mesh Point IJ to the Z value
43
+ *   M421 I<xindex> J<yindex> Q<offset>  : Add the Q value to the Mesh Point IJ
44
+ *   M421 I<xindex> J<yindex> N          : Set the Mesh Point IJ to NAN (not set)
45
+ *   M421 C Z<linear>                    : Set the closest Mesh Point to the Z value
46
+ *   M421 C Q<offset>                    : Add the Q value to the closest Mesh Point
47 47
  */
48 48
 void GcodeSuite::M421() {
49 49
   xy_int8_t ij = { int8_t(parser.intval('I', -1)), int8_t(parser.intval('J', -1)) };
50 50
   const bool hasI = ij.x >= 0,
51 51
              hasJ = ij.y >= 0,
52
-             hasC = parser.seen('C'),
53
-             hasN = parser.seen('N'),
52
+             hasC = parser.seen_test('C'),
53
+             hasN = parser.seen_test('N'),
54 54
              hasZ = parser.seen('Z'),
55 55
              hasQ = !hasZ && parser.seen('Q');
56 56
 
57 57
   if (hasC) ij = ubl.find_closest_mesh_point_of_type(CLOSEST, current_position);
58 58
 
59
+  // Test for bad parameter combinations
59 60
   if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN))
60 61
     SERIAL_ERROR_MSG(STR_ERR_M421_PARAMETERS);
62
+
63
+  // Test for I J out of range
61 64
   else if (!WITHIN(ij.x, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(ij.y, 0, GRID_MAX_POINTS_Y - 1))
62 65
     SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
63 66
   else {
64
-    float &zval = ubl.z_values[ij.x][ij.y];
65
-    zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
66
-    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
67
+    float &zval = ubl.z_values[ij.x][ij.y];                               // Altering this Mesh Point
68
+    zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);  // N=NAN, Z=NEWVAL, or Q=ADDVAL
69
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));          // Ping ExtUI in case it's showing the mesh
67 70
   }
68 71
 }
69 72
 

+ 3
- 3
Marlin/src/gcode/calibrate/G28.cpp Parādīt failu

@@ -219,7 +219,7 @@ void GcodeSuite::G28() {
219 219
   #endif
220 220
 
221 221
   #if ENABLED(MARLIN_DEV_MODE)
222
-    if (parser.seen('S')) {
222
+    if (parser.seen_test('S')) {
223 223
       LOOP_XYZ(a) set_axis_is_at_home((AxisEnum)a);
224 224
       sync_plan_position();
225 225
       SERIAL_ECHOLNPGM("Simulated Homing");
@@ -321,10 +321,10 @@ void GcodeSuite::G28() {
321 321
 
322 322
   #else
323 323
 
324
-    const bool homeZ = parser.seen('Z'),
324
+    const bool homeZ = parser.seen_test('Z'),
325 325
                needX = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(X_AXIS))),
326 326
                needY = homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(Y_AXIS))),
327
-               homeX = needX || parser.seen('X'), homeY = needY || parser.seen('Y'),
327
+               homeX = needX || parser.seen_test('X'), homeY = needY || parser.seen_test('Y'),
328 328
                home_all = homeX == homeY && homeX == homeZ, // All or None
329 329
                doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ;
330 330
 

+ 2
- 2
Marlin/src/gcode/calibrate/G33.cpp Parādīt failu

@@ -395,7 +395,7 @@ void GcodeSuite::G33() {
395 395
     return;
396 396
   }
397 397
 
398
-  const bool towers_set = !parser.seen('T');
398
+  const bool towers_set = !parser.seen_test('T');
399 399
 
400 400
   const float calibration_precision = parser.floatval('C', 0.0f);
401 401
   if (calibration_precision < 0) {
@@ -415,7 +415,7 @@ void GcodeSuite::G33() {
415 415
     return;
416 416
   }
417 417
 
418
-  const bool stow_after_each = parser.seen('E');
418
+  const bool stow_after_each = parser.seen_test('E');
419 419
 
420 420
   const bool _0p_calibration      = probe_points == 0,
421 421
              _1p_calibration      = probe_points == 1 || probe_points == -1,

+ 1
- 1
Marlin/src/gcode/feature/pause/M125.cpp Parādīt failu

@@ -56,7 +56,7 @@
56 56
  */
57 57
 void GcodeSuite::M125() {
58 58
   // Initial retract before move to filament change position
59
-  const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
59
+  const float retract = -ABS(parser.axisunitsval('L', E_AXIS, PAUSE_PARK_RETRACT_LENGTH));
60 60
 
61 61
   xyz_pos_t park_point = NOZZLE_PARK_POINT;
62 62
 

+ 5
- 9
Marlin/src/gcode/feature/pause/M600.cpp Parādīt failu

@@ -81,8 +81,8 @@ void GcodeSuite::M600() {
81 81
 
82 82
   #if ENABLED(DUAL_X_CARRIAGE)
83 83
     int8_t DXC_ext = target_extruder;
84
-    if (!parser.seen('T')) {  // If no tool index is specified, M600 was (probably) sent in response to filament runout.
85
-                              // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
84
+    if (!parser.seen_test('T')) {  // If no tool index is specified, M600 was (probably) sent in response to filament runout.
85
+                                   // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
86 86
       #if MULTI_FILAMENT_SENSOR
87 87
         if (idex_is_duplicating())
88 88
           DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
@@ -110,7 +110,7 @@ void GcodeSuite::M600() {
110 110
   #endif
111 111
 
112 112
   // Initial retract before move to filament change position
113
-  const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
113
+  const float retract = -ABS(parser.axisunitsval('E', E_AXIS, PAUSE_PARK_RETRACT_LENGTH));
114 114
 
115 115
   xyz_pos_t park_point NOZZLE_PARK_POINT;
116 116
 
@@ -132,15 +132,11 @@ void GcodeSuite::M600() {
132 132
                     fast_load_length = 0.0f;
133 133
   #else
134 134
     // Unload filament
135
-    const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
136
-                                                      : fc_settings[active_extruder].unload_length);
137
-
135
+    const float unload_length = -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length));
138 136
     // Slow load filament
139 137
     constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
140
-
141 138
     // Fast load filament
142
-    const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
143
-                                                        : fc_settings[active_extruder].load_length);
139
+    const float fast_load_length = ABS(parser.axisunitsval('L', E_AXIS, fc_settings[active_extruder].load_length));
144 140
   #endif
145 141
 
146 142
   const int beep_count = parser.intval('B', -1

+ 2
- 2
Marlin/src/gcode/feature/powerloss/M1000.cpp Parādīt failu

@@ -59,7 +59,7 @@ inline void plr_error(PGM_P const prefix) {
59 59
 void GcodeSuite::M1000() {
60 60
 
61 61
   if (recovery.valid()) {
62
-    if (parser.seen('S')) {
62
+    if (parser.seen_test('S')) {
63 63
       #if HAS_LCD_MENU
64 64
         ui.goto_screen(menu_job_recovery);
65 65
       #elif ENABLED(DWIN_CREALITY_LCD)
@@ -70,7 +70,7 @@ void GcodeSuite::M1000() {
70 70
         SERIAL_ECHO_MSG("Resume requires LCD.");
71 71
       #endif
72 72
     }
73
-    else if (parser.seen('C')) {
73
+    else if (parser.seen_test('C')) {
74 74
       #if HAS_LCD_MENU
75 75
         lcd_power_loss_recovery_cancel();
76 76
       #else

+ 6
- 6
Marlin/src/gcode/feature/powerloss/M413.cpp Parādīt failu

@@ -48,14 +48,14 @@ void GcodeSuite::M413() {
48 48
 
49 49
   #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
50 50
     if (parser.seen("RL")) recovery.load();
51
-    if (parser.seen('W')) recovery.save(true);
52
-    if (parser.seen('P')) recovery.purge();
53
-    if (parser.seen('D')) recovery.debug(PSTR("M413"));
51
+    if (parser.seen_test('W')) recovery.save(true);
52
+    if (parser.seen_test('P')) recovery.purge();
53
+    if (parser.seen_test('D')) recovery.debug(PSTR("M413"));
54 54
     #if PIN_EXISTS(POWER_LOSS)
55
-      if (parser.seen('O')) recovery._outage();
55
+      if (parser.seen_test('O')) recovery._outage();
56 56
     #endif
57
-    if (parser.seen('E')) SERIAL_ECHOPGM_P(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n"));
58
-    if (parser.seen('V')) SERIAL_ECHOPGM_P(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n"));
57
+    if (parser.seen_test('E')) SERIAL_ECHOPGM_P(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n"));
58
+    if (parser.seen_test('V')) SERIAL_ECHOPGM_P(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n"));
59 59
   #endif
60 60
 }
61 61
 

+ 1
- 1
Marlin/src/gcode/feature/runout/M412.cpp Parādīt failu

@@ -44,7 +44,7 @@ void GcodeSuite::M412() {
44 44
     #if ENABLED(HOST_ACTION_COMMANDS)
45 45
       if (parser.seen('H')) runout.host_handling = parser.value_bool();
46 46
     #endif
47
-    const bool seenR = parser.seen('R'), seenS = parser.seen('S');
47
+    const bool seenR = parser.seen_test('R'), seenS = parser.seen('S');
48 48
     if (seenR || seenS) runout.reset();
49 49
     if (seenS) runout.enabled = parser.value_bool();
50 50
     #if HAS_FILAMENT_RUNOUT_DISTANCE

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M122.cpp Parādīt failu

@@ -48,7 +48,7 @@ void GcodeSuite::M122() {
48 48
       tmc_set_report_interval(interval);
49 49
     #endif
50 50
 
51
-    if (parser.seen('V'))
51
+    if (parser.seen_test('V'))
52 52
       tmc_get_registers(print_axis.x, print_axis.y, print_axis.z, print_axis.e);
53 53
     else
54 54
       tmc_report_all(print_axis.x, print_axis.y, print_axis.z, print_axis.e);

+ 1
- 1
Marlin/src/gcode/gcode_d.cpp Parādīt failu

@@ -52,7 +52,7 @@
52 52
         break;
53 53
 
54 54
       case 10:
55
-        kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen('P'));
55
+        kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen_test('P'));
56 56
         break;
57 57
 
58 58
       case 1: {

+ 3
- 3
Marlin/src/gcode/host/M114.cpp Parādīt failu

@@ -193,7 +193,7 @@
193 193
 void GcodeSuite::M114() {
194 194
 
195 195
   #if ENABLED(M114_DETAIL)
196
-    if (parser.seen('D')) {
196
+    if (parser.seen_test('D')) {
197 197
       #if DISABLED(M114_LEGACY)
198 198
         planner.synchronize();
199 199
       #endif
@@ -201,14 +201,14 @@ void GcodeSuite::M114() {
201 201
       report_current_position_detail();
202 202
       return;
203 203
     }
204
-    if (parser.seen('E')) {
204
+    if (parser.seen_test('E')) {
205 205
       SERIAL_ECHOLNPAIR("Count E:", stepper.position(E_AXIS));
206 206
       return;
207 207
     }
208 208
   #endif
209 209
 
210 210
   #if ENABLED(M114_REALTIME)
211
-    if (parser.seen('R')) { report_real_position(); return; }
211
+    if (parser.seen_test('R')) { report_real_position(); return; }
212 212
   #endif
213 213
 
214 214
   TERN_(M114_LEGACY, planner.synchronize());

+ 3
- 3
Marlin/src/gcode/motion/G0_G1.cpp Parādīt failu

@@ -49,9 +49,9 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) {
49 49
   if (IsRunning()
50 50
     #if ENABLED(NO_MOTION_BEFORE_HOMING)
51 51
       && !homing_needed_error(
52
-          (parser.seen('X') ? _BV(X_AXIS) : 0)
53
-        | (parser.seen('Y') ? _BV(Y_AXIS) : 0)
54
-        | (parser.seen('Z') ? _BV(Z_AXIS) : 0) )
52
+          (parser.seen_test('X') ? _BV(X_AXIS) : 0)
53
+        | (parser.seen_test('Y') ? _BV(Y_AXIS) : 0)
54
+        | (parser.seen_test('Z') ? _BV(Z_AXIS) : 0) )
55 55
     #endif
56 56
   ) {
57 57
     TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_RUNNING));

+ 1
- 1
Marlin/src/gcode/motion/M290.cpp Parādīt failu

@@ -74,7 +74,7 @@ void GcodeSuite::M290() {
74 74
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
75 75
         babystep.add_mm((AxisEnum)a, offs);
76 76
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
77
-          if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_probe_offset(offs);
77
+          if (a == Z_AXIS && parser.boolval('P', true)) mod_probe_offset(offs);
78 78
         #endif
79 79
       }
80 80
   #else

+ 2
- 0
Marlin/src/gcode/parser.h Parādīt failu

@@ -408,6 +408,8 @@ public:
408 408
   static inline int32_t   longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
409 409
   static inline uint32_t  ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
410 410
   static inline float     linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
411
+  static inline float     axisunitsval(const char c, const AxisEnum a, const float dval=0)
412
+                                                                         { return seenval(c) ? value_axis_units(a)  : dval; }
411 413
   static inline celsius_t celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
412 414
 
413 415
   #if ENABLED(MARLIN_DEV_MODE)

+ 1
- 1
Marlin/src/gcode/sd/M27.cpp Parādīt failu

@@ -33,7 +33,7 @@
33 33
  *      OR, with 'C' get the current filename.
34 34
  */
35 35
 void GcodeSuite::M27() {
36
-  if (parser.seen('C')) {
36
+  if (parser.seen_test('C')) {
37 37
     SERIAL_ECHOPGM("Current file: ");
38 38
     card.printSelectedFilename();
39 39
     return;

+ 1
- 1
Marlin/src/gcode/sd/M808.cpp Parādīt failu

@@ -44,7 +44,7 @@ void GcodeSuite::M808() {
44 44
   // Allowed to go into the queue for logging purposes.
45 45
 
46 46
   // M808 K sent from the host to cancel all loops
47
-  if (parser.seen('K')) repeat.cancel();
47
+  if (parser.seen_test('K')) repeat.cancel();
48 48
 
49 49
 }
50 50
 

+ 1
- 1
Marlin/src/gcode/temp/M106_M107.cpp Parādīt failu

@@ -68,7 +68,7 @@ void GcodeSuite::M106() {
68 68
       if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t);
69 69
     #endif
70 70
 
71
-    const uint16_t dspeed = parser.seen('A') ? thermalManager.fan_speed[active_extruder] : 255;
71
+    const uint16_t dspeed = parser.seen_test('A') ? thermalManager.fan_speed[active_extruder] : 255;
72 72
 
73 73
     uint16_t speed = dspeed;
74 74
 

+ 1
- 1
Marlin/src/gcode/temp/M303.cpp Parādīt failu

@@ -47,7 +47,7 @@
47 47
 void GcodeSuite::M303() {
48 48
 
49 49
   #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG)
50
-    if (parser.seen('D')) {
50
+    if (parser.seen_test('D')) {
51 51
       thermalManager.pid_debug_flag ^= true;
52 52
       SERIAL_ECHO_START();
53 53
       SERIAL_ECHOPGM("PID Debug ");

Notiek ielāde…
Atcelt
Saglabāt