ソースを参照

Touch-to-jog on edit screens (#18266)

Victor 4年前
コミット
1d504e596d
コミッターのメールアドレスに関連付けられたアカウントが存在しません
3個のファイルの変更16行の追加9行の削除
  1. 3
    3
      Marlin/src/lcd/menu/menu.cpp
  2. 12
    6
      Marlin/src/lcd/ultralcd.cpp
  3. 1
    0
      Marlin/src/lcd/ultralcd.h

+ 3
- 3
Marlin/src/lcd/menu/menu.cpp ファイルの表示

@@ -84,9 +84,8 @@ void MarlinUI::save_previous_screen() {
84 84
 }
85 85
 
86 86
 void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
87
-  #if DISABLED(TURBO_BACK_MENU_ITEM)
88
-    constexpr bool is_back = false;
89
-  #endif
87
+  TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false);
88
+  TERN_(TOUCH_BUTTONS, on_edit_screen = false);
90 89
   if (screen_history_depth > 0) {
91 90
     menuPosition &sh = screen_history[--screen_history_depth];
92 91
     goto_screen(sh.menu_function,
@@ -155,6 +154,7 @@ void MenuEditItemBase::goto_edit_screen(
155 154
   const screenFunc_t cb,  // Callback after edit
156 155
   const bool le           // Flag to call cb() during editing
157 156
 ) {
157
+  TERN_(TOUCH_BUTTONS, ui.on_edit_screen = true);
158 158
   ui.screen_changed = true;
159 159
   ui.save_previous_screen();
160 160
   ui.refresh();

+ 12
- 6
Marlin/src/lcd/ultralcd.cpp ファイルの表示

@@ -119,6 +119,7 @@ MarlinUI ui;
119 119
   #endif
120 120
   #if ENABLED(TOUCH_BUTTONS)
121 121
     #include "../feature/touch/xpt2046.h"
122
+    bool MarlinUI::on_edit_screen = false;
122 123
   #endif
123 124
 #endif
124 125
 
@@ -1445,18 +1446,23 @@ void MarlinUI::update() {
1445 1446
     //  - On menu screens move directly to the touched item
1446 1447
     //  - On menu screens, right side (last 3 cols) acts like a scroll - half up => prev page, half down = next page
1447 1448
     //  - On select screens (and others) touch the Right Half for +, Left Half for -
1449
+    //  - On edit screens, touch Up Half for -,  Bottom Half to +
1448 1450
     //
1449
-    void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y) {
1450
-      if (screen_items > 0) {
1451
-        //last 3 cols act as a scroll :-)
1451
+    void MarlinUI::screen_click(const uint8_t row, const uint8_t col, const uint8_t, const uint8_t) {
1452
+      const int8_t xdir = col < (LCD_WIDTH ) / 2 ? -1 : 1,
1453
+                   ydir = row < (LCD_HEIGHT) / 2 ? -1 : 1;
1454
+      if (on_edit_screen)
1455
+        encoderDiff = ENCODER_PULSES_PER_STEP * ydir;
1456
+      else if (screen_items > 0) {
1457
+        // Last 3 cols act as a scroll :-)
1452 1458
         if (col > (LCD_WIDTH) - 3)
1453
-          //2 * LCD_HEIGHT to scroll to bottom of next page. If we did 1 * LCD_HEIGHT, it just go 1 item down
1454
-          encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * (row < (LCD_HEIGHT) / 2 ? -1 : 1);
1459
+          // 2 * LCD_HEIGHT to scroll to bottom of next page. (LCD_HEIGHT would only go 1 item down.)
1460
+          encoderDiff = ENCODER_PULSES_PER_STEP * (encoderLine - encoderTopLine + 2 * (LCD_HEIGHT)) * ydir;
1455 1461
         else
1456 1462
           encoderDiff = ENCODER_PULSES_PER_STEP * (row - encoderPosition + encoderTopLine);
1457 1463
       }
1458 1464
       else if (!on_status_screen())
1459
-        encoderDiff = ENCODER_PULSES_PER_STEP * (col < (LCD_WIDTH) / 2 ? -1 : 1);
1465
+        encoderDiff = ENCODER_PULSES_PER_STEP * xdir;
1460 1466
     }
1461 1467
 
1462 1468
   #endif

+ 1
- 0
Marlin/src/lcd/ultralcd.h ファイルの表示

@@ -418,6 +418,7 @@ public:
418 418
       #endif
419 419
 
420 420
       #if ENABLED(TOUCH_BUTTONS)
421
+        static bool on_edit_screen;
421 422
         static void screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y);
422 423
       #endif
423 424
 

読み込み中…
キャンセル
保存