Touch-to-jog on edit screens (#18266)
This commit is contained in:
parent
eef2931150
commit
1d504e596d
3 changed files with 16 additions and 9 deletions
|
@ -84,9 +84,8 @@ void MarlinUI::save_previous_screen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
|
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
|
||||||
#if DISABLED(TURBO_BACK_MENU_ITEM)
|
TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false);
|
||||||
constexpr bool is_back = false;
|
TERN_(TOUCH_BUTTONS, on_edit_screen = false);
|
||||||
#endif
|
|
||||||
if (screen_history_depth > 0) {
|
if (screen_history_depth > 0) {
|
||||||
menuPosition &sh = screen_history[--screen_history_depth];
|
menuPosition &sh = screen_history[--screen_history_depth];
|
||||||
goto_screen(sh.menu_function,
|
goto_screen(sh.menu_function,
|
||||||
|
@ -155,6 +154,7 @@ void MenuEditItemBase::goto_edit_screen(
|
||||||
const screenFunc_t cb, // Callback after edit
|
const screenFunc_t cb, // Callback after edit
|
||||||
const bool le // Flag to call cb() during editing
|
const bool le // Flag to call cb() during editing
|
||||||
) {
|
) {
|
||||||
|
TERN_(TOUCH_BUTTONS, ui.on_edit_screen = true);
|
||||||
ui.screen_changed = true;
|
ui.screen_changed = true;
|
||||||
ui.save_previous_screen();
|
ui.save_previous_screen();
|
||||||
ui.refresh();
|
ui.refresh();
|
||||||
|
|
|
@ -119,6 +119,7 @@ MarlinUI ui;
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(TOUCH_BUTTONS)
|
#if ENABLED(TOUCH_BUTTONS)
|
||||||
#include "../feature/touch/xpt2046.h"
|
#include "../feature/touch/xpt2046.h"
|
||||||
|
bool MarlinUI::on_edit_screen = false;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1445,18 +1446,23 @@ void MarlinUI::update() {
|
||||||
// - On menu screens move directly to the touched item
|
// - On menu screens move directly to the touched item
|
||||||
// - On menu screens, right side (last 3 cols) acts like a scroll - half up => prev page, half down = next page
|
// - On menu screens, right side (last 3 cols) acts like a scroll - half up => prev page, half down = next page
|
||||||
// - On select screens (and others) touch the Right Half for +, Left Half for -
|
// - On select screens (and others) touch the Right Half for +, Left Half for -
|
||||||
|
// - On edit screens, touch Up Half for -, Bottom Half to +
|
||||||
//
|
//
|
||||||
void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y) {
|
void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t, const uint8_t) {
|
||||||
if (screen_items > 0) {
|
const int8_t xdir = col < (LCD_WIDTH ) / 2 ? -1 : 1,
|
||||||
//last 3 cols act as a scroll :-)
|
ydir = row < (LCD_HEIGHT) / 2 ? -1 : 1;
|
||||||
|
if (on_edit_screen)
|
||||||
|
encoderDiff = ENCODER_PULSES_PER_STEP * ydir;
|
||||||
|
else if (screen_items > 0) {
|
||||||
|
// Last 3 cols act as a scroll :-)
|
||||||
if (col > (LCD_WIDTH) - 3)
|
if (col > (LCD_WIDTH) - 3)
|
||||||
//2 * LCD_HEIGHT to scroll to bottom of next page. If we did 1 * LCD_HEIGHT, it just go 1 item down
|
// 2 * LCD_HEIGHT to scroll to bottom of next page. (LCD_HEIGHT would only go 1 item down.)
|
||||||
encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * (row < (LCD_HEIGHT) / 2 ? -1 : 1);
|
encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * ydir;
|
||||||
else
|
else
|
||||||
encoderDiff = ENCODER_PULSES_PER_STEP * (row - encoderPosition + encoderTopLine);
|
encoderDiff = ENCODER_PULSES_PER_STEP * (row - encoderPosition + encoderTopLine);
|
||||||
}
|
}
|
||||||
else if (!on_status_screen())
|
else if (!on_status_screen())
|
||||||
encoderDiff = ENCODER_PULSES_PER_STEP * (col < (LCD_WIDTH) / 2 ? -1 : 1);
|
encoderDiff = ENCODER_PULSES_PER_STEP * xdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -418,6 +418,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(TOUCH_BUTTONS)
|
#if ENABLED(TOUCH_BUTTONS)
|
||||||
|
static bool on_edit_screen;
|
||||||
static void screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y);
|
static void screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Reference in a new issue