Side-key functions added: key lock, switch VFOs

This commit is contained in:
Krzysiek Egzmont
2023-10-21 00:12:55 +02:00
parent b29bae88f1
commit c2090676d8
8 changed files with 74 additions and 34 deletions

View File

@@ -104,6 +104,7 @@ ifeq ($(ENABLE_FMRADIO),1)
OBJS += app/fm.o OBJS += app/fm.o
endif endif
OBJS += app/generic.o OBJS += app/generic.o
OBJS += app/common.o
OBJS += app/main.o OBJS += app/main.o
OBJS += app/menu.o OBJS += app/menu.o
ifeq ($(ENABLE_SPECTRUM), 1) ifeq ($(ENABLE_SPECTRUM), 1)

View File

@@ -18,6 +18,7 @@
#include "app/action.h" #include "app/action.h"
#include "app/app.h" #include "app/app.h"
#include "app/common.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
@@ -411,19 +412,25 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#endif #endif
break; break;
case ACTION_OPT_ALARM: case ACTION_OPT_ALARM:
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
ACTION_AlarmOr1750(false); ACTION_AlarmOr1750(false);
#endif #endif
break; break;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
case ACTION_OPT_FM: case ACTION_OPT_FM:
ACTION_FM(); ACTION_FM();
break; break;
#endif #endif
case ACTION_OPT_1750: case ACTION_OPT_1750:
#ifdef ENABLE_TX1750 #ifdef ENABLE_TX1750
ACTION_AlarmOr1750(true); ACTION_AlarmOr1750(true);
#endif #endif
break; break;
case ACTION_OPT_KEYLOCK:
COMMON_KeypadLockToggle();
break;
case ACTION_OPT_A_B:
COMMON_SwitchVFOs();
break;
} }
} }

36
app/common.c Normal file
View File

@@ -0,0 +1,36 @@
#include "functions.h"
#include "misc.h"
#include "settings.h"
#include "ui/ui.h"
void COMMON_KeypadLockToggle()
{
if (gScreenToDisplay != DISPLAY_MENU &&
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
#ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true;
}
}
void COMMON_SwitchVFOs()
{
gEeprom.TX_VFO ^= 1;
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
gEeprom.CROSS_BAND_RX_TX = gEeprom.TX_VFO + 1;
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
gEeprom.DUAL_WATCH = gEeprom.TX_VFO + 1;
gRequestSaveSettings = 1;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
}

12
app/common.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef APP_COMMON_H
#define APP_COMMON_H
#include "functions.h"
#include "settings.h"
#include "ui/ui.h"
void COMMON_KeypadLockToggle();
void COMMON_SwitchVFOs();
#endif

View File

@@ -17,9 +17,12 @@
#include <string.h> #include <string.h>
#include "app/app.h" #include "app/app.h"
#include "app/common.h"
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
#include "app/menu.h" #include "app/menu.h"
#include "app/scanner.h" #include "app/scanner.h"
@@ -52,18 +55,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
if (!bKeyPressed) // won't ever pass if (!bKeyPressed) // won't ever pass
return; return;
if (gScreenToDisplay != DISPLAY_MENU && COMMON_KeypadLockToggle();
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
#ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true;
}
} }
else // released else // released
{ {

View File

@@ -18,11 +18,10 @@
#include "app/action.h" #include "app/action.h"
#include "app/app.h" #include "app/app.h"
#include "app/common.h"
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
#include "app/main.h" #include "app/main.h"
#include "app/scanner.h" #include "app/scanner.h"
@@ -137,21 +136,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_2: case KEY_2:
gEeprom.TX_VFO ^= 1; COMMON_SwitchVFOs();
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
gEeprom.CROSS_BAND_RX_TX = gEeprom.TX_VFO + 1;
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
gEeprom.DUAL_WATCH = gEeprom.TX_VFO + 1;
gRequestSaveSettings = 1;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
if (beep) if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_3: case KEY_3:

View File

@@ -80,6 +80,8 @@ enum {
ACTION_OPT_ALARM, ACTION_OPT_ALARM,
ACTION_OPT_FM, ACTION_OPT_FM,
ACTION_OPT_1750, ACTION_OPT_1750,
ACTION_OPT_KEYLOCK,
ACTION_OPT_A_B,
ACTION_OPT_LEN ACTION_OPT_LEN
}; };

View File

@@ -348,6 +348,8 @@ const t_sidefunction SIDEFUNCTIONS[] =
#ifdef ENABLE_TX1750 #ifdef ENABLE_TX1750
{"1750HZ", ACTION_OPT_1750}, {"1750HZ", ACTION_OPT_1750},
#endif #endif
{"LOCK\nKEYPAD", ACTION_OPT_KEYLOCK},
{"SWITCH\nVFO", ACTION_OPT_A_B},
}; };
const t_sidefunction* gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS; const t_sidefunction* gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS;
const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS); const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS);