Add support for BACK button (RADDS) (#9835)

This commit is contained in:
Scott Lahteine 2018-02-26 22:52:57 -06:00 committed by GitHub
parent 0bc4c216ac
commit 35ec67885a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 14 deletions

View File

@ -4862,11 +4862,9 @@ void lcd_init() {
#if BUTTON_EXISTS(EN1)
SET_INPUT_PULLUP(BTN_EN1);
#endif
#if BUTTON_EXISTS(EN2)
SET_INPUT_PULLUP(BTN_EN2);
#endif
#if BUTTON_EXISTS(ENC)
SET_INPUT_PULLUP(BTN_ENC);
#endif
@ -5011,6 +5009,14 @@ void lcd_update() {
}
}
else wait_for_unclick = false;
#if BUTTON_EXISTS(BACK)
if (LCD_BACK_CLICKED) {
lcd_quick_feedback();
lcd_goto_previous_menu();
}
#endif
#endif
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
@ -5374,14 +5380,15 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#if BUTTON_EXISTS(EN1)
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
#endif
#if BUTTON_EXISTS(EN2)
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
#endif
#if BUTTON_EXISTS(ENC)
if (BUTTON_PRESSED(ENC)) newbutton |= EN_C;
#endif
#if BUTTON_EXISTS(BACK)
if (BUTTON_PRESSED(BACK)) newbutton |= EN_D;
#endif
//
// Directional buttons

View File

@ -44,9 +44,6 @@
constexpr bool lcd_external_control = false;
#endif
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
#if ENABLED(LCD_BED_LEVELING)
@ -96,6 +93,8 @@
#endif
#define LCD_UPDATE_INTERVAL 100
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
#if ENABLED(ULTIPANEL)
@ -107,15 +106,24 @@
void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder=0);
// Encoder click is directly connected
#define BLEN_A 0
#define BLEN_B 1
// Encoder click is directly connected
#if BUTTON_EXISTS(ENC)
#define BLEN_C 2
#endif
#define EN_A (_BV(BLEN_A))
#define EN_B (_BV(BLEN_B))
#if BUTTON_EXISTS(ENC)
#define BLEN_C 2
#define EN_C (_BV(BLEN_C))
#endif
#if BUTTON_EXISTS(BACK)
#define BLEN_D 3
#define EN_D BIT(BLEN_D)
#define LCD_BACK_CLICKED (buttons & EN_D)
#endif
extern volatile uint8_t buttons; // The last-checked buttons in a bit array.
void lcd_buttons_update();
@ -213,9 +221,13 @@
)
#elif ENABLED(NEWPANEL)
#define LCD_CLICKED (buttons & EN_C)
#else
#define LCD_CLICKED false
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)

View File

@ -78,13 +78,12 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
#undef LCD_CLICKED
#if BUTTON_EXISTS(ENC)
// the pause/stop/restart button is connected to BTN_ENC when used
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
#undef LCD_CLICKED
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
#else
#undef LCD_CLICKED
#define LCD_CLICKED (buttons&(B_MI|B_RI))
#endif