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
   #if ENABLED(REPRAPWORLD_KEYPAD)
218
   #if ENABLED(REPRAPWORLD_KEYPAD)
219
     volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
219
     volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
220
   #endif
220
   #endif
221
-  #if ENABLED(RIGIDBOT_PANEL)
222
-    volatile millis_t next_fake_encoder_update_ms;
223
-  #endif
224
 
221
 
225
   #if ENABLED(LCD_HAS_SLOW_BUTTONS)
222
   #if ENABLED(LCD_HAS_SLOW_BUTTONS)
226
     volatile uint8_t slow_buttons; // Bits of the pressed buttons.
223
     volatile uint8_t slow_buttons; // Bits of the pressed buttons.
1555
       pinMode(BTN_DWN,INPUT);
1552
       pinMode(BTN_DWN,INPUT);
1556
       pinMode(BTN_LFT,INPUT);
1553
       pinMode(BTN_LFT,INPUT);
1557
       pinMode(BTN_RT,INPUT);
1554
       pinMode(BTN_RT,INPUT);
1558
-      next_fake_encoder_update_ms = 0;
1559
     #endif
1555
     #endif
1560
 
1556
 
1561
   #else  // Not NEWPANEL
1557
   #else  // Not NEWPANEL
1685
               int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1681
               int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
1686
 
1682
 
1687
               if (lastEncoderMovementMillis != 0) {
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
                 // loop and that the abs of the encoderDiff value is tracked.
1685
                 // loop and that the abs of the encoderDiff value is tracked.
1690
                 float encoderStepRate = (float)(encoderMovementSteps) / ((float)(ms - lastEncoderMovementMillis)) * 1000.0;
1686
                 float encoderStepRate = (float)(encoderMovementSteps) / ((float)(ms - lastEncoderMovementMillis)) * 1000.0;
1691
 
1687
 
1865
         if (READ(BTN_EN2) == 0) newbutton |= EN_B;
1861
         if (READ(BTN_EN2) == 0) newbutton |= EN_B;
1866
       #endif
1862
       #endif
1867
       #if ENABLED(RIGIDBOT_PANEL)
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
       #endif
1883
       #endif
1885
 
1884
 
1886
-
1887
       #if BTN_ENC > 0
1885
       #if BTN_ENC > 0
1888
         if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
1886
         if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
1889
       #endif
1887
       #endif

+ 0
- 3
Marlin/ultralcd.h View File

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

Loading…
Cancel
Save