Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SHOW_CUSTOM_BOOTSCREEN support to HD44780 #26793

Merged
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,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
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,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 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
Expand Down
69 changes: 59 additions & 10 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,24 @@ 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: {
for (uint8_t i = COUNT(customBootChars); i--;)
createChar_P(i, customBootChars[i]);
} 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);
Expand All @@ -361,7 +370,9 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS
createChar_P(LCD_STR_FOLDER[0], folder);
#endif
}
}
} break;

}

}

Expand Down Expand Up @@ -400,6 +411,42 @@ bool MarlinUI::detected() {
return TERN1(DETECT_I2C_LCD_DEVICE, lcd.LcdDetected() == 1);
}

#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 = 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);
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]);
lcd_put_lchar(x + j, sy + i, c == '\x08' ? '\x00' : c);
}
}
}

// Shows the custom bootscreen and delays
void MarlinUI::show_custom_bootscreen() {
draw_custom_bootscreen();
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)
Expand Down Expand Up @@ -466,6 +513,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();

Expand Down
14 changes: 14 additions & 0 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@

#include "../../inc/MarlinConfig.h"

#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)

#include "../../../_Bootscreen.h"

#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

static_assert(CUSTOM_BOOT_LAST <= LCD_HEIGHT, "custom_boot_lines (plus CUSTOM_BOOTSCREEN_Y) doesn't fit on the selected LCD.");

#endif

#if ENABLED(LCD_I2C_TYPE_PCF8575)

// NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins.
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ typedef bool (*statusResetFunc_t)();
enum HD44780CharSet : uint8_t {
CHARSET_MENU,
CHARSET_INFO,
CHARSET_BOOT
CHARSET_BOOT,
CHARSET_BOOT_CUSTOM
};
#endif

Expand Down
2 changes: 1 addition & 1 deletion ini/native.ini
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this flag known also known be needed for macOS? I know we just added it for Windows. Maybe some Linux need it too…?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On current bugfix-2.1.x / without this PR, both simulator_macos_debug and simulator_macos_release environments build the default Simulator config fine on my Intel-based Mac.

Copy link
Contributor Author

@ellensp ellensp May 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required on Ubuntu 22.04.4 LTS or Ubuntu 24.04 LTS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes macOS needs it, and probably it's ok to use the flag on Linux, or does it complain?

-I/opt/local/include
-I/opt/local/include/freetype2
-I/opt/local/include/SDL2/
Expand Down