Skip to content

Commit

Permalink
🎨 Fix and improve FTDI Eve Touch UI (#22093)
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and thinkyhead committed Jun 15, 2021
1 parent b27447e commit 507e1e4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@

#if ENABLED(SDSUPPORT)
bool MediaFileReader::open(const char *filename) {
card.init(SD_SPI_SPEED, SDSS);
volume.init(&card);
root.openRoot(&volume);
root = CardReader::getroot();
return file.open(&root, filename, O_READ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace FTDI {
box_width = w;
measure_text_box(fm, str, box_width, box_height);
if (box_width <= (uint16_t)w && box_height <= (uint16_t)h) break;
fm.load(--font);
if (font == 26) break;
fm.load(--font);
}

const uint16_t dx = (options & OPT_RIGHTX) ? w :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifdef FTDI_ABOUT_SCREEN

#define GRID_COLS 4
#define GRID_ROWS 7
#define GRID_ROWS 8

using namespace FTDI;
using namespace Theme;
Expand All @@ -47,9 +47,9 @@ void AboutScreen::onRedraw(draw_mode_t) {
#define HEADING_POS BTN_POS(1,2), BTN_SIZE(4,1)
#define FW_VERS_POS BTN_POS(1,3), BTN_SIZE(4,1)
#define FW_INFO_POS BTN_POS(1,4), BTN_SIZE(4,1)
#define LICENSE_POS BTN_POS(1,5), BTN_SIZE(4,2)
#define STATS_POS BTN_POS(1,7), BTN_SIZE(2,1)
#define BACK_POS BTN_POS(3,7), BTN_SIZE(2,1)
#define LICENSE_POS BTN_POS(1,5), BTN_SIZE(4,3)
#define STATS_POS BTN_POS(1,8), BTN_SIZE(2,1)
#define BACK_POS BTN_POS(3,8), BTN_SIZE(2,1)

#define _INSET_POS(x,y,w,h) x + w/10, y, w - w/5, h
#define INSET_POS(pos) _INSET_POS(pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void BedMeshViewScreen::onEntry() {
void BedMeshViewScreen::drawHighlightedPointValue() {
CommandProcessor cmd;
cmd.font(Theme::font_medium)
.colors(normal_btn)
.cmd(COLOR_RGB(bg_text_enabled))
.text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
.font(font_small);

Expand Down Expand Up @@ -161,7 +161,7 @@ void BedMeshViewScreen::doProbe() {
void BedMeshViewScreen::doMeshValidation() {
mydata.count = 0;
GOTO_SCREEN(StatusScreen);
injectCommands_P(PSTR("G28 O\nM117 Heating...\nG26 R X0 Y0"));
injectCommands_P(PSTR("M75\nG28 O\nM117 Heating...\nG26 R X0 Y0\nG27\nM77"));
}

void BedMeshViewScreen::show() {
Expand Down
18 changes: 12 additions & 6 deletions Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
w.heading( GET_TEXT_F(MSG_ZPROBE_ZOFFSET));
w.color(z_axis).adjuster(4, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), getZOffset_mm());
w.increments();
w.button( 2, GET_TEXT_F(MSG_PROBE_WIZARD));
w.button(2, GET_TEXT_F(MSG_PROBE_WIZARD), !isPrinting());
}

void ZOffsetScreen::move(float inc) {
void ZOffsetScreen::move(float mm, int16_t steps) {
// We can't store state after the call to the AlertBox, so
// check whether the current position equal mydata.z in order
// to know whether the user started the wizard.
if (getAxisPosition_mm(Z) == mydata.z) {
mydata.z += inc;
// In the wizard
mydata.z += mm;
setAxisPosition_mm(mydata.z, Z);
}
else {
// Otherwise doing a manual adjustment, possibly during a print.
babystepAxis_steps(steps, Z);
}
}

void ZOffsetScreen::runWizard() {
Expand All @@ -80,11 +85,12 @@ void ZOffsetScreen::runWizard() {
}

bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
const float increment = getIncrement();
const int16_t steps = mmToWholeSteps(getIncrement(), Z);
const float increment = mmFromWholeSteps(steps, Z);
switch (tag) {
case 2: runWizard(); break;
case 4: UI_DECREMENT(ZOffset_mm); move(-increment); break;
case 5: UI_INCREMENT(ZOffset_mm); move( increment); break;
case 4: UI_DECREMENT(ZOffset_mm); move(-increment, -steps); break;
case 5: UI_INCREMENT(ZOffset_mm); move( increment, steps); break;
default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData {

class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ZOFFSET_SCREEN_CACHE> {
private:
static void move(float inc);
static void move(float mm, int16_t steps);
static void runWizard();
public:
static void onEntry();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_ABOUT_TOUCH_PANEL_2 = WEBSITE_URL;
PROGMEM Language_Str MSG_LICENSE = u8"This program is free software: you can redistribute it and/or modify it under the terms of "
"the GNU General Public License as published by the Free Software Foundation, either version 3 "
"of the License, or (at your option) any later version.\n\nTo view a copy of the GNU General "
"of the License, or (at your option) any later version. To view a copy of the GNU General "
"Public License, go to the following location: https://www.gnu.org/licenses.";
PROGMEM Language_Str MSG_RUNOUT_1 = u8"Runout 1";
PROGMEM Language_Str MSG_RUNOUT_2 = u8"Runout 2";
Expand Down Expand Up @@ -130,7 +130,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_EEPROM_RESTORED = u8"Settings restored from backup";
PROGMEM Language_Str MSG_EEPROM_RESET = u8"Settings restored to default";
PROGMEM Language_Str MSG_EEPROM_SAVED = u8"Settings saved!";
PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Do you wish to save these settings as defaults?";
PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Do you wish to save these settings for next power-on?";
PROGMEM Language_Str MSG_EEPROM_RESET_WARNING = u8"Are you sure? Customizations will be lost.";

PROGMEM Language_Str MSG_PASSCODE_REJECTED = u8"Wrong passcode!";
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ namespace ExtUI {
return steps > 0 ? CEIL(steps) : FLOOR(steps);
}

float mmFromWholeSteps(int16_t steps, const axis_t axis) {
return steps * planner.steps_to_mm[axis];
}

#endif // BABYSTEPPING

float getZOffset_mm() {
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/ui_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ namespace ExtUI {

#if ENABLED(BABYSTEPPING)
int16_t mmToWholeSteps(const_float_t mm, const axis_t axis);
float mmFromWholeSteps(int16_t steps, const axis_t axis);

bool babystepAxis_steps(const int16_t steps, const axis_t axis);
void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles);
Expand Down

0 comments on commit 507e1e4

Please sign in to comment.