mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 11:08:20 +00:00
Add long-press functionality to ChName, minor refactoring
This commit is contained in:
1 parent
a20f1ce28e
commit
0501422c64
4 files changed
+35
-44
No files matched your search
+4
-12
@@ -343,22 +343,14 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bKeyHeld && bKeyPressed) // button pushed
|
||||
{
|
||||
if (bKeyHeld != bKeyPressed) { // button pushed or released after hold
|
||||
// (!bKeyHeld && bKeyPressed) or (bKeyHeld && !bKeyPressed)
|
||||
return;
|
||||
}
|
||||
|
||||
// held or released beyond this point
|
||||
// held or released after short press
|
||||
|
||||
if(!(bKeyHeld && !bKeyPressed)) // don't beep on released after hold
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (bKeyHeld && !bKeyPressed) // button released after hold
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// held or released after short press beyond this point
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (gFmRadioMode) { // do not run these actions in FM radio mode
|
||||
|
||||
+2
-1
@@ -2088,7 +2088,8 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
}
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) {
|
||||
// else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) {
|
||||
else if ((bKeyHeld != bKeyPressed) && (gAlarmState == ALARM_STATE_TX1750 || bKeyPressed)) {
|
||||
ALARM_Off();
|
||||
|
||||
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
|
||||
|
||||
+24
-23
@@ -1507,6 +1507,13 @@ static const char* const char_map[10] = {
|
||||
"wxyz9" // KEY_9
|
||||
};
|
||||
|
||||
static bool MENU_IsEditingName() {
|
||||
return !gCssBackgroundScan
|
||||
&& UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME
|
||||
&& gIsInSubMenu
|
||||
&& edit_index >= 0;
|
||||
}
|
||||
|
||||
static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
uint8_t Offset;
|
||||
@@ -1708,12 +1715,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
|
||||
static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
{
|
||||
const bool editing_name = !gCssBackgroundScan
|
||||
&& UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME
|
||||
&& gIsInSubMenu
|
||||
&& edit_index >= 0;
|
||||
|
||||
if (editing_name)
|
||||
if (MENU_IsEditingName())
|
||||
{
|
||||
if (!bKeyPressed)
|
||||
{
|
||||
@@ -1813,9 +1815,9 @@ Skip:
|
||||
|
||||
static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
||||
{
|
||||
if (bKeyHeld || !bKeyPressed)
|
||||
if (!bKeyPressed || (bKeyHeld && (!MENU_IsEditingName() || gAskForConfirmation)))
|
||||
return;
|
||||
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
gRequestDisplayScreen = DISPLAY_MENU;
|
||||
|
||||
@@ -1884,8 +1886,12 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
|
||||
{ // editing the channel name characters
|
||||
edit_last_key = 255;
|
||||
|
||||
if (++edit_index < 10)
|
||||
return; // next char
|
||||
if (bKeyHeld) {
|
||||
edit_index = 10;
|
||||
}
|
||||
else if (++edit_index < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
// exit
|
||||
gFlagAcceptSetting = false;
|
||||
@@ -2013,23 +2019,18 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
||||
uint16_t Channel;
|
||||
bool bCheckScanList;
|
||||
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
if (!bKeyHeld) {
|
||||
gInputBoxIndex = 0;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
|
||||
if (!gEeprom.SET_NAV && gIsInSubMenu) {
|
||||
Direction = -Direction;
|
||||
}
|
||||
|
||||
if (!bKeyHeld)
|
||||
{
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
}
|
||||
else
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
|
||||
{ // change the character
|
||||
if (edit_index < 10 && Direction != 0)
|
||||
|
||||
+5
-8
@@ -243,16 +243,13 @@ static void SCANNER_Key_STAR(bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
}
|
||||
|
||||
static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Direction)
|
||||
static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
||||
{
|
||||
if (pKeyHeld) {
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
if (!bKeyPressed) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!bKeyPressed)
|
||||
return;
|
||||
|
||||
if (!bKeyHeld) {
|
||||
gInputBoxIndex = 0;
|
||||
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
}
|
||||
@@ -266,7 +263,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
|
||||
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
|
||||
gRequestDisplayScreen = DISPLAY_SCANNER;
|
||||
}
|
||||
else
|
||||
else if (!bKeyHeld)
|
||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user