Touch-to-jog on edit screens (#18266)
This commit is contained in:
parent
eef2931150
commit
1d504e596d
@ -84,9 +84,8 @@ void MarlinUI::save_previous_screen() {
|
||||
}
|
||||
|
||||
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
|
||||
#if DISABLED(TURBO_BACK_MENU_ITEM)
|
||||
constexpr bool is_back = false;
|
||||
#endif
|
||||
TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false);
|
||||
TERN_(TOUCH_BUTTONS, on_edit_screen = false);
|
||||
if (screen_history_depth > 0) {
|
||||
menuPosition &sh = screen_history[--screen_history_depth];
|
||||
goto_screen(sh.menu_function,
|
||||
@ -155,6 +154,7 @@ void MenuEditItemBase::goto_edit_screen(
|
||||
const screenFunc_t cb, // Callback after edit
|
||||
const bool le // Flag to call cb() during editing
|
||||
) {
|
||||
TERN_(TOUCH_BUTTONS, ui.on_edit_screen = true);
|
||||
ui.screen_changed = true;
|
||||
ui.save_previous_screen();
|
||||
ui.refresh();
|
||||
|
@ -119,6 +119,7 @@ MarlinUI ui;
|
||||
#endif
|
||||
#if ENABLED(TOUCH_BUTTONS)
|
||||
#include "../feature/touch/xpt2046.h"
|
||||
bool MarlinUI::on_edit_screen = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1445,18 +1446,23 @@ void MarlinUI::update() {
|
||||
// - 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 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) {
|
||||
if (screen_items > 0) {
|
||||
//last 3 cols act as a scroll :-)
|
||||
void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t, const uint8_t) {
|
||||
const int8_t xdir = col < (LCD_WIDTH ) / 2 ? -1 : 1,
|
||||
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)
|
||||
//2 * LCD_HEIGHT to scroll to bottom of next page. If we did 1 * LCD_HEIGHT, it just go 1 item down
|
||||
encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * (row < (LCD_HEIGHT) / 2 ? -1 : 1);
|
||||
// 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)) * ydir;
|
||||
else
|
||||
encoderDiff = ENCODER_PULSES_PER_STEP * (row - encoderPosition + encoderTopLine);
|
||||
}
|
||||
else if (!on_status_screen())
|
||||
encoderDiff = ENCODER_PULSES_PER_STEP * (col < (LCD_WIDTH) / 2 ? -1 : 1);
|
||||
encoderDiff = ENCODER_PULSES_PER_STEP * xdir;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -418,6 +418,7 @@ public:
|
||||
#endif
|
||||
|
||||
#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);
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user