From d622080cfe05470304a16ad3991f46b8c1b4f258 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Tue, 6 Sep 2022 17:23:49 +1000 Subject: [PATCH] Do a better job of determining when to say Menu. In info screen, avoid very rapid announcements of battery fluctuations. For same menu name, only read value changes once per second for automatic reading. --- openrtx/src/ui/ui.c | 10 +--------- openrtx/src/ui/ui_menu.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 2635efae..201e5811 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -1686,15 +1686,7 @@ void ui_updateFSM(bool *sync_rtx) break; // About screen case MENU_ABOUT: - if ((msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep)) - {// quick press repeat vp, long press summary. - if (msg.long_press) - vp_announceAboutScreen(); - else - vp_replayLastPrompt(); - f1Handled = true; - } - else if(msg.keys & KEY_ESC) + if(msg.keys & KEY_ESC) _ui_menuBack(MENU_TOP); break; #ifdef RTC_PRESENT diff --git a/openrtx/src/ui/ui_menu.c b/openrtx/src/ui/ui_menu.c index 8497821b..9d607eb5 100644 --- a/openrtx/src/ui/ui_menu.c +++ b/openrtx/src/ui/ui_menu.c @@ -37,6 +37,8 @@ extern void _ui_drawMainBottom(); static char priorSelectedMenuName[MAX_ENTRY_LEN] = "\0"; static char priorSelectedMenuValue[MAX_ENTRY_LEN] = "\0"; static bool priorEditMode = false; +static uint32_t lastValueUpdate=0; + const char *display_timer_values[] = { "Off", @@ -80,12 +82,37 @@ static bool DidSelectedMenuItemChange(char* menuName, char* menuValue) if ((menuValue != NULL) && (strcmp(menuValue, priorSelectedMenuValue) != 0)) { + // avoid chatter when value changes rapidly! + uint32_t now=getTick(); + + uint32_t interval=now - lastValueUpdate; + lastValueUpdate = now; + if (interval < 1000) + return false; strcpy(priorSelectedMenuValue, menuValue); return true; } return false; } +/* +Normally we determine if we should say the word menu if a menu entry has no +associated value that can be changed. +There are some menus however with no associated value which are not submenus, +e.g. the entries under Channels, contacts, Info, +which are navigable but not modifyable. +*/ +static bool ScreenContainsReadOnlyEntries(int menuScreen) +{ + switch (menuScreen) + { + case MENU_CHANNEL: + case MENU_CONTACTS: + case MENU_INFO: + return true; + } + return false; +} static void announceMenuItemIfNeeded(char* name, char* value, bool editMode) { @@ -109,10 +136,14 @@ static void announceMenuItemIfNeeded(char* name, char* value, bool editMode) // If no value is supplied, or, no prompt is in progress, announce the name. if ((voicePromptWasPlaying == false) || (value == NULL) || (*value == '\0')) vp_announceText(name, vpqDefault); - - // This is a top-level menu rather than a menu/value pair. - if (!editMode && (value == NULL)) +// We determine if we should say the word Menu as follows: +// The name has no associated value , +// i.e. does not represent a modifyable name/value pair. +// We're not in edit mode. +// The screen is navigable but entries are readonly. + if (!value && !editMode && !ScreenContainsReadOnlyEntries(state.ui_screen)) vp_queueStringTableEntry(¤tLanguage->menu); + if (editMode) vp_queuePrompt(PROMPT_EDIT); if ((value != NULL) && (*value != '\0'))