From 507e1e436e7f45078c61e79026d64c55598fd707 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Thu, 10 Jun 2021 02:17:39 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20and=20improve=20FTDI=20Eve?= =?UTF-8?q?=20Touch=20UI=20(#22093)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../archim2-flash/media_file_reader.cpp | 4 +--- .../ftdi_eve_lib/extended/text_box.cpp | 2 +- .../ftdi_eve_touch_ui/generic/about_screen.cpp | 8 ++++---- .../generic/bed_mesh_view_screen.cpp | 4 ++-- .../generic/z_offset_screen.cpp | 18 ++++++++++++------ .../generic/z_offset_screen.h | 2 +- .../ftdi_eve_touch_ui/language/language_en.h | 4 ++-- Marlin/src/lcd/extui/ui_api.cpp | 4 ++++ Marlin/src/lcd/extui/ui_api.h | 1 + 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp index ab6057970..ea8d40375 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp @@ -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); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index 6d53d00bb..9f73c7dfb 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -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 : diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index 8d8c54304..3d2c6a9e4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -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; @@ -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) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp index f5cf1cbb3..75b15828a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp @@ -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); @@ -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() { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp index 58cab4804..8d886c704 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp @@ -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() { @@ -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; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h index 159fd2383..067687f31 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h @@ -31,7 +31,7 @@ struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData { class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen { private: - static void move(float inc); + static void move(float mm, int16_t steps); static void runWizard(); public: static void onEntry(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h index 9de9623e1..4ac44501d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h @@ -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"; @@ -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!"; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index fff31f099..b0def618f 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -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() { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 560316962..9922fa679 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -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);