This commit is contained in:
Krzysiek Egzmont 2024-01-12 21:55:04 +01:00
parent 4efabfc2b6
commit 04b0bd8c93
6 changed files with 156 additions and 277 deletions

View File

@ -156,7 +156,7 @@ void ACTION_Monitor(void)
}
else
#endif
gRequestDisplayScreen = gScreenToDisplay;
gRequestDisplayScreen = gScreenToDisplay;
}
void ACTION_Scan(bool bRestart)

179
app/app.c
View File

@ -72,6 +72,10 @@
#include "ui/status.h"
#include "ui/ui.h"
static bool flagSaveVfo;
static bool flagSaveSettings;
static bool flagSaveChannel;
static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
@ -1564,32 +1568,27 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gEeprom.AUTO_KEYPAD_LOCK)
gKeyLockCountdown = 30; // 15 seconds
if (!bKeyPressed) // key released
{
if (gFlagSaveVfo)
{
if (!bKeyPressed) { // key released
if (flagSaveVfo) {
SETTINGS_SaveVfoIndices();
gFlagSaveVfo = false;
flagSaveVfo = false;
}
if (gFlagSaveSettings)
{
if (flagSaveSettings) {
SETTINGS_SaveSettings();
gFlagSaveSettings = false;
flagSaveSettings = false;
}
#ifdef ENABLE_FMRADIO
if (gFlagSaveFM)
{
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
#endif
#ifdef ENABLE_FMRADIO
if (gFlagSaveFM) {
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
#endif
if (gFlagSaveChannel)
{
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gFlagSaveChannel);
gFlagSaveChannel = false;
if (flagSaveChannel) {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, flagSaveChannel);
flagSaveChannel = false;
RADIO_ConfigureChannel(gEeprom.TX_VFO, VFO_CONFIGURE);
RADIO_SetupRegisters(true);
@ -1597,8 +1596,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
}
else // key pressed or held
{
else { // key pressed or held
const int m = UI_MENU_GetCurrentMenuId();
if ( //not when PTT and the backlight shouldn't turn on on TX
!(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX))
@ -1609,12 +1607,9 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BACKLIGHT_TurnOn();
}
if (Key == KEY_EXIT && bKeyHeld)
{ // exit key held pressed
if (Key == KEY_EXIT && bKeyHeld) { // exit key held pressed
// clear the live DTMF decoder
if (gDTMF_RX_live[0] != 0)
{
if (gDTMF_RX_live[0] != 0) {
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
gDTMF_RX_live_timeout = 0;
gUpdateDisplay = true;
@ -1634,14 +1629,12 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gMenuCountdown = menu_timeout_500ms;
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_DecodeRingCountdown_500ms > 0)
{ // cancel the ringing
if (gDTMF_DecodeRingCountdown_500ms > 0) { // cancel the ringing
gDTMF_DecodeRingCountdown_500ms = 0;
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
if (Key != KEY_PTT)
{
if (Key != KEY_PTT) {
gPttWasReleased = true;
return;
}
@ -1662,14 +1655,11 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;
}
if (Key == KEY_F)
{ // function/key-lock key
if (Key == KEY_F) { // function/key-lock key
if (!bKeyPressed)
return;
if (!bKeyHeld)
{ // keypad is locked, tell the user
if (!bKeyHeld) { // keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true;
@ -1694,10 +1684,8 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
}
if (Key <= KEY_9 || Key == KEY_F)
{
if (gScanStateDir != SCAN_OFF || gCssBackgroundScan)
{ // FREQ/CTCSS/DCS scanning
if (Key <= KEY_9 || Key == KEY_F) {
if (gScanStateDir != SCAN_OFF || gCssBackgroundScan) { // FREQ/CTCSS/DCS scanning
if (bKeyPressed && !bKeyHeld)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return;
@ -1705,31 +1693,26 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
bool bFlag = false;
if (Key == KEY_PTT)
{
if (gPttWasPressed)
{
if (Key == KEY_PTT) {
if (gPttWasPressed) {
bFlag = bKeyHeld;
if (!bKeyPressed)
{
if (!bKeyPressed) {
bFlag = true;
gPttWasPressed = false;
}
}
}
else if (gPttWasReleased)
{
else if (gPttWasReleased) {
if (bKeyHeld)
bFlag = true;
if (!bKeyPressed)
{
if (!bKeyPressed) {
bFlag = true;
gPttWasReleased = false;
}
}
if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
{ // cancel the F-key
if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) {
// cancel the F-key
gWasFKeyPressed = false;
gUpdateStatus = true;
}
@ -1745,30 +1728,23 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
char Code;
if (Key == KEY_PTT)
{
if (Key == KEY_PTT) {
GENERIC_Key_PTT(bKeyPressed);
goto Skip;
}
if (Key == KEY_SIDE2)
{ // transmit 1750Hz tone
if (Key == KEY_SIDE2) { // transmit 1750Hz tone
Code = 0xFE;
}
else
{
else {
Code = DTMF_GetCharacter(Key - KEY_0);
if (Code == 0xFF)
goto Skip;
// transmit DTMF keys
}
if (!bKeyPressed || bKeyHeld)
{
if (!bKeyPressed)
{
if (!bKeyPressed || bKeyHeld) {
if (!bKeyPressed) {
AUDIO_AudioPathOff();
gEnableSpeaker = false;
@ -1781,10 +1757,8 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
}
}
else
{
if (gEeprom.DTMF_SIDE_TONE)
{ // user will here the DTMF tones in speaker
else {
if (gEeprom.DTMF_SIDE_TONE) { // user will here the DTMF tones in speaker
AUDIO_AudioPathOn();
gEnableSpeaker = true;
}
@ -1808,8 +1782,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Key == KEY_PTT)
gPttWasPressed = true;
else
if (!bKeyHeld)
else if (!bKeyHeld)
gPttWasReleased = true;
}
#endif
@ -1829,14 +1802,12 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
Skip:
if (gBeepToPlay != BEEP_NONE)
{
if (gBeepToPlay != BEEP_NONE) {
AUDIO_PlayBeep(gBeepToPlay);
gBeepToPlay = BEEP_NONE;
}
if (gFlagAcceptSetting)
{
if (gFlagAcceptSetting) {
gMenuCountdown = menu_timeout_500ms;
MENU_AcceptSetting();
@ -1845,19 +1816,17 @@ Skip:
gFlagAcceptSetting = false;
}
if (gRequestSaveSettings)
{
if (gRequestSaveSettings) {
if (!bKeyHeld)
SETTINGS_SaveSettings();
else
gFlagSaveSettings = 1;
flagSaveSettings = 1;
gRequestSaveSettings = false;
gUpdateStatus = true;
}
#ifdef ENABLE_FMRADIO
if (gRequestSaveFM)
{
if (gRequestSaveFM) {
gRequestSaveFM = false;
if (!bKeyHeld)
SETTINGS_SaveFM();
@ -1866,28 +1835,24 @@ Skip:
}
#endif
if (gRequestSaveVFO)
{
if (gRequestSaveVFO) {
gRequestSaveVFO = false;
if (!bKeyHeld)
SETTINGS_SaveVfoIndices();
else
gFlagSaveVfo = true;
flagSaveVfo = true;
}
if (gRequestSaveChannel > 0) // TODO: remove the gRequestSaveChannel, why use global variable for that??
{
if (!bKeyHeld)
{
if (gRequestSaveChannel > 0) { // TODO: remove the gRequestSaveChannel, why use global variable for that??
if (!bKeyHeld) {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel);
if (!SCANNER_IsScanning())
if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere
gVfoConfigureMode = VFO_CONFIGURE;
if (!SCANNER_IsScanning() && gVfoConfigureMode == VFO_CONFIGURE_NONE)
// gVfoConfigureMode is so as we don't wipe out previously setting this variable elsewhere
gVfoConfigureMode = VFO_CONFIGURE;
}
else
{
gFlagSaveChannel = gRequestSaveChannel;
else { // this is probably so settings are not saved when up/down button is held and save is postponed to btn release
flagSaveChannel = gRequestSaveChannel;
if (gRequestDisplayScreen == DISPLAY_INVALID)
gRequestDisplayScreen = DISPLAY_MAIN;
@ -1896,10 +1861,8 @@ Skip:
gRequestSaveChannel = 0;
}
if (gVfoConfigureMode != VFO_CONFIGURE_NONE)
{
if (gFlagResetVfos)
{
if (gVfoConfigureMode != VFO_CONFIGURE_NONE) {
if (gFlagResetVfos) {
RADIO_ConfigureChannel(0, gVfoConfigureMode);
RADIO_ConfigureChannel(1, gVfoConfigureMode);
}
@ -1914,8 +1877,7 @@ Skip:
gFlagResetVfos = false;
}
if (gFlagReconfigureVfos)
{
if (gFlagReconfigureVfos) {
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
@ -1940,29 +1902,26 @@ Skip:
ACTION_Monitor(); // 1of11
}
if (gFlagRefreshSetting)
{
if (gFlagRefreshSetting) {
gFlagRefreshSetting = false;
gMenuCountdown = menu_timeout_500ms;
MENU_ShowCurrentSetting();
}
if (gFlagPrepareTX)
{
if (gFlagPrepareTX) {
RADIO_PrepareTX();
gFlagPrepareTX = false;
}
#ifdef ENABLE_VOICE
if (gAnotherVoiceID != VOICE_ID_INVALID)
{
if (gAnotherVoiceID < 76)
AUDIO_SetVoiceID(0, gAnotherVoiceID);
AUDIO_PlaySingleVoice(false);
gAnotherVoiceID = VOICE_ID_INVALID;
}
#endif
#ifdef ENABLE_VOICE
if (gAnotherVoiceID != VOICE_ID_INVALID) {
if (gAnotherVoiceID < 76)
AUDIO_SetVoiceID(0, gAnotherVoiceID);
AUDIO_PlaySingleVoice(false);
gAnotherVoiceID = VOICE_ID_INVALID;
}
#endif
GUI_SelectNextDisplay(gRequestDisplayScreen);
gRequestDisplayScreen = DISPLAY_INVALID;

View File

@ -75,27 +75,17 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{
uint8_t Vfo = gEeprom.TX_VFO;
if (gScreenToDisplay == DISPLAY_MENU)
{
// if (beep)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
if (gScreenToDisplay == DISPLAY_MENU) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
// if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
switch (Key)
{
switch (Key) {
case KEY_0:
#ifdef ENABLE_FMRADIO
ACTION_FM();
#else
// TODO: make use of this function key
#endif
break;
@ -106,14 +96,12 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
#ifdef ENABLE_COPY_CHAN_TO_VFO
if (!gEeprom.VFO_OPEN || gCssBackgroundScan)
{
if (!gEeprom.VFO_OPEN || gCssBackgroundScan) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (gScanStateDir != SCAN_OFF)
{
if (gScanStateDir != SCAN_OFF) {
if (gCurrentFunction != FUNCTION_INCOMING ||
gRxReceptionMode == RX_MODE_NONE ||
gScanPauseDelayIn_10ms == 0)
@ -149,7 +137,6 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
return;
}
#endif
gTxVfo->Band += 1;
if (gTxVfo->Band == BAND5_350MHz && !gSetting_350EN) {
@ -204,13 +191,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_5:
if(beep) {
#ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
}
else
{
else {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
@ -249,8 +233,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break;
case KEY_9:
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0))
{
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) {
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
#ifdef ENABLE_VOICE
@ -279,15 +262,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (bKeyHeld)
{ // key held down
if (bKeyPressed)
{
if (gScreenToDisplay == DISPLAY_MAIN)
{
if (gInputBoxIndex > 0)
{ // delete any inputted chars
if (bKeyHeld) { // key held down
if (bKeyPressed) {
if (gScreenToDisplay == DISPLAY_MAIN) {
if (gInputBoxIndex > 0) { // delete any inputted chars
gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN;
}
@ -298,7 +276,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
processFKeyFunction(Key, false);
}
}
return;
}
@ -308,22 +285,15 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; // don't use the key till it's released
}
if (!gWasFKeyPressed)
{ // F-key wasn't pressed
if (!gWasFKeyPressed) { // F-key wasn't pressed
const uint8_t Vfo = gEeprom.TX_VFO;
gKeyInputCountdown = key_input_timeout_500ms;
INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_MAIN;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering channel number
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering channel number
if (gInputBoxIndex != 3)
{
if (gInputBoxIndex != 3) {
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -335,8 +305,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
const uint16_t Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (!RADIO_CheckValidChannel(Channel, false, 0))
{
if (!RADIO_CheckValidChannel(Channel, false, 0)) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
@ -363,8 +332,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
bool isGigaF = gTxVfo->pRX->Frequency >= _1GHz_in_KHz;
if (gInputBoxIndex < 6 + isGigaF)
{
if (gInputBoxIndex < 6 + isGigaF) {
return;
}
@ -372,26 +340,20 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
uint32_t Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
// clamp the frequency entered to some valid value
if (Frequency < frequencyBandTable[0].lower)
{
if (Frequency < frequencyBandTable[0].lower) {
Frequency = frequencyBandTable[0].lower;
}
else
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
{
else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) {
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
}
else
if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
{
else if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) {
Frequency = frequencyBandTable[BAND_N_ELEM - 1].upper;
}
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
if (gTxVfo->Band != band)
{
if (gTxVfo->Band != band) {
gTxVfo->Band = band;
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST;
@ -419,8 +381,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
else
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering NOAA channel
if (gInputBoxIndex != 2)
{
if (gInputBoxIndex != 2) {
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -431,8 +392,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1];
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
{
if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) {
Channel += NOAA_CHANNEL_FIRST;
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@ -521,22 +481,16 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{
if (bKeyPressed && !bKeyHeld)
// menu key pressed
if (bKeyPressed && !bKeyHeld) // menu key pressed
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bKeyHeld)
{ // menu key held down (long press)
if (bKeyPressed)
{ // long press MENU key
if (bKeyHeld) { // menu key held down (long press)
if (bKeyPressed) { // long press MENU key
gWasFKeyPressed = false;
if (gScreenToDisplay == DISPLAY_MAIN)
{
if (gInputBoxIndex > 0)
{ // delete any inputted chars
if (gScreenToDisplay == DISPLAY_MAIN) {
if (gInputBoxIndex > 0) { // delete any inputted chars
gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_MAIN;
}
@ -551,13 +505,11 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
return;
}
if (!bKeyPressed && !gDTMF_InputMode)
{ // menu key released
if (!bKeyPressed && !gDTMF_InputMode) { // menu key released
const bool bFlag = !gInputBoxIndex;
gInputBoxIndex = 0;
if (bFlag)
{
if (bFlag) {
if (gScanStateDir != SCAN_OFF) {
CHFRSCANNER_Stop();
return;
@ -569,8 +521,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gAnotherVoiceID = VOICE_ID_MENU;
#endif
}
else
{
else {
gRequestDisplayScreen = DISPLAY_MAIN;
}
}
@ -581,15 +532,13 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_TRANSMIT)
return;
if (gInputBoxIndex)
{
if (gInputBoxIndex) {
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (bKeyHeld && !gWasFKeyPressed) // long press
{
if (bKeyHeld && !gWasFKeyPressed){ // long press
if (!bKeyPressed) // released
return;
@ -599,8 +548,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
if (bKeyPressed) // just pressed
{
if (bKeyPressed) { // just pressed
return;
}
@ -639,7 +587,6 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return;
}
#endif
// scan the CTCSS/DCS code
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
@ -655,58 +602,43 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (bKeyHeld || !bKeyPressed)
{
if (bKeyHeld || !bKeyPressed) { // key held or released
if (gInputBoxIndex > 0)
return;
return; // leave if input box active
if (!bKeyPressed)
{
if (!bKeyHeld)
if (!bKeyPressed) {
if (!bKeyHeld || IS_FREQ_CHANNEL(Channel))
return;
if (IS_FREQ_CHANNEL(Channel))
return;
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
// if released long button press and not in freq mode
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1); // say channel number
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
return;
}
}
else
{
if (gInputBoxIndex > 0)
{
else { // short pressed
if (gInputBoxIndex > 0) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
if (gScanStateDir == SCAN_OFF)
{
#ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(Channel))
#endif
if (gScanStateDir == SCAN_OFF) {
#ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(Channel))
#endif
{
uint8_t Next;
if (IS_FREQ_CHANNEL(Channel))
{ // step/down in frequency
if (IS_FREQ_CHANNEL(Channel)) { // step/down in frequency
const uint32_t frequency = APP_SetFrequencyByStep(gTxVfo, Direction);
if (RX_freq_check(frequency) < 0)
{ // frequency not allowed
if (RX_freq_check(frequency) < 0) { // frequency not allowed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gTxVfo->freq_config_RX.Frequency = frequency;
gRequestSaveChannel = 1;
return;
}
@ -714,29 +646,25 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
if (Next == 0xFF)
return;
if (Channel == Next)
return;
gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
gEeprom.MrChannel[gEeprom.TX_VFO] = Next;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next;
if (!bKeyHeld)
{
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, Next + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
if (!bKeyHeld) {
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, Next + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
}
}
#ifdef ENABLE_NOAA
else
{
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
}
#endif
#ifdef ENABLE_NOAA
else {
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel;
}
#endif
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -746,24 +674,22 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
// jump to the next channel
CHFRSCANNER_Start(false, Direction);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
gScheduleScanListen = false;
gPttWasReleased = true;
}
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
#ifdef ENABLE_FMRADIO
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT)
{
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
#endif
#ifdef ENABLE_FMRADIO
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) {
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
#endif
if (gDTMF_InputMode && bKeyPressed && !bKeyHeld)
{
if (gDTMF_InputMode && bKeyPressed && !bKeyHeld) {
const char Character = DTMF_GetCharacter(Key);
if (Character != 0xFF)
{ // add key to DTMF string
@ -782,18 +708,8 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// Key = KEY_SIDE2; // what's this doing ???
// }
switch (Key)
{
case KEY_0:
case KEY_1:
case KEY_2:
case KEY_3:
case KEY_4:
case KEY_5:
case KEY_6:
case KEY_7:
case KEY_8:
case KEY_9:
switch (Key) {
case KEY_0...KEY_9:
MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
break;
case KEY_MENU:

View File

@ -14,6 +14,16 @@ static inline void LogUart(const char *const str)
UART_Send(str, strlen(str));
}
static inline void LogUartf(const char* format, ...)
{
char buffer[128];
va_list va;
va_start(va, format);
vsnprintf(buffer, (size_t)-1, format, va);
va_end(va);
UART_Send(buffer, strlen(buffer));
}
static inline void LogRegUart(uint16_t reg)
{
uint16_t regVal = BK4819_ReadRegister(reg);

3
misc.c
View File

@ -181,9 +181,6 @@ bool gFlagPrepareTX;
bool gFlagAcceptSetting;
bool gFlagRefreshSetting;
bool gFlagSaveVfo;
bool gFlagSaveSettings;
bool gFlagSaveChannel;
#ifdef ENABLE_FMRADIO
bool gFlagSaveFM;
#endif

3
misc.h
View File

@ -260,9 +260,6 @@ extern bool gFlagPrepareTX;
extern bool gFlagAcceptSetting; // accept menu setting
extern bool gFlagRefreshSetting; // refresh menu display
extern bool gFlagSaveVfo;
extern bool gFlagSaveSettings;
extern bool gFlagSaveChannel;
#ifdef ENABLE_FMRADIO
extern bool gFlagSaveFM;
#endif