Browse Source

Merge pull request #2153 from thinkyhead/leveling_shrink

Reduce code size with out_of_range_error function
Scott Lahteine 10 years ago
parent
commit
ffc39dc182
1 changed files with 12 additions and 6 deletions
  1. 12
    6
      Marlin/Marlin_main.cpp

+ 12
- 6
Marlin/Marlin_main.cpp View File

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

Loading…
Cancel
Save