Quellcode durchsuchen

Fix issues with ADC_KEYPAD

Fixes #7150
Scott Lahteine vor 7 Jahren
Ursprung
Commit
fe7e890b09
1 geänderte Dateien mit 17 neuen und 26 gelöschten Zeilen
  1. 17
    26
      Marlin/ultralcd.cpp

+ 17
- 26
Marlin/ultralcd.cpp Datei anzeigen

@@ -4026,44 +4026,34 @@ void kill_screen(const char* lcd_msg) {
4026 4026
    */
4027 4027
   #if ENABLED(ADC_KEYPAD)
4028 4028
 
4029
-    inline void handle_adc_keypad() {
4029
+    inline bool handle_adc_keypad() {
4030 4030
       static uint8_t adc_steps = 0;
4031 4031
       if (buttons_reprapworld_keypad) {
4032
-        adc_steps++;
4033
-        NOMORE(adc_steps, 20);
4034
-
4032
+        if (adc_steps < 20) ++adc_steps;
4035 4033
         lcd_quick_feedback();
4036 4034
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4037
-        return_to_status_ms = millis() + LCD_TIMEOUT_TO_STATUS;
4038 4035
         if (encoderDirection == -1) { // side effect which signals we are inside a menu
4039
-          if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
4040
-            encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
4041
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
4042
-            encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
4043
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
4044
-            menu_action_back();
4045
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
4046
-            // enqueue_and_echo_commands_P(PSTR("M0 Pause"));
4047
-            lcd_return_to_status();
4036
+          if      (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
4037
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
4038
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)  menu_action_back();
4039
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) lcd_return_to_status();
4048 4040
         }
4049 4041
         else {
4050 4042
           const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1;
4051
-          if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
4052
-            encoderPosition += ENCODER_PULSES_PER_STEP * step;
4053
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
4054
-            encoderPosition -= ENCODER_PULSES_PER_STEP * step;
4055
-          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
4056
-            encoderPosition = 0;
4043
+               if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)  encoderPosition += ENCODER_PULSES_PER_STEP * step;
4044
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)    encoderPosition -= ENCODER_PULSES_PER_STEP * step;
4045
+          else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0;
4057 4046
         }
4058 4047
         #if ENABLED(ADC_KEYPAD_DEBUG)
4059 4048
           SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
4060 4049
           SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
4061 4050
         #endif
4051
+        return true;
4062 4052
       }
4063
-      else if (!thermalManager.current_ADCKey_raw) {
4064
-        // reset stepping acceleration
4065
-        adc_steps = 0;
4066
-      }
4053
+      else if (!thermalManager.current_ADCKey_raw)
4054
+        adc_steps = 0; // reset stepping acceleration
4055
+
4056
+      return false;
4067 4057
     }
4068 4058
 
4069 4059
   #elif ENABLED(REPRAPWORLD_KEYPAD)
@@ -4360,7 +4350,8 @@ void lcd_update() {
4360 4350
 
4361 4351
       #if ENABLED(ADC_KEYPAD)
4362 4352
 
4363
-        handle_adc_keypad();
4353
+        if (handle_adc_keypad())
4354
+          return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
4364 4355
 
4365 4356
       #elif ENABLED(REPRAPWORLD_KEYPAD)
4366 4357
 
@@ -4792,7 +4783,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
4792 4783
     uint8_t  ADCKeyNo;
4793 4784
   } _stADCKeypadTable_;
4794 4785
 
4795
-  static const _stADCKeypadTable_ stADCKeyTable[] = PROGMEM {
4786
+  static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = {
4796 4787
     // VALUE_MIN, VALUE_MAX, KEY
4797 4788
     { 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F1 + 1 },     // F1
4798 4789
     { 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F2 + 1 },     // F2

Laden…
Abbrechen
Speichern