Browse Source

Merge pull request #3670 from thinkyhead/rc_scoovo_controller

Use directional buttons when defined
Scott Lahteine 8 years ago
parent
commit
b4b5c7a6b7
2 changed files with 40 additions and 18 deletions
  1. 2
    0
      Marlin/Conditionals.h
  2. 38
    18
      Marlin/ultralcd.cpp

+ 2
- 0
Marlin/Conditionals.h View File

46
 
46
 
47
   #define CONFIGURATION_LCD
47
   #define CONFIGURATION_LCD
48
 
48
 
49
+  #define LCD_HAS_DIRECTIONAL_BUTTONS (BUTTON_EXISTS(UP) || BUTTON_EXISTS(DWN) || BUTTON_EXISTS(LFT) || BUTTON_EXISTS(RT))
50
+
49
   #if ENABLED(MAKRPANEL)
51
   #if ENABLED(MAKRPANEL)
50
     #define DOGLCD
52
     #define DOGLCD
51
     #define DEFAULT_LCD_CONTRAST 17
53
     #define DEFAULT_LCD_CONTRAST 17

+ 38
- 18
Marlin/ultralcd.cpp View File

2042
       WRITE(SHIFT_LD, HIGH);
2042
       WRITE(SHIFT_LD, HIGH);
2043
     #endif
2043
     #endif
2044
 
2044
 
2045
-    #ifdef RIGIDBOT_PANEL
2045
+    #if BUTTON_EXISTS(UP)
2046
       SET_INPUT(BTN_UP);
2046
       SET_INPUT(BTN_UP);
2047
+    #endif
2048
+    #if BUTTON_EXISTS(DWN)
2047
       SET_INPUT(BTN_DWN);
2049
       SET_INPUT(BTN_DWN);
2050
+    #endif
2051
+    #if BUTTON_EXISTS(LFT)
2048
       SET_INPUT(BTN_LFT);
2052
       SET_INPUT(BTN_LFT);
2053
+    #endif
2054
+    #if BUTTON_EXISTS(RT)
2049
       SET_INPUT(BTN_RT);
2055
       SET_INPUT(BTN_RT);
2050
     #endif
2056
     #endif
2051
 
2057
 
2425
       #if BUTTON_EXISTS(EN2)
2431
       #if BUTTON_EXISTS(EN2)
2426
         if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
2432
         if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
2427
       #endif
2433
       #endif
2428
-      #if ENABLED(RIGIDBOT_PANEL) || BUTTON_EXISTS(ENC)
2434
+      #if LCD_HAS_DIRECTIONAL_BUTTONS || BUTTON_EXISTS(ENC)
2429
         millis_t now = millis();
2435
         millis_t now = millis();
2430
       #endif
2436
       #endif
2431
-      #if ENABLED(RIGIDBOT_PANEL)
2437
+
2438
+      #if LCD_HAS_DIRECTIONAL_BUTTONS
2432
         if (ELAPSED(now, next_button_update_ms)) {
2439
         if (ELAPSED(now, next_button_update_ms)) {
2433
-          if (BUTTON_PRESSED(UP)) {
2434
-            encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM);
2435
-            next_button_update_ms = now + 300;
2436
-          }
2437
-          else if (BUTTON_PRESSED(DWN)) {
2438
-            encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
2439
-            next_button_update_ms = now + 300;
2440
-          }
2441
-          else if (BUTTON_PRESSED(LFT)) {
2442
-            encoderDiff = -(ENCODER_PULSES_PER_STEP);
2443
-            next_button_update_ms = now + 300;
2444
-          }
2445
-          else if (BUTTON_PRESSED(RT)) {
2446
-            encoderDiff = ENCODER_PULSES_PER_STEP;
2447
-            next_button_update_ms = now + 300;
2440
+          if (false) {
2441
+            // for the else-ifs below
2448
           }
2442
           }
2443
+          #if BUTTON_EXISTS(UP)
2444
+            else if (BUTTON_PRESSED(UP)) {
2445
+              encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM);
2446
+              next_button_update_ms = now + 300;
2447
+            }
2448
+          #endif
2449
+          #if BUTTON_EXISTS(DWN)
2450
+            else if (BUTTON_PRESSED(DWN)) {
2451
+              encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
2452
+              next_button_update_ms = now + 300;
2453
+            }
2454
+          #endif
2455
+          #if BUTTON_EXISTS(LFT)
2456
+            else if (BUTTON_PRESSED(LFT)) {
2457
+              encoderDiff = -(ENCODER_PULSES_PER_STEP);
2458
+              next_button_update_ms = now + 300;
2459
+            }
2460
+          #endif
2461
+          #if BUTTON_EXISTS(RT)
2462
+            else if (BUTTON_PRESSED(RT)) {
2463
+              encoderDiff = ENCODER_PULSES_PER_STEP;
2464
+              next_button_update_ms = now + 300;
2465
+            }
2466
+          #endif
2449
         }
2467
         }
2450
       #endif
2468
       #endif
2469
+
2451
       #if BUTTON_EXISTS(ENC)
2470
       #if BUTTON_EXISTS(ENC)
2452
         if (ELAPSED(now, next_button_update_ms) && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
2471
         if (ELAPSED(now, next_button_update_ms) && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
2453
       #endif
2472
       #endif
2473
+
2454
       buttons = newbutton;
2474
       buttons = newbutton;
2455
       #if ENABLED(LCD_HAS_SLOW_BUTTONS)
2475
       #if ENABLED(LCD_HAS_SLOW_BUTTONS)
2456
         buttons |= slow_buttons;
2476
         buttons |= slow_buttons;

Loading…
Cancel
Save