From 1f4fba958b75be827ce1acf4a38b6da91417fd4b Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Wed, 23 Dec 2020 11:05:59 +0100 Subject: [PATCH] KBD: Add function to tell if number keys are pressed --- openrtx/include/interfaces/keyboard.h | 6 ++++++ openrtx/src/ui.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/openrtx/include/interfaces/keyboard.h b/openrtx/include/interfaces/keyboard.h index 2d2dc0e4..1ad36afa 100644 --- a/openrtx/include/interfaces/keyboard.h +++ b/openrtx/include/interfaces/keyboard.h @@ -71,6 +71,12 @@ static const uint8_t kbd_num_keys = 29; */ static const uint16_t kbd_long_interval = OS_CFG_TICK_RATE_HZ * 0.7; +/** + * Mask for the numeric keys in a key map + * Numeric keys: bit0->bit9 = 0x1FF + */ +static const uint32_t kbd_num_mask = 0x1FF; + /** * Structure that represents a keyboard event payload * The maximum size of an event payload is 30 bits diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 3b7f9e5a..58155910 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -432,6 +432,11 @@ bool _ui_drawLowBatteryScreen() return true; } +bool _kbd_number_pressed(kbd_msg_t msg) +{ + return msg.keys & kbd_num_mask; +} + void ui_updateFSM(event_t event, bool *sync_rtx) { // Check if battery has enough charge to operate