Put repetitive code into separate function. No change in functionality.
This commit is contained in:
parent
6ee97468ee
commit
a7fdfdd258
4 changed files with 15 additions and 7 deletions
|
@ -683,13 +683,18 @@ ShortTimer longPressTimer;
|
|||
LongTimer lcd_timeoutToStatus;
|
||||
|
||||
|
||||
//! @brief Was button clicked?
|
||||
//!
|
||||
//! Consume click event, following call would return 0.
|
||||
//!
|
||||
//! @retval 0 not clicked
|
||||
//! @retval nonzero clicked
|
||||
uint8_t lcd_clicked(void)
|
||||
{
|
||||
bool clicked = LCD_CLICKED;
|
||||
if(clicked)
|
||||
{
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
lcd_consume_click();
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,6 @@ extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
|
|||
|
||||
extern uint8_t lcd_clicked(void);
|
||||
|
||||
|
||||
extern void lcd_beeper_quick_feedback(void);
|
||||
|
||||
//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
|
||||
|
@ -221,6 +220,12 @@ extern void lcd_set_custom_characters_progress(void);
|
|||
extern void lcd_set_custom_characters_nextpage(void);
|
||||
extern void lcd_set_custom_characters_degree(void);
|
||||
|
||||
//! @brief Consume click event
|
||||
inline void lcd_consume_click()
|
||||
{
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
}
|
||||
|
||||
|
||||
#endif //_LCD_H
|
||||
|
|
|
@ -236,8 +236,7 @@ uint8_t menu_item_function_P(const char* str, menu_func_t func)
|
|||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
menu_clicked = false;
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
lcd_consume_click();
|
||||
lcd_update_enabled = 0;
|
||||
if (func) func();
|
||||
lcd_update_enabled = 1;
|
||||
|
|
|
@ -463,8 +463,7 @@ static uint8_t menu_item_sdfile(const char*
|
|||
}
|
||||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
lcd_button_pressed = 0;
|
||||
lcd_buttons &= 0xff^EN_C;
|
||||
lcd_consume_click();
|
||||
menu_action_sdfile(str_fn);
|
||||
return menu_item_ret();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue