浏览代码

Touch Buttons variable repeat delay (#15236)

Robby Candra 5 年前
父节点
当前提交
3f129b6574
共有 3 个文件被更改,包括 16 次插入1 次删除
  1. 7
    0
      Marlin/src/lcd/menu/menu.cpp
  2. 5
    1
      Marlin/src/lcd/ultralcd.cpp
  3. 4
    0
      Marlin/src/lcd/ultralcd.h

+ 7
- 0
Marlin/src/lcd/menu/menu.cpp 查看文件

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

+ 5
- 1
Marlin/src/lcd/ultralcd.cpp 查看文件

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

+ 4
- 0
Marlin/src/lcd/ultralcd.h 查看文件

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

正在加载...
取消
保存