Pārlūkot izejas kodu

Touch Buttons variable repeat delay (#15236)

Robby Candra 5 gadus atpakaļ
vecāks
revīzija
3f129b6574

+ 7
- 0
Marlin/src/lcd/menu/menu.cpp Parādīt failu

@@ -143,6 +143,9 @@ void MenuItem_gcode::action(PGM_P const pgcode) { queue.inject_P(pgcode); }
143 143
  *       MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
144 144
  */
145 145
 void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
146
+  #if ENABLED(TOUCH_BUTTONS)
147
+    ui.repeat_delay = 50;
148
+  #endif
146 149
   if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
147 150
   if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
148 151
   if (ui.should_draw())
@@ -212,6 +215,10 @@ bool printer_busy() {
212 215
 void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
213 216
   if (currentScreen != screen) {
214 217
 
218
+    #if ENABLED(TOUCH_BUTTONS)
219
+      repeat_delay = 250;
220
+    #endif
221
+
215 222
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
216 223
       // Shadow for editing the fade height
217 224
       lcd_z_fade_height = planner.z_fade_height;

+ 5
- 1
Marlin/src/lcd/ultralcd.cpp Parādīt failu

@@ -195,6 +195,10 @@ millis_t MarlinUI::next_button_update_ms; // = 0
195 195
     int8_t MarlinUI::encoderDirection = ENCODERBASE;
196 196
   #endif
197 197
 
198
+  #if ENABLED(TOUCH_BUTTONS)
199
+    uint8_t MarlinUI::repeat_delay;
200
+  #endif
201
+
198 202
   bool MarlinUI::lcd_clicked;
199 203
   float move_menu_scale;
200 204
 
@@ -792,7 +796,7 @@ void MarlinUI::update() {
792 796
           if (touch_buttons & (EN_A | EN_B)) {          // A and/or B button?
793 797
             encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP) * encoderDirection;
794 798
             if (touch_buttons & EN_A) encoderDiff *= -1;
795
-            next_button_update_ms = ms + 50;            // Assume the repeat delay
799
+            next_button_update_ms = ms + repeat_delay;  // Assume the repeat delay
796 800
             if (!wait_for_unclick && !arrow_pressed) {  // On click prepare for repeat
797 801
               next_button_update_ms += 250;             // Longer delay on first press
798 802
               arrow_pressed = true;                     // Mark arrow as pressed

+ 4
- 0
Marlin/src/lcd/ultralcd.h Parādīt failu

@@ -406,6 +406,10 @@ public:
406 406
 
407 407
   #if HAS_LCD_MENU
408 408
 
409
+    #if ENABLED(TOUCH_BUTTONS)
410
+      static uint8_t repeat_delay;
411
+    #endif
412
+
409 413
     #if ENABLED(ENCODER_RATE_MULTIPLIER)
410 414
       static bool encoderRateMultiplierEnabled;
411 415
       static millis_t lastEncoderMovementMillis;

Notiek ielāde…
Atcelt
Saglabāt