Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Refactor PROGMEM strings
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 2, 2024
1 parent 9953230 commit cdf121a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
10 changes: 3 additions & 7 deletions Marlin/src/feature/bltouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ void BLTouch::init(const bool set_voltage/*=false*/) {
#else

#ifdef DEBUG_OUT
if (DEBUGGING(LEVELING)) {
PGMSTR(mode0, "OD");
PGMSTR(mode1, "5V");
DEBUG_ECHOPGM("BLTouch Mode: ");
DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0);
DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")");
}
if (DEBUGGING(LEVELING))
DEBUG_ECHOLN( F("BLTouch Mode: "), bltouch.od_5v_mode ? F("5V") : F("OD"),
F(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")"));
#endif

const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
static lv_obj_t *scr;

void lv_draw_error_message(FSTR_P const fmsg) {
FSTR_P fhalted = F("PRINTER HALTED"), fplease = F("Please Reset");
FSTR_P const fhalted = F("PRINTER HALTED"), fplease = F("Please Reset");
SPI_TFT.lcdClear(0x0000);
if (fmsg) disp_string((TFT_WIDTH - strlen_P(FTOP(fmsg)) * 16) / 2, 100, fmsg, 0xFFFF, 0x0000);
disp_string((TFT_WIDTH - strlen_P(FTOP(fhalted)) * 16) / 2, 140, fhalted, 0xFFFF, 0x0000);
Expand Down
16 changes: 3 additions & 13 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,16 +1466,6 @@ void MarlinUI::host_notify(const char * const cstr) {
* Reset the status message
*/
void MarlinUI::reset_status(const bool no_welcome) {
#if SERVICE_INTERVAL_1 > 0
static PGMSTR(service1, "> " SERVICE_NAME_1 "!");
#endif
#if SERVICE_INTERVAL_2 > 0
static PGMSTR(service2, "> " SERVICE_NAME_2 "!");
#endif
#if SERVICE_INTERVAL_3 > 0
static PGMSTR(service3, "> " SERVICE_NAME_3 "!");
#endif

FSTR_P msg;
if (printingIsPaused())
msg = GET_TEXT_F(MSG_PRINT_PAUSED);
Expand All @@ -1487,13 +1477,13 @@ void MarlinUI::host_notify(const char * const cstr) {
msg = GET_TEXT_F(MSG_PRINTING);

#if SERVICE_INTERVAL_1 > 0
else if (print_job_timer.needsService(1)) msg = FPSTR(service1);
else if (print_job_timer.needsService(1)) msg = F("> " SERVICE_NAME_1 "!");
#endif
#if SERVICE_INTERVAL_2 > 0
else if (print_job_timer.needsService(2)) msg = FPSTR(service2);
else if (print_job_timer.needsService(2)) msg = F("> " SERVICE_NAME_2 "!");
#endif
#if SERVICE_INTERVAL_3 > 0
else if (print_job_timer.needsService(3)) msg = FPSTR(service3);
else if (print_job_timer.needsService(3)) msg = F("> " SERVICE_NAME_3 "!");
#endif

else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG);
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,14 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
// all moves are finished. Go back to calling screen when done.
//
void MarlinUI::synchronize(FSTR_P const fmsg/*=nullptr*/) {
static FSTR_P sync_message = fmsg ?: GET_TEXT_F(MSG_MOVING);
push_current_screen();

// Hijack 'editable' for the string pointer
editable.fstr = fmsg ?: GET_TEXT_F(MSG_MOVING);
goto_screen([]{
if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message);
if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, editable.fstr);
});

defer_status_screen();
planner.synchronize(); // idle() is called until moves complete
goto_previous_screen_no_defer();
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ typedef union {
uint16_t uint16;
uint32_t uint32;
celsius_t celsius;
void *ptr;
FSTR_P fstr;
} chimera_t;

extern chimera_t editable;
Expand Down

0 comments on commit cdf121a

Please sign in to comment.