Skip to content

Commit

Permalink
🐛 Fix and improve FTDI Eve Touch UI (#22361, #22439, #22459, #22468, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and thinkyhead committed Aug 9, 2021
1 parent 3924545 commit 166324f
Show file tree
Hide file tree
Showing 45 changed files with 175 additions and 168 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LINUX/hardware/Gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct GpioEvent {
pin_type pin_id;
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->pin_id = pin_id;
this->event = event;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LINUX/hardware/LinearAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void LinearAxis::update() {
}

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) {
last_update = ev.timestamp;
position += -1 + 2 * Gpio::pin_map[dir_pin].value;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LINUX/hardware/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Timer {
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;
_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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.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_ROWS
}
Expand Down
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(F(
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(F(
SpinnerDialogBox::enqueueAndWait(F(
"G28\n"
PARK_AND_RELEASE_COMMANDS
));
Expand Down
20 changes: 10 additions & 10 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 @@ -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(9).button(BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_INFO_MENU))
.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
Expand All @@ -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 ? F("G0 E0 F120") : F("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(F(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(F("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 @@ -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(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))
.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_ROWS
Expand All @@ -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(F("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 @@ -67,7 +67,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU))
.tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void LevelingMenu::onRedraw(draw_mode_t what) {
#undef GRID_COLS
#define GRID_COLS 3
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}

Expand All @@ -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(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;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void MainMenu::onRedraw(draw_mode_t what) {
.tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING))
.tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU))
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void PreheatMenu::onRedraw(draw_mode_t what) {
}
#endif
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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void PreheatTimerScreen::draw_interaction_buttons(draw_mode_t what) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(font_medium)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ enum {
#include "../generic/display_tuning_screen.h"
#include "../generic/statistics_screen.h"
#include "../generic/stepper_current_screen.h"
#include "../generic/leveling_menu.h"
#include "../generic/z_offset_screen.h"
#include "../generic/bed_mesh_base.h"
#include "../generic/bed_mesh_view_screen.h"
Expand All @@ -130,5 +129,6 @@ enum {
#include "preheat_menu.h"
#include "preheat_screen.h"
#include "load_chocolate.h"
#include "leveling_menu.h"
#include "move_xyz_screen.h"
#include "move_e_screen.h"
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(F("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 @@ -42,7 +42,7 @@ namespace FTDI {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
CLCD::FontMetrics fm(_font);
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,
// so we must introduce a fudge factor based on the line height to
// actually center the control.
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);
return *this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ namespace FTDI {
width = height = 0;
for (;;) {
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);
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;
if (*line_start == '\n' || *line_start == ' ') line_start++;
if (*line_start == '\0') break;
}
}

Expand Down Expand Up @@ -109,7 +109,6 @@ namespace FTDI {
const char *line_start = str, *line_end;
for (;;) {
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;
if (line_len) {
Expand All @@ -125,9 +124,10 @@ namespace FTDI {
}
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;
if (*line_start == '\n' || *line_start == ' ') line_start++;
if (*line_start == '\0') break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
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);
const int16_t ellipsisWidth = fm.get_char_width('.') * 3;
#if ENABLED(TOUCH_UI_USE_UTF8)
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
// the location in the string where it can
// split and still allow the ellipsis to fit.
int16_t lineWidth = 0;
char *breakPoint = str;
#ifdef TOUCH_UI_USE_UTF8
char *tstr = str;
while (*tstr) {
breakPoint = tstr;
const utf8_char_t c = get_utf8_char_and_inc(tstr);
lineWidth += fm.get_char_width(c);
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
char *breakPoint = str;
char *next = str;
while (*next) {
const utf8_char_t c = get_utf8_char_and_inc(next);
lineWidth += CHAR_WIDTH(c);
if (lineWidth + ellipsisWidth < w)
breakPoint = next;
}

if (lineWidth > w) {
*breakPoint = '\0';
Expand All @@ -61,7 +61,7 @@ namespace FTDI {

cmd.apply_text_alignment(x, y, w, h, options);
#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);
} else
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@

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

utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) {
utf8_char_t val = *(uint8_t*)c++;
while ((*c & 0xC0) == 0x80)
val = (val << 8) | *(uint8_t*)c++;
if ((val & 0xC0) == 0xC0)
while ((*c & 0xC0) == 0x80)
val = (val << 8) | *(uint8_t*)c++;
return val;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void AboutScreen::onRedraw(draw_mode_t) {
.tag(2).button(STATS_POS, GET_TEXT_F(MSG_INFO_STATS_MENU));
#endif
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.enabled(ENABLED(BACKLASH_GCODE))
.tag(8).button(BACKLASH_POS, GET_TEXT_F(MSG_BACKLASH))
.colors(action_btn)
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ void AlertDialogBox::onRedraw(draw_mode_t what) {
}

template<typename T>
void AlertDialogBox::show(const T message) {
void AlertDialogBox::show(T message) {
drawMessage(message);
storeBackground();
mydata.isError = false;
GOTO_SCREEN(AlertDialogBox);
}

template<typename T>
void AlertDialogBox::showError(const T message) {
void AlertDialogBox::showError(T message) {
drawMessage(message);
storeBackground();
mydata.isError = true;
Expand All @@ -64,8 +64,8 @@ void AlertDialogBox::hide() {
}

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 progmem_str);
template void AlertDialogBox::showError(progmem_str);

#endif // FTDI_ALERT_DIALOG_BOX
Loading

0 comments on commit 166324f

Please sign in to comment.