From 6677362f7db55a00a3b3afe814f22133b79811a6 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:27:20 +1300 Subject: [PATCH 01/11] add SHOW_CUSTOM_BOOTSCREEN support to HD44780 --- Marlin/Configuration_adv.h | 2 +- Marlin/src/inc/SanityCheck.h | 4 +-- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 31 +++++++++++++++++++++ Marlin/src/lcd/HD44780/marlinui_HD44780.h | 28 +++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1f22c6d7a501..94a603da9dc0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1583,7 +1583,7 @@ #if HAS_MARLINUI_U8GLIB //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of flash. #endif - #if ANY(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE) + #if ANY(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, HAS_MARLINUI_HD44780) //#define SHOW_CUSTOM_BOOTSCREEN // Show the bitmap in Marlin/_Bootscreen.h on startup. #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index eaba158da898..7440811059b1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -386,8 +386,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Custom Boot and Status screens */ -#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) - #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE." +#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_HD44780, HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) + #error "SHOW_CUSTOM_BOOTSCREEN requires Text LCD, Graphical LCD or TOUCH_UI_FTDI_EVE." #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 1126b4a4b62c..d8372b4723ac 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -400,6 +400,35 @@ bool MarlinUI::detected() { return TERN1(DETECT_I2C_LCD_DEVICE, lcd.LcdDetected() == 1); } +#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) + void MarlinUI::draw_custom_bootscreen(const uint8_t) { + const uint8_t PROGMEM * const chars = custom_start_char; + + TERN_(HAS_CUSTOMCHAR0, createChar_P(0x0, customChar0)); + TERN_(HAS_CUSTOMCHAR1, createChar_P(0x1, customChar1)); + TERN_(HAS_CUSTOMCHAR2, createChar_P(0x2, customChar2)); + TERN_(HAS_CUSTOMCHAR3, createChar_P(0x3, customChar3)); + TERN_(HAS_CUSTOMCHAR4, createChar_P(0x4, customChar4)); + TERN_(HAS_CUSTOMCHAR5, createChar_P(0x5, customChar5)); + TERN_(HAS_CUSTOMCHAR6, createChar_P(0x6, customChar6)); + TERN_(HAS_CUSTOMCHAR7, createChar_P(0x7, customChar7)); + + lcd.clear(); + for (lcd_uint_t y = 0; y < CUSTOM_BOOTSCREEN_CHAR_HEIGHT; y++) + for (lcd_uint_t x = 0; x < CUSTOM_BOOTSCREEN_CHAR_WIDTH; x++) + lcd_put_lchar(x + lcd_uint_t(CUSTOM_BOOTSCREEN_X), y + lcd_uint_t(CUSTOM_BOOTSCREEN_Y), pgm_read_byte(&chars[y * CUSTOM_BOOTSCREEN_CHAR_WIDTH + x])); + } + + // Shows the custom bootscreen and delays + void MarlinUI::show_custom_bootscreen() { + draw_custom_bootscreen(); + #ifndef CUSTOM_BOOTSCREEN_TIMEOUT + #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 + #endif + safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); + } +#endif // SHOW_CUSTOM_BOOTSCREEN + #if HAS_SLOW_BUTTONS uint8_t MarlinUI::read_slow_buttons() { #if ENABLED(LCD_I2C_TYPE_MCP23017) @@ -466,6 +495,8 @@ void MarlinUI::clear_lcd() { lcd.clear(); } } void MarlinUI::show_bootscreen() { + TERN_(SHOW_CUSTOM_BOOTSCREEN, show_custom_bootscreen()); + set_custom_characters(CHARSET_BOOT); lcd.clear(); diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.h b/Marlin/src/lcd/HD44780/marlinui_HD44780.h index 6f6f5a6855b6..ef01fd88af9c 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.h +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.h @@ -27,6 +27,34 @@ #include "../../inc/MarlinConfig.h" +#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) + + #include "../../../_Bootscreen.h" + + #ifndef CUSTOM_BOOTSCREEN_CHARWIDTH + #define CUSTOM_BOOTSCREEN_CHARWIDTH LCD_WIDTH + #endif + + #ifndef CUSTOM_BOOTSCREEN_CHAR_HEIGHT + #define CUSTOM_BOOTSCREEN_CHAR_HEIGHT (sizeof(custom_start_char) / (CUSTOM_BOOTSCREEN_CHAR_WIDTH)) + #endif + + #ifndef CUSTOM_BOOTSCREEN_X + #define CUSTOM_BOOTSCREEN_X ((LCD_WIDTH - (CUSTOM_BOOTSCREEN_CHAR_WIDTH)) / 2) + #endif + + #ifndef CUSTOM_BOOTSCREEN_Y + #define CUSTOM_BOOTSCREEN_Y ((LCD_HEIGHT - (CUSTOM_BOOTSCREEN_CHAR_HEIGHT)) / 2) + #endif + + static_assert(CUSTOM_BOOTSCREEN_CHAR_WIDTH <= LCD_WIDTH, "CUSTOM_BOOTSCREEN_CHAR_WIDTH is larger than LCD_WIDTH."); + static_assert(CUSTOM_BOOTSCREEN_CHAR_HEIGHT <= LCD_HEIGHT, "CUSTOM_BOOTSCREEN_CHAR_HEIGHT is larger than LCD_HEIGHT."); + static_assert(CUSTOM_BOOTSCREEN_CHAR_WIDTH + CUSTOM_BOOTSCREEN_X <= LCD_WIDTH, "CUSTOM_BOOTSCREEN_CHAR_WIDTH + CUSTOM_BOOTSCREEN_X is larger than LCD_WIDTH."); + static_assert(CUSTOM_BOOTSCREEN_CHAR_HEIGHT + CUSTOM_BOOTSCREEN_Y <= LCD_HEIGHT, "CUSTOM_BOOTSCREEN_CHAR_HEIGHT + CUSTOM_BOOTSCREEN_Y is larger than LCD_HEIGHT."); + static_assert(sizeof(custom_start_char) % CUSTOM_BOOTSCREEN_CHAR_WIDTH == 0, "size of custom_start_char array is not evenly divisible by CUSTOM_BOOTSCREEN_CHAR_WIDTH."); + +#endif + #if ENABLED(LCD_I2C_TYPE_PCF8575) // NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins. From e92dcf17aa14eba996807ef024066f0d3a1cd69f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 11 Mar 2024 21:37:53 -0500 Subject: [PATCH 02/11] move to set_custom_characters --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 48 +++++++++++++-------- Marlin/src/lcd/marlinui.h | 3 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index d8372b4723ac..26ed8c01afaa 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -331,15 +331,30 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif // HAS_MEDIA - #if ENABLED(SHOW_BOOTSCREEN) - // Set boot screen corner characters - if (screen_charset == CHARSET_BOOT) { - for (uint8_t i = 4; i--;) - createChar_P(i, corner[i]); - } - else - #endif - { // Info Screen uses 5 special characters + switch (screen_charset) { + + #if ENABLED(SHOW_BOOTSCREEN) + case CHARSET_BOOT: { + // Set boot screen corner characters + for (uint8_t i = 4; i--;) createChar_P(i, corner[i]); + } break; + #endif + + #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) + case CHARSET_BOOT_CUSTOM: + TERN_(HAS_CUSTOM_BOOT_CHAR_0, createChar_P(0x0, customBootChar0)); + TERN_(HAS_CUSTOM_BOOT_CHAR_1, createChar_P(0x1, customBootChar1)); + TERN_(HAS_CUSTOM_BOOT_CHAR_2, createChar_P(0x2, customBootChar2)); + TERN_(HAS_CUSTOM_BOOT_CHAR_3, createChar_P(0x3, customBootChar3)); + TERN_(HAS_CUSTOM_BOOT_CHAR_4, createChar_P(0x4, customBootChar4)); + TERN_(HAS_CUSTOM_BOOT_CHAR_5, createChar_P(0x5, customBootChar5)); + TERN_(HAS_CUSTOM_BOOT_CHAR_6, createChar_P(0x6, customBootChar6)); + TERN_(HAS_CUSTOM_BOOT_CHAR_7, createChar_P(0x7, customBootChar7)); + break; + #endif + + default: { + // Info Screen uses 5 special characters createChar_P(LCD_STR_BEDTEMP[0], bedTemp); createChar_P(LCD_STR_DEGREE[0], degree); createChar_P(LCD_STR_THERMOMETER[0], thermometer); @@ -361,7 +376,9 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS createChar_P(LCD_STR_FOLDER[0], folder); #endif } - } + } break; + + } } @@ -401,17 +418,11 @@ bool MarlinUI::detected() { } #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) + void MarlinUI::draw_custom_bootscreen(const uint8_t) { const uint8_t PROGMEM * const chars = custom_start_char; - TERN_(HAS_CUSTOMCHAR0, createChar_P(0x0, customChar0)); - TERN_(HAS_CUSTOMCHAR1, createChar_P(0x1, customChar1)); - TERN_(HAS_CUSTOMCHAR2, createChar_P(0x2, customChar2)); - TERN_(HAS_CUSTOMCHAR3, createChar_P(0x3, customChar3)); - TERN_(HAS_CUSTOMCHAR4, createChar_P(0x4, customChar4)); - TERN_(HAS_CUSTOMCHAR5, createChar_P(0x5, customChar5)); - TERN_(HAS_CUSTOMCHAR6, createChar_P(0x6, customChar6)); - TERN_(HAS_CUSTOMCHAR7, createChar_P(0x7, customChar7)); + set_custom_characters(CHARSET_BOOT_CUSTOM); lcd.clear(); for (lcd_uint_t y = 0; y < CUSTOM_BOOTSCREEN_CHAR_HEIGHT; y++) @@ -427,6 +438,7 @@ bool MarlinUI::detected() { #endif safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); } + #endif // SHOW_CUSTOM_BOOTSCREEN #if HAS_SLOW_BUTTONS diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index d578826e4970..22f4b659730e 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -101,7 +101,8 @@ typedef bool (*statusResetFunc_t)(); enum HD44780CharSet : uint8_t { CHARSET_MENU, CHARSET_INFO, - CHARSET_BOOT + CHARSET_BOOT, + CHARSET_BOOT_CUSTOM }; #endif From eb27f244ebbbed8cd294d6761100c76cf6ee9670 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:02:13 +1300 Subject: [PATCH 03/11] remove PROGMEM --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 26ed8c01afaa..57d2d50a46d0 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -420,7 +420,7 @@ bool MarlinUI::detected() { #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) void MarlinUI::draw_custom_bootscreen(const uint8_t) { - const uint8_t PROGMEM * const chars = custom_start_char; + const uint8_t * const chars = custom_start_char; set_custom_characters(CHARSET_BOOT_CUSTOM); From bd6bb3d5ea7e8e3911e74e64ea2a1bb3b01c7508 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Mar 2024 17:55:04 -0500 Subject: [PATCH 04/11] string instead of char array --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 44 ++++++++++++--------- Marlin/src/lcd/HD44780/marlinui_HD44780.h | 24 +++-------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 57d2d50a46d0..16184bdad279 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -341,16 +341,10 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) - case CHARSET_BOOT_CUSTOM: - TERN_(HAS_CUSTOM_BOOT_CHAR_0, createChar_P(0x0, customBootChar0)); - TERN_(HAS_CUSTOM_BOOT_CHAR_1, createChar_P(0x1, customBootChar1)); - TERN_(HAS_CUSTOM_BOOT_CHAR_2, createChar_P(0x2, customBootChar2)); - TERN_(HAS_CUSTOM_BOOT_CHAR_3, createChar_P(0x3, customBootChar3)); - TERN_(HAS_CUSTOM_BOOT_CHAR_4, createChar_P(0x4, customBootChar4)); - TERN_(HAS_CUSTOM_BOOT_CHAR_5, createChar_P(0x5, customBootChar5)); - TERN_(HAS_CUSTOM_BOOT_CHAR_6, createChar_P(0x6, customBootChar6)); - TERN_(HAS_CUSTOM_BOOT_CHAR_7, createChar_P(0x7, customBootChar7)); - break; + case CHARSET_BOOT_CUSTOM: { + for (uint8_t i = COUNT(customBootChars); i--;) + createChar_P(i, customBootChars[i]); + } break; #endif default: { @@ -419,15 +413,27 @@ bool MarlinUI::detected() { #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) - void MarlinUI::draw_custom_bootscreen(const uint8_t) { - const uint8_t * const chars = custom_start_char; - - set_custom_characters(CHARSET_BOOT_CUSTOM); - - lcd.clear(); - for (lcd_uint_t y = 0; y < CUSTOM_BOOTSCREEN_CHAR_HEIGHT; y++) - for (lcd_uint_t x = 0; x < CUSTOM_BOOTSCREEN_CHAR_WIDTH; x++) - lcd_put_lchar(x + lcd_uint_t(CUSTOM_BOOTSCREEN_X), y + lcd_uint_t(CUSTOM_BOOTSCREEN_Y), pgm_read_byte(&chars[y * CUSTOM_BOOTSCREEN_CHAR_WIDTH + x])); + void MarlinUI::draw_custom_bootscreen(const uint8_t/*=0*/) { + const uint8_t sy = ( + #ifdef CUSTOM_BOOTSCREEN_Y + CUSTOM_BOOTSCREEN_Y + #else + (LCD_HEIGHT - COUNT(custom_boot_lines)) / 2 + #endif + ); + const int8_t sx = ( + #ifdef CUSTOM_BOOTSCREEN_X + CUSTOM_BOOTSCREEN_X + #else + -1 + #endif + ); + for (lcd_uint_t i = 0; i < COUNT(custom_boot_lines); ++i) { + PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]); + const uint8_t x = sx >= 0 ? sx : (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; + lcd_moveto(x, CUSTOM_BOOTSCREEN_Y + i); + lcd_put_u8str_max_P(pstr, LCD_WIDTH - x); + } } // Shows the custom bootscreen and delays diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.h b/Marlin/src/lcd/HD44780/marlinui_HD44780.h index ef01fd88af9c..15f268f8d996 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.h +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.h @@ -31,27 +31,13 @@ #include "../../../_Bootscreen.h" - #ifndef CUSTOM_BOOTSCREEN_CHARWIDTH - #define CUSTOM_BOOTSCREEN_CHARWIDTH LCD_WIDTH + #ifdef CUSTOM_BOOTSCREEN_Y + #define CUSTOM_BOOT_LAST COUNT(custom_boot_lines) + CUSTOM_BOOTSCREEN_Y + #else + #define CUSTOM_BOOT_LAST COUNT(custom_boot_lines) #endif - #ifndef CUSTOM_BOOTSCREEN_CHAR_HEIGHT - #define CUSTOM_BOOTSCREEN_CHAR_HEIGHT (sizeof(custom_start_char) / (CUSTOM_BOOTSCREEN_CHAR_WIDTH)) - #endif - - #ifndef CUSTOM_BOOTSCREEN_X - #define CUSTOM_BOOTSCREEN_X ((LCD_WIDTH - (CUSTOM_BOOTSCREEN_CHAR_WIDTH)) / 2) - #endif - - #ifndef CUSTOM_BOOTSCREEN_Y - #define CUSTOM_BOOTSCREEN_Y ((LCD_HEIGHT - (CUSTOM_BOOTSCREEN_CHAR_HEIGHT)) / 2) - #endif - - static_assert(CUSTOM_BOOTSCREEN_CHAR_WIDTH <= LCD_WIDTH, "CUSTOM_BOOTSCREEN_CHAR_WIDTH is larger than LCD_WIDTH."); - static_assert(CUSTOM_BOOTSCREEN_CHAR_HEIGHT <= LCD_HEIGHT, "CUSTOM_BOOTSCREEN_CHAR_HEIGHT is larger than LCD_HEIGHT."); - static_assert(CUSTOM_BOOTSCREEN_CHAR_WIDTH + CUSTOM_BOOTSCREEN_X <= LCD_WIDTH, "CUSTOM_BOOTSCREEN_CHAR_WIDTH + CUSTOM_BOOTSCREEN_X is larger than LCD_WIDTH."); - static_assert(CUSTOM_BOOTSCREEN_CHAR_HEIGHT + CUSTOM_BOOTSCREEN_Y <= LCD_HEIGHT, "CUSTOM_BOOTSCREEN_CHAR_HEIGHT + CUSTOM_BOOTSCREEN_Y is larger than LCD_HEIGHT."); - static_assert(sizeof(custom_start_char) % CUSTOM_BOOTSCREEN_CHAR_WIDTH == 0, "size of custom_start_char array is not evenly divisible by CUSTOM_BOOTSCREEN_CHAR_WIDTH."); + static_assert(CUSTOM_BOOT_LAST <= LCD_HEIGHT, "custom_boot_lines (plus CUSTOM_BOOTSCREEN_Y) doesn't fit on the selected LCD."); #endif From 2e11274977fc2f515ffaefca0980d2e0fb4cc020 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Mar 2024 18:01:24 -0500 Subject: [PATCH 05/11] fix y --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 16184bdad279..29c8a224cc2b 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -431,7 +431,7 @@ bool MarlinUI::detected() { for (lcd_uint_t i = 0; i < COUNT(custom_boot_lines); ++i) { PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]); const uint8_t x = sx >= 0 ? sx : (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; - lcd_moveto(x, CUSTOM_BOOTSCREEN_Y + i); + lcd_moveto(x, sy + i); lcd_put_u8str_max_P(pstr, LCD_WIDTH - x); } } From 3d56945d93b515caf2520eee017cf1a02c2c963f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Mar 2024 18:28:06 -0500 Subject: [PATCH 06/11] handle CHR0 --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 28 +++++++++++++-------- ini/native.ini | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 29c8a224cc2b..0d5cc12e4cc1 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -414,13 +414,8 @@ bool MarlinUI::detected() { #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) void MarlinUI::draw_custom_bootscreen(const uint8_t/*=0*/) { - const uint8_t sy = ( - #ifdef CUSTOM_BOOTSCREEN_Y - CUSTOM_BOOTSCREEN_Y - #else - (LCD_HEIGHT - COUNT(custom_boot_lines)) / 2 - #endif - ); + set_custom_characters(CHARSET_BOOT_CUSTOM); + lcd.clear(); const int8_t sx = ( #ifdef CUSTOM_BOOTSCREEN_X CUSTOM_BOOTSCREEN_X @@ -428,11 +423,24 @@ bool MarlinUI::detected() { -1 #endif ); + const uint8_t sy = ( + #ifdef CUSTOM_BOOTSCREEN_Y + CUSTOM_BOOTSCREEN_Y + #else + (LCD_HEIGHT - COUNT(custom_boot_lines)) / 2 + #endif + ); for (lcd_uint_t i = 0; i < COUNT(custom_boot_lines); ++i) { PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]); - const uint8_t x = sx >= 0 ? sx : (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; - lcd_moveto(x, sy + i); - lcd_put_u8str_max_P(pstr, LCD_WIDTH - x); + uint8_t clen = 0; + for (lcd_uint_t j = 0; j < LCD_WIDTH; ++j) { + const lchar_t c = pgm_read_byte(&pstr[j]); + if (!c && !pgm_read_byte(pstr + j + 1)) break; + ++clen; + } + const lcd_uint_t x = sx >= 0 ? sx : (LCD_WIDTH - clen) / 2; + for (lcd_uint_t j = 0; j < clen; ++j) + lcd_put_lchar(x + j, sy + i, pgm_read_byte(&pstr[j])); } } diff --git a/ini/native.ini b/ini/native.ini index 86608ff3d71a..9e04bbc9e93b 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -100,7 +100,7 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} [simulator_macos] build_unflags = -lGL -fstack-protector-strong build_flags = - -DHAS_LIBBSD + -DHAS_LIBBSD -DGLM_ENABLE_EXPERIMENTAL -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/SDL2/ From 6b77038dc4e6b71d7338e1292e69728e228a0f43 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Mar 2024 18:35:00 -0500 Subject: [PATCH 07/11] better --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 0d5cc12e4cc1..1fd2d32439f8 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -432,15 +432,12 @@ bool MarlinUI::detected() { ); for (lcd_uint_t i = 0; i < COUNT(custom_boot_lines); ++i) { PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]); - uint8_t clen = 0; - for (lcd_uint_t j = 0; j < LCD_WIDTH; ++j) { + const uint8_t clen = utf8_strlen_P(pstr); + const lcd_uint_t x = sx >= 0 ? sx : (LCD_WIDTH - clen) / 2; + for (lcd_uint_t j = 0; j < clen; ++j) { const lchar_t c = pgm_read_byte(&pstr[j]); - if (!c && !pgm_read_byte(pstr + j + 1)) break; - ++clen; + lcd_put_lchar(x + j, sy + i, c == '\x08' ? '\x00' : c); } - const lcd_uint_t x = sx >= 0 ? sx : (LCD_WIDTH - clen) / 2; - for (lcd_uint_t j = 0; j < clen; ++j) - lcd_put_lchar(x + j, sy + i, pgm_read_byte(&pstr[j])); } } From b1d5ad362afb53dfe4b3032cbc4c53996e5367f8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Mar 2024 13:24:53 -0500 Subject: [PATCH 08/11] tweak --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 29 +++++++++------------ 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 1fd2d32439f8..954064914208 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -413,23 +413,21 @@ bool MarlinUI::detected() { #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) + #ifndef CUSTOM_BOOTSCREEN_X + #define CUSTOM_BOOTSCREEN_X -1 + #endif + #ifndef CUSTOM_BOOTSCREEN_Y + #define CUSTOM_BOOTSCREEN_Y ((LCD_HEIGHT - COUNT(custom_boot_lines)) / 2) + #endif + #ifndef CUSTOM_BOOTSCREEN_TIMEOUT + #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 + #endif + void MarlinUI::draw_custom_bootscreen(const uint8_t/*=0*/) { set_custom_characters(CHARSET_BOOT_CUSTOM); lcd.clear(); - const int8_t sx = ( - #ifdef CUSTOM_BOOTSCREEN_X - CUSTOM_BOOTSCREEN_X - #else - -1 - #endif - ); - const uint8_t sy = ( - #ifdef CUSTOM_BOOTSCREEN_Y - CUSTOM_BOOTSCREEN_Y - #else - (LCD_HEIGHT - COUNT(custom_boot_lines)) / 2 - #endif - ); + const int8_t sx = CUSTOM_BOOTSCREEN_X; + const uint8_t sy = CUSTOM_BOOTSCREEN_Y; for (lcd_uint_t i = 0; i < COUNT(custom_boot_lines); ++i) { PGM_P const pstr = (PGM_P)pgm_read_ptr(&custom_boot_lines[i]); const uint8_t clen = utf8_strlen_P(pstr); @@ -444,9 +442,6 @@ bool MarlinUI::detected() { // Shows the custom bootscreen and delays void MarlinUI::show_custom_bootscreen() { draw_custom_bootscreen(); - #ifndef CUSTOM_BOOTSCREEN_TIMEOUT - #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 - #endif safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); } From d649ecf6f2655c726bb2af3d6b05a633dac66b2d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 May 2024 19:36:28 -0500 Subject: [PATCH 09/11] "character" --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 08b2038cccc3..63fca4cab25a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -389,7 +389,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L * Custom Boot and Status screens */ #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_HD44780, HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) - #error "SHOW_CUSTOM_BOOTSCREEN requires Text LCD, Graphical LCD or TOUCH_UI_FTDI_EVE." + #error "SHOW_CUSTOM_BOOTSCREEN requires Character LCD, Graphical LCD or TOUCH_UI_FTDI_EVE." #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB From 35f8963d2cf771e4143457512addba7ec420a0b4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 May 2024 19:38:46 -0500 Subject: [PATCH 10/11] oxford --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 63fca4cab25a..52ecac5475f5 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -389,7 +389,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L * Custom Boot and Status screens */ #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_HD44780, HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) - #error "SHOW_CUSTOM_BOOTSCREEN requires Character LCD, Graphical LCD or TOUCH_UI_FTDI_EVE." + #error "SHOW_CUSTOM_BOOTSCREEN requires Character LCD, Graphical LCD, or TOUCH_UI_FTDI_EVE." #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB From 9e8348a5b919fc5e3697d0f4bc446a9445710ea7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 19 May 2024 18:49:48 -0500 Subject: [PATCH 11/11] currently all --- ini/native.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/native.ini b/ini/native.ini index 641d8c9d2541..28c558d39f39 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -114,7 +114,7 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} [simulator_macos] build_unflags = -lGL -fstack-protector-strong build_flags = - -DHAS_LIBBSD -DGLM_ENABLE_EXPERIMENTAL + -DHAS_LIBBSD -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/SDL2/