From af5cf823eaee255fbcc6b7a7c746a8e1a651cc02 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sat, 7 Nov 2020 06:00:29 -0300 Subject: [PATCH] Color UI single touch menu navigation (#20053) --- Marlin/Configuration.h | 4 ++++ Marlin/src/lcd/tft/touch.cpp | 5 ++++- Marlin/src/lcd/tft/ui_320x240.cpp | 5 ++++- Marlin/src/lcd/tft/ui_480x320.cpp | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1297c61aed..719e11b899 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2343,6 +2343,10 @@ //#define XPT2046_Y_CALIBRATION -8981 //#define XPT2046_X_OFFSET -43 //#define XPT2046_Y_OFFSET 257 + + #if ENABLED(TFT_COLOR_UI) + //#define SINGLE_TOUCH_NAVIGATION + #endif #endif // diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index cde9698024..adbc2923a4 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -206,7 +206,10 @@ void Touch::touch(touch_control_t *control) { case MENU_SCREEN: ui.goto_screen((screenFunc_t)control->data); break; case BACK: ui.goto_previous_screen(); break; - case CLICK: ui.lcd_clicked = true; break; + case CLICK: + TERN_(SINGLE_TOUCH_NAVIGATION, ui.encoderPosition = control->data); + ui.lcd_clicked = true; + break; #if HAS_RESUME_CONTINUE case RESUME_CONTINUE: extern bool wait_for_user; wait_for_user = false; break; #endif diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 4e2cd8acc4..999cec29ba 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -647,7 +647,10 @@ void menu_item(const uint8_t row, bool sel ) { #endif menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); - TERN_(TOUCH_SCREEN, touch.add_control(sel ? CLICK : MENU_ITEM, 0, 2 + 34 * row, 320, 32, encoderTopLine + row)); + #if ENABLED(TOUCH_SCREEN) + const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? CLICK : MENU_ITEM; + touch.add_control(tct, 0, 2 + 34 * row, 320, 32, encoderTopLine + row); + #endif } void MarlinUI::move_axis_screen() { diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 0c44a3151b..9ba5c1b157 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -652,7 +652,10 @@ void menu_item(const uint8_t row, bool sel ) { #endif menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); - TERN_(TOUCH_SCREEN, touch.add_control(sel ? CLICK : MENU_ITEM, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row)); + #if ENABLED(TOUCH_SCREEN) + const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? CLICK : MENU_ITEM; + touch.add_control(tct, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row); + #endif } #if ENABLED(BABYSTEP_ZPROBE_OFFSET)