diff --git a/radio/src/gui/128x64/gui.h b/radio/src/gui/128x64/gui.h index f5a2be095..11f8faa0f 100644 --- a/radio/src/gui/128x64/gui.h +++ b/radio/src/gui/128x64/gui.h @@ -36,7 +36,6 @@ #define HEADER_LINE_COLUMNS 0, #endif -#define COLUMN_X 0 #define drawFieldLabel(x, y, str) lcdDrawTextAlignedLeft(y, str) #define NUM_BODY_LINES (LCD_LINES-1) diff --git a/radio/src/gui/128x64/model_select.cpp b/radio/src/gui/128x64/model_select.cpp index f3efd28d5..cf6410d63 100644 --- a/radio/src/gui/128x64/model_select.cpp +++ b/radio/src/gui/128x64/model_select.cpp @@ -83,7 +83,7 @@ void onModelSelectMenu(const char * result) void menuModelSelect(event_t event) { event_t _event_ = event; - if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event)) { + if ((s_copyMode && IS_KEY_EVT(event, KEY_EXIT)) || event == EVT_KEY_BREAK(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event)) { _event_ = 0; } diff --git a/radio/src/keys.h b/radio/src/keys.h index e60e9dfe6..44c1e53fe 100644 --- a/radio/src/keys.h +++ b/radio/src/keys.h @@ -46,14 +46,34 @@ // normal order of events is: FIRST, LONG, REPEAT, REPEAT, ..., BREAK #define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) // fired when key is pressed -#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while #define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) // fired when key is held pressed long enough, fires multiple times with increasing speed +#define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) // fired when key is held pressed for a while #define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK) // fired when key is released (short or long), but only if the event was not killed -#define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST) -#define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG) -#define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT) -#define IS_KEY_BREAK(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_BREAK) +inline bool IS_KEY_FIRST(event_t evt) +{ + return (evt & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST; +} + +inline bool IS_KEY_REPT(event_t evt) +{ + return (evt & _MSK_KEY_FLAGS) == _MSK_KEY_REPT; +} + +inline bool IS_KEY_LONG(event_t evt) +{ + return (evt & _MSK_KEY_FLAGS) == _MSK_KEY_LONG; +} + +inline bool IS_KEY_BREAK(event_t evt) +{ + return (evt & _MSK_KEY_FLAGS) == _MSK_KEY_BREAK; +} + +inline bool IS_KEY_EVT(event_t evt, uint8_t key) +{ + return (evt & _MSK_KEY_FLAGS) && (EVT_KEY_MASK(evt) == key); +} #if defined(PCBXLITE) #define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER)