Encapsulate common display code in a singleton (#12395)
* Encapsulate common LCD code in a singleton * Depend more UBL code on UBL_DEVEL_DEBUGGING - Since most users don't need the debugging on at all times, this helps reduce the default build size for UBL by over 2K, a little closer to fitting on 128K boards.
This commit is contained in:
@ -39,70 +39,6 @@
|
||||
// macro name. The mapping is independent of whether the button is directly connected or
|
||||
// via a shift/i2c register.
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
extern volatile uint8_t buttons;
|
||||
|
||||
//
|
||||
// Setup other button mappings of each panel
|
||||
//
|
||||
#if ENABLED(LCD_I2C_VIKI)
|
||||
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
||||
|
||||
// button and encoder bit positions within 'buttons'
|
||||
#define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
||||
#define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
|
||||
#define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
|
||||
#define B_DW (BUTTON_DOWN << B_I2C_BTN_OFFSET)
|
||||
#define B_RI (BUTTON_RIGHT << B_I2C_BTN_OFFSET)
|
||||
|
||||
#undef LCD_CLICKED
|
||||
#if BUTTON_EXISTS(ENC)
|
||||
// the pause/stop/restart button is connected to BTN_ENC when used
|
||||
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
|
||||
#define LCD_CLICKED() (buttons & (B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
|
||||
#else
|
||||
#define LCD_CLICKED() (buttons & (B_MI|B_RI))
|
||||
#endif
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
|
||||
#elif ENABLED(LCD_I2C_PANELOLU2)
|
||||
|
||||
#if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
|
||||
|
||||
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
||||
|
||||
#define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
||||
|
||||
#undef LCD_CLICKED
|
||||
#define LCD_CLICKED() (buttons & B_MI)
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
|
||||
#endif
|
||||
|
||||
#elif DISABLED(NEWPANEL) // old style ULTIPANEL
|
||||
// Shift register bits correspond to buttons:
|
||||
#define BL_LE 7 // Left
|
||||
#define BL_UP 6 // Up
|
||||
#define BL_MI 5 // Middle
|
||||
#define BL_DW 4 // Down
|
||||
#define BL_RI 3 // Right
|
||||
#define BL_ST 2 // Red Button
|
||||
#define B_LE (_BV(BL_LE))
|
||||
#define B_UP (_BV(BL_UP))
|
||||
#define B_MI (_BV(BL_MI))
|
||||
#define B_DW (_BV(BL_DW))
|
||||
#define B_RI (_BV(BL_RI))
|
||||
#define B_ST (_BV(BL_ST))
|
||||
#define LCD_CLICKED() (buttons & (B_MI|B_ST))
|
||||
#endif
|
||||
|
||||
#endif // HAS_LCD_MENU
|
||||
|
||||
////////////////////////////////////
|
||||
// Create LCD class instance and chipset-specific information
|
||||
#if ENABLED(LCD_I2C_TYPE_PCF8575)
|
||||
@ -122,7 +58,7 @@
|
||||
#define LCD_CLASS LiquidCrystal_I2C
|
||||
|
||||
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
|
||||
// For the LED indicators (which may be mapped to different events in lcd_implementation_update_indicators())
|
||||
// For the LED indicators (which may be mapped to different events in update_indicators())
|
||||
#define LCD_HAS_STATUS_INDICATORS
|
||||
#define LED_A 0x04 //100
|
||||
#define LED_B 0x02 //010
|
||||
|
@ -86,10 +86,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
|
||||
static void lcd_implementation_update_indicators();
|
||||
#endif
|
||||
|
||||
static void createChar_P(const char c, const byte * const ptr) {
|
||||
byte temp[8];
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
@ -101,7 +97,7 @@ static void createChar_P(const char c, const byte * const ptr) {
|
||||
#define LCD_STR_PROGRESS "\x03\x04\x05"
|
||||
#endif
|
||||
|
||||
void lcd_set_custom_characters(
|
||||
void MarlinUI::set_custom_characters(
|
||||
#if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
|
||||
const HD44780CharSet screen_charset/*=CHARSET_INFO*/
|
||||
#endif
|
||||
@ -319,7 +315,7 @@ void lcd_set_custom_characters(
|
||||
|
||||
}
|
||||
|
||||
void lcd_implementation_init() {
|
||||
void MarlinUI::init_lcd() {
|
||||
|
||||
#if ENABLED(LCD_I2C_TYPE_PCF8575)
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
@ -331,7 +327,7 @@ void lcd_implementation_init() {
|
||||
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
|
||||
lcd.setMCPType(LTI_TYPE_MCP23017);
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
lcd_implementation_update_indicators();
|
||||
update_indicators();
|
||||
|
||||
#elif ENABLED(LCD_I2C_TYPE_MCP23008)
|
||||
lcd.setMCPType(LTI_TYPE_MCP23008);
|
||||
@ -345,12 +341,12 @@ void lcd_implementation_init() {
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
#endif
|
||||
|
||||
LCD_SET_CHARSET(currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
|
||||
LCD_SET_CHARSET(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
|
||||
|
||||
lcd.clear();
|
||||
}
|
||||
|
||||
void lcd_implementation_clear() { lcd.clear(); }
|
||||
void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
|
||||
@ -408,7 +404,7 @@ void lcd_implementation_clear() { lcd.clear(); }
|
||||
lcd_moveto(indent, 2); lcd_put_wchar('\x02'); lcd_put_u8str_P(PSTR( "------" )); lcd_put_wchar('\x03');
|
||||
}
|
||||
|
||||
void lcd_bootscreen() {
|
||||
void MarlinUI::show_bootscreen() {
|
||||
LCD_SET_CHARSET(CHARSET_BOOT);
|
||||
lcd.clear();
|
||||
|
||||
@ -454,6 +450,9 @@ void lcd_implementation_clear() { lcd.clear(); }
|
||||
CENTER_OR_SCROLL(STRING_SPLASH_LINE1, _SPLASH_WAIT_1);
|
||||
#ifdef STRING_SPLASH_LINE2
|
||||
CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 1500);
|
||||
#ifdef STRING_SPLASH_LINE3
|
||||
CENTER_OR_SCROLL(STRING_SPLASH_LINE3, 1500);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#elif defined(STRING_SPLASH_LINE2)
|
||||
@ -484,9 +483,9 @@ void lcd_implementation_clear() { lcd.clear(); }
|
||||
|
||||
#endif // SHOW_BOOTSCREEN
|
||||
|
||||
void lcd_kill_screen() {
|
||||
void MarlinUI::draw_kill_screen() {
|
||||
lcd_moveto(0, 0);
|
||||
lcd_put_u8str(lcd_status_message);
|
||||
lcd_put_u8str(status_message);
|
||||
#if LCD_HEIGHT < 4
|
||||
lcd_moveto(0, 2);
|
||||
#else
|
||||
@ -572,13 +571,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
|
||||
#if HAS_PRINT_PROGRESS
|
||||
|
||||
FORCE_INLINE void _draw_print_progress() {
|
||||
const uint8_t percent = (
|
||||
#if ENABLED(SDSUPPORT)
|
||||
IS_SD_PRINTING() ? card.percentDone() : 0
|
||||
#else
|
||||
progress_bar_percent
|
||||
#endif
|
||||
);
|
||||
const uint8_t progress = ui.get_progress();
|
||||
lcd_put_u8str_P(PSTR(
|
||||
#if ENABLED(SDSUPPORT)
|
||||
"SD"
|
||||
@ -586,8 +579,8 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
|
||||
"P:"
|
||||
#endif
|
||||
));
|
||||
if (percent)
|
||||
lcd_put_u8str(itostr3(percent));
|
||||
if (progress)
|
||||
lcd_put_u8str(itostr3(progress));
|
||||
else
|
||||
lcd_put_u8str_P(PSTR("---"));
|
||||
lcd_put_wchar('%');
|
||||
@ -616,7 +609,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
|
||||
|
||||
#endif // LCD_PROGRESS_BAR
|
||||
|
||||
FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
lcd_moveto(0, LCD_HEIGHT - 1);
|
||||
|
||||
@ -624,17 +617,15 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
|
||||
// Draw the progress bar if the message has shown long enough
|
||||
// or if there is no message set.
|
||||
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
const uint8_t progress_bar_percent = card.percentDone();
|
||||
#endif
|
||||
if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
|
||||
return lcd_draw_progress_bar(progress_bar_percent);
|
||||
if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !has_status()) {
|
||||
const uint8_t progress = get_progress();
|
||||
if (progress > 2) return lcd_draw_progress_bar(progress);
|
||||
}
|
||||
|
||||
#elif ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
|
||||
|
||||
// Show Filament Diameter and Volumetric Multiplier %
|
||||
// After allowing lcd_status_message to show for 5 seconds
|
||||
if (ELAPSED(millis(), previous_lcd_status_ms + 5000UL)) {
|
||||
// Alternate Status message and Filament display
|
||||
if (ELAPSED(millis(), next_filament_display)) {
|
||||
lcd_put_u8str_P(PSTR("Dia "));
|
||||
lcd_put_u8str(ftostr12ns(filament_width_meas));
|
||||
lcd_put_u8str_P(PSTR(" V"));
|
||||
@ -654,13 +645,13 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
static bool last_blink = false;
|
||||
|
||||
// Get the UTF8 character count of the string
|
||||
uint8_t slen = utf8_strlen(lcd_status_message);
|
||||
uint8_t slen = utf8_strlen(status_message);
|
||||
|
||||
// If the string fits into the LCD, just print it and do not scroll it
|
||||
if (slen <= LCD_WIDTH) {
|
||||
|
||||
// The string isn't scrolling and may not fill the screen
|
||||
lcd_put_u8str(lcd_status_message);
|
||||
lcd_put_u8str(status_message);
|
||||
|
||||
// Fill the rest with spaces
|
||||
while (slen < LCD_WIDTH) {
|
||||
@ -672,7 +663,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
// String is larger than the available space in screen.
|
||||
|
||||
// Get a pointer to the next valid UTF8 character
|
||||
const char *stat = lcd_status_message + status_scroll_offset;
|
||||
const char *stat = status_message + status_scroll_offset;
|
||||
|
||||
// Get the string remaining length
|
||||
const uint8_t rlen = utf8_strlen(stat);
|
||||
@ -692,7 +683,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
if (--chars) { // Draw a second dot if there's space
|
||||
lcd_put_wchar('.');
|
||||
if (--chars)
|
||||
lcd_put_u8str_max(lcd_status_message, chars); // Print a second copy of the message
|
||||
lcd_put_u8str_max(status_message, chars); // Print a second copy of the message
|
||||
}
|
||||
}
|
||||
if (last_blink != blink) {
|
||||
@ -701,7 +692,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
// Adjust by complete UTF8 characters
|
||||
if (status_scroll_offset < slen) {
|
||||
status_scroll_offset++;
|
||||
while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
|
||||
while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
|
||||
status_scroll_offset++;
|
||||
}
|
||||
else
|
||||
@ -712,10 +703,10 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
UNUSED(blink);
|
||||
|
||||
// Get the UTF8 character count of the string
|
||||
uint8_t slen = utf8_strlen(lcd_status_message);
|
||||
uint8_t slen = utf8_strlen(status_message);
|
||||
|
||||
// Just print the string to the LCD
|
||||
lcd_put_u8str_max(lcd_status_message, LCD_WIDTH);
|
||||
lcd_put_u8str_max(status_message, LCD_WIDTH);
|
||||
|
||||
// Fill the rest with spaces if there are missing spaces
|
||||
while (slen < LCD_WIDTH) {
|
||||
@ -725,35 +716,47 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LCD_INFO_SCREEN_STYLE == 0
|
||||
/**
|
||||
* LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen
|
||||
*
|
||||
* 16x2 |000/000 B000/000|
|
||||
* |0123456789012345|
|
||||
*
|
||||
* 16x4 |000/000 B000/000|
|
||||
* |SD---% Z 000.00|
|
||||
* |F---% T--:--|
|
||||
* |0123456789012345|
|
||||
*
|
||||
* 20x2 |T000/000° B000/000° |
|
||||
* |01234567890123456789|
|
||||
*
|
||||
* 20x4 |T000/000° B000/000° |
|
||||
* |X 000 Y 000 Z000.000|
|
||||
* |F---% SD---% T--:--|
|
||||
* |01234567890123456789|
|
||||
*
|
||||
* LCD_INFO_SCREEN_STYLE 1 : Prusa-style Status Screen
|
||||
*
|
||||
* |T000/000° Z 000.00 |
|
||||
* |B000/000° F---% |
|
||||
* |SD---% T--:-- |
|
||||
* |01234567890123456789|
|
||||
*
|
||||
* |T000/000° Z 000.00 |
|
||||
* |T000/000° F---% |
|
||||
* |B000/000° SD---% |
|
||||
* |01234567890123456789|
|
||||
*/
|
||||
|
||||
/**
|
||||
* LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen
|
||||
*
|
||||
* 16x2 |000/000 B000/000|
|
||||
* |0123456789012345|
|
||||
*
|
||||
* 16x4 |000/000 B000/000|
|
||||
* |SD---% Z 000.00|
|
||||
* |F---% T--:--|
|
||||
* |0123456789012345|
|
||||
*
|
||||
* 20x2 |T000/000° B000/000° |
|
||||
* |01234567890123456789|
|
||||
*
|
||||
* 20x4 |T000/000° B000/000° |
|
||||
* |X 000 Y 000 Z000.000|
|
||||
* |F---% SD---% T--:--|
|
||||
* |01234567890123456789|
|
||||
*/
|
||||
void MarlinUI::draw_status_screen() {
|
||||
|
||||
void lcd_impl_status_screen_0() {
|
||||
const bool blink = lcd_blink();
|
||||
const bool blink = get_blink();
|
||||
lcd_moveto(0, 0);
|
||||
|
||||
#if LCD_INFO_SCREEN_STYLE == 0
|
||||
|
||||
// ========== Line 1 ==========
|
||||
|
||||
lcd_moveto(0, 0);
|
||||
|
||||
#if LCD_WIDTH < 20
|
||||
|
||||
//
|
||||
@ -885,39 +888,13 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
|
||||
#endif // LCD_HEIGHT > 3
|
||||
|
||||
// ========= Last Line ========
|
||||
|
||||
//
|
||||
// Status Message (which may be a Progress Bar or Filament display)
|
||||
//
|
||||
_draw_status_message(blink);
|
||||
}
|
||||
|
||||
#elif LCD_INFO_SCREEN_STYLE == 1
|
||||
|
||||
/**
|
||||
* LCD_INFO_SCREEN_STYLE 1 : Prusa-style Status Screen
|
||||
*
|
||||
* |T000/000° Z 000.00 |
|
||||
* |B000/000° F---% |
|
||||
* |SD---% T--:-- |
|
||||
* |01234567890123456789|
|
||||
*
|
||||
* |T000/000° Z 000.00 |
|
||||
* |T000/000° F---% |
|
||||
* |B000/000° SD---% |
|
||||
* |01234567890123456789|
|
||||
*/
|
||||
|
||||
void lcd_impl_status_screen_1() {
|
||||
const bool blink = lcd_blink();
|
||||
#elif LCD_INFO_SCREEN_STYLE == 1
|
||||
|
||||
// ========== Line 1 ==========
|
||||
|
||||
//
|
||||
// Hotend 0 Temperature
|
||||
//
|
||||
lcd_moveto(0, 0);
|
||||
_draw_heater_status(0, LCD_STR_THERMOMETER[0], blink);
|
||||
|
||||
//
|
||||
@ -977,30 +954,30 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
lcd_put_u8str(buffer);
|
||||
#endif
|
||||
|
||||
// ========== Line 4 ==========
|
||||
#endif // LCD_INFO_SCREEN_STYLE 1
|
||||
|
||||
//
|
||||
// Status Message (which may be a Progress Bar or Filament display)
|
||||
//
|
||||
_draw_status_message(blink);
|
||||
}
|
||||
// ========= Last Line ========
|
||||
|
||||
#endif
|
||||
//
|
||||
// Status Message (which may be a Progress Bar or Filament display)
|
||||
//
|
||||
draw_status_message(blink);
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder) {
|
||||
void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
|
||||
if (row < LCD_HEIGHT) {
|
||||
lcd_moveto(LCD_WIDTH - 9, row);
|
||||
_draw_heater_status(extruder, LCD_STR_THERMOMETER[0], lcd_blink());
|
||||
_draw_heater_status(extruder, LCD_STR_THERMOMETER[0], ui.get_blink());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
void lcd_implementation_drawmenu_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
|
||||
void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
|
||||
UNUSED(invert);
|
||||
int8_t n = LCD_WIDTH;
|
||||
lcd_moveto(0, row);
|
||||
@ -1013,35 +990,35 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
for (; n > 0; --n) lcd_put_wchar(' ');
|
||||
}
|
||||
|
||||
void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
|
||||
void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) {
|
||||
uint8_t n = LCD_WIDTH - 2;
|
||||
lcd_moveto(0, row);
|
||||
lcd_put_wchar(sel ? pre_char : ' ');
|
||||
lcd_put_wchar(isSelected ? pre_char : ' ');
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
while (n--) lcd_put_wchar(' ');
|
||||
lcd_put_wchar(post_char);
|
||||
}
|
||||
|
||||
void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
|
||||
void draw_menu_item_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
|
||||
uint8_t n = LCD_WIDTH - 2 - utf8_strlen(data);
|
||||
lcd_moveto(0, row);
|
||||
lcd_put_wchar(sel ? pre_char : ' ');
|
||||
lcd_put_wchar(isSelected ? pre_char : ' ');
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
lcd_put_wchar(':');
|
||||
while (n--) lcd_put_wchar(' ');
|
||||
lcd_put_u8str(data);
|
||||
}
|
||||
void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
|
||||
void draw_menu_item_setting_edit_generic_P(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) {
|
||||
uint8_t n = LCD_WIDTH - 2 - utf8_strlen_P(data);
|
||||
lcd_moveto(0, row);
|
||||
lcd_put_wchar(sel ? pre_char : ' ');
|
||||
lcd_put_wchar(isSelected ? pre_char : ' ');
|
||||
n -= lcd_put_u8str_max_P(pstr, n);
|
||||
lcd_put_wchar(':');
|
||||
while (n--) lcd_put_wchar(' ');
|
||||
lcd_put_u8str_P(data);
|
||||
}
|
||||
|
||||
void lcd_implementation_drawedit(PGM_P pstr, const char* const value/*=NULL*/) {
|
||||
void draw_edit_screen(PGM_P const pstr, const char* const value/*=NULL*/) {
|
||||
lcd_moveto(1, 1);
|
||||
lcd_put_u8str_P(pstr);
|
||||
if (value != NULL) {
|
||||
@ -1056,27 +1033,29 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
static void lcd_implementation_drawmenu_sd(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const uint8_t concat, const char post_char) {
|
||||
void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) {
|
||||
const char post_char = isDir ? LCD_STR_FOLDER[0] : ' ',
|
||||
sel_char = isSelected ? '>' : ' ';
|
||||
UNUSED(pstr);
|
||||
lcd_moveto(0, row);
|
||||
lcd_put_wchar(sel ? '>' : ' ');
|
||||
lcd_put_wchar(sel_char);
|
||||
|
||||
uint8_t n = LCD_WIDTH - concat;
|
||||
uint8_t n = LCD_WIDTH - 2;
|
||||
const char *outstr = theCard.longest_filename();
|
||||
if (theCard.longFilename[0]) {
|
||||
#if ENABLED(SCROLL_LONG_FILENAMES)
|
||||
static uint8_t filename_scroll_hash;
|
||||
if (sel) {
|
||||
if (isSelected) {
|
||||
uint8_t name_hash = row;
|
||||
for (uint8_t l = FILENAME_LENGTH; l--;)
|
||||
name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ theCard.filename[l]; // rotate, xor
|
||||
if (filename_scroll_hash != name_hash) { // If the hash changed...
|
||||
filename_scroll_hash = name_hash; // Save the new hash
|
||||
filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - n); // Update the scroll limit
|
||||
filename_scroll_pos = 0; // Reset scroll to the start
|
||||
lcd_status_update_delay = 8; // Don't scroll right away
|
||||
ui.filename_scroll_max = MAX(0, utf8_strlen(theCard.longFilename) - n); // Update the scroll limit
|
||||
ui.filename_scroll_pos = 0; // Reset scroll to the start
|
||||
ui.lcd_status_update_delay = 8; // Don't scroll right away
|
||||
}
|
||||
outstr += filename_scroll_pos;
|
||||
outstr += ui.filename_scroll_pos;
|
||||
}
|
||||
#else
|
||||
theCard.longFilename[n] = '\0'; // cutoff at screen edge
|
||||
@ -1084,45 +1063,18 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
}
|
||||
|
||||
lcd_moveto(0, row);
|
||||
lcd_put_wchar(sel ? '>' : ' ');
|
||||
lcd_put_wchar(sel_char);
|
||||
n -= lcd_put_u8str_max(outstr, n);
|
||||
|
||||
while (n) { --n; lcd_put_wchar(' '); }
|
||||
for (; n; --n) lcd_put_wchar(' ');
|
||||
lcd_put_wchar(post_char);
|
||||
}
|
||||
|
||||
void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
|
||||
lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, ' ');
|
||||
}
|
||||
|
||||
void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard) {
|
||||
lcd_implementation_drawmenu_sd(sel, row, pstr, theCard, 2, LCD_STR_FOLDER[0]);
|
||||
}
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
|
||||
|
||||
extern millis_t next_button_update_ms;
|
||||
|
||||
static uint8_t lcd_implementation_read_slow_buttons() {
|
||||
#if ENABLED(LCD_I2C_TYPE_MCP23017)
|
||||
// Reading these buttons this is likely to be too slow to call inside interrupt context
|
||||
// so they are called during normal lcd_update
|
||||
uint8_t slow_bits = lcd.readButtons() << B_I2C_BTN_OFFSET;
|
||||
#if ENABLED(LCD_I2C_VIKI)
|
||||
if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
|
||||
slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
|
||||
#endif // LCD_I2C_VIKI
|
||||
return slow_bits;
|
||||
#endif // LCD_I2C_TYPE_MCP23017
|
||||
}
|
||||
|
||||
#endif // LCD_HAS_SLOW_BUTTONS
|
||||
|
||||
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
|
||||
|
||||
static void lcd_implementation_update_indicators() {
|
||||
static void MarlinUI::update_indicators() {
|
||||
// Set the LEDS - referred to as backlights by the LiquidTWI2 library
|
||||
static uint8_t ledsprev = 0;
|
||||
uint8_t leds = 0;
|
||||
@ -1242,7 +1194,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
lcd_put_wchar(c);
|
||||
}
|
||||
|
||||
void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y) {
|
||||
void MarlinUI::ubl_plot(const uint8_t x, const uint8_t inverted_y) {
|
||||
|
||||
#if LCD_WIDTH >= 20
|
||||
#define _LCD_W_POS 12
|
||||
@ -1292,7 +1244,7 @@ FORCE_INLINE void _draw_status_message(const bool blink) {
|
||||
lower_right.column = 0;
|
||||
lower_right.row = 0;
|
||||
|
||||
lcd_implementation_clear();
|
||||
clear_lcd();
|
||||
|
||||
x_map_pixels = (HD44780_CHAR_WIDTH) * (MESH_MAP_COLS) - 2; // Minus 2 because we are drawing a box around the map
|
||||
y_map_pixels = (HD44780_CHAR_HEIGHT) * (MESH_MAP_ROWS) - 2;
|
||||
|
Reference in New Issue
Block a user