Skip to content

Commit

Permalink
🐛 Fix FTDI Eve Touch UI progmem strings (MarlinFirmware#22439)
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and Night69 committed Aug 31, 2021
1 parent f1aa78a commit dc475f3
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool BioConfirmHomeE::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
#if defined(AXIS_LEVELING_COMMANDS) && defined(PARK_AND_RELEASE_COMMANDS)
SpinnerDialogBox::enqueueAndWait_P(PSTR(
SpinnerDialogBox::enqueueAndWait(F(
"G28 E\n"
AXIS_LEVELING_COMMANDS "\n"
PARK_AND_RELEASE_COMMANDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
#ifdef PARK_AND_RELEASE_COMMANDS
SpinnerDialogBox::enqueueAndWait_P(PSTR(
SpinnerDialogBox::enqueueAndWait(F(
"G28\n"
PARK_AND_RELEASE_COMMANDS
));
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ bool MainMenu::onTouchEnd(uint8_t tag) {
const bool e_homed = isAxisPositionKnown(E0);

switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 3: SpinnerDialogBox::enqueueAndWait_P(e_homed ? PSTR("G0 E0 F120") : PSTR("G112")); break;
case 4: StatusScreen::unlockMotors(); break;
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 3: SpinnerDialogBox::enqueueAndWait(e_homed ? F("G0 E0 F120") : F("G112")); break;
case 4: StatusScreen::unlockMotors(); break;
#ifdef AXIS_LEVELING_COMMANDS
case 5: SpinnerDialogBox::enqueueAndWait_P(PSTR(AXIS_LEVELING_COMMANDS)); break;
case 5: SpinnerDialogBox::enqueueAndWait(F(AXIS_LEVELING_COMMANDS)); break;
#endif
case 6: GOTO_SCREEN(TemperatureScreen); break;
case 7: GOTO_SCREEN(InterfaceSettingsScreen); break;
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
case 9: GOTO_SCREEN(AboutScreen); break;
case 6: GOTO_SCREEN(TemperatureScreen); break;
case 7: GOTO_SCREEN(InterfaceSettingsScreen); break;
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
case 9: GOTO_SCREEN(AboutScreen); break;
default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break;
case 13: GOTO_SCREEN(BioConfirmHomeE); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28Z")); break;
case 14: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
case 15: GOTO_SCREEN(TemperatureScreen); break;
case 16: fine_motion = !fine_motion; break;
default: return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool TuneMenu::onTouchEnd(uint8_t tag) {
case 3: GOTO_SCREEN(TemperatureScreen); break;
case 4: GOTO_SCREEN(NudgeNozzleScreen); break;
case 5: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 6: SpinnerDialogBox::enqueueAndWait_P(PSTR("G0 E0 F120")); break;
case 6: SpinnerDialogBox::enqueueAndWait(F("G0 E0 F120")); break;
case 7: StatusScreen::unlockMotors(); break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
case 3: BedMeshViewScreen::show(); break;
case 4: BedMeshEditScreen::show(); break;
case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
case 6: SpinnerDialogBox::enqueueAndWait_P(PSTR("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
case 6: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
default: return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool StatusScreen::onTouchStart(uint8_t) {

bool StatusScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28 O\nG27")); break;
case 1: SpinnerDialogBox::enqueueAndWait(F("G28 O\nG27")); break;
case 2: GOTO_SCREEN(LoadChocolateScreen); break;
case 3: GOTO_SCREEN(PreheatMenu); break;
case 4: GOTO_SCREEN(MainMenu); break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) {

void BedMeshEditScreen::show() {
// On entry, always home (to account for possible Z offset changes) and save current mesh
SpinnerDialogBox::enqueueAndWait_P(PSTR("G28\nG29 S1"));
SpinnerDialogBox::enqueueAndWait(F("G28\nG29 S1"));
// After the spinner, go to this screen.
current_screen.forget();
PUSH_SCREEN(BedMeshEditScreen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void DialogBoxBaseClass::drawMessage(T message, int16_t font) {
.cmd(CLEAR(true,true,true))
.cmd(COLOR_RGB(bg_text_enabled))
.tag(0);
draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,6), message, OPT_CENTER, font ? font : font_large);
draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), message, OPT_CENTER, font ? font : font_large);
cmd.colors(normal_btn);
}

Expand Down Expand Up @@ -69,6 +69,12 @@ void DialogBoxBaseClass::drawButton(T label) {
template void DialogBoxBaseClass::drawButton(const char *);
template void DialogBoxBaseClass::drawButton(progmem_str);

void DialogBoxBaseClass::drawSpinner() {
CommandProcessor cmd;
cmd.cmd(COLOR_RGB(bg_text_enabled))
.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute();
}

bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DialogBoxBaseClass : public BaseScreen {
template<typename T> static void drawButton(T);
static void drawYesNoButtons(uint8_t default_btn = 0);
static void drawOkayButton();
static void drawSpinner();

static void onRedraw(draw_mode_t) {};
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); break;
#if EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION)
case 2: SpinnerDialogBox::enqueueAndWait_P(PSTR("G34")); break;
case 2: SpinnerDialogBox::enqueueAndWait(F("G34")); break;
#endif
#if HAS_BED_PROBE
case 3:
Expand All @@ -114,7 +114,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
#if ENABLED(AUTO_BED_LEVELING_UBL)
BedMeshViewScreen::doProbe();
#else
SpinnerDialogBox::enqueueAndWait_P(PSTR(BED_LEVELING_COMMANDS));
SpinnerDialogBox::enqueueAndWait(F(BED_LEVELING_COMMANDS));
#endif
break;
#endif
Expand All @@ -127,7 +127,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
#endif
#if ENABLED(BLTOUCH)
case 7: injectCommands_P(PSTR("M280 P0 S60")); break;
case 8: SpinnerDialogBox::enqueueAndWait_P(PSTR("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
case 8: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
#endif
default: return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) {

switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28")); break;
case 2: SpinnerDialogBox::enqueueAndWait(F("G28")); break;
#if ENABLED(NOZZLE_CLEAN_FEATURE)
case 3: injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break;
case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break;
#endif
case 20: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28X")); break;
case 21: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28Y")); break;
case 22: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28Z")); break;
case 23: SpinnerDialogBox::enqueueAndWait_P(PSTR("G28")); break;
case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break;
case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break;
case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
case 23: SpinnerDialogBox::enqueueAndWait(F("G28")); break;
case 24: raiseZtoTop(); break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,82 +26,46 @@

#ifdef FTDI_SPINNER_DIALOG_BOX

#define GRID_COLS 2
#define GRID_ROWS 8

using namespace FTDI;
using namespace ExtUI;
using namespace Theme;

constexpr static SpinnerDialogBoxData &mydata = screen_data.SpinnerDialogBox;

void SpinnerDialogBox::onEntry() {
UIScreen::onEntry();
mydata.auto_hide = true;
}

void SpinnerDialogBox::onExit() {
CommandProcessor cmd;
cmd.stop().execute();
}

void SpinnerDialogBox::onRefresh() {
using namespace FTDI;
DLCache dlcache(SPINNER_CACHE);
CommandProcessor cmd;
cmd.cmd(CMD_DLSTART);
if (dlcache.has_data())
dlcache.append();
else
dlcache.store(SPINNER_DL_SIZE);
cmd.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute();
}

void SpinnerDialogBox::onRedraw(draw_mode_t) {
}

void SpinnerDialogBox::show(progmem_str message) {
CommandProcessor cmd;
if (AT_SCREEN(SpinnerDialogBox)) cmd.stop().execute();
cmd.cmd(CMD_DLSTART)
.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true))
.cmd(COLOR_RGB(bg_text_enabled))
.tag(0);
draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), message, OPT_CENTER, font_large);
DLCache dlcache(SPINNER_CACHE);
if (!dlcache.store(SPINNER_DL_SIZE)) {
SERIAL_ECHO_MSG("CachedScreen::storeBackground() failed: not enough DL cache space");
cmd.cmd(CMD_DLSTART).cmd(CLEAR(true,true,true));
dlcache.store(SPINNER_DL_SIZE);
}
if (AT_SCREEN(SpinnerDialogBox))
cmd.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute();
else
GOTO_SCREEN(SpinnerDialogBox);
drawMessage(message);
drawSpinner();
storeBackground();
mydata.auto_hide = false;
}

void SpinnerDialogBox::hide() {
GOTO_PREVIOUS();
CommandProcessor cmd;
cmd.stop().execute();
}

void SpinnerDialogBox::enqueueAndWait(progmem_str message, progmem_str commands) {
show(message);
GOTO_SCREEN(SpinnerDialogBox);
ExtUI::injectCommands_P((const char*)commands);
mydata.auto_hide = true;
}

void SpinnerDialogBox::enqueueAndWait(progmem_str message, char *commands) {
show(message);
GOTO_SCREEN(SpinnerDialogBox);
ExtUI::injectCommands(commands);
mydata.auto_hide = true;
}

void SpinnerDialogBox::onIdle() {
if (mydata.auto_hide && !commandsInQueue() && TERN1(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state == GcodeSuite::NOT_BUSY)) {
reset_menu_timeout();
if (mydata.auto_hide && !commandsInQueue()) {
mydata.auto_hide = false;
hide();
GOTO_PREVIOUS();
}
}

Expand Down

0 comments on commit dc475f3

Please sign in to comment.