Some cleanup around 'lcd_bootscreen()' and 'lcd_kill_screen()'
Move 'lcd_bootscreen()' from `lcd_init()` to 'setup()' where it is cexecute exactly once. Saves 'bool show_bootscreen'. Move the call of 'lcd_custom_bootscreen()' to the begin of 'lcd_bootscreen()'. Move the delays into the related functions. Move the picture loop around 'lcd_kill_screen()' into the function.
This commit is contained in:
parent
84b93d941f
commit
ca0e4b4e96
|
@ -816,22 +816,10 @@ void setup() {
|
||||||
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
|
|
||||||
#ifndef CUSTOM_BOOTSCREEN_TIMEOUT
|
|
||||||
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(SHOW_BOOTSCREEN)
|
#if ENABLED(SHOW_BOOTSCREEN)
|
||||||
#if ENABLED(DOGLCD) // On DOGM the first bootscreen is already drawn
|
lcd_bootscreen();
|
||||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
#if ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
|
||||||
safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); // Custom boot screen pause
|
|
||||||
lcd_bootscreen(); // Show Marlin boot screen
|
|
||||||
#endif
|
|
||||||
safe_delay(BOOTSCREEN_TIMEOUT); // Pause
|
|
||||||
#elif ENABLED(ULTRA_LCD)
|
|
||||||
lcd_bootscreen();
|
|
||||||
#if DISABLED(SDSUPPORT)
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -715,14 +715,7 @@ void lcd_reset_status() { lcd_setstatusPGM(PSTR(""), -1); }
|
||||||
void kill_screen(const char* lcd_msg) {
|
void kill_screen(const char* lcd_msg) {
|
||||||
lcd_init();
|
lcd_init();
|
||||||
lcd_setalertstatusPGM(lcd_msg);
|
lcd_setalertstatusPGM(lcd_msg);
|
||||||
#if ENABLED(DOGLCD)
|
lcd_kill_screen();
|
||||||
u8g.firstPage();
|
|
||||||
do {
|
|
||||||
lcd_kill_screen();
|
|
||||||
} while (u8g.nextPage());
|
|
||||||
#else
|
|
||||||
lcd_kill_screen();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(ULTIPANEL)
|
#if ENABLED(ULTIPANEL)
|
||||||
|
|
|
@ -278,10 +278,12 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
|
||||||
|
|
||||||
#if ENABLED(SHOW_BOOTSCREEN)
|
#if ENABLED(SHOW_BOOTSCREEN)
|
||||||
|
|
||||||
bool show_bootscreen = true;
|
|
||||||
|
|
||||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
||||||
|
|
||||||
|
#ifndef CUSTOM_BOOTSCREEN_TIMEOUT
|
||||||
|
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
|
||||||
|
#endif
|
||||||
|
|
||||||
void lcd_custom_bootscreen() {
|
void lcd_custom_bootscreen() {
|
||||||
u8g.firstPage();
|
u8g.firstPage();
|
||||||
do {
|
do {
|
||||||
|
@ -290,37 +292,38 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
|
||||||
( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
|
( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
|
||||||
CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
|
CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
|
||||||
} while (u8g.nextPage());
|
} while (u8g.nextPage());
|
||||||
|
safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SHOW_CUSTOM_BOOTSCREEN
|
#endif // SHOW_CUSTOM_BOOTSCREEN
|
||||||
|
|
||||||
void lcd_bootscreen() {
|
void lcd_bootscreen() {
|
||||||
|
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
||||||
|
lcd_custom_bootscreen();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (show_bootscreen) {
|
#if ENABLED(START_BMPHIGH)
|
||||||
show_bootscreen = false;
|
constexpr uint8_t offy = 0;
|
||||||
|
#else
|
||||||
|
constexpr uint8_t offy = DOG_CHAR_HEIGHT;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(START_BMPHIGH)
|
const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2,
|
||||||
constexpr uint8_t offy = 0;
|
txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
||||||
|
|
||||||
|
u8g.firstPage();
|
||||||
|
do {
|
||||||
|
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
|
||||||
|
lcd_setFont(FONT_MENU);
|
||||||
|
#ifndef STRING_SPLASH_LINE2
|
||||||
|
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
|
||||||
#else
|
#else
|
||||||
constexpr uint8_t offy = DOG_CHAR_HEIGHT;
|
const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
||||||
|
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
|
||||||
|
u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
|
||||||
#endif
|
#endif
|
||||||
|
} while (u8g.nextPage());
|
||||||
const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2,
|
safe_delay(BOOTSCREEN_TIMEOUT);
|
||||||
txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
|
||||||
|
|
||||||
u8g.firstPage();
|
|
||||||
do {
|
|
||||||
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
|
|
||||||
lcd_setFont(FONT_MENU);
|
|
||||||
#ifndef STRING_SPLASH_LINE2
|
|
||||||
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
|
|
||||||
#else
|
|
||||||
const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
|
||||||
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
|
|
||||||
u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
|
|
||||||
#endif
|
|
||||||
} while (u8g.nextPage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SHOW_BOOTSCREEN
|
#endif // SHOW_BOOTSCREEN
|
||||||
|
@ -351,27 +354,20 @@ static void lcd_implementation_init() {
|
||||||
#elif ENABLED(LCD_SCREEN_ROT_270)
|
#elif ENABLED(LCD_SCREEN_ROT_270)
|
||||||
u8g.setRot270(); // Rotate screen by 270°
|
u8g.setRot270(); // Rotate screen by 270°
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SHOW_BOOTSCREEN)
|
|
||||||
if (show_bootscreen) {
|
|
||||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
|
||||||
lcd_custom_bootscreen();
|
|
||||||
#else
|
|
||||||
lcd_bootscreen();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The kill screen is displayed for unrecoverable conditions
|
// The kill screen is displayed for unrecoverable conditions
|
||||||
void lcd_kill_screen() {
|
void lcd_kill_screen() {
|
||||||
lcd_setFont(FONT_MENU);
|
u8g.firstPage();
|
||||||
u8g.setPrintPos(0, u8g.getHeight()/4*1);
|
do {
|
||||||
lcd_print_utf(lcd_status_message);
|
lcd_setFont(FONT_MENU);
|
||||||
u8g.setPrintPos(0, u8g.getHeight()/4*2);
|
u8g.setPrintPos(0, u8g.getHeight()/4*1);
|
||||||
lcd_printPGM(PSTR(MSG_HALTED));
|
lcd_print_utf(lcd_status_message);
|
||||||
u8g.setPrintPos(0, u8g.getHeight()/4*3);
|
u8g.setPrintPos(0, u8g.getHeight()/4*2);
|
||||||
lcd_printPGM(PSTR(MSG_PLEASE_RESET));
|
lcd_printPGM(PSTR(MSG_HALTED));
|
||||||
|
u8g.setPrintPos(0, u8g.getHeight()/4*3);
|
||||||
|
lcd_printPGM(PSTR(MSG_PLEASE_RESET));
|
||||||
|
} while (u8g.nextPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
|
||||||
|
@ -477,6 +473,7 @@ inline void lcd_implementation_status_message(const bool blink) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
UNUSED(blink);
|
||||||
lcd_print_utf(lcd_status_message);
|
lcd_print_utf(lcd_status_message);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue