Skip to content

Commit

Permalink
🐛 Fix FTDI Eve Touch UI (MarlinFirmware#22500)
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and Night69 committed Aug 31, 2021
1 parent c37d425 commit bf41e86
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
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,3), message, OPT_CENTER, font ? font : font_large);
draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,6), message, OPT_CENTER, font ? font : font_large);
cmd.colors(normal_btn);
}

Expand Down Expand Up @@ -69,12 +69,6 @@ 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,7 +31,6 @@ 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 @@ -26,44 +26,78 @@

#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() {
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) {
drawMessage(message);
drawSpinner();
storeBackground();
GOTO_SCREEN(SpinnerDialogBox);
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);
mydata.auto_hide = false;
}

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

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

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

void SpinnerDialogBox::onIdle() {
reset_menu_timeout();
if (mydata.auto_hide && !commandsInQueue()) {
mydata.auto_hide = false;
hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ struct SpinnerDialogBoxData {
bool auto_hide;
};

class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen<SPINNER_CACHE,SPINNER_DL_SIZE> {
class SpinnerDialogBox : public BaseScreen {
public:
static void onEntry();
static void onExit();
static void onRedraw(draw_mode_t);
static void onRefresh();
static void onIdle();

static void show(progmem_str);
Expand Down

0 comments on commit bf41e86

Please sign in to comment.