From 0b98f50a12be72af558e05bf9afc4fb58f60bed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Thu, 28 Jan 2021 12:52:10 +0100 Subject: [PATCH] Add absolute knob positioning and horizontal keys emulation --- openrtx/src/ui/ui.c | 2 +- platform/drivers/keyboard/keyboard_MDx.c | 14 +++++++++++++- platform/targets/MD-380/hwconfig.h | 3 +++ platform/targets/MD-390/hwconfig.h | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index ffb1da20..d202a640 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -811,7 +811,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx) case MENU_MACRO: _ui_drawDarkOverlay(); // If a number is pressed perform the corresponding macro - if(!msg.long_press && input_isNumberPressed(msg)) + if(!msg.long_press) { _ui_fsm_menuMacro(msg, sync_rtx); } diff --git a/platform/drivers/keyboard/keyboard_MDx.c b/platform/drivers/keyboard/keyboard_MDx.c index 95522ebc..059ef539 100644 --- a/platform/drivers/keyboard/keyboard_MDx.c +++ b/platform/drivers/keyboard/keyboard_MDx.c @@ -49,6 +49,19 @@ void kbd_terminate() keyboard_t kbd_getKeys() { + keyboard_t keys = 0; + + /* Use absolute position knob to emulate left and right buttons */ + static uint8_t old_pos = 0; + uint8_t new_pos = platform_getChSelector(); + if (old_pos != new_pos) { + if (new_pos < old_pos) + keys |= KEY_LEFT; + else + keys |= KEY_RIGHT; + old_pos = new_pos; + } + /* * First of all, configure the row lines as inputs. Since they are in common * with the display, their configuration can have been screwed up by display @@ -73,7 +86,6 @@ keyboard_t kbd_getKeys() * this means that we have to put a small delay before reading the GPIOs to * allow voltage to settle. */ - keyboard_t keys = 0; gpio_setPin(KB_ROW1); delayUs(1); diff --git a/platform/targets/MD-380/hwconfig.h b/platform/targets/MD-380/hwconfig.h index 58c69bac..a03510d7 100644 --- a/platform/targets/MD-380/hwconfig.h +++ b/platform/targets/MD-380/hwconfig.h @@ -25,6 +25,9 @@ /* Device has a working real time clock */ #define HAS_RTC +/* Device has a channel selection knob */ +#define HAS_ABSOLUTE_KNOB + /* Supported radio bands */ #define BAND_VHF #define BAND_UHF diff --git a/platform/targets/MD-390/hwconfig.h b/platform/targets/MD-390/hwconfig.h index 601a6667..0068f1d3 100644 --- a/platform/targets/MD-390/hwconfig.h +++ b/platform/targets/MD-390/hwconfig.h @@ -25,6 +25,9 @@ /* Device has a working real time clock */ #define HAS_RTC +/* Device has a channel selection knob */ +#define HAS_ABSOLUTE_KNOB + /* Supported radio bands */ #define BAND_VHF #define BAND_UHF