Browse Source

Improve Zonestar keypad responsiveness (#14056)

Pavel4e5 5 years ago
parent
commit
3cd19a8ec0
2 changed files with 14 additions and 10 deletions
  1. 2
    2
      Marlin/src/lcd/ultralcd.cpp
  2. 12
    8
      Marlin/src/module/temperature.cpp

+ 2
- 2
Marlin/src/lcd/ultralcd.cpp View File

996
 
996
 
997
   uint8_t get_ADC_keyValue(void) {
997
   uint8_t get_ADC_keyValue(void) {
998
     if (thermalManager.ADCKey_count >= 16) {
998
     if (thermalManager.ADCKey_count >= 16) {
999
-      const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw >> 2;
1000
-      thermalManager.current_ADCKey_raw = 0;
999
+      const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw << 2;
1000
+      thermalManager.current_ADCKey_raw = 1024;
1001
       thermalManager.ADCKey_count = 0;
1001
       thermalManager.ADCKey_count = 0;
1002
       if (currentkpADCValue < 4000)
1002
       if (currentkpADCValue < 4000)
1003
         for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {
1003
         for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {

+ 12
- 8
Marlin/src/module/temperature.cpp View File

310
 // public:
310
 // public:
311
 
311
 
312
 #if HAS_ADC_BUTTONS
312
 #if HAS_ADC_BUTTONS
313
-  uint32_t Temperature::current_ADCKey_raw = 0;
313
+  uint32_t Temperature::current_ADCKey_raw = 1024;
314
   uint8_t Temperature::ADCKey_count = 0;
314
   uint8_t Temperature::ADCKey_count = 0;
315
 #endif
315
 #endif
316
 
316
 
2300
 
2300
 
2301
   #if HAS_ADC_BUTTONS
2301
   #if HAS_ADC_BUTTONS
2302
     static unsigned int raw_ADCKey_value = 0;
2302
     static unsigned int raw_ADCKey_value = 0;
2303
+    static bool ADCKey_pressed = false;
2303
   #endif
2304
   #endif
2304
 
2305
 
2305
   #if ENABLED(SLOW_PWM_HEATERS)
2306
   #if ENABLED(SLOW_PWM_HEATERS)
2702
           next_sensor_state = adc_sensor_state; // redo this state
2703
           next_sensor_state = adc_sensor_state; // redo this state
2703
         else if (ADCKey_count < 16) {
2704
         else if (ADCKey_count < 16) {
2704
           raw_ADCKey_value = HAL_READ_ADC();
2705
           raw_ADCKey_value = HAL_READ_ADC();
2705
-          if (raw_ADCKey_value > 900) {
2706
-            //ADC Key release
2707
-            ADCKey_count = 0;
2708
-            current_ADCKey_raw = 0;
2709
-          }
2710
-          else {
2711
-            current_ADCKey_raw += raw_ADCKey_value;
2706
+          if (raw_ADCKey_value <= 900) {
2707
+            NOMORE(current_ADCKey_raw, raw_ADCKey_value);
2712
             ADCKey_count++;
2708
             ADCKey_count++;
2713
           }
2709
           }
2710
+          else { //ADC Key release
2711
+            if (ADCKey_count > 0) ADCKey_count++; else ADCKey_pressed = false;
2712
+            if (ADCKey_pressed) {
2713
+              ADCKey_count = 0;
2714
+              current_ADCKey_raw = 1024;
2715
+            }
2716
+          }
2714
         }
2717
         }
2718
+        if (ADCKey_count == 16) ADCKey_pressed = true;
2715
         break;
2719
         break;
2716
     #endif // ADC_KEYPAD
2720
     #endif // ADC_KEYPAD
2717
 
2721
 

Loading…
Cancel
Save