Przeglądaj źródła

Faster menu navigation for Anet A8

Addressing #8166
Scott Lahteine 7 lat temu
rodzic
commit
704640bf98
1 zmienionych plików z 11 dodań i 8 usunięć
  1. 11
    8
      Marlin/ultralcd.cpp

+ 11
- 8
Marlin/ultralcd.cpp Wyświetl plik

@@ -4337,27 +4337,30 @@ void kill_screen(const char* lcd_msg) {
4337 4337
   #if ENABLED(ADC_KEYPAD)
4338 4338
 
4339 4339
     inline bool handle_adc_keypad() {
4340
+      #define ADC_MIN_KEY_DELAY 100
4340 4341
       static uint8_t adc_steps = 0;
4341 4342
       if (buttons_reprapworld_keypad) {
4342 4343
         if (adc_steps < 20) ++adc_steps;
4343
-        lcd_quick_feedback();
4344 4344
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4345 4345
         if (encoderDirection == -1) { // side effect which signals we are inside a menu
4346 4346
           if      (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
4347 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 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 4359
         #if ENABLED(ADC_KEYPAD_DEBUG)
4358 4360
           SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
4359 4361
           SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
4360 4362
         #endif
4363
+        next_button_update_ms = millis() + ADC_MIN_KEY_DELAY;
4361 4364
         return true;
4362 4365
       }
4363 4366
       else if (!thermalManager.current_ADCKey_raw)
@@ -4672,7 +4675,7 @@ void lcd_update() {
4672 4675
 
4673 4676
       #endif
4674 4677
 
4675
-      bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
4678
+      const bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
4676 4679
       if (encoderPastThreshold || lcd_clicked) {
4677 4680
         if (encoderPastThreshold) {
4678 4681
           int32_t encoderMultiplier = 1;

Ładowanie…
Anuluj
Zapisz