Merge pull request #3670 from thinkyhead/rc_scoovo_controller

Use directional buttons when defined
This commit is contained in:
Scott Lahteine 2016-05-03 17:42:18 -07:00
commit b4b5c7a6b7
2 changed files with 40 additions and 18 deletions

View File

@ -46,6 +46,8 @@
#define CONFIGURATION_LCD #define CONFIGURATION_LCD
#define LCD_HAS_DIRECTIONAL_BUTTONS (BUTTON_EXISTS(UP) || BUTTON_EXISTS(DWN) || BUTTON_EXISTS(LFT) || BUTTON_EXISTS(RT))
#if ENABLED(MAKRPANEL) #if ENABLED(MAKRPANEL)
#define DOGLCD #define DOGLCD
#define DEFAULT_LCD_CONTRAST 17 #define DEFAULT_LCD_CONTRAST 17

View File

@ -2042,10 +2042,16 @@ void lcd_init() {
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
#endif #endif
#ifdef RIGIDBOT_PANEL #if BUTTON_EXISTS(UP)
SET_INPUT(BTN_UP); SET_INPUT(BTN_UP);
#endif
#if BUTTON_EXISTS(DWN)
SET_INPUT(BTN_DWN); SET_INPUT(BTN_DWN);
#endif
#if BUTTON_EXISTS(LFT)
SET_INPUT(BTN_LFT); SET_INPUT(BTN_LFT);
#endif
#if BUTTON_EXISTS(RT)
SET_INPUT(BTN_RT); SET_INPUT(BTN_RT);
#endif #endif
@ -2425,32 +2431,46 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#if BUTTON_EXISTS(EN2) #if BUTTON_EXISTS(EN2)
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
#endif #endif
#if ENABLED(RIGIDBOT_PANEL) || BUTTON_EXISTS(ENC) #if LCD_HAS_DIRECTIONAL_BUTTONS || BUTTON_EXISTS(ENC)
millis_t now = millis(); millis_t now = millis();
#endif #endif
#if ENABLED(RIGIDBOT_PANEL)
#if LCD_HAS_DIRECTIONAL_BUTTONS
if (ELAPSED(now, next_button_update_ms)) { if (ELAPSED(now, next_button_update_ms)) {
if (BUTTON_PRESSED(UP)) { if (false) {
encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM); // for the else-ifs below
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(DWN)) {
encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(LFT)) {
encoderDiff = -(ENCODER_PULSES_PER_STEP);
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(RT)) {
encoderDiff = ENCODER_PULSES_PER_STEP;
next_button_update_ms = now + 300;
} }
#if BUTTON_EXISTS(UP)
else if (BUTTON_PRESSED(UP)) {
encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM);
next_button_update_ms = now + 300;
}
#endif
#if BUTTON_EXISTS(DWN)
else if (BUTTON_PRESSED(DWN)) {
encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
next_button_update_ms = now + 300;
}
#endif
#if BUTTON_EXISTS(LFT)
else if (BUTTON_PRESSED(LFT)) {
encoderDiff = -(ENCODER_PULSES_PER_STEP);
next_button_update_ms = now + 300;
}
#endif
#if BUTTON_EXISTS(RT)
else if (BUTTON_PRESSED(RT)) {
encoderDiff = ENCODER_PULSES_PER_STEP;
next_button_update_ms = now + 300;
}
#endif
} }
#endif #endif
#if BUTTON_EXISTS(ENC) #if BUTTON_EXISTS(ENC)
if (ELAPSED(now, next_button_update_ms) && BUTTON_PRESSED(ENC)) newbutton |= EN_C; if (ELAPSED(now, next_button_update_ms) && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
#endif #endif
buttons = newbutton; buttons = newbutton;
#if ENABLED(LCD_HAS_SLOW_BUTTONS) #if ENABLED(LCD_HAS_SLOW_BUTTONS)
buttons |= slow_buttons; buttons |= slow_buttons;