Minor LCD cleanup, improvement
This commit is contained in:
@ -414,7 +414,7 @@ void MarlinUI::draw_status_screen() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const bool showxy = TERN1(LCD_SHOW_E_TOTAL, !printingIsActive());
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
|
||||
|
||||
// At the first page, generate new display values
|
||||
if (first_page) {
|
||||
@ -434,16 +434,16 @@ void MarlinUI::draw_status_screen() {
|
||||
const xyz_pos_t lpos = current_position.asLogical();
|
||||
strcpy(zstring, ftostr52sp(lpos.z));
|
||||
|
||||
if (showxy) {
|
||||
strcpy(xstring, ftostr4sign(lpos.x));
|
||||
strcpy(ystring, ftostr4sign(lpos.y));
|
||||
}
|
||||
else {
|
||||
if (show_e_total) {
|
||||
#if ENABLED(LCD_SHOW_E_TOTAL)
|
||||
const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
|
||||
sprintf_P(xstring, PSTR("%ld%cm"), uint32_t(_MAX(e_move_accumulator, 0.0f)) / escale, escale == 10 ? 'c' : 'm'); // 1234567mm
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
strcpy(xstring, ftostr4sign(lpos.x));
|
||||
strcpy(ystring, ftostr4sign(lpos.y));
|
||||
}
|
||||
|
||||
#if ENABLED(FILAMENT_LCD_DISPLAY)
|
||||
strcpy(wstring, ftostr12ns(filwidth.measured_mm));
|
||||
@ -772,14 +772,14 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
#else
|
||||
|
||||
if (showxy) {
|
||||
_draw_axis_value(X_AXIS, xstring, blink);
|
||||
_draw_axis_value(Y_AXIS, ystring, blink);
|
||||
}
|
||||
else {
|
||||
if (show_e_total) {
|
||||
_draw_axis_value(E_AXIS, xstring, true);
|
||||
lcd_put_u8str_P(PSTR(" "));
|
||||
}
|
||||
else {
|
||||
_draw_axis_value(X_AXIS, xstring, blink);
|
||||
_draw_axis_value(Y_AXIS, ystring, blink);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -318,7 +318,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
// Set the colors for a menu item based on whether it is selected
|
||||
// Mark a menu item and set font color if selected.
|
||||
// Return 'false' if the item is not on screen.
|
||||
static bool mark_as_selected(const uint8_t row, const bool sel) {
|
||||
row_y1 = row * (MENU_FONT_HEIGHT) + 1;
|
||||
row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
|
||||
@ -330,15 +331,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
|
||||
u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH);
|
||||
#else
|
||||
u8g.setColorIndex(1); // black on white
|
||||
u8g.setColorIndex(1); // solid outline
|
||||
u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
|
||||
u8g.setColorIndex(0); // white on black
|
||||
u8g.setColorIndex(0); // inverted text
|
||||
#endif
|
||||
}
|
||||
#if DISABLED(MENU_HOLLOW_FRAME)
|
||||
else {
|
||||
u8g.setColorIndex(1); // unmarked text is black on white
|
||||
}
|
||||
else u8g.setColorIndex(1); // solid text
|
||||
#endif
|
||||
|
||||
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
|
||||
@ -352,13 +351,15 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
|
||||
if (mark_as_selected(row, style & SS_INVERT)) {
|
||||
|
||||
u8g_uint_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
|
||||
pixel_len_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
|
||||
|
||||
if ((style & SS_CENTER) && !valstr) {
|
||||
int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2;
|
||||
while (--pad >= 0) { lcd_put_wchar(' '); n--; }
|
||||
}
|
||||
n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH) * (MENU_FONT_WIDTH);
|
||||
if ((style & SS_CENTER) && !valstr)
|
||||
for (int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; pad > 0; --pad) {
|
||||
lcd_put_wchar(' ');
|
||||
n -= MENU_FONT_WIDTH;
|
||||
}
|
||||
|
||||
n = lcd_put_u8str_ind_P(pstr, itemIndex, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH);
|
||||
if (valstr) n -= lcd_put_u8str_max(valstr, n);
|
||||
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
|
||||
}
|
||||
@ -367,7 +368,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
// Draw a generic menu item
|
||||
void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char, const char post_char) {
|
||||
if (mark_as_selected(row, sel)) {
|
||||
u8g_uint_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2) * (MENU_FONT_WIDTH);
|
||||
pixel_len_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 1) * (MENU_FONT_WIDTH);
|
||||
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
|
||||
lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char);
|
||||
lcd_put_wchar(' ');
|
||||
@ -380,7 +381,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)),
|
||||
pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), data) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), (char*)data));
|
||||
|
||||
u8g_uint_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
|
||||
pixel_len_t n = lcd_put_u8str_ind_P(pstr, itemIndex, LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH);
|
||||
if (vallen) {
|
||||
lcd_put_wchar(':');
|
||||
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
|
||||
@ -440,8 +441,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
}
|
||||
|
||||
inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) {
|
||||
const u8g_uint_t len = utf8_strlen_P(pstr), bw = len * (MENU_FONT_WIDTH),
|
||||
bx = x * (MENU_FONT_WIDTH), by = (y + 1) * (MENU_FONT_HEIGHT);
|
||||
const u8g_uint_t len = utf8_strlen_P(pstr),
|
||||
by = (y + 1) * (MENU_FONT_HEIGHT);
|
||||
const pixel_len_t bw = len * (MENU_FONT_WIDTH), bx = x * (MENU_FONT_WIDTH);
|
||||
if (inv) {
|
||||
u8g.setColorIndex(1);
|
||||
u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1);
|
||||
@ -463,8 +465,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
if (mark_as_selected(row, sel)) {
|
||||
if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]);
|
||||
constexpr uint8_t maxlen = LCD_WIDTH - 1;
|
||||
const u8g_uint_t pixw = maxlen * (MENU_FONT_WIDTH);
|
||||
u8g_uint_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw);
|
||||
const pixel_len_t pixw = maxlen * (MENU_FONT_WIDTH);
|
||||
pixel_len_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw);
|
||||
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' ');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user