Browse Source

Reduce code size with out_of_range_error function

- Affects code size when automatic bed leveling is enabled
pull/1/head
Scott Lahteine 10 years ago
parent
commit
68f6f149d0
  1. 18
      Marlin/Marlin_main.cpp

18
Marlin/Marlin_main.cpp

@ -2444,6 +2444,12 @@ inline void gcode_G28() {
#elif defined(ENABLE_AUTO_BED_LEVELING) #elif defined(ENABLE_AUTO_BED_LEVELING)
void out_of_range_error(const char *edge) {
char msg[40];
sprintf_P(msg, PSTR("?Probe %s position out of range.\n"), edge);
SERIAL_PROTOCOL(msg);
}
/** /**
* G29: Detailed Z-Probe, probes the bed at 3 or more points. * G29: Detailed Z-Probe, probes the bed at 3 or more points.
* Will fail if the printer has not been homed with G28. * Will fail if the printer has not been homed with G28.
@ -2539,19 +2545,19 @@ inline void gcode_G28() {
if (left_out || right_out || front_out || back_out) { if (left_out || right_out || front_out || back_out) {
if (left_out) { if (left_out) {
SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n"); out_of_range_error(PSTR("(L)eft"));
left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - MIN_PROBE_EDGE; left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - MIN_PROBE_EDGE;
} }
if (right_out) { if (right_out) {
SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n"); out_of_range_error(PSTR("(R)ight"));
right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE; right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE;
} }
if (front_out) { if (front_out) {
SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n"); out_of_range_error(PSTR("(F)ront"));
front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - MIN_PROBE_EDGE; front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - MIN_PROBE_EDGE;
} }
if (back_out) { if (back_out) {
SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n"); out_of_range_error(PSTR("(B)ack"));
back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE; back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE;
} }
return; return;
@ -3170,7 +3176,7 @@ inline void gcode_M42() {
if (code_seen('X') || code_seen('x')) { if (code_seen('X') || code_seen('x')) {
X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER; X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) { if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
SERIAL_PROTOCOLPGM("?X position out of range.\n"); out_of_range_error(PSTR("X"));
return; return;
} }
} }
@ -3178,7 +3184,7 @@ inline void gcode_M42() {
if (code_seen('Y') || code_seen('y')) { if (code_seen('Y') || code_seen('y')) {
Y_probe_location = code_value() - Y_PROBE_OFFSET_FROM_EXTRUDER; Y_probe_location = code_value() - Y_PROBE_OFFSET_FROM_EXTRUDER;
if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) { if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
SERIAL_PROTOCOLPGM("?Y position out of range.\n"); out_of_range_error(PSTR("Y"));
return; return;
} }
} }

Loading…
Cancel
Save