Add _draw_axis_label function to reduce source

This commit is contained in:
Scott Lahteine 2016-04-18 19:45:55 -07:00
parent 34b17d4a8a
commit 90c97c8185
2 changed files with 43 additions and 82 deletions

View File

@ -309,6 +309,23 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) {
} }
} }
FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
if (blink)
lcd_printPGM(pstr);
else {
if (!axis_homed[axis])
lcd_printPGM(PSTR("?"));
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[axis])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(pstr);
}
}
}
static void lcd_implementation_status_screen() { static void lcd_implementation_status_screen() {
u8g.setColorIndex(1); // black on white u8g.setColorIndex(1); // black on white
@ -382,59 +399,22 @@ static void lcd_implementation_status_screen() {
u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9); u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9);
#endif #endif
u8g.setColorIndex(0); // white on black u8g.setColorIndex(0); // white on black
u8g.setPrintPos(2, XYZ_BASELINE); u8g.setPrintPos(2, XYZ_BASELINE);
if (blink) _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
lcd_printPGM(PSTR(MSG_X));
else {
if (!axis_homed[X_AXIS])
lcd_printPGM(PSTR("?"));
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[X_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_X));
}
}
u8g.setPrintPos(10, XYZ_BASELINE); u8g.setPrintPos(10, XYZ_BASELINE);
lcd_print(ftostr4sign(current_position[X_AXIS])); lcd_print(ftostr4sign(current_position[X_AXIS]));
u8g.setPrintPos(43, XYZ_BASELINE); u8g.setPrintPos(43, XYZ_BASELINE);
if (blink) _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
lcd_printPGM(PSTR(MSG_Y));
else {
if (!axis_homed[Y_AXIS])
lcd_printPGM(PSTR("?"));
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Y_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_Y));
}
}
u8g.setPrintPos(51, XYZ_BASELINE); u8g.setPrintPos(51, XYZ_BASELINE);
lcd_print(ftostr4sign(current_position[Y_AXIS])); lcd_print(ftostr4sign(current_position[Y_AXIS]));
u8g.setPrintPos(83, XYZ_BASELINE); u8g.setPrintPos(83, XYZ_BASELINE);
if (blink) _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
lcd_printPGM(PSTR(MSG_Z));
else {
if (!axis_homed[Z_AXIS])
lcd_printPGM(PSTR("?"));
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Z_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_Z));
}
}
u8g.setPrintPos(91, XYZ_BASELINE); u8g.setPrintPos(91, XYZ_BASELINE);
lcd_print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); lcd_print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
u8g.setColorIndex(1); // black on white u8g.setColorIndex(1); // black on white
// Feedrate // Feedrate

View File

@ -569,6 +569,23 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
#endif // SHOW_BOOTSCREEN #endif // SHOW_BOOTSCREEN
FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
if (blink)
lcd_printPGM(pstr);
else {
if (!axis_homed[axis])
lcd_printPGM(PSTR("?"));
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[axis])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(pstr);
}
}
}
/** /**
Possible status screens: Possible status screens:
16x2 |000/000 B000/000| 16x2 |000/000 B000/000|
@ -692,36 +709,12 @@ static void lcd_implementation_status_screen() {
// When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '. // When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
// When everything is ok you see a constant 'X'. // When everything is ok you see a constant 'X'.
if (blink) _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
lcd_printPGM(PSTR(MSG_X));
else {
if (!axis_homed[X_AXIS])
lcd_printPGM(PSTR("?"));
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[X_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_X));
}
lcd.print(ftostr4sign(current_position[X_AXIS])); lcd.print(ftostr4sign(current_position[X_AXIS]));
lcd_printPGM(PSTR(" ")); lcd_printPGM(PSTR(" "));
if (blink)
lcd_printPGM(PSTR(MSG_Y)); _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
else {
if (!axis_homed[Y_AXIS])
lcd_printPGM(PSTR("?"));
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Y_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_Y));
}
lcd.print(ftostr4sign(current_position[Y_AXIS])); lcd.print(ftostr4sign(current_position[Y_AXIS]));
#endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
@ -729,19 +722,7 @@ static void lcd_implementation_status_screen() {
#endif // LCD_WIDTH >= 20 #endif // LCD_WIDTH >= 20
lcd.setCursor(LCD_WIDTH - 8, 1); lcd.setCursor(LCD_WIDTH - 8, 1);
if (blink) _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
lcd_printPGM(PSTR(MSG_Z));
else {
if (!axis_homed[Z_AXIS])
lcd_printPGM(PSTR("?"));
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Z_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR(MSG_Z));
}
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
#endif // LCD_HEIGHT > 2 #endif // LCD_HEIGHT > 2