🐛 Fix and improve FTDI Eve Touch UI (#22361, #22439, #22459, #22468, #22500, #22530)

This commit is contained in:
Marcio T 2021-07-14 21:13:08 -06:00 committed by Scott Lahteine
parent 3924545912
commit 166324fc7b
45 changed files with 177 additions and 170 deletions

View File

@ -40,7 +40,7 @@ struct GpioEvent {
pin_type pin_id; pin_type pin_id;
GpioEvent::Type event; GpioEvent::Type event;
GpioEvent(uint64_t timestamp, pin_type pin_id, GpioEvent::Type event){ GpioEvent(uint64_t timestamp, pin_type pin_id, GpioEvent::Type event) {
this->timestamp = timestamp; this->timestamp = timestamp;
this->pin_id = pin_id; this->pin_id = pin_id;
this->event = event; this->event = event;

View File

@ -51,7 +51,7 @@ void LinearAxis::update() {
} }
void LinearAxis::interrupt(GpioEvent ev) { void LinearAxis::interrupt(GpioEvent ev) {
if (ev.pin_id == step_pin && !Gpio::pin_map[enable_pin].value){ if (ev.pin_id == step_pin && !Gpio::pin_map[enable_pin].value) {
if (ev.event == GpioEvent::RISE) { if (ev.event == GpioEvent::RISE) {
last_update = ev.timestamp; last_update = ev.timestamp;
position += -1 + 2 * Gpio::pin_map[dir_pin].value; position += -1 + 2 * Gpio::pin_map[dir_pin].value;

View File

@ -52,7 +52,7 @@ public:
return (*(intptr_t*)timerid); return (*(intptr_t*)timerid);
} }
static void handler(int sig, siginfo_t *si, void *uc){ static void handler(int sig, siginfo_t *si, void *uc) {
Timer* _this = (Timer*)si->si_value.sival_ptr; Timer* _this = (Timer*)si->si_value.sival_ptr;
_this->avg_error += (Clock::nanos() - _this->start_time) - _this->period; //high_resolution_clock is also limited in precision, but best we have _this->avg_error += (Clock::nanos() - _this->start_time) - _this->period; //high_resolution_clock is also limited in precision, but best we have
_this->avg_error /= 2; //very crude precision analysis (actually within +-500ns usually) _this->avg_error /= 2; //very crude precision analysis (actually within +-500ns usually)

View File

@ -87,7 +87,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.tag(13) .button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE)) .tag(13) .button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE))
.tag(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS)) .tag(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.colors(action_btn) .colors(action_btn)
.tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
#undef GRID_COLS #undef GRID_COLS
#undef GRID_ROWS #undef GRID_ROWS
} }

View File

@ -36,7 +36,7 @@ bool BioConfirmHomeE::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: case 1:
#if defined(AXIS_LEVELING_COMMANDS) && defined(PARK_AND_RELEASE_COMMANDS) #if defined(AXIS_LEVELING_COMMANDS) && defined(PARK_AND_RELEASE_COMMANDS)
SpinnerDialogBox::enqueueAndWait_P(F( SpinnerDialogBox::enqueueAndWait(F(
"G28 E\n" "G28 E\n"
AXIS_LEVELING_COMMANDS "\n" AXIS_LEVELING_COMMANDS "\n"
PARK_AND_RELEASE_COMMANDS PARK_AND_RELEASE_COMMANDS

View File

@ -36,7 +36,7 @@ bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: case 1:
#ifdef PARK_AND_RELEASE_COMMANDS #ifdef PARK_AND_RELEASE_COMMANDS
SpinnerDialogBox::enqueueAndWait_P(F( SpinnerDialogBox::enqueueAndWait(F(
"G28\n" "G28\n"
PARK_AND_RELEASE_COMMANDS PARK_AND_RELEASE_COMMANDS
)); ));

View File

@ -54,7 +54,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
.tag(8).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_ADVANCED_SETTINGS)) .tag(8).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_ADVANCED_SETTINGS))
.tag(9).button(BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_INFO_MENU)) .tag(9).button(BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_INFO_MENU))
.colors(action_btn) .colors(action_btn)
.tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); .tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
} }
#undef GRID_COLS #undef GRID_COLS
@ -67,17 +67,17 @@ bool MainMenu::onTouchEnd(uint8_t tag) {
const bool e_homed = isAxisPositionKnown(E0); const bool e_homed = isAxisPositionKnown(E0);
switch (tag) { switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break; case 2: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 3: SpinnerDialogBox::enqueueAndWait_P(e_homed ? F("G0 E0 F120") : F("G112")); break; case 3: SpinnerDialogBox::enqueueAndWait(e_homed ? F("G0 E0 F120") : F("G112")); break;
case 4: StatusScreen::unlockMotors(); break; case 4: StatusScreen::unlockMotors(); break;
#ifdef AXIS_LEVELING_COMMANDS #ifdef AXIS_LEVELING_COMMANDS
case 5: SpinnerDialogBox::enqueueAndWait_P(F(AXIS_LEVELING_COMMANDS)); break; case 5: SpinnerDialogBox::enqueueAndWait(F(AXIS_LEVELING_COMMANDS)); break;
#endif #endif
case 6: GOTO_SCREEN(TemperatureScreen); break; case 6: GOTO_SCREEN(TemperatureScreen); break;
case 7: GOTO_SCREEN(InterfaceSettingsScreen); break; case 7: GOTO_SCREEN(InterfaceSettingsScreen); break;
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
case 9: GOTO_SCREEN(AboutScreen); break; case 9: GOTO_SCREEN(AboutScreen); break;
default: default:
return false; return false;
} }

View File

@ -316,7 +316,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
case 9: GOTO_SCREEN(FilesScreen); break; case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break; case 10: GOTO_SCREEN(MainMenu); break;
case 13: GOTO_SCREEN(BioConfirmHomeE); break; case 13: GOTO_SCREEN(BioConfirmHomeE); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break; case 14: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
case 15: GOTO_SCREEN(TemperatureScreen); break; case 15: GOTO_SCREEN(TemperatureScreen); break;
case 16: fine_motion = !fine_motion; break; case 16: fine_motion = !fine_motion; break;
default: return false; default: return false;

View File

@ -54,7 +54,7 @@ void TuneMenu::onRedraw(draw_mode_t what) {
.enabled(!isPrinting()).tag(5).button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_MOVE_TO_HOME)) .enabled(!isPrinting()).tag(5).button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_MOVE_TO_HOME))
.enabled(!isPrinting()).tag(6).button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_RAISE_PLUNGER)) .enabled(!isPrinting()).tag(6).button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_RAISE_PLUNGER))
.enabled(!isPrinting()).tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS)) .enabled(!isPrinting()).tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS))
.colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); .colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
} }
#undef GRID_COLS #undef GRID_COLS
#undef GRID_ROWS #undef GRID_ROWS
@ -67,7 +67,7 @@ bool TuneMenu::onTouchEnd(uint8_t tag) {
case 3: GOTO_SCREEN(TemperatureScreen); break; case 3: GOTO_SCREEN(TemperatureScreen); break;
case 4: GOTO_SCREEN(NudgeNozzleScreen); break; case 4: GOTO_SCREEN(NudgeNozzleScreen); break;
case 5: GOTO_SCREEN(BioConfirmHomeXYZ); break; case 5: GOTO_SCREEN(BioConfirmHomeXYZ); break;
case 6: SpinnerDialogBox::enqueueAndWait_P(F("G0 E0 F120")); break; case 6: SpinnerDialogBox::enqueueAndWait(F("G0 E0 F120")); break;
case 7: StatusScreen::unlockMotors(); break; case 7: StatusScreen::unlockMotors(); break;
default: default:
return false; return false;

View File

@ -67,7 +67,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU)) .tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU))
.tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS)) .tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -71,7 +71,7 @@ void LevelingMenu::onRedraw(draw_mode_t what) {
#undef GRID_COLS #undef GRID_COLS
#define GRID_COLS 3 #define GRID_COLS 3
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }
@ -82,7 +82,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
case 3: BedMeshViewScreen::show(); break; case 3: BedMeshViewScreen::show(); break;
case 4: BedMeshEditScreen::show(); break; case 4: BedMeshEditScreen::show(); break;
case 5: injectCommands_P(PSTR("M280 P0 S60")); break; case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
case 6: SpinnerDialogBox::enqueueAndWait_P(F("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; default: return false;
} }
return true; return true;

View File

@ -90,7 +90,7 @@ void LoadChocolateScreen::draw_buttons(draw_mode_t what) {
cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_FULL_LOAD)); cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_FULL_LOAD));
ui.bounds(POLY(load_screen_back_btn), x, y, h, v); ui.bounds(POLY(load_screen_back_btn), x, y, h, v);
cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BACK)); cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_DONE));
} }
void LoadChocolateScreen::draw_text(draw_mode_t what) { void LoadChocolateScreen::draw_text(draw_mode_t what) {

View File

@ -68,7 +68,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
.tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) .tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING))
.tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) .tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU))
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -65,7 +65,7 @@ void PreheatMenu::onRedraw(draw_mode_t what) {
} }
#endif #endif
cmd.colors(action_btn) cmd.colors(action_btn)
.tag(1) .button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); .tag(1) .button(BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -77,7 +77,7 @@ void PreheatTimerScreen::draw_interaction_buttons(draw_mode_t what) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.colors(normal_btn) cmd.colors(normal_btn)
.font(font_medium) .font(font_medium)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -108,7 +108,6 @@ enum {
#include "../generic/display_tuning_screen.h" #include "../generic/display_tuning_screen.h"
#include "../generic/statistics_screen.h" #include "../generic/statistics_screen.h"
#include "../generic/stepper_current_screen.h" #include "../generic/stepper_current_screen.h"
#include "../generic/leveling_menu.h"
#include "../generic/z_offset_screen.h" #include "../generic/z_offset_screen.h"
#include "../generic/bed_mesh_base.h" #include "../generic/bed_mesh_base.h"
#include "../generic/bed_mesh_view_screen.h" #include "../generic/bed_mesh_view_screen.h"
@ -130,5 +129,6 @@ enum {
#include "preheat_menu.h" #include "preheat_menu.h"
#include "preheat_screen.h" #include "preheat_screen.h"
#include "load_chocolate.h" #include "load_chocolate.h"
#include "leveling_menu.h"
#include "move_xyz_screen.h" #include "move_xyz_screen.h"
#include "move_e_screen.h" #include "move_e_screen.h"

View File

@ -233,7 +233,7 @@ bool StatusScreen::onTouchStart(uint8_t) {
bool StatusScreen::onTouchEnd(uint8_t tag) { bool StatusScreen::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: SpinnerDialogBox::enqueueAndWait_P(F("G28 O\nG27")); break; case 1: SpinnerDialogBox::enqueueAndWait(F("G28 O\nG27")); break;
case 2: GOTO_SCREEN(LoadChocolateScreen); break; case 2: GOTO_SCREEN(LoadChocolateScreen); break;
case 3: GOTO_SCREEN(PreheatMenu); break; case 3: GOTO_SCREEN(PreheatMenu); break;
case 4: GOTO_SCREEN(MainMenu); break; case 4: GOTO_SCREEN(MainMenu); break;

View File

@ -42,7 +42,7 @@ namespace FTDI {
strcat_P(str, (const char*) units); strcat_P(str, (const char*) units);
} }
cmd.text(VAL_POS, str); cmd.tag(0).text(VAL_POS, str);
} }
void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) {

View File

@ -232,13 +232,11 @@ class CommandProcessor : public CLCD::CommandFifo {
FORCEDINLINE CommandProcessor& toggle(int16_t x, int16_t y, int16_t w, int16_t h, T text, bool state, uint16_t options = FTDI::OPT_3D) { FORCEDINLINE CommandProcessor& toggle(int16_t x, int16_t y, int16_t w, int16_t h, T text, bool state, uint16_t options = FTDI::OPT_3D) {
CLCD::FontMetrics fm(_font); CLCD::FontMetrics fm(_font);
const int16_t widget_h = fm.height * 20.0 / 16; const int16_t widget_h = fm.height * 20.0 / 16;
//const int16_t outer_bar_r = widget_h / 2;
//const int16_t knob_r = outer_bar_r - 1.5;
// The y coordinate of the toggle is the baseline of the text, // The y coordinate of the toggle is the baseline of the text,
// so we must introduce a fudge factor based on the line height to // so we must introduce a fudge factor based on the line height to
// actually center the control. // actually center the control.
const int16_t fudge_y = fm.height * 5 / 16; const int16_t fudge_y = fm.height * 5 / 16;
CLCD::CommandFifo::toggle(x + h / 2, y + (h - widget_h) / 2 + fudge_y, w - h, _font, options, state); CLCD::CommandFifo::toggle(x + widget_h, y + (h - widget_h) / 2 + fudge_y, w - widget_h, _font, options, state);
CLCD::CommandFifo::str(text); CLCD::CommandFifo::str(text);
return *this; return *this;
} }

View File

@ -67,12 +67,12 @@ namespace FTDI {
width = height = 0; width = height = 0;
for (;;) { for (;;) {
const uint16_t line_width = find_line_break(utf8_fm, clcd_fm, wrap_width, line_start, line_end, use_utf8); const uint16_t line_width = find_line_break(utf8_fm, clcd_fm, wrap_width, line_start, line_end, use_utf8);
if (line_end == line_start) break;
width = max(width, line_width); width = max(width, line_width);
height += utf8_fm.get_height(); height += utf8_fm.get_height();
if (*line_end == '\n' || *line_end == ' ') line_end++;
if (*line_end == '\0') break;
if (line_end == line_start) break;
line_start = line_end; line_start = line_end;
if (*line_start == '\n' || *line_start == ' ') line_start++;
if (*line_start == '\0') break;
} }
} }
@ -109,7 +109,6 @@ namespace FTDI {
const char *line_start = str, *line_end; const char *line_start = str, *line_end;
for (;;) { for (;;) {
find_line_break(utf8_fm, clcd_fm, w, line_start, line_end, use_utf8); find_line_break(utf8_fm, clcd_fm, w, line_start, line_end, use_utf8);
if (line_end == line_start) break;
const size_t line_len = line_end - line_start; const size_t line_len = line_end - line_start;
if (line_len) { if (line_len) {
@ -125,9 +124,10 @@ namespace FTDI {
} }
y += utf8_fm.get_height(); y += utf8_fm.get_height();
if (*line_end == '\n' || *line_end == ' ') line_end++;
if (*line_end == '\0') break;
if (line_end == line_start) break;
line_start = line_end; line_start = line_end;
if (*line_start == '\n' || *line_start == ' ') line_start++;
if (*line_start == '\0') break;
} }
} }

View File

@ -29,30 +29,30 @@ namespace FTDI {
* Helper function for drawing text with ellipses. The str buffer may be modified and should have space for up to two extra characters. * Helper function for drawing text with ellipses. The str buffer may be modified and should have space for up to two extra characters.
*/ */
static void _draw_text_with_ellipsis(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, char *str, uint16_t options, uint8_t font) { static void _draw_text_with_ellipsis(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, char *str, uint16_t options, uint8_t font) {
FontMetrics fm(font); #if ENABLED(TOUCH_UI_USE_UTF8)
const int16_t ellipsisWidth = fm.get_char_width('.') * 3; const bool use_utf8 = has_utf8_chars(str);
#define CHAR_WIDTH(c) use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c]
#else
#define CHAR_WIDTH(c) utf8_fm.get_char_width(c)
constexpr bool use_utf8 = false;
#endif
FontMetrics utf8_fm(font);
CLCD::FontMetrics clcd_fm;
clcd_fm.load(font);
const int16_t ellipsisWidth = utf8_fm.get_char_width('.') * 3;
// Compute the total line length, as well as // Compute the total line length, as well as
// the location in the string where it can // the location in the string where it can
// split and still allow the ellipsis to fit. // split and still allow the ellipsis to fit.
int16_t lineWidth = 0; int16_t lineWidth = 0;
char *breakPoint = str; char *breakPoint = str;
#ifdef TOUCH_UI_USE_UTF8 char *next = str;
char *tstr = str; while (*next) {
while (*tstr) { const utf8_char_t c = get_utf8_char_and_inc(next);
breakPoint = tstr; lineWidth += CHAR_WIDTH(c);
const utf8_char_t c = get_utf8_char_and_inc(tstr); if (lineWidth + ellipsisWidth < w)
lineWidth += fm.get_char_width(c); breakPoint = next;
if (lineWidth + ellipsisWidth < w) }
break;
}
#else
for (char *c = str; *c; c++) {
lineWidth += fm.get_char_width(*c);
if (lineWidth + ellipsisWidth < w)
breakPoint = c;
}
#endif
if (lineWidth > w) { if (lineWidth > w) {
*breakPoint = '\0'; *breakPoint = '\0';
@ -61,7 +61,7 @@ namespace FTDI {
cmd.apply_text_alignment(x, y, w, h, options); cmd.apply_text_alignment(x, y, w, h, options);
#if ENABLED(TOUCH_UI_USE_UTF8) #if ENABLED(TOUCH_UI_USE_UTF8)
if (has_utf8_chars(str)) { if (use_utf8) {
draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options); draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options);
} else } else
#endif #endif

View File

@ -68,15 +68,17 @@
utf8_char_t FTDI::get_utf8_char_and_inc(const char *&c) { utf8_char_t FTDI::get_utf8_char_and_inc(const char *&c) {
utf8_char_t val = *(uint8_t*)c++; utf8_char_t val = *(uint8_t*)c++;
while ((*c & 0xC0) == 0x80) if ((val & 0xC0) == 0xC0)
val = (val << 8) | *(uint8_t*)c++; while ((*c & 0xC0) == 0x80)
val = (val << 8) | *(uint8_t*)c++;
return val; return val;
} }
utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) { utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) {
utf8_char_t val = *(uint8_t*)c++; utf8_char_t val = *(uint8_t*)c++;
while ((*c & 0xC0) == 0x80) if ((val & 0xC0) == 0xC0)
val = (val << 8) | *(uint8_t*)c++; while ((*c & 0xC0) == 0x80)
val = (val << 8) | *(uint8_t*)c++;
return val; return val;
} }

View File

@ -96,7 +96,7 @@ void AboutScreen::onRedraw(draw_mode_t) {
.tag(2).button(STATS_POS, GET_TEXT_F(MSG_INFO_STATS_MENU)); .tag(2).button(STATS_POS, GET_TEXT_F(MSG_INFO_STATS_MENU));
#endif #endif
cmd.colors(action_btn) cmd.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
bool AboutScreen::onTouchEnd(uint8_t tag) { bool AboutScreen::onTouchEnd(uint8_t tag) {

View File

@ -111,7 +111,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.enabled(ENABLED(BACKLASH_GCODE)) .enabled(ENABLED(BACKLASH_GCODE))
.tag(8).button(BACKLASH_POS, GET_TEXT_F(MSG_BACKLASH)) .tag(8).button(BACKLASH_POS, GET_TEXT_F(MSG_BACKLASH))
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -43,7 +43,7 @@ void AlertDialogBox::onRedraw(draw_mode_t what) {
} }
template<typename T> template<typename T>
void AlertDialogBox::show(const T message) { void AlertDialogBox::show(T message) {
drawMessage(message); drawMessage(message);
storeBackground(); storeBackground();
mydata.isError = false; mydata.isError = false;
@ -51,7 +51,7 @@ void AlertDialogBox::show(const T message) {
} }
template<typename T> template<typename T>
void AlertDialogBox::showError(const T message) { void AlertDialogBox::showError(T message) {
drawMessage(message); drawMessage(message);
storeBackground(); storeBackground();
mydata.isError = true; mydata.isError = true;
@ -64,8 +64,8 @@ void AlertDialogBox::hide() {
} }
template void AlertDialogBox::show(const char *); template void AlertDialogBox::show(const char *);
template void AlertDialogBox::show(const progmem_str); template void AlertDialogBox::show(progmem_str);
template void AlertDialogBox::showError(const char *); template void AlertDialogBox::showError(const char *);
template void AlertDialogBox::showError(const progmem_str); template void AlertDialogBox::showError(progmem_str);
#endif // FTDI_ALERT_DIALOG_BOX #endif // FTDI_ALERT_DIALOG_BOX

View File

@ -61,7 +61,7 @@ BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what
#else #else
BTN_POS(15,7), BTN_SIZE(4,1), BTN_POS(15,7), BTN_SIZE(4,1),
#endif #endif
GET_TEXT_F(MSG_BACK), true, true GET_TEXT_F(MSG_BUTTON_DONE), true, true
); );
_line = 1; _line = 1;

View File

@ -136,7 +136,7 @@ void BedMeshEditScreen::drawHighlightedPointValue() {
if (mydata.highlight.x != NONE) if (mydata.highlight.x != NONE)
draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3); draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3);
cmd.colors(mydata.needSave ? normal_btn : action_btn) cmd.colors(mydata.needSave ? normal_btn : action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK)) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE))
.colors(mydata.needSave ? action_btn : normal_btn) .colors(mydata.needSave ? action_btn : normal_btn)
.enabled(mydata.needSave) .enabled(mydata.needSave)
.tag(2).button(SAVE_POS, GET_TEXT_F(MSG_TOUCHMI_SAVE)); .tag(2).button(SAVE_POS, GET_TEXT_F(MSG_TOUCHMI_SAVE));
@ -191,7 +191,7 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) {
void BedMeshEditScreen::show() { void BedMeshEditScreen::show() {
// On entry, always home (to account for possible Z offset changes) and save current mesh // On entry, always home (to account for possible Z offset changes) and save current mesh
SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1")); SpinnerDialogBox::enqueueAndWait(F("G28\nG29 S1"));
// After the spinner, go to this screen. // After the spinner, go to this screen.
current_screen.forget(); current_screen.forget();
PUSH_SCREEN(BedMeshEditScreen); PUSH_SCREEN(BedMeshEditScreen);

View File

@ -224,7 +224,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
.tag(6) .enabled(t_ok).button (LOAD_MOMN_POS, GET_TEXT_F(MSG_MOMENTARY)) .tag(6) .enabled(t_ok).button (LOAD_MOMN_POS, GET_TEXT_F(MSG_MOMENTARY))
.tag(7).TOG_STYLE(tog7).enabled(t_ok).button (UNLD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS)) .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (UNLD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS))
.tag(8).TOG_STYLE(tog8).enabled(t_ok).button (LOAD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS)) .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (LOAD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS))
.tag(1).colors(action_btn) .button (BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).colors(action_btn) .button (BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -135,7 +135,7 @@ void CustomUserMenus::onRedraw(draw_mode_t what) {
_USER_ITEM(20) _USER_ITEM(20)
#endif #endif
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -32,14 +32,14 @@ using namespace Theme;
#define GRID_ROWS 8 #define GRID_ROWS 8
template<typename T> template<typename T>
void DialogBoxBaseClass::drawMessage(const T message, int16_t font) { void DialogBoxBaseClass::drawMessage(T message, int16_t font) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.cmd(CMD_DLSTART) cmd.cmd(CMD_DLSTART)
.cmd(CLEAR_COLOR_RGB(bg_color)) .cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true)) .cmd(CLEAR(true,true,true))
.cmd(COLOR_RGB(bg_text_enabled)) .cmd(COLOR_RGB(bg_text_enabled))
.tag(0); .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); cmd.colors(normal_btn);
} }
@ -59,17 +59,15 @@ void DialogBoxBaseClass::drawOkayButton() {
.tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_OKAY)); .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_OKAY));
} }
void DialogBoxBaseClass::drawButton(const progmem_str label) { template<typename T>
void DialogBoxBaseClass::drawButton(T label) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.font(font_medium) cmd.font(font_medium)
.tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), label); .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), label);
} }
void DialogBoxBaseClass::drawSpinner() { template void DialogBoxBaseClass::drawButton(const char *);
CommandProcessor cmd; template void DialogBoxBaseClass::drawButton(progmem_str);
cmd.cmd(COLOR_RGB(bg_text_enabled))
.spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute();
}
bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) { bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {

View File

@ -27,11 +27,10 @@
class DialogBoxBaseClass : public BaseScreen { class DialogBoxBaseClass : public BaseScreen {
protected: protected:
template<typename T> static void drawMessage(const T, int16_t font = 0); template<typename T> static void drawMessage(T, int16_t font = 0);
template<typename T> static void drawButton(T);
static void drawYesNoButtons(uint8_t default_btn = 0); static void drawYesNoButtons(uint8_t default_btn = 0);
static void drawOkayButton(); static void drawOkayButton();
static void drawSpinner();
static void drawButton(const progmem_str);
static void onRedraw(draw_mode_t) {}; static void onRedraw(draw_mode_t) {};
public: public:

View File

@ -120,7 +120,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) {
cmd.font(font_medium) cmd.font(font_medium)
.colors(action_btn) .colors(action_btn)
.tag(1).button(BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BACK)); .tag(1).button(BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BUTTON_DONE));
#undef GRID_COLS #undef GRID_COLS
#undef GRID_ROWS #undef GRID_ROWS
} }

View File

@ -63,7 +63,7 @@ void FilamentMenu::onRedraw(draw_mode_t what) {
.enabled(ENABLED(LIN_ADVANCE)) .enabled(ENABLED(LIN_ADVANCE))
.tag(3).button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE)) .tag(3).button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE))
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -168,7 +168,7 @@ void FilesScreen::drawFooter() {
cmd.colors(normal_btn) cmd.colors(normal_btn)
.font(font_medium) .font(font_medium)
.colors(has_selection ? normal_btn : action_btn) .colors(has_selection ? normal_btn : action_btn)
.tag(back_tag).button(BTN_POS(4,y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BACK)) .tag(back_tag).button(BTN_POS(4,y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_DONE))
.enabled(has_selection) .enabled(has_selection)
.colors(has_selection ? action_btn : normal_btn); .colors(has_selection ? action_btn : normal_btn);

View File

@ -104,15 +104,15 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
#endif #endif
#undef EDGE_R #undef EDGE_R
#define EDGE_R 0 #define EDGE_R 0
#if ENABLED(TOUCH_UI_PORTRAIT)
.colors(normal_btn) .colors(normal_btn)
#if ENABLED(TOUCH_UI_PORTRAIT)
.tag(6).button (BTN_POS(1,6), BTN_SIZE(4,1), GET_TEXT_F(MSG_SOUNDS)) .tag(6).button (BTN_POS(1,6), BTN_SIZE(4,1), GET_TEXT_F(MSG_SOUNDS))
.colors(action_btn) .colors(action_btn)
.tag(1).button (BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BACK)); .tag(1).button (BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BUTTON_DONE));
#else #else
.tag(6).button (BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_SOUNDS)) .tag(6).button (BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_SOUNDS))
.colors(action_btn) .colors(action_btn)
.tag(1).button (BTN_POS(3,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK)); .tag(1).button (BTN_POS(3,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE));
#endif #endif
} }
} }

View File

@ -74,8 +74,7 @@ void InterfaceSoundsScreen::onRedraw(draw_mode_t what) {
#undef EDGE_R #undef EDGE_R
#define EDGE_R 30 #define EDGE_R 30
.font(font_small) .font(font_small)
.tag(0).text (BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXT_F(MSG_SOUND_VOLUME), OPT_RIGHTX | OPT_CENTERY) .tag(0).text (BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXT_F(MSG_CLICK_SOUNDS), OPT_RIGHTX | OPT_CENTERY)
.text (BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXT_F(MSG_CLICK_SOUNDS), OPT_RIGHTX | OPT_CENTERY)
.text (BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_STARTING), OPT_RIGHTX | OPT_CENTERY) .text (BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_STARTING), OPT_RIGHTX | OPT_CENTERY)
.text (BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_FINISHED), OPT_RIGHTX | OPT_CENTERY) .text (BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_FINISHED), OPT_RIGHTX | OPT_CENTERY)
.text (BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_ERROR), OPT_RIGHTX | OPT_CENTERY); .text (BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_PRINT_ERROR), OPT_RIGHTX | OPT_CENTERY);
@ -89,20 +88,18 @@ void InterfaceSoundsScreen::onRedraw(draw_mode_t what) {
constexpr uint8_t w = 1; constexpr uint8_t w = 1;
#endif #endif
cmd.font(font_medium) cmd.font(font_small)
.colors(ui_slider)
#define EDGE_R 30 #define EDGE_R 30
.tag(2).slider (BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettingsScreen.volume, 0xFF)
.colors(ui_toggle) .colors(ui_toggle)
.tag(3).toggle2 (BTN_POS(3,3), BTN_SIZE(w,1), GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), UIData::touch_sounds_enabled()) .tag(2).toggle2 (BTN_POS(3,3), BTN_SIZE(w,1), GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), UIData::touch_sounds_enabled())
#undef EDGE_R #undef EDGE_R
.colors(normal_btn) .colors(normal_btn)
#define EDGE_R 0 #define EDGE_R 0
.tag(4).button (BTN_POS(3,5), BTN_SIZE(2,1), getSoundSelection(PRINTING_STARTED)) .tag(3).button (BTN_POS(3,5), BTN_SIZE(2,1), getSoundSelection(PRINTING_STARTED))
.tag(5).button (BTN_POS(3,6), BTN_SIZE(2,1), getSoundSelection(PRINTING_FINISHED)) .tag(4).button (BTN_POS(3,6), BTN_SIZE(2,1), getSoundSelection(PRINTING_FINISHED))
.tag(6).button (BTN_POS(3,7), BTN_SIZE(2,1), getSoundSelection(PRINTING_FAILED)) .tag(5).button (BTN_POS(3,7), BTN_SIZE(2,1), getSoundSelection(PRINTING_FAILED))
.colors(action_btn) .colors(action_btn)
.tag(1).button (BTN_POS(1,9), BTN_SIZE(4,1), GET_TEXT_F(MSG_BACK)); .tag(1).button (BTN_POS(1,9), BTN_SIZE(4,1), GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }
@ -114,10 +111,10 @@ void InterfaceSoundsScreen::onEntry() {
bool InterfaceSoundsScreen::onTouchEnd(uint8_t tag) { bool InterfaceSoundsScreen::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: GOTO_PREVIOUS(); return true; case 1: GOTO_PREVIOUS(); return true;
case 3: UIData::enable_touch_sounds(!UIData::touch_sounds_enabled()); break; case 2: UIData::enable_touch_sounds(!UIData::touch_sounds_enabled()); break;
case 4: toggleSoundSelection(PRINTING_STARTED); break; case 3: toggleSoundSelection(PRINTING_STARTED); break;
case 5: toggleSoundSelection(PRINTING_FINISHED); break; case 4: toggleSoundSelection(PRINTING_FINISHED); break;
case 6: toggleSoundSelection(PRINTING_FAILED); break; case 5: toggleSoundSelection(PRINTING_FAILED); break;
default: default:
return false; return false;
} }
@ -125,35 +122,4 @@ bool InterfaceSoundsScreen::onTouchEnd(uint8_t tag) {
return true; return true;
} }
bool InterfaceSoundsScreen::onTouchStart(uint8_t tag) {
CommandProcessor cmd;
#undef EDGE_R
#define EDGE_R 30
switch (tag) {
case 2: cmd.track_linear(BTN_POS(3,2), BTN_SIZE(2,1), 2).execute(); break;
default: break;
}
return true;
}
void InterfaceSoundsScreen::onIdle() {
if (refresh_timer.elapsed(TOUCH_UPDATE_INTERVAL)) {
refresh_timer.start();
uint16_t value;
CommandProcessor cmd;
switch (cmd.track_tag(value)) {
case 2:
screen_data.InterfaceSettingsScreen.volume = value >> 8;
SoundPlayer::set_volume(screen_data.InterfaceSettingsScreen.volume);
SaveSettingsDialogBox::settingsChanged();
break;
default:
return;
}
onRefresh();
}
BaseScreen::onIdle();
}
#endif // FTDI_INTERFACE_SOUNDS_SCREEN #endif // FTDI_INTERFACE_SOUNDS_SCREEN

View File

@ -51,7 +51,5 @@ class InterfaceSoundsScreen : public BaseScreen, public CachedScreen<INTERFACE_S
static void onEntry(); static void onEntry();
static void onRedraw(draw_mode_t); static void onRedraw(draw_mode_t);
static bool onTouchStart(uint8_t tag);
static bool onTouchEnd(uint8_t tag); static bool onTouchEnd(uint8_t tag);
static void onIdle();
}; };

View File

@ -96,7 +96,7 @@ void LevelingMenu::onRedraw(draw_mode_t what) {
.tag(8).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)) .tag(8).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST))
#endif #endif
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }
@ -104,7 +104,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: GOTO_PREVIOUS(); break; case 1: GOTO_PREVIOUS(); break;
#if EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION) #if EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION)
case 2: SpinnerDialogBox::enqueueAndWait_P(F("G34")); break; case 2: SpinnerDialogBox::enqueueAndWait(F("G34")); break;
#endif #endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
case 3: case 3:
@ -114,7 +114,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
BedMeshViewScreen::doProbe(); BedMeshViewScreen::doProbe();
#else #else
SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS)); SpinnerDialogBox::enqueueAndWait(F(BED_LEVELING_COMMANDS));
#endif #endif
break; break;
#endif #endif
@ -127,7 +127,7 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
case 7: injectCommands_P(PSTR("M280 P0 S60")); break; case 7: injectCommands_P(PSTR("M280 P0 S60")); break;
case 8: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; case 8: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
#endif #endif
default: return false; default: return false;
} }

View File

@ -95,7 +95,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
.tag(11).button(CUSTOM_MENU_POS, GET_TEXT_F(MSG_CUSTOM_COMMANDS)) .tag(11).button(CUSTOM_MENU_POS, GET_TEXT_F(MSG_CUSTOM_COMMANDS))
#endif #endif
.colors(action_btn) .colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }
@ -104,7 +104,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) {
switch (tag) { switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
case 2: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break; case 2: SpinnerDialogBox::enqueueAndWait(F("G28")); break;
#if ENABLED(NOZZLE_CLEAN_FEATURE) #if ENABLED(NOZZLE_CLEAN_FEATURE)
case 3: injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break; case 3: injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break;
#endif #endif

View File

@ -98,10 +98,10 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break; case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break;
case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break; case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break;
#endif #endif
case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break; case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break;
case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break; case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break;
case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break; case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break;
case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break; case 23: SpinnerDialogBox::enqueueAndWait(F("G28")); break;
case 24: raiseZtoTop(); break; case 24: raiseZtoTop(); break;
default: default:
return false; return false;

View File

@ -26,43 +26,82 @@
#ifdef FTDI_SPINNER_DIALOG_BOX #ifdef FTDI_SPINNER_DIALOG_BOX
#define GRID_COLS 2
#define GRID_ROWS 8
using namespace FTDI; using namespace FTDI;
using namespace ExtUI; using namespace ExtUI;
using namespace Theme;
constexpr static SpinnerDialogBoxData &mydata = screen_data.SpinnerDialogBox; constexpr static SpinnerDialogBoxData &mydata = screen_data.SpinnerDialogBox;
void SpinnerDialogBox::onRedraw(draw_mode_t) { void SpinnerDialogBox::onEntry() {
UIScreen::onEntry();
mydata.auto_hide = true;
} }
void SpinnerDialogBox::show(const progmem_str message) { void SpinnerDialogBox::onExit() {
drawMessage(message);
drawSpinner();
storeBackground();
mydata.auto_hide = false;
}
void SpinnerDialogBox::hide() {
CommandProcessor cmd; CommandProcessor cmd;
cmd.stop().execute(); cmd.stop().execute();
} }
void SpinnerDialogBox::enqueueAndWait_P(const progmem_str commands) { void SpinnerDialogBox::onRefresh() {
enqueueAndWait_P(GET_TEXT_F(MSG_PLEASE_WAIT), commands); 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::enqueueAndWait_P(const progmem_str message, const progmem_str commands) { 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);
mydata.auto_hide = false;
}
void SpinnerDialogBox::hide() {
GOTO_PREVIOUS();
}
void SpinnerDialogBox::enqueueAndWait(progmem_str message, progmem_str commands) {
show(message); show(message);
GOTO_SCREEN(SpinnerDialogBox);
ExtUI::injectCommands_P((const char*)commands); ExtUI::injectCommands_P((const char*)commands);
mydata.auto_hide = true; mydata.auto_hide = true;
} }
void SpinnerDialogBox::enqueueAndWait(progmem_str message, char *commands) {
show(message);
ExtUI::injectCommands(commands);
mydata.auto_hide = true;
}
void SpinnerDialogBox::onIdle() { void SpinnerDialogBox::onIdle() {
reset_menu_timeout(); if (mydata.auto_hide && !commandsInQueue() && TERN1(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state == GcodeSuite::NOT_BUSY)) {
if (mydata.auto_hide && !commandsInQueue()) {
mydata.auto_hide = false; mydata.auto_hide = false;
hide(); hide();
GOTO_PREVIOUS();
} }
} }

View File

@ -29,13 +29,20 @@ struct SpinnerDialogBoxData {
bool auto_hide; bool auto_hide;
}; };
class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen<SPINNER_CACHE,SPINNER_DL_SIZE> { class SpinnerDialogBox : public UIScreen {
public: public:
static void onEntry();
static void onExit();
static void onRedraw(draw_mode_t); static void onRedraw(draw_mode_t);
static void onRefresh();
static void onIdle(); static void onIdle();
static void show(const progmem_str); static void show(progmem_str);
static void hide(); static void hide();
static void enqueueAndWait_P(const progmem_str commands);
static void enqueueAndWait_P(const progmem_str message, const progmem_str commands); template<typename T>
static void enqueueAndWait(T commands) {enqueueAndWait(GET_TEXT_F(MSG_PLEASE_WAIT), commands);}
static void enqueueAndWait(progmem_str message, char *commands);
static void enqueueAndWait(progmem_str message, progmem_str commands);
}; };

View File

@ -63,7 +63,7 @@ void StatisticsScreen::onRedraw(draw_mode_t what) {
if (what & FOREGROUND) { if (what & FOREGROUND) {
cmd.font(Theme::font_medium) cmd.font(Theme::font_medium)
.colors(action_btn) .colors(action_btn)
.tag(1).button(BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BACK)); .tag(1).button(BTN_POS(1,7), BTN_SIZE(4,1), GET_TEXT_F(MSG_BUTTON_DONE));
} }
} }

View File

@ -92,7 +92,7 @@ void TuneMenu::onRedraw(draw_mode_t what) {
.tag(10).button(CASE_LIGHT_POS, GET_TEXT_F(MSG_CASE_LIGHT)) .tag(10).button(CASE_LIGHT_POS, GET_TEXT_F(MSG_CASE_LIGHT))
.tag(11).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS)) .tag(11).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS))
.tag(1).colors(action_btn) .tag(1).colors(action_btn)
.button(BACK_POS, GET_TEXT_F(MSG_BACK)); .button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
} }
#undef GRID_COLS #undef GRID_COLS
#undef GRID_ROWS #undef GRID_ROWS

View File

@ -84,7 +84,7 @@ void ZOffsetScreen::runWizard() {
strcat(cmd, str); strcat(cmd, str);
injectCommands(cmd); injectCommands(cmd);
// Show instructions for user. // Show instructions for user.
AlertDialogBox::show(PSTR("After the printer finishes homing, adjust the Z Offset so that a sheet of paper can pass between the nozzle and bed with slight resistance.")); AlertDialogBox::show(F("After the printer finishes homing, adjust the Z Offset so that a sheet of paper can pass between the nozzle and bed with slight resistance."));
} }
bool ZOffsetScreen::wizardRunning() { bool ZOffsetScreen::wizardRunning() {