Quellcode durchsuchen

🚸 Improve M422 error messages

Scott Lahteine vor 3 Jahren
Ursprung
Commit
4b84b28c14
1 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen
  1. 15
    14
      Marlin/src/gcode/calibrate/G34_M422.cpp

+ 15
- 14
Marlin/src/gcode/calibrate/G34_M422.cpp Datei anzeigen

493
     return;
493
     return;
494
   }
494
   }
495
 
495
 
496
-  xy_pos_t *pos_dest = (
496
+  xy_pos_t * const pos_dest = (
497
     TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :)
497
     TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :)
498
     z_stepper_align.xy
498
     z_stepper_align.xy
499
   );
499
   );
504
   }
504
   }
505
 
505
 
506
   // Get the Probe Position Index or Z Stepper Index
506
   // Get the Probe Position Index or Z Stepper Index
507
-  int8_t position_index;
508
-  if (is_probe_point) {
509
-    position_index = parser.intval('S') - 1;
510
-    if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) {
511
-      SERIAL_ECHOLNPGM("?(S) Probe-position index invalid.");
512
-      return;
513
-    }
514
-  }
507
+  int8_t position_index = 1;
508
+  FSTR_P err_string = F("?(S) Probe-position");
509
+  if (is_probe_point)
510
+    position_index = parser.intval('S');
515
   else {
511
   else {
516
     #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
512
     #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
517
-      position_index = parser.intval('W') - 1;
518
-      if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) {
519
-        SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid.");
520
-        return;
521
-      }
513
+      err_string = F("?(W) Z-stepper");
514
+      position_index = parser.intval('W');
522
     #endif
515
     #endif
523
   }
516
   }
524
 
517
 
518
+  if (!WITHIN(position_index, 1, NUM_Z_STEPPER_DRIVERS)) {
519
+    SERIAL_ECHOF(err_string);
520
+    SERIAL_ECHOLNPGM(" index invalid (1.." STRINGIFY(NUM_Z_STEPPER_DRIVERS) ").");
521
+    return;
522
+  }
523
+
524
+  --position_index;
525
+
525
   const xy_pos_t pos = {
526
   const xy_pos_t pos = {
526
     parser.floatval('X', pos_dest[position_index].x),
527
     parser.floatval('X', pos_dest[position_index].x),
527
     parser.floatval('Y', pos_dest[position_index].y)
528
     parser.floatval('Y', pos_dest[position_index].y)

Laden…
Abbrechen
Speichern