Group button-related LCD code

This commit is contained in:
Scott Lahteine 2018-05-22 00:44:59 -05:00
parent cb6e58559c
commit 083726b2ae
2 changed files with 43 additions and 36 deletions

View File

@ -87,7 +87,7 @@
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
#if ENABLED(ULTIPANEL)
#if ENABLED(ULTIPANEL) // LCD with a click-wheel input
extern bool defer_return_to_status;
@ -111,27 +111,6 @@
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
#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 _BV(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();
void lcd_completion_feedback(const bool good=true);
#if ENABLED(ADVANCED_PAUSE_FEATURE)
@ -139,7 +118,7 @@
void lcd_advanced_pause_show_message(const AdvancedPauseMessage message,
const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT,
const uint8_t extruder=active_extruder);
#endif // ADVANCED_PAUSE_FEATURE
#endif
#if ENABLED(G26_MESH_VALIDATION)
void lcd_chirp();
@ -152,10 +131,6 @@
float lcd_z_offset_edit();
#endif
#else
inline void lcd_buttons_update() {}
#endif
#if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
@ -240,7 +215,6 @@
constexpr bool lcd_wait_for_move = false;
inline void lcd_refresh() {}
inline void lcd_buttons_update() {}
inline bool lcd_hasstatus() { return false; }
inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
inline void lcd_setstatusPGM(const char* const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
@ -250,6 +224,39 @@
#endif // ULTRA_LCD
#if ENABLED(ULTIPANEL)
#if ENABLED(NEWPANEL) // Uses digital switches, not a shift register
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
#define BLEN_A 0
#define BLEN_B 1
#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 _BV(BLEN_D)
#define LCD_BACK_CLICKED (buttons & EN_D)
#endif
#endif // NEWPANEL
extern volatile uint8_t buttons; // The last-checked buttons in a bit array.
void lcd_buttons_update();
#else
inline void lcd_buttons_update() {}
#endif
#define LCD_MESSAGEPGM(x) lcd_setstatusPGM(PSTR(x))
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatusPGM(PSTR(x))

View File

@ -67,19 +67,19 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
// button and encoder bit positions within 'buttons'
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
#define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
#define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
#define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
#define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
#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
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
#define LCD_CLICKED (buttons & (B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
#else
#define LCD_CLICKED (buttons&(B_MI|B_RI))
#define LCD_CLICKED (buttons & (B_MI|B_RI))
#endif
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
@ -91,7 +91,7 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
#define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
#define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
#undef LCD_CLICKED
#define LCD_CLICKED (buttons & B_MI)