Skip to content

Commit

Permalink
Update LCD for modified flags
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 30, 2020
1 parent 6d8cc93 commit 0a4ba9d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 79 deletions.
18 changes: 6 additions & 12 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd_put_wchar('X' + uint8_t(axis));
if (blink)
lcd_put_u8str(value);
else {
if (!axis_was_homed(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd.write('X' + uint8_t(axis));
if (blink)
lcd.print(value);
else {
if (!axis_was_homed(axis))
while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd.write(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) {
Expand Down
18 changes: 6 additions & 12 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,12 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const

if (blink)
lcd_put_u8str(value);
else {
if (!axis_was_homed(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
}
}
else if (axis_should_home(axis))
while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
lcd_put_u8str(value);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,8 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
}
}

if (countdown == 0 && (forceUpdate || position_changed()
|| TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())
)) draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_trusted()));
if (countdown == 0 && (forceUpdate || position_changed() || TERN(DISABLE_REDUCED_ACCURACY_WARNING, 0, blink_changed())))
draw_position(current_position, TERN(DISABLE_REDUCED_ACCURACY_WARNING, 1, all_axes_trusted()));
#endif
}

Expand All @@ -855,7 +854,7 @@ void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) {

UNUSED(forceUpdate);

#endif // LCD_SET_PROGRESS_MANUALLY || SDSUPPORT
#endif
}

void ST7920_Lite_Status_Screen::update(const bool forceUpdate) {
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ namespace ExtUI {
bool canMove(const axis_t axis) {
switch (axis) {
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
case X: return axis_was_homed(X_AXIS);
case Y: return axis_was_homed(Y_AXIS);
case Z: return axis_was_homed(Z_AXIS);
case X: return axis_should_home(X_AXIS);
case Y: return axis_should_home(Y_AXIS);
case Z: return axis_should_home(Z_AXIS);
#else
case X: case Y: case Z: return true;
#endif
Expand Down
31 changes: 13 additions & 18 deletions Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,42 +257,37 @@ void MarlinUI::draw_status_screen() {
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, 312, 24, COLOR_AXIS_HOMED);

uint16_t color;
uint16_t offset;
bool is_homed;

tft.add_text( 10, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(127, 3, COLOR_AXIS_HOMED , "Y");
tft.add_text(219, 3, COLOR_AXIS_HOMED , "Z");

is_homed = axis_was_homed(X_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text( 68 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
bool not_homed = axis_should_home(X_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text( 68 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = axis_was_homed(Y_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(185 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
not_homed = axis_should_home(Y_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(185 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = axis_was_homed(Z_AXIS);
if (blink & !is_homed) {
not_homed = axis_should_home(Z_AXIS);
uint16_t offset = 25;
if (blink && not_homed)
tft_string.set("?");
offset = 25; // ".00"
}
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
tft_string.rtrim();
offset = tft_string.width();
offset += tft_string.width();

tft_string.set(ftostr52sp(z));
offset += 25 - tft_string.width();
offset -= tft_string.width();
}
tft.add_text(301 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

// feed rate
tft.canvas(70, 136, 80, 32);
tft.set_background(COLOR_BACKGROUND);
color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
tft_string.set(i16tostr3rj(feedrate_percentage));
tft_string.add('%');
Expand Down
31 changes: 13 additions & 18 deletions Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,43 +262,38 @@ void MarlinUI::draw_status_screen() {
tft.set_background(COLOR_BACKGROUND);
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);

uint16_t color;
uint16_t offset;
bool is_homed;

tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
tft.add_text(330, 3, COLOR_AXIS_HOMED , "Z");

is_homed = axis_was_homed(X_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(102 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
bool not_homed = axis_should_home(X_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
tft.add_text(102 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = axis_was_homed(Y_AXIS);
tft_string.set(blink & !is_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(280 - tft_string.width(), 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
not_homed = axis_should_home(Y_AXIS);
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
tft.add_text(280 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);

is_homed = axis_was_homed(Z_AXIS);
if (blink & !is_homed) {
uint16_t offset = 32;
not_homed = axis_should_home(Z_AXIS);
if (blink && not_homed)
tft_string.set("?");
offset = 32; // ".00"
}
else {
const float z = LOGICAL_Z_POSITION(current_position.z);
tft_string.set(ftostr52sp((int16_t)z));
tft_string.rtrim();
offset = tft_string.width();
offset += tft_string.width();

tft_string.set(ftostr52sp(z));
offset += 32 - tft_string.width();
offset -= tft_string.width();
}
tft.add_text(455 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string);
tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));

// feed rate
tft.canvas(96, 180, 100, 32);
tft.set_background(COLOR_BACKGROUND);
color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
tft_string.set(i16tostr3rj(feedrate_percentage));
tft_string.add('%');
Expand Down

0 comments on commit 0a4ba9d

Please sign in to comment.