Przeglądaj źródła

Merge pull request #2153 from thinkyhead/leveling_shrink

Reduce code size with out_of_range_error function
Scott Lahteine 10 lat temu
rodzic
commit
ffc39dc182
1 zmienionych plików z 12 dodań i 6 usunięć
  1. 12
    6
      Marlin/Marlin_main.cpp

+ 12
- 6
Marlin/Marlin_main.cpp Wyświetl plik

@@ -2444,6 +2444,12 @@ inline void gcode_G28() {
2444 2444
 
2445 2445
 #elif defined(ENABLE_AUTO_BED_LEVELING)
2446 2446
 
2447
+  void out_of_range_error(const char *edge) {
2448
+    char msg[40];
2449
+    sprintf_P(msg, PSTR("?Probe %s position out of range.\n"), edge);
2450
+    SERIAL_PROTOCOL(msg);
2451
+  }
2452
+
2447 2453
   /**
2448 2454
    * G29: Detailed Z-Probe, probes the bed at 3 or more points.
2449 2455
    *      Will fail if the printer has not been homed with G28.
@@ -2539,19 +2545,19 @@ inline void gcode_G28() {
2539 2545
 
2540 2546
       if (left_out || right_out || front_out || back_out) {
2541 2547
         if (left_out) {
2542
-          SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n");
2548
+          out_of_range_error(PSTR("(L)eft"));
2543 2549
           left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - MIN_PROBE_EDGE;
2544 2550
         }
2545 2551
         if (right_out) {
2546
-          SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n");
2552
+          out_of_range_error(PSTR("(R)ight"));
2547 2553
           right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE;
2548 2554
         }
2549 2555
         if (front_out) {
2550
-          SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n");
2556
+          out_of_range_error(PSTR("(F)ront"));
2551 2557
           front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - MIN_PROBE_EDGE;
2552 2558
         }
2553 2559
         if (back_out) {
2554
-          SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n");
2560
+          out_of_range_error(PSTR("(B)ack"));
2555 2561
           back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE;
2556 2562
         }
2557 2563
         return;
@@ -3170,7 +3176,7 @@ inline void gcode_M42() {
3170 3176
     if (code_seen('X') || code_seen('x')) {
3171 3177
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
3172 3178
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
3173
-        SERIAL_PROTOCOLPGM("?X position out of range.\n");
3179
+        out_of_range_error(PSTR("X"));
3174 3180
         return;
3175 3181
       }
3176 3182
     }
@@ -3178,7 +3184,7 @@ inline void gcode_M42() {
3178 3184
     if (code_seen('Y') || code_seen('y')) {
3179 3185
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
3180 3186
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
3181
-        SERIAL_PROTOCOLPGM("?Y position out of range.\n");
3187
+        out_of_range_error(PSTR("Y"));
3182 3188
         return;
3183 3189
       }
3184 3190
     }

Ładowanie…
Anuluj
Zapisz