mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-21 17:57:59 +00:00
Hold EXIT key to cancel user inputs, also timeout added
This commit is contained in:
parent
dfd7a1f2b4
commit
7ae40a361b
@ -57,7 +57,7 @@ void ACTION_Power(void)
|
||||
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||
|
||||
//gRequestSaveChannel = 1;
|
||||
gRequestSaveChannel = 2; // TODO: fix me
|
||||
gRequestSaveChannel = 2;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_POWER;
|
||||
@ -248,10 +248,10 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed)
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
if (gDTMF_InputIndex)
|
||||
if (gDTMF_InputIndex > 0)
|
||||
{
|
||||
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
||||
if (gDTMF_InputIndex)
|
||||
if (gDTMF_InputIndex > 0)
|
||||
{
|
||||
gPttWasReleased = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
|
57
app/app.c
57
app/app.c
@ -1137,14 +1137,15 @@ void APP_CheckKeys(void)
|
||||
if (gDebounceCounter == key_repeat_delay)
|
||||
{ // initial delay after pressed
|
||||
if (Key == KEY_STAR ||
|
||||
Key == KEY_F ||
|
||||
Key == KEY_SIDE2 ||
|
||||
Key == KEY_SIDE1 ||
|
||||
Key == KEY_UP ||
|
||||
Key == KEY_DOWN
|
||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
|
||||
#endif
|
||||
Key == KEY_F ||
|
||||
Key == KEY_SIDE2 ||
|
||||
Key == KEY_SIDE1 ||
|
||||
Key == KEY_UP ||
|
||||
Key == KEY_DOWN ||
|
||||
Key == KEY_EXIT
|
||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
|
||||
#endif
|
||||
)
|
||||
{
|
||||
gKeyBeingHeld = true;
|
||||
@ -1424,6 +1425,20 @@ void APP_TimeSlice10ms(void)
|
||||
APP_CheckKeys();
|
||||
}
|
||||
|
||||
void cancelUserInputModes(void)
|
||||
{
|
||||
gKeyInputCountdown = 0;
|
||||
if (gDTMF_InputMode || gInputBoxIndex > 0)
|
||||
{
|
||||
gDTMF_InputMode = false;
|
||||
gDTMF_InputIndex = 0;
|
||||
memset(gDTMF_String, 0, sizeof(gDTMF_String));
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
}
|
||||
|
||||
// this is called once every 500ms
|
||||
void APP_TimeSlice500ms(void)
|
||||
{
|
||||
@ -1453,6 +1468,10 @@ void APP_TimeSlice500ms(void)
|
||||
|
||||
gBatteryCheckCounter++;
|
||||
|
||||
if (gKeyInputCountdown > 0)
|
||||
if (--gKeyInputCountdown == 0)
|
||||
cancelUserInputModes();
|
||||
|
||||
// Skipped authentic device check
|
||||
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
@ -1479,7 +1498,6 @@ void APP_TimeSlice500ms(void)
|
||||
if (gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
|
||||
#endif
|
||||
{
|
||||
|
||||
if (gBacklightCountdown > 0)
|
||||
if (--gBacklightCountdown == 0)
|
||||
if (gEeprom.BACKLIGHT < 5)
|
||||
@ -1705,7 +1723,7 @@ void CHANNEL_Next(bool bFlag, int8_t Direction)
|
||||
|
||||
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
bool bFlag;
|
||||
bool bFlag = false;
|
||||
|
||||
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
@ -1819,8 +1837,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
}
|
||||
|
||||
bFlag = false;
|
||||
|
||||
if (gPttWasPressed && Key == KEY_PTT)
|
||||
{
|
||||
bFlag = bKeyHeld;
|
||||
@ -1938,23 +1954,31 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
case DISPLAY_MAIN:
|
||||
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||
bKeyHeld = false; // allow the channel setting to be saved
|
||||
#endif
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
case DISPLAY_FM:
|
||||
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case DISPLAY_MENU:
|
||||
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
|
||||
case DISPLAY_SCANNER:
|
||||
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
case DISPLAY_AIRCOPY:
|
||||
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case DISPLAY_INVALID:
|
||||
default:
|
||||
break;
|
||||
@ -1973,6 +1997,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Key == KEY_EXIT && bKeyHeld)
|
||||
cancelUserInputModes();
|
||||
}
|
||||
|
||||
Skip:
|
||||
if (gBeepToPlay)
|
||||
@ -1984,6 +2013,7 @@ Skip:
|
||||
if (gFlagAcceptSetting)
|
||||
{
|
||||
MENU_AcceptSetting();
|
||||
|
||||
gFlagRefreshSetting = true;
|
||||
gFlagAcceptSetting = false;
|
||||
}
|
||||
@ -1991,12 +2021,13 @@ Skip:
|
||||
if (gFlagStopScan)
|
||||
{
|
||||
BK4819_StopScan();
|
||||
|
||||
gFlagStopScan = false;
|
||||
}
|
||||
|
||||
if (gRequestSaveSettings)
|
||||
{
|
||||
if (bKeyHeld == 0)
|
||||
if (!bKeyHeld)
|
||||
SETTINGS_SaveSettings();
|
||||
else
|
||||
gFlagSaveSettings = 1;
|
||||
|
45
app/main.c
45
app/main.c
@ -162,6 +162,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
||||
|
||||
case KEY_5:
|
||||
// TODO: something wrong here !!
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
||||
{
|
||||
@ -244,8 +245,10 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
gWasFKeyPressed = false;
|
||||
gUpdateStatus = true;
|
||||
|
||||
processFKeyFunction(Key, false);
|
||||
}
|
||||
}
|
||||
@ -272,6 +275,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
uint8_t Vfo = gEeprom.TX_CHANNEL;
|
||||
|
||||
gKeyInputCountdown = key_input_timeout;
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
@ -418,6 +422,8 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
|
||||
gKeyInputCountdown = key_input_timeout;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (gInputBoxIndex == 0)
|
||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||
@ -439,6 +445,21 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
ACTION_FM();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (bKeyHeld && bKeyPressed)
|
||||
{
|
||||
if (gInputBoxIndex > 0)
|
||||
{ // cancel key input mode (channel/frequency entry)
|
||||
gDTMF_InputMode = false;
|
||||
gDTMF_InputIndex = 0;
|
||||
memset(gDTMF_String, 0, sizeof(gDTMF_String));
|
||||
gInputBoxIndex = 0;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,6 +516,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
||||
if (gScanState == SCAN_OFF)
|
||||
#endif
|
||||
{
|
||||
gKeyInputCountdown = key_input_timeout;
|
||||
gDTMF_InputMode = true;
|
||||
memcpy(gDTMF_InputBox, gDTMF_String, 15);
|
||||
gDTMF_InputIndex = 0;
|
||||
@ -635,21 +657,26 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gDTMF_InputMode && !bKeyHeld && bKeyPressed)
|
||||
if (gDTMF_InputMode && bKeyPressed)
|
||||
{
|
||||
const char Character = DTMF_GetCharacter(Key);
|
||||
if (Character != 0xFF)
|
||||
if (!bKeyHeld)
|
||||
{
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
DTMF_Append(Character);
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gPttWasReleased = true;
|
||||
return;
|
||||
const char Character = DTMF_GetCharacter(Key);
|
||||
if (Character != 0xFF)
|
||||
{ // add key to DTMF string
|
||||
DTMF_Append(Character);
|
||||
|
||||
gKeyInputCountdown = key_input_timeout;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
gPttWasReleased = true;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: ???
|
||||
if (KEY_PTT < Key)
|
||||
if (Key > KEY_PTT)
|
||||
{
|
||||
Key = KEY_SIDE2;
|
||||
}
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
3
misc.c
3
misc.c
@ -18,6 +18,8 @@
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
const uint8_t key_input_timeout = 10; // 5 seconds
|
||||
|
||||
const uint16_t key_repeat_delay = 40; // 400ms
|
||||
const uint16_t key_repeat = 8; // was 15 (150ms) .. MUST be less than 'key_repeat_delay'
|
||||
const uint16_t key_debounce = 2; // 20ms
|
||||
@ -79,6 +81,7 @@ volatile uint16_t gTailNoteEliminationCountdown;
|
||||
#endif
|
||||
|
||||
bool gEnableSpeaker;
|
||||
uint8_t gKeyInputCountdown = 0;
|
||||
uint8_t gKeyLockCountdown;
|
||||
uint8_t gRTTECountdown;
|
||||
bool bIsInLockScreen;
|
||||
|
3
misc.h
3
misc.h
@ -74,6 +74,8 @@ enum CssScanMode_t
|
||||
|
||||
typedef enum CssScanMode_t CssScanMode_t;
|
||||
|
||||
extern const uint8_t key_input_timeout;
|
||||
|
||||
extern const uint16_t key_repeat_delay;
|
||||
extern const uint16_t key_repeat;
|
||||
extern const uint16_t key_debounce;
|
||||
@ -135,6 +137,7 @@ extern volatile uint16_t gTailNoteEliminationCountdown;
|
||||
extern volatile uint16_t gNOAA_Countdown;
|
||||
#endif
|
||||
extern bool gEnableSpeaker;
|
||||
extern uint8_t gKeyInputCountdown;
|
||||
extern uint8_t gKeyLockCountdown;
|
||||
extern uint8_t gRTTECountdown;
|
||||
extern bool bIsInLockScreen;
|
||||
|
12
settings.h
12
settings.h
@ -161,18 +161,18 @@ typedef struct {
|
||||
uint16_t VOX0_THRESHOLD;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
uint16_t FM_SelectedFrequency;
|
||||
uint8_t FM_SelectedChannel;
|
||||
bool FM_IsMrMode;
|
||||
uint16_t FM_FrequencyPlaying;
|
||||
uint16_t FM_SelectedFrequency;
|
||||
uint8_t FM_SelectedChannel;
|
||||
bool FM_IsMrMode;
|
||||
uint16_t FM_FrequencyPlaying;
|
||||
#endif
|
||||
|
||||
uint8_t field37_0x32;
|
||||
uint8_t field38_0x33;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
uint16_t FM_LowerLimit;
|
||||
uint16_t FM_UpperLimit;
|
||||
uint16_t FM_LowerLimit;
|
||||
uint16_t FM_UpperLimit;
|
||||
#endif
|
||||
|
||||
bool AUTO_KEYPAD_LOCK;
|
||||
|
11
ui/menu.c
11
ui/menu.c
@ -297,9 +297,14 @@ void UI_DisplayMenu(void)
|
||||
for (i = 0; i < 6; i++)
|
||||
gFrameBuffer[i][49] = 0xAA;
|
||||
#endif
|
||||
|
||||
NUMBER_ToDigits(gMenuCursor + 1, String);
|
||||
UI_DisplaySmallDigits(2, String + 6, 33, 6, false);
|
||||
|
||||
#if 0
|
||||
NUMBER_ToDigits(1 + gMenuCursor, String);
|
||||
UI_DisplaySmallDigits(2, String + 6, 33, 6, false);
|
||||
#else
|
||||
sprintf(String, "%2u/%u", 1u + gMenuCursor, gMenuListCount);
|
||||
UI_PrintStringSmall(String, 8, 0, 6);
|
||||
#endif
|
||||
|
||||
if (gIsInSubMenu)
|
||||
memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
||||
|
Loading…
Reference in New Issue
Block a user