Selaa lähdekoodia

Faster menu navigation for Anet A8

Addressing #8166
Scott Lahteine 7 vuotta sitten
vanhempi
commit
704640bf98
1 muutettua tiedostoa jossa 11 lisäystä ja 8 poistoa
  1. 11
    8
      Marlin/ultralcd.cpp

+ 11
- 8
Marlin/ultralcd.cpp Näytä tiedosto

4337
   #if ENABLED(ADC_KEYPAD)
4337
   #if ENABLED(ADC_KEYPAD)
4338
 
4338
 
4339
     inline bool handle_adc_keypad() {
4339
     inline bool handle_adc_keypad() {
4340
+      #define ADC_MIN_KEY_DELAY 100
4340
       static uint8_t adc_steps = 0;
4341
       static uint8_t adc_steps = 0;
4341
       if (buttons_reprapworld_keypad) {
4342
       if (buttons_reprapworld_keypad) {
4342
         if (adc_steps < 20) ++adc_steps;
4343
         if (adc_steps < 20) ++adc_steps;
4343
-        lcd_quick_feedback();
4344
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4344
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4345
         if (encoderDirection == -1) { // side effect which signals we are inside a menu
4345
         if (encoderDirection == -1) { // side effect which signals we are inside a menu
4346
           if      (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
4346
           if      (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
4347
           else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
4347
           else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
4348
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)  menu_action_back();
4349
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) lcd_return_to_status();
4348
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)  { menu_action_back(); lcd_quick_feedback(); }
4349
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) { lcd_return_to_status(); lcd_quick_feedback(); }
4350
         }
4350
         }
4351
         else {
4351
         else {
4352
-          const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1;
4353
-               if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition += ENCODER_PULSES_PER_STEP * step;
4354
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition -= ENCODER_PULSES_PER_STEP * step;
4355
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0;
4352
+          if (buttons_reprapworld_keypad & (EN_REPRAPWORLD_KEYPAD_DOWN|EN_REPRAPWORLD_KEYPAD_UP|EN_REPRAPWORLD_KEYPAD_RIGHT)) {
4353
+            const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1;
4354
+                 if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition += ENCODER_PULSES_PER_STEP * step;
4355
+            else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition -= ENCODER_PULSES_PER_STEP * step;
4356
+            else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0;
4357
+          }
4356
         }
4358
         }
4357
         #if ENABLED(ADC_KEYPAD_DEBUG)
4359
         #if ENABLED(ADC_KEYPAD_DEBUG)
4358
           SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
4360
           SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
4359
           SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
4361
           SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
4360
         #endif
4362
         #endif
4363
+        next_button_update_ms = millis() + ADC_MIN_KEY_DELAY;
4361
         return true;
4364
         return true;
4362
       }
4365
       }
4363
       else if (!thermalManager.current_ADCKey_raw)
4366
       else if (!thermalManager.current_ADCKey_raw)
4672
 
4675
 
4673
       #endif
4676
       #endif
4674
 
4677
 
4675
-      bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
4678
+      const bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
4676
       if (encoderPastThreshold || lcd_clicked) {
4679
       if (encoderPastThreshold || lcd_clicked) {
4677
         if (encoderPastThreshold) {
4680
         if (encoderPastThreshold) {
4678
           int32_t encoderMultiplier = 1;
4681
           int32_t encoderMultiplier = 1;

Loading…
Peruuta
Tallenna