LULZBOT_TOUCH_UI performance/cosmetic fixes (#15319)

This commit is contained in:
Marcio Teixeira 2019-09-24 16:46:00 -06:00 committed by Scott Lahteine
parent 6fc4d4c3b7
commit bafcd084cc
9 changed files with 230 additions and 170 deletions

View File

@ -199,6 +199,9 @@ class CachedScreen {
public: public:
static void onRefresh() { static void onRefresh() {
#if ENABLED(TOUCH_UI_DEBUG)
const uint32_t start_time = millis();
#endif
using namespace FTDI; using namespace FTDI;
DLCache dlcache(DL_SLOT); DLCache dlcache(DL_SLOT);
CommandProcessor cmd; CommandProcessor cmd;
@ -220,5 +223,8 @@ class CachedScreen {
cmd.cmd(DL::DL_DISPLAY); cmd.cmd(DL::DL_DISPLAY);
cmd.cmd(CMD_SWAP); cmd.cmd(CMD_SWAP);
cmd.execute(); cmd.execute();
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHOLNPAIR("Time to draw screen (ms): ", millis() - start_time);
#endif
} }
}; };

View File

@ -197,7 +197,7 @@
#else #else
#define LULZBOT_BIOPRINTER_STRINGS ,\ #define LULZBOT_BIOPRINTER_STRINGS ,\
MAIN_MENU, \ MAIN_MENU, \
UNLOCK_XY_AXIS, \ RELEASE_XY_AXIS, \
LOAD_SYRINGE, \ LOAD_SYRINGE, \
BED_TEMPERATURE, \ BED_TEMPERATURE, \
LOADING_WARNING, \ LOADING_WARNING, \
@ -302,7 +302,11 @@ namespace Language_en {
PROGMEM Language_Str PLEASE_RESET = u8"Please reset"; PROGMEM Language_Str PLEASE_RESET = u8"Please reset";
PROGMEM Language_Str COLOR_TOUCH_PANEL = u8"Color Touch Panel"; PROGMEM Language_Str COLOR_TOUCH_PANEL = u8"Color Touch Panel";
#if ENABLED(TOUCH_UI_UTF8_COPYRIGHT)
PROGMEM Language_Str ABOUT_ALEPH_OBJECTS = u8"© 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com";
#else
PROGMEM Language_Str ABOUT_ALEPH_OBJECTS = u8"(C) 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com"; PROGMEM Language_Str ABOUT_ALEPH_OBJECTS = u8"(C) 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com";
#endif
PROGMEM Language_Str FIRMWARE_FOR_TOOLHEAD = u8"Firmware for toolhead:\n%s\n\n"; PROGMEM Language_Str FIRMWARE_FOR_TOOLHEAD = u8"Firmware for toolhead:\n%s\n\n";
@ -327,10 +331,14 @@ namespace Language_en {
PROGMEM Language_Str UNITS_MILLIAMP = u8"mA"; PROGMEM Language_Str UNITS_MILLIAMP = u8"mA";
PROGMEM Language_Str UNITS_MM = u8"mm"; PROGMEM Language_Str UNITS_MM = u8"mm";
PROGMEM Language_Str UNITS_MM_S = u8"mm/s"; PROGMEM Language_Str UNITS_MM_S = u8"mm/s";
#if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
PROGMEM Language_Str UNITS_MM_S2 = u8"mm/s²";
#else
PROGMEM Language_Str UNITS_MM_S2 = u8"mm/s^2"; PROGMEM Language_Str UNITS_MM_S2 = u8"mm/s^2";
#endif
PROGMEM Language_Str UNITS_STEP_MM = u8"st/mm"; PROGMEM Language_Str UNITS_STEP_MM = u8"st/mm";
PROGMEM Language_Str UNITS_PERCENT = u8"%"; PROGMEM Language_Str UNITS_PERCENT = u8"%";
#if defined(TOUCH_UI_USE_UTF8) && defined(TOUCH_UI_UTF8_WESTERN_CHARSET) #if ENABLED(TOUCH_UI_UTF8_WESTERN_CHARSET)
PROGMEM Language_Str UNITS_C = u8"°C"; PROGMEM Language_Str UNITS_C = u8"°C";
#else #else
PROGMEM Language_Str UNITS_C = u8" C"; PROGMEM Language_Str UNITS_C = u8" C";
@ -399,10 +407,10 @@ namespace Language_en {
#ifdef LULZBOT_USE_BIOPRINTER_UI #ifdef LULZBOT_USE_BIOPRINTER_UI
PROGMEM Language_Str MAIN_MENU = u8"Main Menu"; PROGMEM Language_Str MAIN_MENU = u8"Main Menu";
PROGMEM Language_Str UNLOCK_XY_AXIS = u8"Unlock XY Axis"; PROGMEM Language_Str RELEASE_XY_AXIS = u8"Release XY Axis";
PROGMEM Language_Str LOAD_SYRINGE = u8"Load Syringe"; PROGMEM Language_Str LOAD_SYRINGE = u8"Load Syringe";
PROGMEM Language_Str BED_TEMPERATURE = u8"Bed Temperature"; PROGMEM Language_Str BED_TEMPERATURE = u8"Bed Temperature";
PROGMEM Language_Str LOADING_WARNING = u8"About to home to loading position.\nEnsure the top and the bed of the printer are clear.\n\nContinue?"; PROGMEM Language_Str LOADING_WARNING = u8"About to home to loading position. Ensure the top and the bed of the printer are clear.\n\nContinue?";
PROGMEM Language_Str HOMING_WARNING = u8"About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?"; PROGMEM Language_Str HOMING_WARNING = u8"About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?";
#endif #endif

View File

@ -33,34 +33,84 @@ using namespace Theme;
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
#define GRID_COLS 13 #define GRID_COLS 13
#define GRID_ROWS 10 #define GRID_ROWS 10
#define LAYOUT_FONT font_small
#else #else
#define GRID_COLS 18 #define GRID_COLS 18
#define GRID_ROWS 7 #define GRID_ROWS 7
#define LAYOUT_FONT font_medium
#endif #endif
BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what) { BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what) {
if (what & BACKGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
if (what & BACKGROUND) {
cmd.cmd(CLEAR_COLOR_RGB(bg_color)) cmd.cmd(CLEAR_COLOR_RGB(bg_color))
.cmd(CLEAR(true,true,true)); .cmd(CLEAR(true,true,true))
.colors(normal_btn)
.cmd(COLOR_RGB(bg_text_enabled));
} }
if (what & FOREGROUND) { cmd.font(font_medium);
CommandProcessor cmd; _button(cmd, 1,
cmd.font(font_medium)
.colors(action_btn)
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
.tag(1).button( BTN_POS(1,10), BTN_SIZE(13,1), GET_TEXTF(BACK)) BTN_POS(1,10), BTN_SIZE(13,1),
#else #else
.tag(1).button( BTN_POS(15,7), BTN_SIZE(4,1), GET_TEXTF(BACK)) BTN_POS(15,7), BTN_SIZE(4,1),
#endif #endif
.colors(normal_btn); GET_TEXTF(BACK), true, true
} );
_line = 1; _line = 1;
_units = F(""); _units = F("");
} }
/**
* Speed optimization for changing button style.
*/
void BaseNumericAdjustmentScreen::widgets_t::_button_style(CommandProcessor &cmd, BaseNumericAdjustmentScreen::widgets_t::style_t style) {
if (_style != style) {
const btn_colors *old_colors = &normal_btn;
const btn_colors *new_colors = &normal_btn;
switch(_style) {
case BTN_ACTION: old_colors = &action_btn; break;
case BTN_TOGGLE: old_colors = &ui_toggle; break;
case BTN_DISABLED: old_colors = &disabled_btn; break;
default: break;
}
switch(style) {
case BTN_ACTION: new_colors = &action_btn; break;
case BTN_TOGGLE: new_colors = &ui_toggle; break;
case BTN_DISABLED: new_colors = &disabled_btn; break;
default: break;
}
const bool rgb_changed = old_colors->rgb != new_colors->rgb;
const bool grad_changed = old_colors->grad != new_colors->grad;
const bool fg_changed = (old_colors->fg != new_colors->fg) || (_style == TEXT_AREA);
const bool bg_changed = old_colors->bg != new_colors->bg;
if (rgb_changed) cmd.cmd(COLOR_RGB(new_colors->rgb));
if (grad_changed) cmd.gradcolor(new_colors->grad);
if (fg_changed) cmd.fgcolor(new_colors->fg);
if (bg_changed) cmd.bgcolor(new_colors->bg);
_style = style;
}
}
/**
* Speed optimization for drawing buttons. Draw all unpressed buttons in the
* background layer and draw only the pressed button in the foreground layer.
*/
void BaseNumericAdjustmentScreen::widgets_t::_button(CommandProcessor &cmd, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str text, bool enabled, bool highlight) {
if (_what & BACKGROUND) enabled = true;
if ((_what & BACKGROUND) || buttonIsPressed(tag) || highlight || !enabled) {
_button_style(cmd, (!enabled) ? BTN_DISABLED : (highlight ? BTN_ACTION : BTN_NORMAL));
cmd.tag(enabled ? tag : 0).button(x, y, w, h, text);
}
}
BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) { BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) {
_decimals = decimals; _decimals = decimals;
if (screen_data.BaseNumericAdjustmentScreen.increment == 0) { if (screen_data.BaseNumericAdjustmentScreen.increment == 0) {
@ -70,14 +120,17 @@ BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::
} }
void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) { void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) {
CommandProcessor cmd;
cmd.font(font_medium).cmd(COLOR_RGB(bg_text_enabled));
if (_what & BACKGROUND) { if (_what & BACKGROUND) {
CommandProcessor cmd;
cmd.font(font_medium)
.text(
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
cmd.tag(0).fgcolor(bg_color).button( BTN_POS(1, _line), BTN_SIZE(12,1), label, OPT_FLAT); BTN_POS(1, _line), BTN_SIZE(12,1),
#else #else
cmd.tag(0).fgcolor(bg_color).button( BTN_POS(5, _line), BTN_SIZE(8,1), label, OPT_FLAT); BTN_POS(5, _line), BTN_SIZE(8,1),
#endif #endif
label
);
} }
_line++; _line++;
@ -93,8 +146,7 @@ void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) {
#endif #endif
#endif #endif
void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(uint8_t, const uint8_t tag) { void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(CommandProcessor &cmd, uint8_t, const uint8_t tag) {
CommandProcessor cmd;
const char *label = PSTR("?"); const char *label = PSTR("?");
uint8_t pos; uint8_t pos;
uint8_t & increment = screen_data.BaseNumericAdjustmentScreen.increment; uint8_t & increment = screen_data.BaseNumericAdjustmentScreen.increment;
@ -112,45 +164,40 @@ void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(uint8_t, const
default: label = PSTR("100" ); pos = _decimals + 2; break; default: label = PSTR("100" ); pos = _decimals + 2; break;
} }
cmd.tag(tag) const bool highlight = (_what & FOREGROUND) && (increment == tag);
.colors(increment == tag ? action_btn : normal_btn)
#ifdef TOUCH_UI_PORTRAIT
.font(font_small);
#else
.font(font_medium);
#endif
switch (pos) { switch (pos) {
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
case 0: cmd.button( BTN_POS(5,_line), BTN_SIZE(2,1), progmem_str(label)); break; case 0: _button(cmd, tag, BTN_POS(5,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
case 1: cmd.button( BTN_POS(7,_line), BTN_SIZE(2,1), progmem_str(label)); break; case 1: _button(cmd, tag, BTN_POS(7,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
case 2: cmd.button( BTN_POS(9,_line), BTN_SIZE(2,1), progmem_str(label)); break; case 2: _button(cmd, tag, BTN_POS(9,_line), BTN_SIZE(2,1), progmem_str(label), true, highlight); break;
#else #else
case 0: cmd.button( BTN_POS(15,2), BTN_SIZE(4,1), progmem_str(label)); break; case 0: _button(cmd, tag, BTN_POS(15,2), BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
case 1: cmd.button( BTN_POS(15,3), BTN_SIZE(4,1), progmem_str(label)); break; case 1: _button(cmd, tag, BTN_POS(15,3), BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
case 2: cmd.button( BTN_POS(15,4), BTN_SIZE(4,1), progmem_str(label)); break; case 2: _button(cmd, tag, BTN_POS(15,4), BTN_SIZE(4,1), progmem_str(label), true, highlight); break;
#endif #endif
} }
cmd.colors(normal_btn);
} }
void BaseNumericAdjustmentScreen::widgets_t::increments() { void BaseNumericAdjustmentScreen::widgets_t::increments() {
if (_what & BACKGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.fgcolor(bg_color)
.tag(0) cmd.font(LAYOUT_FONT);
if (_what & BACKGROUND) {
cmd.text(
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
.font(font_small).button( BTN_POS(1, _line), BTN_SIZE(4,1), GET_TEXTF(INCREMENT), OPT_FLAT); BTN_POS(1, _line), BTN_SIZE(4,1),
#else #else
.font(font_medium).button( BTN_POS(15,1), BTN_SIZE(4,1), GET_TEXTF(INCREMENT), OPT_FLAT); BTN_POS(15, 1), BTN_SIZE(4,1),
#endif #endif
GET_TEXTF(INCREMENT)
);
} }
if (_what & FOREGROUND) { _draw_increment_btn(cmd, _line+1, 245 - _decimals);
_draw_increment_btn(_line+1, 245 - _decimals); _draw_increment_btn(cmd, _line+1, 244 - _decimals);
_draw_increment_btn(_line+1, 244 - _decimals); _draw_increment_btn(cmd, _line+1, 243 - _decimals);
_draw_increment_btn(_line+1, 243 - _decimals);
}
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
_line++; _line++;
@ -161,19 +208,22 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster_sram_val(uint8_t tag, prog
CommandProcessor cmd; CommandProcessor cmd;
if (_what & BACKGROUND) { if (_what & BACKGROUND) {
cmd.enabled(1) _button_style(cmd, TEXT_AREA);
cmd.tag(0)
.font(font_small) .font(font_small)
.fgcolor(_color) .tag(0).button( BTN_POS(5,_line), BTN_SIZE(5,1), F(""), OPT_FLAT) .text( BTN_POS(1,_line), BTN_SIZE(4,1), label)
.cmd(COLOR_RGB(bg_text_enabled)) .fgcolor(_color).button( BTN_POS(5,_line), BTN_SIZE(5,1), F(""), OPT_FLAT);
.fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), (progmem_str) label, OPT_FLAT);
} }
if (_what & FOREGROUND) { cmd.font(font_medium);
cmd.colors(normal_btn) _button(cmd, tag, BTN_POS(10,_line), BTN_SIZE(2,1), F("-"), is_enabled);
.font(font_medium) _button(cmd, tag + 1, BTN_POS(12,_line), BTN_SIZE(2,1), F("+"), is_enabled);
.tag(is_enabled ? tag : 0).enabled(is_enabled).button( BTN_POS(10,_line), BTN_SIZE(2,1), F("-"))
.tag(is_enabled ? tag+1 : 0).enabled(is_enabled).button( BTN_POS(12,_line), BTN_SIZE(2,1), F("+")) if ((_what & FOREGROUND) && is_enabled) {
.tag(0).font(font_small) .text ( BTN_POS(5,_line), BTN_SIZE(5,1), is_enabled ? value : "-"); _button_style(cmd, BTN_NORMAL);
cmd.tag(0)
.font(font_small)
.text(BTN_POS(5,_line), BTN_SIZE(5,1), value);
} }
_line++; _line++;
@ -206,18 +256,9 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, progmem_str l
} }
void BaseNumericAdjustmentScreen::widgets_t::button(uint8_t tag, progmem_str label, bool is_enabled) { void BaseNumericAdjustmentScreen::widgets_t::button(uint8_t tag, progmem_str label, bool is_enabled) {
if (_what & FOREGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.colors(normal_btn) cmd.font(LAYOUT_FONT);
.tag(is_enabled ? tag : 0) _button(cmd, tag, BTN_POS(5,_line), BTN_SIZE(9,1), label, is_enabled);
.enabled(is_enabled)
#ifdef TOUCH_UI_PORTRAIT
.font(font_small)
#else
.font(font_medium)
#endif
.button(BTN_POS(5,_line), BTN_SIZE(9,1), label);
}
_line++; _line++;
} }
@ -226,89 +267,78 @@ void BaseNumericAdjustmentScreen::widgets_t::text_field(uint8_t tag, progmem_str
CommandProcessor cmd; CommandProcessor cmd;
if (_what & BACKGROUND) { if (_what & BACKGROUND) {
_button_style(cmd, TEXT_AREA);
cmd.enabled(1) cmd.enabled(1)
.tag(0)
.font(font_small) .font(font_small)
.cmd(COLOR_RGB(bg_text_enabled)) .text( BTN_POS(1,_line), BTN_SIZE(4,1), label)
.fgcolor(_color).tag(0).button( BTN_POS(5,_line), BTN_SIZE(9,1), F(""), OPT_FLAT) .fgcolor(_color)
.fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), label, OPT_FLAT); .tag(tag)
.button( BTN_POS(5,_line), BTN_SIZE(9,1), F(""), OPT_FLAT);
} }
if (_what & FOREGROUND) { if (_what & FOREGROUND) {
cmd.colors(normal_btn) cmd.font(font_small).text( BTN_POS(5,_line), BTN_SIZE(9,1), is_enabled ? value : "-");
.font(font_medium)
.tag(tag).font(font_small).text ( BTN_POS(5,_line), BTN_SIZE(9,1), is_enabled ? value : "-");
} }
_line++; _line++;
} }
void BaseNumericAdjustmentScreen::widgets_t::two_buttons(uint8_t tag1, progmem_str label1, uint8_t tag2, progmem_str label2, bool is_enabled) { void BaseNumericAdjustmentScreen::widgets_t::two_buttons(uint8_t tag1, progmem_str label1, uint8_t tag2, progmem_str label2, bool is_enabled) {
if (_what & FOREGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.enabled(is_enabled) cmd.font(LAYOUT_FONT);
#ifdef TOUCH_UI_PORTRAIT _button(cmd, tag1, BTN_POS(5,_line), BTN_SIZE(4.5,1), label1, is_enabled);
.font(font_small) _button(cmd, tag2, BTN_POS(9.5,_line), BTN_SIZE(4.5,1), label2, is_enabled);
#else
.font(font_medium)
#endif
.tag(is_enabled ? tag1: 0).button(BTN_POS(5,_line), BTN_SIZE(4.5,1), label1)
.tag(is_enabled ? tag2: 0).button(BTN_POS(9.5,_line), BTN_SIZE(4.5,1), label2);
}
_line++; _line++;
} }
void BaseNumericAdjustmentScreen::widgets_t::toggle(uint8_t tag, progmem_str label, bool value, bool is_enabled) { void BaseNumericAdjustmentScreen::widgets_t::toggle(uint8_t tag, progmem_str label, bool value, bool is_enabled) {
if (_what & BACKGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.fgcolor(bg_color)
.tag(0) if (_what & BACKGROUND) {
.font(font_small) cmd.font(font_small)
.text(
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
.button( BTN_POS(1, _line), BTN_SIZE( 8,1), label, OPT_FLAT); BTN_POS(1, _line), BTN_SIZE( 8,1),
#else #else
.button( BTN_POS(1, _line), BTN_SIZE(10,1), label, OPT_FLAT); BTN_POS(1, _line), BTN_SIZE(10,1),
#endif #endif
label
);
} }
if (_what & FOREGROUND) { if (_what & FOREGROUND) {
CommandProcessor cmd; _button_style(cmd, BTN_TOGGLE);
cmd.tag(is_enabled ? tag : 0) cmd.tag(is_enabled ? tag : 0)
.enabled(is_enabled) .enabled(is_enabled)
.font(font_small) .font(font_small)
.colors(ui_toggle) .toggle2(
#ifdef TOUCH_UI_PORTRAIT #ifdef TOUCH_UI_PORTRAIT
.toggle2(BTN_POS( 9,_line), BTN_SIZE(5,1), GET_TEXTF(NO), GET_TEXTF(YES), value); BTN_POS( 9,_line), BTN_SIZE(5,1),
#else #else
.toggle2(BTN_POS(10,_line), BTN_SIZE(4,1), GET_TEXTF(NO), GET_TEXTF(YES), value); BTN_POS(10,_line), BTN_SIZE(4,1),
#endif #endif
GET_TEXTF(NO), GET_TEXTF(YES), value
);
} }
_line++; _line++;
} }
void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) { void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
if (_what & BACKGROUND) {
CommandProcessor cmd; CommandProcessor cmd;
cmd.fgcolor(bg_color)
.tag(0) if (_what & BACKGROUND) {
.font(font_small) cmd.font(font_small)
.button( BTN_POS(1, _line), BTN_SIZE(4,1), GET_TEXTF(HOME), OPT_FLAT); .text(BTN_POS(1, _line), BTN_SIZE(4,1), GET_TEXTF(HOME));
} }
if (_what & FOREGROUND) { cmd.font(LAYOUT_FONT);
CommandProcessor cmd; _button(cmd, tag+0, BTN_POS(5,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_X));
cmd _button(cmd, tag+1, BTN_POS(7,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_Y));
#ifdef TOUCH_UI_PORTRAIT _button(cmd, tag+2, BTN_POS(9,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_Z));
.font(font_small) _button(cmd, tag+3, BTN_POS(11,_line), BTN_SIZE(3,1), GET_TEXTF(AXIS_ALL));
#else
.font(font_medium)
#endif
.tag(tag+0).button(BTN_POS(5,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_X))
.tag(tag+1).button(BTN_POS(7,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_Y))
.tag(tag+2).button(BTN_POS(9,_line), BTN_SIZE(2,1), GET_TEXTF(AXIS_Z))
.tag(tag+3).button(BTN_POS(11,_line), BTN_SIZE(3,1), GET_TEXTF(AXIS_ALL));
}
_line++; _line++;
} }
@ -316,6 +346,8 @@ void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
void BaseNumericAdjustmentScreen::onEntry() { void BaseNumericAdjustmentScreen::onEntry() {
screen_data.BaseNumericAdjustmentScreen.increment = 0; // This will force the increment to be picked while drawing. screen_data.BaseNumericAdjustmentScreen.increment = 0; // This will force the increment to be picked while drawing.
BaseScreen::onEntry(); BaseScreen::onEntry();
CommandProcessor cmd;
cmd.set_button_style_callback(nullptr);
} }
bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) { bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) {

View File

@ -36,6 +36,10 @@ void BaseScreen::onEntry() {
UIScreen::onEntry(); UIScreen::onEntry();
} }
bool BaseScreen::buttonIsPressed(uint8_t tag) {
return tag != 0 && EventLoop::get_pressed_tag() == tag;
}
bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post) { bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post) {
if (post) { if (post) {
cmd.colors(normal_btn); cmd.colors(normal_btn);
@ -48,7 +52,7 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
} }
#endif #endif
if (tag != 0 && EventLoop::get_pressed_tag() == tag) { if (buttonIsPressed(tag)) {
options = OPT_FLAT; options = OPT_FLAT;
} }
@ -65,7 +69,7 @@ void BaseScreen::onIdle() {
#ifdef LCD_TIMEOUT_TO_STATUS #ifdef LCD_TIMEOUT_TO_STATUS
if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) { if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
reset_menu_timeout(); reset_menu_timeout();
#ifdef UI_FRAMEWORK_DEBUG #if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_MSG("Returning to status due to menu timeout"); SERIAL_ECHO_MSG("Returning to status due to menu timeout");
#endif #endif
GOTO_SCREEN(StatusScreen); GOTO_SCREEN(StatusScreen);

View File

@ -46,7 +46,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
.colors(normal_btn) .colors(normal_btn)
.font(font_medium) .font(font_medium)
.tag(2).button( BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE)) .tag(2).button( BTN_POS(1,2), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE))
.tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXTF(UNLOCK_XY_AXIS)) .tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXTF(RELEASE_XY_AXIS))
.tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(BED_TEMPERATURE)) .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(BED_TEMPERATURE))
.tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(INTERFACE_SETTINGS)) .tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(INTERFACE_SETTINGS))
.tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(ADVANCED_SETTINGS)) .tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(ADVANCED_SETTINGS))

View File

@ -37,9 +37,10 @@
#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0])) #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
const uint8_t shadow_depth = 5; const uint8_t shadow_depth = 5;
const float max_speed = 0.30; const float max_speed = 1.00;
const float min_speed = 0.05; const float min_speed = 0.02;
const uint8_t num_speeds = 10; const float emax_speed = 2.00;
const float emin_speed = 0.70;
using namespace FTDI; using namespace FTDI;
using namespace Theme; using namespace Theme;
@ -251,7 +252,7 @@ void StatusScreen::onRedraw(draw_mode_t what) {
} }
bool StatusScreen::onTouchStart(uint8_t) { bool StatusScreen::onTouchStart(uint8_t) {
increment = min_speed; increment = 0;
return true; return true;
} }
@ -288,7 +289,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
bool StatusScreen::onTouchHeld(uint8_t tag) { bool StatusScreen::onTouchHeld(uint8_t tag) {
if (tag >= 1 && tag <= 4 && !jog_xy) return false; if (tag >= 1 && tag <= 4 && !jog_xy) return false;
const float s = fine_motion ? min_speed : increment; const float s = min_speed + (fine_motion ? 0 : (max_speed - min_speed) * sq(increment));
switch (tag) { switch (tag) {
case 1: jog(-s, 0, 0); break; case 1: jog(-s, 0, 0); break;
case 2: jog( s, 0, 0); break; case 2: jog( s, 0, 0); break;
@ -297,22 +298,20 @@ bool StatusScreen::onTouchHeld(uint8_t tag) {
case 5: jog( 0, 0, -s); break; case 5: jog( 0, 0, -s); break;
case 6: jog( 0, 0, s); break; case 6: jog( 0, 0, s); break;
case 7: case 7:
case 8:
{
if (ExtUI::isMoving()) return false; if (ExtUI::isMoving()) return false;
MoveAxisScreen::setManualFeedrate(E0, 1); const float feedrate = emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));
const float increment = 0.25 * feedrate * (tag == 7 ? -1 : 1);
MoveAxisScreen::setManualFeedrate(E0, feedrate);
UI_INCREMENT(AxisPosition_mm, E0); UI_INCREMENT(AxisPosition_mm, E0);
current_screen.onRefresh(); current_screen.onRefresh();
break; break;
case 8: }
if (ExtUI::isMoving()) return false;
MoveAxisScreen::setManualFeedrate(E0, 1);
UI_DECREMENT(AxisPosition_mm, E0);
current_screen.onRefresh();
break;
default: default:
return false; return false;
} }
if (increment < max_speed) increment = min(1.0f, increment + 0.1f);
increment += (max_speed - min_speed) / num_speeds;
return false; return false;
} }
@ -325,11 +324,11 @@ void StatusScreen::setStatusMessage(const char * const str) {
} }
void StatusScreen::onIdle() { void StatusScreen::onIdle() {
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
if (!EventLoop::is_touch_held())
onRefresh();
if (isPrintingFromMedia()) if (isPrintingFromMedia())
BioPrintingDialogBox::show(); BioPrintingDialogBox::show();
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start(); refresh_timer.start();
} }
} }

View File

@ -56,7 +56,7 @@ void TuneMenu::onRedraw(draw_mode_t what) {
#endif #endif
.tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(NUDGE_NOZZLE)) .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), GET_TEXTF(NUDGE_NOZZLE))
.enabled(!isPrinting()).tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE)) .enabled(!isPrinting()).tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), GET_TEXTF(LOAD_SYRINGE))
.enabled(!isPrinting()).tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(UNLOCK_XY_AXIS)) .enabled(!isPrinting()).tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(RELEASE_XY_AXIS))
.colors(action_btn) .tag(1).button( BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXTF(BACK)); .colors(action_btn) .tag(1).button( BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXTF(BACK));
} }
#undef GRID_COLS #undef GRID_COLS

View File

@ -48,28 +48,29 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) {
w.units(GET_TEXTF(UNITS_MM)); w.units(GET_TEXTF(UNITS_MM));
w.heading( GET_TEXTF(MOVE_AXIS)); w.heading( GET_TEXTF(MOVE_AXIS));
w.home_buttons(20); w.home_buttons(20);
w.color(Theme::x_axis ) .adjuster( 2, GET_TEXTF(AXIS_X), getAxisPosition_mm(X), canMove(X)); w.color(Theme::x_axis).adjuster( 2, GET_TEXTF(AXIS_X), getAxisPosition_mm(X), canMove(X));
w.color(Theme::y_axis ) .adjuster( 4, GET_TEXTF(AXIS_Y), getAxisPosition_mm(Y), canMove(Y)); w.color(Theme::y_axis).adjuster( 4, GET_TEXTF(AXIS_Y), getAxisPosition_mm(Y), canMove(Y));
w.color(Theme::z_axis ) .adjuster( 6, GET_TEXTF(AXIS_Z), getAxisPosition_mm(Z), canMove(Z)); w.color(Theme::z_axis).adjuster( 6, GET_TEXTF(AXIS_Z), getAxisPosition_mm(Z), canMove(Z));
w.color(Theme::e_axis);
#if EXTRUDERS == 1 #if EXTRUDERS == 1
w.color(Theme::e_axis) .adjuster( 8, GET_TEXTF(AXIS_E), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); w.adjuster( 8, GET_TEXTF(AXIS_E), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
#elif EXTRUDERS > 1 #elif EXTRUDERS > 1
w.color(Theme::e_axis) .adjuster( 8, GET_TEXTF(AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); w.adjuster( 8, GET_TEXTF(AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
w.color(Theme::e_axis) .adjuster( 10, GET_TEXTF(AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1)); w.adjuster( 10, GET_TEXTF(AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1));
#if EXTRUDERS > 2 #if EXTRUDERS > 2
w.color(Theme::e_axis) .adjuster( 12, GET_TEXTF(AXIS_E3), screen_data.MoveAxisScreen.e_rel[2], canMove(E2)); w.adjuster( 12, GET_TEXTF(AXIS_E3), screen_data.MoveAxisScreen.e_rel[2], canMove(E2));
#endif #endif
#if EXTRUDERS > 3 #if EXTRUDERS > 3
w.color(Theme::e_axis) .adjuster( 14, GET_TEXTF(AXIS_E4), screen_data.MoveAxisScreen.e_rel[3], canMove(E3)); w.adjuster( 14, GET_TEXTF(AXIS_E4), screen_data.MoveAxisScreen.e_rel[3], canMove(E3));
#endif #endif
#endif #endif
w.increments(); w.increments();
} }
bool MoveAxisScreen::onTouchHeld(uint8_t tag) { bool MoveAxisScreen::onTouchHeld(uint8_t tag) {
#define UI_INCREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis); #define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis);
#define UI_DECREMENT_AXIS(axis) setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis); #define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis);
const float increment = getIncrement(); const float increment = getIncrement();
switch (tag) { switch (tag) {
case 2: UI_DECREMENT_AXIS(X); break; case 2: UI_DECREMENT_AXIS(X); break;
@ -93,10 +94,10 @@ bool MoveAxisScreen::onTouchHeld(uint8_t tag) {
case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] -= increment; break; case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] -= increment; break;
case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] += increment; break; case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxisScreen.e_rel[3] += increment; break;
#endif #endif
case 20: injectCommands_P(PSTR("G28 X")); break; case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28 X")); break;
case 21: injectCommands_P(PSTR("G28 Y")); break; case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28 Y")); break;
case 22: injectCommands_P(PSTR("G28 Z")); break; case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
case 23: injectCommands_P(PSTR("G28")); break; case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break;
default: default:
return false; return false;
} }
@ -109,9 +110,9 @@ float MoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
// Compute feedrate so that the tool lags the adjuster when it is // Compute feedrate so that the tool lags the adjuster when it is
// being held down, this allows enough margin for the planner to // being held down, this allows enough margin for the planner to
// connect segments and even out the motion. // connect segments and even out the motion.
constexpr float max_manual_feedrate[XYZE] = MAX_MANUAL_FEEDRATE; constexpr float manual_feedrate[XYZE] = MANUAL_FEEDRATE;
return min(max_manual_feedrate[axis]/60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80)); return min(manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
return min(max_manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80)); return min(manual_feedrate[axis] / 60, abs(increment_mm * TOUCH_REPEATS_PER_SECOND * 0.80));
} }
void MoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) { void MoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) {

View File

@ -97,6 +97,8 @@ class BaseScreen : public UIScreen {
static uint32_t last_interaction; static uint32_t last_interaction;
#endif #endif
static bool buttonIsPressed(uint8_t tag);
public: public:
static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool); static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool);
@ -353,10 +355,18 @@ class BaseNumericAdjustmentScreen : public BaseScreen {
uint32_t _color; uint32_t _color;
uint8_t _decimals; uint8_t _decimals;
progmem_str _units; progmem_str _units;
enum style_t {
BTN_NORMAL,
BTN_ACTION,
BTN_TOGGLE,
BTN_DISABLED,
TEXT_AREA
} _style;
protected: protected:
void _draw_increment_btn(uint8_t line, const uint8_t tag); void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag);
void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str, bool enabled = true, bool highlight = false);
void _button_style(CommandProcessor &cmd, style_t style);
public: public:
widgets_t(draw_mode_t); widgets_t(draw_mode_t);