From 3ec5cd312beb3077b661129144e214c83a232d69 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Tue, 13 Apr 2021 17:31:12 -0600 Subject: [PATCH] Enhance and fix FTDI Eve Touch UI (#21607) --- .../ftdi_eve_touch_ui/language/language_en.h | 1 + .../screens/bed_mesh_edit_screen.cpp | 20 ++++++-- .../screens/bed_mesh_edit_screen.h | 3 +- .../screens/bed_mesh_view_screen.cpp | 4 +- .../screens/move_axis_screen.cpp | 11 ++++- .../screens/move_axis_screen.h | 1 + .../ftdi_eve_touch_ui/screens/screen_data.h | 1 + .../screens/status_screen.cpp | 4 +- .../screens/z_offset_screen.cpp | 46 ++++++++++++++++++- .../screens/z_offset_screen.h | 8 ++++ 10 files changed, 86 insertions(+), 13 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index c34d5b775..9de9623e1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -147,6 +147,7 @@ namespace Language_en { PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh"; PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test"; + PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home"; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp index 01d4d1428..94e43bdec 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp @@ -30,7 +30,7 @@ using namespace Theme; using namespace ExtUI; constexpr static BedMeshEditScreenData &mydata = screen_data.BedMeshEditScreen; -constexpr static float gaugeThickness = 0.25; +constexpr static float gaugeThickness = 0.1; #if ENABLED(TOUCH_UI_PORTRAIT) #define GRID_COLS 3 @@ -54,20 +54,29 @@ constexpr static float gaugeThickness = 0.25; #define SAVE_POS BTN_POS(5,5), BTN_SIZE(1,1) #endif +constexpr uint8_t NONE = 255; + static float meshGetter(uint8_t x, uint8_t y, void*) { xy_uint8_t pos; pos.x = x; pos.y = y; - return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != -1 && mydata.highlight == pos ? mydata.zAdjustment : 0); + return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != NONE && mydata.highlight == pos ? mydata.zAdjustment : 0); } void BedMeshEditScreen::onEntry() { mydata.needSave = false; - mydata.highlight.x = -1; + mydata.highlight.x = NONE; mydata.zAdjustment = 0; + mydata.savedMeshLevelingState = ExtUI::getLevelingActive(); + mydata.savedEndstopState = ExtUI::getSoftEndstopState(); BaseScreen::onEntry(); } +void BedMeshEditScreen::onExit() { + ExtUI::setLevelingActive(mydata.savedMeshLevelingState); + ExtUI::setSoftEndstopState(mydata.savedEndstopState); +} + float BedMeshEditScreen::getHighlightedValue() { const float val = ExtUI::getMeshPoint(mydata.highlight); return (ISNAN(val) ? 0 : val) + mydata.zAdjustment; @@ -80,12 +89,13 @@ void BedMeshEditScreen::setHighlightedValue(float value) { void BedMeshEditScreen::moveToHighlightedValue() { if (ExtUI::getMeshValid()) { ExtUI::setLevelingActive(true); + ExtUI::setSoftEndstopState(false); ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment); } } void BedMeshEditScreen::adjustHighlightedValue(float increment) { - if(mydata.highlight.x != -1) { + if (mydata.highlight.x != NONE) { mydata.zAdjustment += increment; moveToHighlightedValue(); mydata.needSave = true; @@ -114,7 +124,7 @@ void BedMeshEditScreen::drawHighlightedPointValue() { .colors(normal_btn) .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) .font(font_small); - if(mydata.highlight.x != -1) + if (mydata.highlight.x != NONE) draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3); cmd.colors(mydata.needSave ? normal_btn : action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK)) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h index 62121941b..b856b9b33 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h @@ -25,7 +25,7 @@ #define FTDI_BED_MESH_EDIT_SCREEN_CLASS BedMeshEditScreen struct BedMeshEditScreenData { - bool needSave; + bool needSave, savedMeshLevelingState, savedEndstopState; xy_uint8_t highlight; float zAdjustment; }; @@ -41,6 +41,7 @@ class BedMeshEditScreen : public BedMeshBase, public CachedScreen { + private: + static void move(float inc); + static void runWizard(); public: + static void onEntry(); static void onRedraw(draw_mode_t); static bool onTouchHeld(uint8_t tag); };