Browse Source

Add shorthand value accessors to gcode.h

Scott Lahteine 7 years ago
parent
commit
05449cf6ee
4 changed files with 147 additions and 142 deletions
  1. 6
    6
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 127
    133
      Marlin/Marlin_main.cpp
  3. 11
    0
      Marlin/gcode.h
  4. 3
    3
      Marlin/ubl_G29.cpp

+ 6
- 6
Marlin/G26_Mesh_Validation_Tool.cpp View File

638
     g26_hotend_temp           = HOTEND_TEMP;
638
     g26_hotend_temp           = HOTEND_TEMP;
639
     g26_prime_flag            = 0;
639
     g26_prime_flag            = 0;
640
 
640
 
641
-    g26_ooze_amount           = parser.seenval('O') ? parser.value_linear_units() : OOZE_AMOUNT;
642
-    g26_keep_heaters_on       = parser.seen('K') && parser.value_bool();
643
-    g26_continue_with_closest = parser.seen('C') && parser.value_bool();
641
+    g26_ooze_amount           = parser.linearval('O', OOZE_AMOUNT);
642
+    g26_keep_heaters_on       = parser.boolval('K');
643
+    g26_continue_with_closest = parser.boolval('C');
644
 
644
 
645
     if (parser.seenval('B')) {
645
     if (parser.seenval('B')) {
646
       g26_bed_temp = parser.value_celsius();
646
       g26_bed_temp = parser.value_celsius();
727
     }
727
     }
728
 
728
 
729
     #if ENABLED(NEWPANEL)
729
     #if ENABLED(NEWPANEL)
730
-      g26_repeats = parser.seen('R') && parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
730
+      g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
731
     #else
731
     #else
732
       if (!parser.seen('R')) {
732
       if (!parser.seen('R')) {
733
         SERIAL_PROTOCOLLNPGM("?(R)epeat must be specified when not using an LCD.");
733
         SERIAL_PROTOCOLLNPGM("?(R)epeat must be specified when not using an LCD.");
741
       return UBL_ERR;
741
       return UBL_ERR;
742
     }
742
     }
743
 
743
 
744
-    g26_x_pos = parser.seen('X') ? parser.value_linear_units() : current_position[X_AXIS];
745
-    g26_y_pos = parser.seen('Y') ? parser.value_linear_units() : current_position[Y_AXIS];
744
+    g26_x_pos = parser.linearval('X', current_position[X_AXIS]);
745
+    g26_y_pos = parser.linearval('Y', current_position[Y_AXIS]);
746
     if (!position_is_reachable_xy(g26_x_pos, g26_y_pos)) {
746
     if (!position_is_reachable_xy(g26_x_pos, g26_y_pos)) {
747
       SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
747
       SERIAL_PROTOCOLLNPGM("?Specified X,Y coordinate out of bounds.");
748
       return UBL_ERR;
748
       return UBL_ERR;

+ 127
- 133
Marlin/Marlin_main.cpp View File

3175
       destination[i] = current_position[i];
3175
       destination[i] = current_position[i];
3176
   }
3176
   }
3177
 
3177
 
3178
-  if (parser.seen('F') && parser.value_linear_units() > 0.0)
3178
+  if (parser.linearval('F') > 0.0)
3179
     feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
3179
     feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
3180
 
3180
 
3181
   #if ENABLED(PRINTCOUNTER)
3181
   #if ENABLED(PRINTCOUNTER)
3329
 
3329
 
3330
         #if ENABLED(ARC_P_CIRCLES)
3330
         #if ENABLED(ARC_P_CIRCLES)
3331
           // P indicates number of circles to do
3331
           // P indicates number of circles to do
3332
-          int8_t circles_to_do = parser.seen('P') ? parser.value_byte() : 0;
3332
+          int8_t circles_to_do = parser.byteval('P');
3333
           if (!WITHIN(circles_to_do, 0, 100)) {
3333
           if (!WITHIN(circles_to_do, 0, 100)) {
3334
             SERIAL_ERROR_START();
3334
             SERIAL_ERROR_START();
3335
             SERIAL_ERRORLNPGM(MSG_ERR_ARC_ARGS);
3335
             SERIAL_ERRORLNPGM(MSG_ERR_ARC_ARGS);
3388
       gcode_get_destination();
3388
       gcode_get_destination();
3389
 
3389
 
3390
       const float offset[] = {
3390
       const float offset[] = {
3391
-        parser.seen('I') ? parser.value_linear_units() : 0.0,
3392
-        parser.seen('J') ? parser.value_linear_units() : 0.0,
3393
-        parser.seen('P') ? parser.value_linear_units() : 0.0,
3394
-        parser.seen('Q') ? parser.value_linear_units() : 0.0
3391
+        parser.linearval('I'),
3392
+        parser.linearval('J'),
3393
+        parser.linearval('P'),
3394
+        parser.linearval('Q')
3395
       };
3395
       };
3396
 
3396
 
3397
       plan_cubic_move(offset);
3397
       plan_cubic_move(offset);
3408
    */
3408
    */
3409
   inline void gcode_G10_G11(bool doRetract=false) {
3409
   inline void gcode_G10_G11(bool doRetract=false) {
3410
     #if EXTRUDERS > 1
3410
     #if EXTRUDERS > 1
3411
-      if (doRetract) {
3412
-        retracted_swap[active_extruder] = (parser.seen('S') && parser.value_bool()); // checks for swap retract argument
3413
-      }
3411
+      if (doRetract)
3412
+        retracted_swap[active_extruder] = parser.boolval('S'); // checks for swap retract argument
3414
     #endif
3413
     #endif
3415
     retract(doRetract
3414
     retract(doRetract
3416
      #if EXTRUDERS > 1
3415
      #if EXTRUDERS > 1
3429
     // Don't allow nozzle cleaning without homing first
3428
     // Don't allow nozzle cleaning without homing first
3430
     if (axis_unhomed_error()) return;
3429
     if (axis_unhomed_error()) return;
3431
 
3430
 
3432
-    const uint8_t pattern = parser.seen('P') ? parser.value_ushort() : 0,
3433
-                  strokes = parser.seen('S') ? parser.value_ushort() : NOZZLE_CLEAN_STROKES,
3434
-                  objects = parser.seen('T') ? parser.value_ushort() : NOZZLE_CLEAN_TRIANGLES;
3435
-    const float radius = parser.seen('R') ? parser.value_float() : NOZZLE_CLEAN_CIRCLE_RADIUS;
3431
+    const uint8_t pattern = parser.ushortval('P', 0),
3432
+                  strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
3433
+                  objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
3434
+    const float radius = parser.floatval('R', NOZZLE_CLEAN_CIRCLE_RADIUS);
3436
 
3435
 
3437
     Nozzle::clean(pattern, strokes, radius, objects);
3436
     Nozzle::clean(pattern, strokes, radius, objects);
3438
   }
3437
   }
3476
   inline void gcode_G27() {
3475
   inline void gcode_G27() {
3477
     // Don't allow nozzle parking without homing first
3476
     // Don't allow nozzle parking without homing first
3478
     if (axis_unhomed_error()) return;
3477
     if (axis_unhomed_error()) return;
3479
-    Nozzle::park(parser.seen('P') ? parser.value_ushort() : 0);
3478
+    Nozzle::park(parser.ushortval('P'));
3480
   }
3479
   }
3481
 #endif // NOZZLE_PARK_FEATURE
3480
 #endif // NOZZLE_PARK_FEATURE
3482
 
3481
 
4039
       static bool enable_soft_endstops;
4038
       static bool enable_soft_endstops;
4040
     #endif
4039
     #endif
4041
 
4040
 
4042
-    const MeshLevelingState state = parser.seen('S') ? (MeshLevelingState)parser.value_byte() : MeshReport;
4041
+    const MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport);
4043
     if (!WITHIN(state, 0, 5)) {
4042
     if (!WITHIN(state, 0, 5)) {
4044
       SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
4043
       SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
4045
       return;
4044
       return;
4269
     #endif
4268
     #endif
4270
 
4269
 
4271
     #if ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY)
4270
     #if ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY)
4272
-      const bool faux = parser.seen('C') && parser.value_bool();
4271
+      const bool faux = parser.boolval('C');
4273
     #elif ENABLED(PROBE_MANUALLY)
4272
     #elif ENABLED(PROBE_MANUALLY)
4274
       const bool faux = no_action;
4273
       const bool faux = no_action;
4275
     #else
4274
     #else
4371
             return;
4370
             return;
4372
           }
4371
           }
4373
 
4372
 
4374
-          const float z = parser.seenval('Z') ? parser.value_float() : RAW_CURRENT_POSITION(Z);
4373
+          const float z = parser.floatval('Z', RAW_CURRENT_POSITION(Z));
4375
           if (!WITHIN(z, -10, 10)) {
4374
           if (!WITHIN(z, -10, 10)) {
4376
             SERIAL_ERROR_START();
4375
             SERIAL_ERROR_START();
4377
             SERIAL_ERRORLNPGM("Bad Z value");
4376
             SERIAL_ERRORLNPGM("Bad Z value");
4378
             return;
4377
             return;
4379
           }
4378
           }
4380
 
4379
 
4381
-          const float x = parser.seenval('X') ? parser.value_float() : NAN,
4382
-                      y = parser.seenval('Y') ? parser.value_float() : NAN;
4383
-          int8_t i = parser.seenval('I') ? parser.value_byte() : -1,
4384
-                 j = parser.seenval('J') ? parser.value_byte() : -1;
4380
+          const float x = parser.floatval('X', NAN),
4381
+                      y = parser.floatval('Y', NAN);
4382
+          int8_t i = parser.byteval('I', -1),
4383
+                 j = parser.byteval('J', -1);
4385
 
4384
 
4386
           if (!isnan(x) && !isnan(y)) {
4385
           if (!isnan(x) && !isnan(y)) {
4387
             // Get nearest i / j from x / y
4386
             // Get nearest i / j from x / y
4413
 
4412
 
4414
       #endif
4413
       #endif
4415
 
4414
 
4416
-      verbose_level = parser.seenval('V') ? parser.value_int() : 0;
4415
+      verbose_level = parser.intval('V');
4417
       if (!WITHIN(verbose_level, 0, 4)) {
4416
       if (!WITHIN(verbose_level, 0, 4)) {
4418
         SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
4417
         SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
4419
         return;
4418
         return;
4420
       }
4419
       }
4421
 
4420
 
4422
-      dryrun = (parser.seen('D') && parser.value_bool())
4421
+      dryrun = parser.boolval('D')
4423
         #if ENABLED(PROBE_MANUALLY)
4422
         #if ENABLED(PROBE_MANUALLY)
4424
           || no_action
4423
           || no_action
4425
         #endif
4424
         #endif
4427
 
4426
 
4428
       #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4427
       #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4429
 
4428
 
4430
-        do_topography_map = verbose_level > 2 || parser.seen('T');
4429
+        do_topography_map = verbose_level > 2 || parser.boolval('T');
4431
 
4430
 
4432
         // X and Y specify points in each direction, overriding the default
4431
         // X and Y specify points in each direction, overriding the default
4433
         // These values may be saved with the completed mesh
4432
         // These values may be saved with the completed mesh
4434
-        abl_grid_points_x = parser.seen('X') ? parser.value_int() : GRID_MAX_POINTS_X;
4435
-        abl_grid_points_y = parser.seen('Y') ? parser.value_int() : GRID_MAX_POINTS_Y;
4433
+        abl_grid_points_x = parser.intval('X', GRID_MAX_POINTS_X);
4434
+        abl_grid_points_y = parser.intval('Y', GRID_MAX_POINTS_Y);
4436
         if (parser.seenval('P')) abl_grid_points_x = abl_grid_points_y = parser.value_int();
4435
         if (parser.seenval('P')) abl_grid_points_x = abl_grid_points_y = parser.value_int();
4437
 
4436
 
4438
         if (abl_grid_points_x < 2 || abl_grid_points_y < 2) {
4437
         if (abl_grid_points_x < 2 || abl_grid_points_y < 2) {
4444
 
4443
 
4445
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4444
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4446
 
4445
 
4447
-        zoffset = parser.seen('Z') ? parser.value_linear_units() : 0;
4446
+        zoffset = parser.linearval('Z');
4448
 
4447
 
4449
       #endif
4448
       #endif
4450
 
4449
 
4451
       #if ABL_GRID
4450
       #if ABL_GRID
4452
 
4451
 
4453
-        xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.seen('S') ? parser.value_linear_units() : XY_PROBE_SPEED);
4452
+        xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
4454
 
4453
 
4455
-        left_probe_bed_position = parser.seen('L') ? (int)parser.value_linear_units() : LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION);
4456
-        right_probe_bed_position = parser.seen('R') ? (int)parser.value_linear_units() : LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION);
4457
-        front_probe_bed_position = parser.seen('F') ? (int)parser.value_linear_units() : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION);
4458
-        back_probe_bed_position = parser.seen('B') ? (int)parser.value_linear_units() : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
4454
+        left_probe_bed_position = (int)parser.linearval('L', LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION));
4455
+        right_probe_bed_position = (int)parser.linearval('R', LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION));
4456
+        front_probe_bed_position = (int)parser.linearval('F', LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION));
4457
+        back_probe_bed_position = (int)parser.linearval('B', LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION));
4459
 
4458
 
4460
         const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
4459
         const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
4461
                    left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
4460
                    left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
4735
 
4734
 
4736
     #else // !PROBE_MANUALLY
4735
     #else // !PROBE_MANUALLY
4737
 
4736
 
4738
-      const bool stow_probe_after_each = parser.seen('E');
4737
+      const bool stow_probe_after_each = parser.boolval('E');
4739
 
4738
 
4740
       #if ABL_GRID
4739
       #if ABL_GRID
4741
 
4740
 
5086
    *   S0  Leave the probe deployed
5085
    *   S0  Leave the probe deployed
5087
    */
5086
    */
5088
   inline void gcode_G30() {
5087
   inline void gcode_G30() {
5089
-    const float xpos = parser.seen('X') ? parser.value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
5090
-                ypos = parser.seen('Y') ? parser.value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
5088
+    const float xpos = parser.linearval('X', current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER),
5089
+                ypos = parser.linearval('Y', current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER);
5091
 
5090
 
5092
     if (!position_is_reachable_by_probe_xy(xpos, ypos)) return;
5091
     if (!position_is_reachable_by_probe_xy(xpos, ypos)) return;
5093
 
5092
 
5098
 
5097
 
5099
     setup_for_endstop_or_probe_move();
5098
     setup_for_endstop_or_probe_move();
5100
 
5099
 
5101
-    const float measured_z = probe_pt(xpos, ypos, !parser.seen('S') || parser.value_bool(), 1);
5100
+    const float measured_z = probe_pt(xpos, ypos, parser.boolval('S', true), 1);
5102
 
5101
 
5103
     if (!isnan(measured_z)) {
5102
     if (!isnan(measured_z)) {
5104
       SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5103
       SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5164
 
5163
 
5165
     inline void gcode_G33() {
5164
     inline void gcode_G33() {
5166
 
5165
 
5167
-      const int8_t probe_points = parser.seen('P') ? parser.value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
5166
+      const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
5168
       if (!WITHIN(probe_points, 1, 7)) {
5167
       if (!WITHIN(probe_points, 1, 7)) {
5169
         SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (1 to 7).");
5168
         SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (1 to 7).");
5170
         return;
5169
         return;
5171
       }
5170
       }
5172
 
5171
 
5173
-      const int8_t verbose_level = parser.seen('V') ? parser.value_byte() : 1;
5172
+      const int8_t verbose_level = parser.byteval('V', 1);
5174
       if (!WITHIN(verbose_level, 0, 2)) {
5173
       if (!WITHIN(verbose_level, 0, 2)) {
5175
         SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-2).");
5174
         SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-2).");
5176
         return;
5175
         return;
5177
       }
5176
       }
5178
 
5177
 
5179
-      const float calibration_precision = parser.seen('C') ? parser.value_float() : 0.0;
5178
+      const float calibration_precision = parser.floatval('C');
5180
       if (calibration_precision < 0) {
5179
       if (calibration_precision < 0) {
5181
         SERIAL_PROTOCOLLNPGM("?(C)alibration precision is implausible (>0).");
5180
         SERIAL_PROTOCOLLNPGM("?(C)alibration precision is implausible (>0).");
5182
         return;
5181
         return;
5183
       }
5182
       }
5184
 
5183
 
5185
-      const int8_t force_iterations = parser.seen('F') ? parser.value_int() : 1;
5184
+      const int8_t force_iterations = parser.intval('F', 1);
5186
       if (!WITHIN(force_iterations, 1, 30)) {
5185
       if (!WITHIN(force_iterations, 1, 30)) {
5187
         SERIAL_PROTOCOLLNPGM("?(F)orce iteration is implausible (1-30).");
5186
         SERIAL_PROTOCOLLNPGM("?(F)orce iteration is implausible (1-30).");
5188
         return;
5187
         return;
5189
       }
5188
       }
5190
 
5189
 
5191
-      const bool towers_set           = !parser.seen('T'),
5192
-                 stow_after_each      = parser.seen('E') && parser.value_bool(),
5190
+      const bool towers_set           = !parser.boolval('T'),
5191
+                 stow_after_each      = parser.boolval('E'),
5193
                  _1p_calibration      = probe_points == 1,
5192
                  _1p_calibration      = probe_points == 1,
5194
                  _4p_calibration      = probe_points == 2,
5193
                  _4p_calibration      = probe_points == 2,
5195
                  _4p_towers_points    = _4p_calibration && towers_set,
5194
                  _4p_towers_points    = _4p_calibration && towers_set,
5640
       set_destination_to_current();
5639
       set_destination_to_current();
5641
       if (hasI) destination[X_AXIS] = LOGICAL_X_POSITION(_GET_MESH_X(ix));
5640
       if (hasI) destination[X_AXIS] = LOGICAL_X_POSITION(_GET_MESH_X(ix));
5642
       if (hasJ) destination[Y_AXIS] = LOGICAL_Y_POSITION(_GET_MESH_Y(iy));
5641
       if (hasJ) destination[Y_AXIS] = LOGICAL_Y_POSITION(_GET_MESH_Y(iy));
5643
-      if (parser.seen('P') && parser.value_bool()) {
5642
+      if (parser.boolval('P')) {
5644
         if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
5643
         if (hasI) destination[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
5645
         if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
5644
         if (hasJ) destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
5646
       }
5645
       }
5647
 
5646
 
5648
-      if (parser.seen('F') && parser.value_linear_units() > 0.0)
5649
-        feedrate_mm_s = MMM_TO_MMS(parser.value_linear_units());
5647
+      const float fval = parser.linearval('F');
5648
+      if (fval > 0.0) feedrate_mm_s = MMM_TO_MMS(fval);
5650
 
5649
 
5651
       // SCARA kinematic has "safe" XY raw moves
5650
       // SCARA kinematic has "safe" XY raw moves
5652
       #if IS_SCARA
5651
       #if IS_SCARA
5851
     #if ENABLED(SPINDLE_LASER_PWM)
5850
     #if ENABLED(SPINDLE_LASER_PWM)
5852
       if (parser.seen('O')) ocr_val_mode();
5851
       if (parser.seen('O')) ocr_val_mode();
5853
       else {
5852
       else {
5854
-        const float spindle_laser_power = parser.seen('S') ? parser.value_float() : 0;
5853
+        const float spindle_laser_power = parser.floatval('S');
5855
         if (spindle_laser_power == 0) {
5854
         if (spindle_laser_power == 0) {
5856
           WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT);                                    // turn spindle off (active low)
5855
           WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT);                                    // turn spindle off (active low)
5857
           delay_for_power_down();
5856
           delay_for_power_down();
6329
       stepper.synchronize();
6328
       stepper.synchronize();
6330
 
6329
 
6331
     char* namestartpos = parser.string_arg;
6330
     char* namestartpos = parser.string_arg;
6332
-    bool call_procedure = parser.seen('P');
6331
+    const bool call_procedure = parser.boolval('P');
6333
 
6332
 
6334
     if (card.cardOK) {
6333
     if (card.cardOK) {
6335
       card.openFile(namestartpos, true, call_procedure);
6334
       card.openFile(namestartpos, true, call_procedure);
6407
   if (!parser.seenval('S')) return;
6406
   if (!parser.seenval('S')) return;
6408
   const byte pin_status = parser.value_byte();
6407
   const byte pin_status = parser.value_byte();
6409
 
6408
 
6410
-  int pin_number = parser.seen('P') ? parser.value_int() : LED_PIN;
6409
+  const int pin_number = parser.intval('P', LED_PIN);
6411
   if (pin_number < 0) return;
6410
   if (pin_number < 0) return;
6412
 
6411
 
6413
   if (pin_is_protected(pin_number)) {
6412
   if (pin_is_protected(pin_number)) {
6440
   #include "pinsDebug.h"
6439
   #include "pinsDebug.h"
6441
 
6440
 
6442
   inline void toggle_pins() {
6441
   inline void toggle_pins() {
6443
-    const bool I_flag = parser.seen('I') && parser.value_bool();
6444
-    const int repeat = parser.seen('R') ? parser.value_int() : 1,
6445
-              start = parser.seen('S') ? parser.value_int() : 0,
6446
-              end = parser.seen('E') ? parser.value_int() : NUM_DIGITAL_PINS - 1,
6447
-              wait = parser.seen('W') ? parser.value_int() : 500;
6442
+    const bool I_flag = parser.boolval('I');
6443
+    const int repeat = parser.intval('R', 1),
6444
+              start = parser.intval('S'),
6445
+              end = parser.intval('E', NUM_DIGITAL_PINS - 1),
6446
+              wait = parser.intval('W', 500);
6448
 
6447
 
6449
     for (uint8_t pin = start; pin <= end; pin++) {
6448
     for (uint8_t pin = start; pin <= end; pin++) {
6450
       //report_pin_state_extended(pin, I_flag, false);
6449
       //report_pin_state_extended(pin, I_flag, false);
6503
 
6502
 
6504
     #else
6503
     #else
6505
 
6504
 
6506
-      const uint8_t probe_index = parser.seen('P') ? parser.value_byte() : Z_ENDSTOP_SERVO_NR;
6505
+      const uint8_t probe_index = parser.byteval('P', Z_ENDSTOP_SERVO_NR);
6507
 
6506
 
6508
       SERIAL_PROTOCOLLNPGM("Servo probe test");
6507
       SERIAL_PROTOCOLLNPGM("Servo probe test");
6509
       SERIAL_PROTOCOLLNPAIR(".  using index:  ", probe_index);
6508
       SERIAL_PROTOCOLLNPAIR(".  using index:  ", probe_index);
6664
     }
6663
     }
6665
 
6664
 
6666
     // Get the range of pins to test or watch
6665
     // Get the range of pins to test or watch
6667
-    const uint8_t first_pin = parser.seenval('P') ? parser.value_byte() : 0,
6666
+    const uint8_t first_pin = parser.byteval('P'),
6668
                   last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
6667
                   last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
6669
 
6668
 
6670
     if (first_pin > last_pin) return;
6669
     if (first_pin > last_pin) return;
6671
 
6670
 
6672
-    const bool ignore_protection = parser.seen('I') && parser.value_bool();
6671
+    const bool ignore_protection = parser.boolval('I');
6673
 
6672
 
6674
     // Watch until click, M108, or reset
6673
     // Watch until click, M108, or reset
6675
-    if (parser.seen('W') && parser.value_bool()) {
6674
+    if (parser.boolval('W')) {
6676
       SERIAL_PROTOCOLLNPGM("Watching pins");
6675
       SERIAL_PROTOCOLLNPGM("Watching pins");
6677
       byte pin_state[last_pin - first_pin + 1];
6676
       byte pin_state[last_pin - first_pin + 1];
6678
       for (int8_t pin = first_pin; pin <= last_pin; pin++) {
6677
       for (int8_t pin = first_pin; pin <= last_pin; pin++) {
6751
 
6750
 
6752
     if (axis_unhomed_error()) return;
6751
     if (axis_unhomed_error()) return;
6753
 
6752
 
6754
-    const int8_t verbose_level = parser.seen('V') ? parser.value_byte() : 1;
6753
+    const int8_t verbose_level = parser.byteval('V', 1);
6755
     if (!WITHIN(verbose_level, 0, 4)) {
6754
     if (!WITHIN(verbose_level, 0, 4)) {
6756
       SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
6755
       SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
6757
       return;
6756
       return;
6760
     if (verbose_level > 0)
6759
     if (verbose_level > 0)
6761
       SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability Test");
6760
       SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability Test");
6762
 
6761
 
6763
-    int8_t n_samples = parser.seen('P') ? parser.value_byte() : 10;
6762
+    const int8_t n_samples = parser.byteval('P', 10);
6764
     if (!WITHIN(n_samples, 4, 50)) {
6763
     if (!WITHIN(n_samples, 4, 50)) {
6765
       SERIAL_PROTOCOLLNPGM("?Sample size not plausible (4-50).");
6764
       SERIAL_PROTOCOLLNPGM("?Sample size not plausible (4-50).");
6766
       return;
6765
       return;
6767
     }
6766
     }
6768
 
6767
 
6769
-    const bool stow_probe_after_each = parser.seen('E');
6768
+    const bool stow_probe_after_each = parser.boolval('E');
6770
 
6769
 
6771
     float X_current = current_position[X_AXIS],
6770
     float X_current = current_position[X_AXIS],
6772
           Y_current = current_position[Y_AXIS];
6771
           Y_current = current_position[Y_AXIS];
6773
 
6772
 
6774
-    const float X_probe_location = parser.seen('X') ? parser.value_linear_units() : X_current + X_PROBE_OFFSET_FROM_EXTRUDER,
6775
-                Y_probe_location = parser.seen('Y') ? parser.value_linear_units() : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
6773
+    const float X_probe_location = parser.linearval('X', X_current + X_PROBE_OFFSET_FROM_EXTRUDER),
6774
+                Y_probe_location = parser.linearval('Y', Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER);
6776
 
6775
 
6777
     #if DISABLED(DELTA)
6776
     #if DISABLED(DELTA)
6778
       if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
6777
       if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
6798
     }
6797
     }
6799
     if (n_legs == 1) n_legs = 2;
6798
     if (n_legs == 1) n_legs = 2;
6800
 
6799
 
6801
-    bool schizoid_flag = parser.seen('S');
6800
+    const bool schizoid_flag = parser.boolval('S');
6802
     if (schizoid_flag && !seen_L) n_legs = 7;
6801
     if (schizoid_flag && !seen_L) n_legs = 7;
6803
 
6802
 
6804
     /**
6803
     /**
7006
    */
7005
    */
7007
   inline void gcode_M78() {
7006
   inline void gcode_M78() {
7008
     // "M78 S78" will reset the statistics
7007
     // "M78 S78" will reset the statistics
7009
-    if (parser.seen('S') && parser.value_int() == 78)
7008
+    if (parser.intval('S') == 78)
7010
       print_job_timer.initStats();
7009
       print_job_timer.initStats();
7011
     else
7010
     else
7012
       print_job_timer.showStats();
7011
       print_job_timer.showStats();
7177
    *  P<index> Fan index, if more than one fan
7176
    *  P<index> Fan index, if more than one fan
7178
    */
7177
    */
7179
   inline void gcode_M106() {
7178
   inline void gcode_M106() {
7180
-    uint16_t s = parser.seen('S') ? parser.value_ushort() : 255,
7181
-             p = parser.seen('P') ? parser.value_ushort() : 0;
7179
+    uint16_t s = parser.ushortval('S', 255);
7182
     NOMORE(s, 255);
7180
     NOMORE(s, 255);
7181
+    const uint8_t p = parser.byteval('P', 0);
7183
     if (p < FAN_COUNT) fanSpeeds[p] = s;
7182
     if (p < FAN_COUNT) fanSpeeds[p] = s;
7184
   }
7183
   }
7185
 
7184
 
7187
    * M107: Fan Off
7186
    * M107: Fan Off
7188
    */
7187
    */
7189
   inline void gcode_M107() {
7188
   inline void gcode_M107() {
7190
-    uint16_t p = parser.seen('P') ? parser.value_ushort() : 0;
7189
+    const uint16_t p = parser.ushortval('P');
7191
     if (p < FAN_COUNT) fanSpeeds[p] = 0;
7190
     if (p < FAN_COUNT) fanSpeeds[p] = 0;
7192
   }
7191
   }
7193
 
7192
 
7502
  * M111: Set the debug level
7501
  * M111: Set the debug level
7503
  */
7502
  */
7504
 inline void gcode_M111() {
7503
 inline void gcode_M111() {
7505
-  marlin_debug_flags = parser.seen('S') ? parser.value_byte() : (uint8_t)DEBUG_NONE;
7504
+  marlin_debug_flags = parser.byteval('S', (uint8_t)DEBUG_NONE);
7506
 
7505
 
7507
   const static char str_debug_1[] PROGMEM = MSG_DEBUG_ECHO;
7506
   const static char str_debug_1[] PROGMEM = MSG_DEBUG_ECHO;
7508
   const static char str_debug_2[] PROGMEM = MSG_DEBUG_INFO;
7507
   const static char str_debug_2[] PROGMEM = MSG_DEBUG_INFO;
7563
     /**
7562
     /**
7564
      * M126: Heater 1 valve open
7563
      * M126: Heater 1 valve open
7565
      */
7564
      */
7566
-    inline void gcode_M126() { baricuda_valve_pressure = parser.seen('S') ? parser.value_byte() : 255; }
7565
+    inline void gcode_M126() { baricuda_valve_pressure = parser.byteval('S', 255); }
7567
     /**
7566
     /**
7568
      * M127: Heater 1 valve close
7567
      * M127: Heater 1 valve close
7569
      */
7568
      */
7574
     /**
7573
     /**
7575
      * M128: Heater 2 valve open
7574
      * M128: Heater 2 valve open
7576
      */
7575
      */
7577
-    inline void gcode_M128() { baricuda_e_to_p_pressure = parser.seen('S') ? parser.value_byte() : 255; }
7576
+    inline void gcode_M128() { baricuda_e_to_p_pressure = parser.byteval('S', 255); }
7578
     /**
7577
     /**
7579
      * M129: Heater 2 valve close
7578
      * M129: Heater 2 valve close
7580
      */
7579
      */
7602
    *   F<fan speed>
7601
    *   F<fan speed>
7603
    */
7602
    */
7604
   inline void gcode_M145() {
7603
   inline void gcode_M145() {
7605
-    uint8_t material = parser.seen('S') ? (uint8_t)parser.value_int() : 0;
7604
+    const uint8_t material = (uint8_t)parser.intval('S');
7606
     if (material >= COUNT(lcd_preheat_hotend_temp)) {
7605
     if (material >= COUNT(lcd_preheat_hotend_temp)) {
7607
       SERIAL_ERROR_START();
7606
       SERIAL_ERROR_START();
7608
       SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
7607
       SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
8034
     ;
8033
     ;
8035
 
8034
 
8036
     // Lift Z axis
8035
     // Lift Z axis
8037
-    const float z_lift = parser.seen('Z') ? parser.value_linear_units() :
8038
-      #if defined(PAUSE_PARK_Z_ADD) && PAUSE_PARK_Z_ADD > 0
8039
-        PAUSE_PARK_Z_ADD
8040
-      #else
8041
-        0
8036
+    const float z_lift = parser.linearval('Z')
8037
+      #if PAUSE_PARK_Z_ADD > 0
8038
+        + PAUSE_PARK_Z_ADD
8042
       #endif
8039
       #endif
8043
     ;
8040
     ;
8044
 
8041
 
8045
     // Move XY axes to filament change position or given position
8042
     // Move XY axes to filament change position or given position
8046
-    const float x_pos = parser.seen('X') ? parser.value_linear_units() : 0
8043
+    const float x_pos = parser.linearval('X')
8047
       #ifdef PAUSE_PARK_X_POS
8044
       #ifdef PAUSE_PARK_X_POS
8048
         + PAUSE_PARK_X_POS
8045
         + PAUSE_PARK_X_POS
8049
       #endif
8046
       #endif
8051
         + (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0)
8048
         + (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0)
8052
       #endif
8049
       #endif
8053
     ;
8050
     ;
8054
-    const float y_pos = parser.seen('Y') ? parser.value_linear_units() : 0
8051
+    const float y_pos = parser.linearval('Y')
8055
       #ifdef PAUSE_PARK_Y_POS
8052
       #ifdef PAUSE_PARK_Y_POS
8056
         + PAUSE_PARK_Y_POS
8053
         + PAUSE_PARK_Y_POS
8057
       #endif
8054
       #endif
8491
  */
8488
  */
8492
 inline void gcode_M226() {
8489
 inline void gcode_M226() {
8493
   if (parser.seen('P')) {
8490
   if (parser.seen('P')) {
8494
-    int pin_number = parser.value_int(),
8495
-        pin_state = parser.seen('S') ? parser.value_int() : -1; // required pin state - default is inverted
8491
+    const int pin_number = parser.value_int(),
8492
+              pin_state = parser.intval('S', -1); // required pin state - default is inverted
8496
 
8493
 
8497
-    if (pin_state >= -1 && pin_state <= 1 && pin_number > -1 && !pin_is_protected(pin_number)) {
8494
+    if (WITHIN(pin_state, -1, 1) && pin_number > -1 && !pin_is_protected(pin_number)) {
8498
 
8495
 
8499
       int target = LOW;
8496
       int target = LOW;
8500
 
8497
 
8559
   inline void gcode_M261() {
8556
   inline void gcode_M261() {
8560
     if (parser.seen('A')) i2c.address(parser.value_byte());
8557
     if (parser.seen('A')) i2c.address(parser.value_byte());
8561
 
8558
 
8562
-    uint8_t bytes = parser.seen('B') ? parser.value_byte() : 1;
8559
+    uint8_t bytes = parser.byteval('B', 1);
8563
 
8560
 
8564
     if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE) {
8561
     if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE) {
8565
       i2c.relay(bytes);
8562
       i2c.relay(bytes);
8604
    * M300: Play beep sound S<frequency Hz> P<duration ms>
8601
    * M300: Play beep sound S<frequency Hz> P<duration ms>
8605
    */
8602
    */
8606
   inline void gcode_M300() {
8603
   inline void gcode_M300() {
8607
-    uint16_t const frequency = parser.seen('S') ? parser.value_ushort() : 260;
8608
-    uint16_t duration = parser.seen('P') ? parser.value_ushort() : 1000;
8604
+    uint16_t const frequency = parser.ushortval('S', 260);
8605
+    uint16_t duration = parser.ushortval('P', 1000);
8609
 
8606
 
8610
     // Limits the tone duration to 0-5 seconds.
8607
     // Limits the tone duration to 0-5 seconds.
8611
     NOMORE(duration, 5000);
8608
     NOMORE(duration, 5000);
8633
 
8630
 
8634
     // multi-extruder PID patch: M301 updates or prints a single extruder's PID values
8631
     // multi-extruder PID patch: M301 updates or prints a single extruder's PID values
8635
     // default behaviour (omitting E parameter) is to update for extruder 0 only
8632
     // default behaviour (omitting E parameter) is to update for extruder 0 only
8636
-    int e = parser.seen('E') ? parser.value_int() : 0; // extruder being updated
8633
+    const uint8_t e = parser.byteval('E'); // extruder being updated
8637
 
8634
 
8638
     if (e < HOTENDS) { // catch bad input value
8635
     if (e < HOTENDS) { // catch bad input value
8639
       if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
8636
       if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
8781
  */
8778
  */
8782
 inline void gcode_M303() {
8779
 inline void gcode_M303() {
8783
   #if HAS_PID_HEATING
8780
   #if HAS_PID_HEATING
8784
-    const int e = parser.seen('E') ? parser.value_int() : 0,
8785
-              c = parser.seen('C') ? parser.value_int() : 5;
8786
-    const bool u = parser.seen('U') && parser.value_bool();
8781
+    const int e = parser.intval('E'), c = parser.intval('C', 5);
8782
+    const bool u = parser.boolval('U');
8787
 
8783
 
8788
-    int16_t temp = parser.seen('S') ? parser.value_celsius() : (e < 0 ? 70 : 150);
8784
+    int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
8789
 
8785
 
8790
     if (WITHIN(e, 0, HOTENDS - 1))
8786
     if (WITHIN(e, 0, HOTENDS - 1))
8791
       target_extruder = e;
8787
       target_extruder = e;
9078
       #endif
9074
       #endif
9079
     }
9075
     }
9080
 
9076
 
9081
-    bool to_enable = false;
9082
-    if (parser.seen('S')) {
9083
-      to_enable = parser.value_bool();
9077
+    const bool to_enable = parser.boolval('S');
9078
+    if (parser.seen('S'))
9084
       set_bed_leveling_enabled(to_enable);
9079
       set_bed_leveling_enabled(to_enable);
9085
-    }
9086
 
9080
 
9087
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
9081
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
9088
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9082
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9149
    *   M421 I<xindex> J<yindex> Q<offset>
9143
    *   M421 I<xindex> J<yindex> Q<offset>
9150
    */
9144
    */
9151
   inline void gcode_M421() {
9145
   inline void gcode_M421() {
9152
-    const bool hasI = parser.seen('I');
9153
-    const int8_t ix = hasI ? parser.value_int() : -1;
9154
-    const bool hasJ = parser.seen('J');
9155
-    const int8_t iy = hasJ ? parser.value_int() : -1;
9156
-    const bool hasZ = parser.seen('Z'), hasQ = !hasZ && parser.seen('Q');
9146
+    int8_t ix = parser.intval('I', -1), iy = parser.intval('J', -1);
9147
+    const bool hasI = ix >= 0,
9148
+               hasJ = iy >= 0,
9149
+               hasC = parser.seen('C'),
9150
+               hasZ = parser.seen('Z'),
9151
+               hasQ = !hasZ && parser.seen('Q');
9157
 
9152
 
9158
     if (!hasI || !hasJ || !(hasZ || hasQ)) {
9153
     if (!hasI || !hasJ || !(hasZ || hasQ)) {
9159
       SERIAL_ERROR_START();
9154
       SERIAL_ERROR_START();
9183
    *   M421 C Q<offset>
9178
    *   M421 C Q<offset>
9184
    */
9179
    */
9185
   inline void gcode_M421() {
9180
   inline void gcode_M421() {
9186
-    const bool hasC = parser.seen('C'), hasI = parser.seen('I');
9187
-    int8_t ix = hasI ? parser.value_int() : -1;
9188
-    const bool hasJ = parser.seen('J');
9189
-    int8_t iy = hasJ ? parser.value_int() : -1;
9190
-    const bool hasZ = parser.seen('Z'), hasQ = !hasZ && parser.seen('Q');
9181
+    int8_t ix = parser.intval('I', -1), iy = parser.intval('J', -1);
9182
+    const bool hasI = ix >= 0,
9183
+               hasJ = iy >= 0,
9184
+               hasC = parser.seen('C'),
9185
+               hasZ = parser.seen('Z'),
9186
+               hasQ = !hasZ && parser.seen('Q');
9191
 
9187
 
9192
     if (hasC) {
9188
     if (hasC) {
9193
       const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL, false);
9189
       const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL, false);
9278
  * M503: print settings currently in memory
9274
  * M503: print settings currently in memory
9279
  */
9275
  */
9280
 inline void gcode_M503() {
9276
 inline void gcode_M503() {
9281
-  (void)settings.report(parser.seen('S') && !parser.value_bool());
9277
+  (void)settings.report(!parser.boolval('S', true));
9282
 }
9278
 }
9283
 
9279
 
9284
 #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
9280
 #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
9382
     ;
9378
     ;
9383
 
9379
 
9384
     // Lift Z axis
9380
     // Lift Z axis
9385
-    const float z_lift = parser.seen('Z') ? parser.value_linear_units() :
9381
+    const float z_lift = parser.linearval('Z', 0
9386
       #if defined(PAUSE_PARK_Z_ADD) && PAUSE_PARK_Z_ADD > 0
9382
       #if defined(PAUSE_PARK_Z_ADD) && PAUSE_PARK_Z_ADD > 0
9387
-        PAUSE_PARK_Z_ADD
9388
-      #else
9389
-        0
9383
+        + PAUSE_PARK_Z_ADD
9390
       #endif
9384
       #endif
9391
-    ;
9385
+    );
9392
 
9386
 
9393
     // Move XY axes to filament exchange position
9387
     // Move XY axes to filament exchange position
9394
-    const float x_pos = parser.seen('X') ? parser.value_linear_units() : 0
9388
+    const float x_pos = parser.linearval('X', 0
9395
       #ifdef PAUSE_PARK_X_POS
9389
       #ifdef PAUSE_PARK_X_POS
9396
         + PAUSE_PARK_X_POS
9390
         + PAUSE_PARK_X_POS
9397
       #endif
9391
       #endif
9398
-    ;
9399
-    const float y_pos = parser.seen('Y') ? parser.value_linear_units() : 0
9392
+    );
9393
+    const float y_pos = parser.linearval('Y', 0
9400
       #ifdef PAUSE_PARK_Y_POS
9394
       #ifdef PAUSE_PARK_Y_POS
9401
         + PAUSE_PARK_Y_POS
9395
         + PAUSE_PARK_Y_POS
9402
       #endif
9396
       #endif
9403
-    ;
9397
+    );
9404
 
9398
 
9405
     // Unload filament
9399
     // Unload filament
9406
     const float unload_length = parser.seen('U') ? parser.value_axis_units(E_AXIS) : 0
9400
     const float unload_length = parser.seen('U') ? parser.value_axis_units(E_AXIS) : 0
9416
       #endif
9410
       #endif
9417
     ;
9411
     ;
9418
 
9412
 
9419
-    const int beep_count = parser.seen('B') ? parser.value_int() :
9413
+    const int beep_count = parser.intval('B',
9420
       #ifdef FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
9414
       #ifdef FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
9421
         FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
9415
         FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS
9422
       #else
9416
       #else
9423
         -1
9417
         -1
9424
       #endif
9418
       #endif
9425
-    ;
9419
+    );
9426
 
9420
 
9427
     const bool job_running = print_job_timer.isRunning();
9421
     const bool job_running = print_job_timer.isRunning();
9428
 
9422
 
9485
 
9479
 
9486
   inline void gcode_M605() {
9480
   inline void gcode_M605() {
9487
     stepper.synchronize();
9481
     stepper.synchronize();
9488
-    extruder_duplication_enabled = parser.seen('S') && parser.value_int() == (int)DXC_DUPLICATION_MODE;
9482
+    extruder_duplication_enabled = parser.intval('S') == (int)DXC_DUPLICATION_MODE;
9489
     SERIAL_ECHO_START();
9483
     SERIAL_ECHO_START();
9490
     SERIAL_ECHOLNPAIR(MSG_DUPLICATION_MODE, extruder_duplication_enabled ? MSG_ON : MSG_OFF);
9484
     SERIAL_ECHOLNPAIR(MSG_DUPLICATION_MODE, extruder_duplication_enabled ? MSG_ON : MSG_OFF);
9491
   }
9485
   }
9503
   inline void gcode_M900() {
9497
   inline void gcode_M900() {
9504
     stepper.synchronize();
9498
     stepper.synchronize();
9505
 
9499
 
9506
-    const float newK = parser.seen('K') ? parser.value_float() : -1;
9500
+    const float newK = parser.floatval('K', -1);
9507
     if (newK >= 0) planner.extruder_advance_k = newK;
9501
     if (newK >= 0) planner.extruder_advance_k = newK;
9508
 
9502
 
9509
-    float newR = parser.seen('R') ? parser.value_float() : -1;
9503
+    float newR = parser.floatval('R', -1);
9510
     if (newR < 0) {
9504
     if (newR < 0) {
9511
-      const float newD = parser.seen('D') ? parser.value_float() : -1,
9512
-                  newW = parser.seen('W') ? parser.value_float() : -1,
9513
-                  newH = parser.seen('H') ? parser.value_float() : -1;
9505
+      const float newD = parser.floatval('D', -1),
9506
+                  newW = parser.floatval('W', -1),
9507
+                  newH = parser.floatval('H', -1);
9514
       if (newD >= 0 && newW >= 0 && newH >= 0)
9508
       if (newD >= 0 && newW >= 0 && newH >= 0)
9515
         newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0;
9509
         newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0;
9516
     }
9510
     }
9579
   inline void gcode_M906() {
9573
   inline void gcode_M906() {
9580
     uint16_t values[XYZE];
9574
     uint16_t values[XYZE];
9581
     LOOP_XYZE(i)
9575
     LOOP_XYZE(i)
9582
-      values[i] = parser.seen(axis_codes[i]) ? parser.value_int() : 0;
9576
+      values[i] = parser.intval(axis_codes[i]);
9583
 
9577
 
9584
     #if ENABLED(X_IS_TMC2130)
9578
     #if ENABLED(X_IS_TMC2130)
9585
       if (values[X_AXIS]) tmc2130_set_current(stepperX, 'X', values[X_AXIS]);
9579
       if (values[X_AXIS]) tmc2130_set_current(stepperX, 'X', values[X_AXIS]);
9651
     inline void gcode_M913() {
9645
     inline void gcode_M913() {
9652
       uint16_t values[XYZE];
9646
       uint16_t values[XYZE];
9653
       LOOP_XYZE(i)
9647
       LOOP_XYZE(i)
9654
-        values[i] = parser.seen(axis_codes[i]) ? parser.value_int() : 0;
9648
+        values[i] = parser.intval(axis_codes[i]);
9655
 
9649
 
9656
       #if ENABLED(X_IS_TMC2130)
9650
       #if ENABLED(X_IS_TMC2130)
9657
         if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
9651
         if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
9738
   inline void gcode_M908() {
9732
   inline void gcode_M908() {
9739
     #if HAS_DIGIPOTSS
9733
     #if HAS_DIGIPOTSS
9740
       stepper.digitalPotWrite(
9734
       stepper.digitalPotWrite(
9741
-        parser.seen('P') ? parser.value_int() : 0,
9742
-        parser.seen('S') ? parser.value_int() : 0
9735
+        parser.intval('P'),
9736
+        parser.intval('S')
9743
       );
9737
       );
9744
     #endif
9738
     #endif
9745
     #ifdef DAC_STEPPER_CURRENT
9739
     #ifdef DAC_STEPPER_CURRENT
9746
       dac_current_raw(
9740
       dac_current_raw(
9747
-        parser.seen('P') ? parser.value_byte() : -1,
9748
-        parser.seen('S') ? parser.value_ushort() : 0
9741
+        parser.byteval('P', -1),
9742
+        parser.ushortval('S', 0)
9749
       );
9743
       );
9750
     #endif
9744
     #endif
9751
   }
9745
   }
9856
    *
9850
    *
9857
    */
9851
    */
9858
   inline void gcode_M163() {
9852
   inline void gcode_M163() {
9859
-    const int mix_index = parser.seen('S') ? parser.value_int() : 0;
9853
+    const int mix_index = parser.intval('S');
9860
     if (mix_index < MIXING_STEPPERS) {
9854
     if (mix_index < MIXING_STEPPERS) {
9861
-      float mix_value = parser.seen('P') ? parser.value_float() : 0.0;
9855
+      float mix_value = parser.floatval('P');
9862
       NOLESS(mix_value, 0.0);
9856
       NOLESS(mix_value, 0.0);
9863
       mixing_factor[mix_index] = RECIPROCAL(mix_value);
9857
       mixing_factor[mix_index] = RECIPROCAL(mix_value);
9864
     }
9858
     }
9873
      *
9867
      *
9874
      */
9868
      */
9875
     inline void gcode_M164() {
9869
     inline void gcode_M164() {
9876
-      const int tool_index = parser.seen('S') ? parser.value_int() : 0;
9870
+      const int tool_index = parser.intval('S');
9877
       if (tool_index < MIXING_VIRTUAL_TOOLS) {
9871
       if (tool_index < MIXING_VIRTUAL_TOOLS) {
9878
         normalize_mix();
9872
         normalize_mix();
9879
         for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
9873
         for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
9916
   Running = true;
9910
   Running = true;
9917
   lcd_reset_alert_level();
9911
   lcd_reset_alert_level();
9918
 
9912
 
9919
-  if (parser.seen('S') && parser.value_bool()) return;
9913
+  if (parser.boolval('S')) return;
9920
 
9914
 
9921
   // gcode_LastN = Stopped_gcode_LastN;
9915
   // gcode_LastN = Stopped_gcode_LastN;
9922
   FlushSerialRequestResend();
9916
   FlushSerialRequestResend();
10298
 
10292
 
10299
     tool_change(
10293
     tool_change(
10300
       tmp_extruder,
10294
       tmp_extruder,
10301
-      parser.seen('F') ? MMM_TO_MMS(parser.value_linear_units()) : 0.0,
10302
-      (tmp_extruder == active_extruder) || (parser.seen('S') && parser.value_bool())
10295
+      MMM_TO_MMS(parser.linearval('F')),
10296
+      (tmp_extruder == active_extruder) || parser.boolval('S')
10303
     );
10297
     );
10304
 
10298
 
10305
   #endif
10299
   #endif

+ 11
- 0
Marlin/gcode.h View File

293
 
293
 
294
   void unknown_command_error();
294
   void unknown_command_error();
295
 
295
 
296
+  // Provide simple value accessors with default option
297
+  FORCE_INLINE static float    floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
298
+  FORCE_INLINE static bool     boolval(const char c, const bool dval=false)   { return seen(c)    ? value_bool()         : dval; }
299
+  FORCE_INLINE static uint8_t  byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
300
+  FORCE_INLINE static int16_t  intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
301
+  FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
302
+  FORCE_INLINE static int32_t  longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
303
+  FORCE_INLINE static uint32_t ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
304
+  FORCE_INLINE static float    linearval(const char c, const float dval=0.0)  { return seenval(c) ? value_linear_units() : dval; }
305
+  FORCE_INLINE static float    celsiusval(const char c, const float dval=0.0) { return seenval(c) ? value_celsius()      : dval; }
306
+
296
 };
307
 };
297
 
308
 
298
 extern GCodeParser parser;
309
 extern GCodeParser parser;

+ 3
- 3
Marlin/ubl_G29.cpp View File

314
 
314
 
315
     // Check for commands that require the printer to be homed
315
     // Check for commands that require the printer to be homed
316
     if (axis_unhomed_error()) {
316
     if (axis_unhomed_error()) {
317
-      const int8_t p_val = parser.seenval('P') ? parser.value_int() : -1;
317
+      const int8_t p_val = parser.intval('P', -1);
318
       if (p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'))
318
       if (p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'))
319
         home_all_axes();
319
         home_all_axes();
320
     }
320
     }
492
               return;
492
               return;
493
             }
493
             }
494
 
494
 
495
-            const float height = parser.seenval('H') ? parser.value_float() : Z_CLEARANCE_BETWEEN_PROBES;
495
+            const float height = parser.floatval('H', Z_CLEARANCE_BETWEEN_PROBES);
496
             manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
496
             manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
497
 
497
 
498
             SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
498
             SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
1180
       }
1180
       }
1181
     #endif
1181
     #endif
1182
 
1182
 
1183
-    g29_map_type = parser.seenval('T') ? parser.value_int() : 0;
1183
+    g29_map_type = parser.intval('T');
1184
     if (!WITHIN(g29_map_type, 0, 2)) {
1184
     if (!WITHIN(g29_map_type, 0, 2)) {
1185
       SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1185
       SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1186
       return UBL_ERR;
1186
       return UBL_ERR;

Loading…
Cancel
Save