Browse Source

Cleaning up, getting rid of the fake encoder count variable.

Ruwan J Egoda Gamage 9 years ago
parent
commit
6f9e9c0e4f
2 changed files with 19 additions and 24 deletions
  1. 19
    21
      Marlin/ultralcd.cpp
  2. 0
    3
      Marlin/ultralcd.h

+ 19
- 21
Marlin/ultralcd.cpp View File

@@ -218,9 +218,6 @@ static void lcd_status_screen();
218 218
   #if ENABLED(REPRAPWORLD_KEYPAD)
219 219
     volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
220 220
   #endif
221
-  #if ENABLED(RIGIDBOT_PANEL)
222
-    volatile millis_t next_fake_encoder_update_ms;
223
-  #endif
224 221
 
225 222
   #if ENABLED(LCD_HAS_SLOW_BUTTONS)
226 223
     volatile uint8_t slow_buttons; // Bits of the pressed buttons.
@@ -1555,7 +1552,6 @@ void lcd_init() {
1555 1552
       pinMode(BTN_DWN,INPUT);
1556 1553
       pinMode(BTN_LFT,INPUT);
1557 1554
       pinMode(BTN_RT,INPUT);
1558
-      next_fake_encoder_update_ms = 0;
1559 1555
     #endif
1560 1556
 
1561 1557
   #else  // Not NEWPANEL
@@ -1685,7 +1681,7 @@ void lcd_update() {
1685 1681
               int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1686 1682
 
1687 1683
               if (lastEncoderMovementMillis != 0) {
1688
-                // Note that the rate is always calculated between to passes through the 
1684
+                // Note that the rate is always calculated between to passes through the
1689 1685
                 // loop and that the abs of the encoderDiff value is tracked.
1690 1686
                 float encoderStepRate = (float)(encoderMovementSteps) / ((float)(ms - lastEncoderMovementMillis)) * 1000.0;
1691 1687
 
@@ -1865,25 +1861,27 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
1865 1861
         if (READ(BTN_EN2) == 0) newbutton |= EN_B;
1866 1862
       #endif
1867 1863
       #if ENABLED(RIGIDBOT_PANEL)
1868
-        if (millis() > next_fake_encoder_update_ms && READ(BTN_UP) == 0) {
1869
-          encoderDiff = -1 * ENCODER_STEPS_PER_MENU_ITEM;
1870
-          next_fake_encoder_update_ms = millis() + 300;
1871
-        }
1872
-        if (millis() > next_fake_encoder_update_ms && READ(BTN_DWN) == 0) {
1873
-          encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
1874
-          next_fake_encoder_update_ms = millis() + 300;
1875
-        }
1876
-        if (millis() > next_fake_encoder_update_ms && READ(BTN_LFT) == 0) {
1877
-          encoderDiff = -1 * ENCODER_PULSES_PER_STEP;
1878
-          next_fake_encoder_update_ms = millis() + 300;
1879
-        }
1880
-        if (millis() > next_fake_encoder_update_ms && READ(BTN_RT) == 0) {
1881
-          encoderDiff = ENCODER_PULSES_PER_STEP;
1882
-          next_fake_encoder_update_ms = millis() + 300;
1864
+        millis_t now = millis();
1865
+        if (now > next_button_update_ms) {
1866
+          if (READ(BTN_UP) == 0) {
1867
+            encoderDiff = -1 * ENCODER_STEPS_PER_MENU_ITEM;
1868
+            next_button_update_ms = now + 300;
1869
+          }
1870
+          else if (READ(BTN_DWN) == 0) {
1871
+            encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
1872
+            next_button_update_ms = now + 300;
1873
+          }
1874
+          else if (READ(BTN_LFT) == 0) {
1875
+            encoderDiff = -1 * ENCODER_PULSES_PER_STEP;
1876
+            next_button_update_ms = now + 300;
1877
+          }
1878
+          else if (READ(BTN_RT) == 0) {
1879
+            encoderDiff = ENCODER_PULSES_PER_STEP;
1880
+            next_button_update_ms = now + 300;
1881
+          }
1883 1882
         }
1884 1883
       #endif
1885 1884
 
1886
-
1887 1885
       #if BTN_ENC > 0
1888 1886
         if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
1889 1887
       #endif

+ 0
- 3
Marlin/ultralcd.h View File

@@ -41,9 +41,6 @@
41 41
     #if ENABLED(REPRAPWORLD_KEYPAD)
42 42
       extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
43 43
     #endif
44
-    #if ENABLED(RIGIDBOT_PANEL)
45
-      extern volatile millis_t next_fake_encoder_update_ms;
46
-    #endif
47 44
   #else
48 45
     FORCE_INLINE void lcd_buttons_update() {}
49 46
   #endif

Loading…
Cancel
Save