mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03: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;
|
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||||
|
|
||||||
//gRequestSaveChannel = 1;
|
//gRequestSaveChannel = 1;
|
||||||
gRequestSaveChannel = 2; // TODO: fix me
|
gRequestSaveChannel = 2;
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = VOICE_ID_POWER;
|
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)
|
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed)
|
||||||
{
|
{
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
if (gDTMF_InputIndex)
|
if (gDTMF_InputIndex > 0)
|
||||||
{
|
{
|
||||||
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
||||||
if (gDTMF_InputIndex)
|
if (gDTMF_InputIndex > 0)
|
||||||
{
|
{
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
|
43
app/app.c
43
app/app.c
@ -1141,7 +1141,8 @@ void APP_CheckKeys(void)
|
|||||||
Key == KEY_SIDE2 ||
|
Key == KEY_SIDE2 ||
|
||||||
Key == KEY_SIDE1 ||
|
Key == KEY_SIDE1 ||
|
||||||
Key == KEY_UP ||
|
Key == KEY_UP ||
|
||||||
Key == KEY_DOWN
|
Key == KEY_DOWN ||
|
||||||
|
Key == KEY_EXIT
|
||||||
#ifdef ENABLE_MAIN_KEY_HOLD
|
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||||
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
|
|| Key <= KEY_9 // keys 0-9 can be held down to bypass pressing the F-Key
|
||||||
#endif
|
#endif
|
||||||
@ -1424,6 +1425,20 @@ void APP_TimeSlice10ms(void)
|
|||||||
APP_CheckKeys();
|
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
|
// this is called once every 500ms
|
||||||
void APP_TimeSlice500ms(void)
|
void APP_TimeSlice500ms(void)
|
||||||
{
|
{
|
||||||
@ -1453,6 +1468,10 @@ void APP_TimeSlice500ms(void)
|
|||||||
|
|
||||||
gBatteryCheckCounter++;
|
gBatteryCheckCounter++;
|
||||||
|
|
||||||
|
if (gKeyInputCountdown > 0)
|
||||||
|
if (--gKeyInputCountdown == 0)
|
||||||
|
cancelUserInputModes();
|
||||||
|
|
||||||
// Skipped authentic device check
|
// Skipped authentic device check
|
||||||
|
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
if (gCurrentFunction != FUNCTION_TRANSMIT)
|
||||||
@ -1479,7 +1498,6 @@ void APP_TimeSlice500ms(void)
|
|||||||
if (gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
|
if (gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gBacklightCountdown > 0)
|
if (gBacklightCountdown > 0)
|
||||||
if (--gBacklightCountdown == 0)
|
if (--gBacklightCountdown == 0)
|
||||||
if (gEeprom.BACKLIGHT < 5)
|
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)
|
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||||
{
|
{
|
||||||
bool bFlag;
|
bool bFlag = false;
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
@ -1819,8 +1837,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bFlag = false;
|
|
||||||
|
|
||||||
if (gPttWasPressed && Key == KEY_PTT)
|
if (gPttWasPressed && Key == KEY_PTT)
|
||||||
{
|
{
|
||||||
bFlag = bKeyHeld;
|
bFlag = bKeyHeld;
|
||||||
@ -1938,23 +1954,31 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
{
|
{
|
||||||
case DISPLAY_MAIN:
|
case DISPLAY_MAIN:
|
||||||
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
|
#ifdef ENABLE_MAIN_KEY_HOLD
|
||||||
|
bKeyHeld = false; // allow the channel setting to be saved
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
case DISPLAY_FM:
|
case DISPLAY_FM:
|
||||||
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case DISPLAY_MENU:
|
case DISPLAY_MENU:
|
||||||
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DISPLAY_SCANNER:
|
case DISPLAY_SCANNER:
|
||||||
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
case DISPLAY_AIRCOPY:
|
case DISPLAY_AIRCOPY:
|
||||||
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case DISPLAY_INVALID:
|
case DISPLAY_INVALID:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1973,6 +1997,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (!bKeyHeld && bKeyPressed)
|
if (!bKeyHeld && bKeyPressed)
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Key == KEY_EXIT && bKeyHeld)
|
||||||
|
cancelUserInputModes();
|
||||||
|
}
|
||||||
|
|
||||||
Skip:
|
Skip:
|
||||||
if (gBeepToPlay)
|
if (gBeepToPlay)
|
||||||
@ -1984,6 +2013,7 @@ Skip:
|
|||||||
if (gFlagAcceptSetting)
|
if (gFlagAcceptSetting)
|
||||||
{
|
{
|
||||||
MENU_AcceptSetting();
|
MENU_AcceptSetting();
|
||||||
|
|
||||||
gFlagRefreshSetting = true;
|
gFlagRefreshSetting = true;
|
||||||
gFlagAcceptSetting = false;
|
gFlagAcceptSetting = false;
|
||||||
}
|
}
|
||||||
@ -1991,12 +2021,13 @@ Skip:
|
|||||||
if (gFlagStopScan)
|
if (gFlagStopScan)
|
||||||
{
|
{
|
||||||
BK4819_StopScan();
|
BK4819_StopScan();
|
||||||
|
|
||||||
gFlagStopScan = false;
|
gFlagStopScan = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gRequestSaveSettings)
|
if (gRequestSaveSettings)
|
||||||
{
|
{
|
||||||
if (bKeyHeld == 0)
|
if (!bKeyHeld)
|
||||||
SETTINGS_SaveSettings();
|
SETTINGS_SaveSettings();
|
||||||
else
|
else
|
||||||
gFlagSaveSettings = 1;
|
gFlagSaveSettings = 1;
|
||||||
|
35
app/main.c
35
app/main.c
@ -162,6 +162,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
|||||||
|
|
||||||
case KEY_5:
|
case KEY_5:
|
||||||
// TODO: something wrong here !!
|
// TODO: something wrong here !!
|
||||||
|
|
||||||
#ifdef ENABLE_NOAA
|
#ifdef ENABLE_NOAA
|
||||||
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
|
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;
|
gInputBoxIndex = 0;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
gWasFKeyPressed = false;
|
gWasFKeyPressed = false;
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
|
|
||||||
processFKeyFunction(Key, false);
|
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;
|
uint8_t Vfo = gEeprom.TX_CHANNEL;
|
||||||
|
|
||||||
|
gKeyInputCountdown = key_input_timeout;
|
||||||
INPUTBOX_Append(Key);
|
INPUTBOX_Append(Key);
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
@ -418,6 +422,8 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
gInputBox[--gInputBoxIndex] = 10;
|
gInputBox[--gInputBoxIndex] = 10;
|
||||||
|
|
||||||
|
gKeyInputCountdown = key_input_timeout;
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
if (gInputBoxIndex == 0)
|
if (gInputBoxIndex == 0)
|
||||||
gAnotherVoiceID = VOICE_ID_CANCEL;
|
gAnotherVoiceID = VOICE_ID_CANCEL;
|
||||||
@ -439,6 +445,21 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
|||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
#endif
|
#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)
|
if (gScanState == SCAN_OFF)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
gKeyInputCountdown = key_input_timeout;
|
||||||
gDTMF_InputMode = true;
|
gDTMF_InputMode = true;
|
||||||
memcpy(gDTMF_InputBox, gDTMF_String, 15);
|
memcpy(gDTMF_InputBox, gDTMF_String, 15);
|
||||||
gDTMF_InputIndex = 0;
|
gDTMF_InputIndex = 0;
|
||||||
@ -635,21 +657,26 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gDTMF_InputMode && !bKeyHeld && bKeyPressed)
|
if (gDTMF_InputMode && bKeyPressed)
|
||||||
|
{
|
||||||
|
if (!bKeyHeld)
|
||||||
{
|
{
|
||||||
const char Character = DTMF_GetCharacter(Key);
|
const char Character = DTMF_GetCharacter(Key);
|
||||||
if (Character != 0xFF)
|
if (Character != 0xFF)
|
||||||
{
|
{ // add key to DTMF string
|
||||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
DTMF_Append(Character);
|
DTMF_Append(Character);
|
||||||
|
|
||||||
|
gKeyInputCountdown = key_input_timeout;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
|
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: ???
|
// TODO: ???
|
||||||
if (KEY_PTT < Key)
|
if (Key > KEY_PTT)
|
||||||
{
|
{
|
||||||
Key = KEY_SIDE2;
|
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"
|
#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_delay = 40; // 400ms
|
||||||
const uint16_t key_repeat = 8; // was 15 (150ms) .. MUST be less than 'key_repeat_delay'
|
const uint16_t key_repeat = 8; // was 15 (150ms) .. MUST be less than 'key_repeat_delay'
|
||||||
const uint16_t key_debounce = 2; // 20ms
|
const uint16_t key_debounce = 2; // 20ms
|
||||||
@ -79,6 +81,7 @@ volatile uint16_t gTailNoteEliminationCountdown;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool gEnableSpeaker;
|
bool gEnableSpeaker;
|
||||||
|
uint8_t gKeyInputCountdown = 0;
|
||||||
uint8_t gKeyLockCountdown;
|
uint8_t gKeyLockCountdown;
|
||||||
uint8_t gRTTECountdown;
|
uint8_t gRTTECountdown;
|
||||||
bool bIsInLockScreen;
|
bool bIsInLockScreen;
|
||||||
|
3
misc.h
3
misc.h
@ -74,6 +74,8 @@ enum CssScanMode_t
|
|||||||
|
|
||||||
typedef enum CssScanMode_t 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_delay;
|
||||||
extern const uint16_t key_repeat;
|
extern const uint16_t key_repeat;
|
||||||
extern const uint16_t key_debounce;
|
extern const uint16_t key_debounce;
|
||||||
@ -135,6 +137,7 @@ extern volatile uint16_t gTailNoteEliminationCountdown;
|
|||||||
extern volatile uint16_t gNOAA_Countdown;
|
extern volatile uint16_t gNOAA_Countdown;
|
||||||
#endif
|
#endif
|
||||||
extern bool gEnableSpeaker;
|
extern bool gEnableSpeaker;
|
||||||
|
extern uint8_t gKeyInputCountdown;
|
||||||
extern uint8_t gKeyLockCountdown;
|
extern uint8_t gKeyLockCountdown;
|
||||||
extern uint8_t gRTTECountdown;
|
extern uint8_t gRTTECountdown;
|
||||||
extern bool bIsInLockScreen;
|
extern bool bIsInLockScreen;
|
||||||
|
@ -298,8 +298,13 @@ void UI_DisplayMenu(void)
|
|||||||
gFrameBuffer[i][49] = 0xAA;
|
gFrameBuffer[i][49] = 0xAA;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NUMBER_ToDigits(gMenuCursor + 1, String);
|
#if 0
|
||||||
|
NUMBER_ToDigits(1 + gMenuCursor, String);
|
||||||
UI_DisplaySmallDigits(2, String + 6, 33, 6, false);
|
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)
|
if (gIsInSubMenu)
|
||||||
memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user