22 Commits
v0.9 ... v0.12

Author SHA1 Message Date
Krzysiek Egzmont
f11d0fbcda Code refactoring 2023-10-17 21:47:39 +02:00
Krzysiek Egzmont
96144af9e9 Added function buttons configuration to menu 2023-10-17 20:16:56 +02:00
Krzysiek Egzmont
4dd2445833 Menu items reordered 2023-10-17 13:34:18 +02:00
Krzysiek Egzmont
6172d942be Fix scanning on opposite VFO, ignore scan result on EXIT button, changed status bar while scanning 2023-10-17 02:57:55 +02:00
Krzysiek Egzmont
0c0cbb232c Refactoring 2023-10-17 02:26:20 +02:00
Krzysiek Egzmont
298ff29cf4 Fix restore VFO settings after scan 2023-10-16 22:59:17 +02:00
Krzysiek Egzmont
f70707e17f Fix copy channel to VFO function copying wrong VFO, clean VFO setup 2023-10-16 18:39:20 +02:00
Krzysiek Egzmont
f1fc04591c Fix compiler errors 2023-10-16 17:17:17 +02:00
Krzysiek Egzmont
a26c397417 Remove fall-through pragmas 2023-10-16 16:52:32 +02:00
Krzysiek Egzmont
d3a2a7bee9 Menu id fix 2023-10-16 16:02:39 +02:00
Krzysiek Egzmont
d817ff7e6a Fixed RSSI calibration 2023-10-16 13:01:24 +02:00
Krzysiek Egzmont
ec4bec5b1f Flashlight SOS function 2023-10-16 00:15:04 +02:00
Krzysiek Egzmont
d7c458839c Change menu items names 2023-10-15 22:07:55 +02:00
Krzysiek Egzmont
cff2f25e56 Consolidate "T VFO" and "DUALRX" into one "RXMODE" 2023-10-15 21:52:42 +02:00
Krzysiek Egzmont
63ac84883e add execute rights to compile-with-docker.sh 2023-10-15 21:12:06 +02:00
wrobepio
f8252df281 fixed: "compiled-firmware" folder missing under linux - fixed shell variable $PWD 2023-10-14 20:26:29 +02:00
Krzysiek Egzmont
be00bb99ad FIX #28: After entering item 51(BATVOL) of the menu, the automatic lock screen cannot be unlocked 2023-10-12 20:45:26 +02:00
Krzysiek Egzmont
7e6a78ab6c FIX #26: vfo state (TX DISABLE label) update issue when FM radio disabled in Makefile 2023-10-12 00:44:52 +02:00
Krzysiek Egzmont
06c2ddf543 BUG FIX: power save never activated 2023-10-10 19:36:12 +02:00
Krzysiek Egzmont
47f1e80252 Fix #25: When you stop the scan with the PTT the Walkie stays in permanent TX 2023-10-10 17:32:58 +02:00
Krzysiek Egzmont
64bc29d362 FIX #24: lock/unlock doesn't work when FM radio active 2023-10-10 14:29:51 +02:00
Krzysiek Egzmont
8d17f5922c FIX #21: Battery symbol fix of a fix 2023-10-10 02:39:02 +02:00
33 changed files with 888 additions and 961 deletions

View File

@@ -25,7 +25,7 @@ ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_CODE_SCAN_TIMEOUT := 0 ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_AM_FIX := 1 ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 0 ENABLE_AM_FIX_SHOW_DATA := 0
@@ -209,7 +209,7 @@ endif
#CFLAGS += -Wpadded #CFLAGS += -Wpadded
# catch any and all warnings # catch any and all warnings
#CFLAGS += -Wextra CFLAGS += -Wextra
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"

View File

@@ -45,6 +45,7 @@ static void ACTION_FlashLight(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break; break;
case 1: case 1:
case 2:
gFlashLightState++; gFlashLightState++;
break; break;
default: default:
@@ -192,7 +193,7 @@ void ACTION_Scan(bool bRestart)
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel // jump to the next channel
CHANNEL_Next(true, gScanStateDir); SCANNER_NextChannel(false, gScanStateDir);
gScanPauseDelayIn_10ms = 1; gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false; gScheduleScanListen = false;
@@ -211,7 +212,7 @@ void ACTION_Scan(bool bRestart)
else else
{ // start scanning { // start scanning
CHANNEL_Next(true, SCAN_FWD); SCANNER_NextChannel(true, SCAN_FWD);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
@@ -234,7 +235,7 @@ void ACTION_Scan(bool bRestart)
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel // jump to the next channel
CHANNEL_Next(true, gScanStateDir); SCANNER_NextChannel(false, gScanStateDir);
gScanPauseDelayIn_10ms = 1; gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false; gScheduleScanListen = false;
@@ -325,18 +326,15 @@ void ACTION_Scan(bool bRestart)
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
uint8_t Short = ACTION_OPT_NONE; if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode) // entering DTMF code
uint8_t Long = ACTION_OPT_NONE;
if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode)
{ {
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed) if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed) // side1 btn pressed
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gDTMF_InputBox_Index > 0) if (gDTMF_InputBox_Index > 0) // DTMF codes are in the input box
{ {
gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; // delete one code
if (gDTMF_InputBox_Index > 0) if (gDTMF_InputBox_Index > 0)
{ {
gPttWasReleased = true; gPttWasReleased = true;
@@ -350,43 +348,47 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
gDTMF_InputMode = false; gDTMF_InputMode = false; // turn off DTMF input box if no codes left
} }
gPttWasReleased = true; gPttWasReleased = true;
return; return;
} }
uint8_t funcShort = ACTION_OPT_NONE;
uint8_t funcLong = ACTION_OPT_NONE;
if (Key == KEY_SIDE1) if (Key == KEY_SIDE1)
{ {
Short = gEeprom.KEY_1_SHORT_PRESS_ACTION; funcShort = gEeprom.KEY_1_SHORT_PRESS_ACTION;
Long = gEeprom.KEY_1_LONG_PRESS_ACTION; funcLong = gEeprom.KEY_1_LONG_PRESS_ACTION;
} }
else else if (Key == KEY_SIDE2)
if (Key == KEY_SIDE2)
{ {
Short = gEeprom.KEY_2_SHORT_PRESS_ACTION; funcShort = gEeprom.KEY_2_SHORT_PRESS_ACTION;
Long = gEeprom.KEY_2_LONG_PRESS_ACTION; funcLong = gEeprom.KEY_2_LONG_PRESS_ACTION;
} }
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed) // button pushed
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }
if (bKeyHeld || bKeyPressed) // held or released beyond this point
if (bKeyHeld || bKeyPressed) // held
{ {
if (!bKeyHeld) funcShort = funcLong;
return;
Short = Long; if (!bKeyPressed) //ignore release if held
if (!bKeyPressed)
return; return;
} }
switch (Short) // held or released after short press beyond this point
switch (funcShort)
{ {
default: default:
case ACTION_OPT_NONE: case ACTION_OPT_NONE:

View File

@@ -22,7 +22,7 @@
//static void ACTION_FlashLight(void) //static void ACTION_FlashLight(void)
void ACTION_Power(void); void ACTION_Power(void);
void ACTION_Monitor(void); void ACTION_Monitor(void);
void ACTION_Scan(bool bFlag); void ACTION_Scan(bool bRestart);
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
void ACTION_Vox(void); void ACTION_Vox(void);
#endif #endif

517
app/app.c
View File

@@ -621,127 +621,6 @@ uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
return Frequency; return Frequency;
} }
static void FREQ_NextChannel(void)
{
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
gScanPauseDelayIn_10ms = 9; // 90ms
#else
gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
#endif
bScanKeepFrequency = false;
gUpdateDisplay = true;
}
static void MR_NextChannel(void)
{
static unsigned int prev_mr_chan = 0;
const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1;
const unsigned int prev_chan = gNextMrChannel;
unsigned int chan = 0;
if (enabled)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gCurrentScanList)
{
case SCAN_NEXT_CHAN_SCANLIST1:
prev_mr_chan = gNextMrChannel;
if (chan1 >= 0)
{
if (RADIO_CheckValidChannel(chan1, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
break;
}
}
case SCAN_NEXT_CHAN_SCANLIST2:
if (chan2 >= 0)
{
if (RADIO_CheckValidChannel(chan2, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2;
gNextMrChannel = chan2;
break;
}
}
// this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
// {
// chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan];
// if (chan <= MR_CHANNEL_LAST)
// {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan;
// break;
// }
// }
default:
case SCAN_NEXT_CHAN_MR:
gCurrentScanList = SCAN_NEXT_CHAN_MR;
gNextMrChannel = prev_mr_chan;
chan = 0xff;
break;
}
#pragma GCC diagnostic pop
}
if (!enabled || chan == 0xff)
{
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF)
{ // no valid channel found
chan = MR_CHANNEL_FIRST;
// return;
}
gNextMrChannel = chan;
}
if (gNextMrChannel != prev_chan)
{
gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
RADIO_SetupRegisters(true);
gUpdateDisplay = true;
}
#ifdef ENABLE_FASTER_CHANNEL_SCAN
gScanPauseDelayIn_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
#else
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
#endif
bScanKeepFrequency = false;
if (enabled)
if (++gCurrentScanList >= SCAN_NEXT_NUM)
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
}
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
static void NOAA_IncreaseChannel(void) static void NOAA_IncreaseChannel(void)
{ {
@@ -1064,56 +943,38 @@ void APP_Update(void)
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_TRANSMIT)
APP_HandleFunction(); APP_HandleFunction();
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
// if (gFmRadioCountdown_500ms > 0) // if (gFmRadioCountdown_500ms > 0)
if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11
return; return;
#endif #endif
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0) if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
#endif #endif
{ // scanning { // scanning
SCANNER_ContinueScanning();
if (IS_FREQ_CHANNEL(gNextMrChannel))
{
if (gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
FREQ_NextChannel(); // switch to next frequency
}
else
{
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
MR_NextChannel(); // switch to next channel
}
gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0) if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0)
#else #else
if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen) if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen)
#endif #endif
{ {
MENU_SelectNextCode(); MENU_SelectNextCode();
gScheduleScanListen = false; gScheduleScanListen = false;
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0)
#else #else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA)
#endif #endif
{ {
NOAA_IncreaseChannel(); NOAA_IncreaseChannel();
RADIO_SetupRegisters(false); RADIO_SetupRegisters(false);
@@ -1121,23 +982,23 @@ void APP_Update(void)
gNOAA_Countdown_10ms = 7; // 70ms gNOAA_Countdown_10ms = 7; // 70ms
gScheduleNOAA = false; gScheduleNOAA = false;
} }
#endif #endif
// toggle between the VFO's if dual watch is enabled // toggle between the VFO's if dual watch is enabled
if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gScheduleDualWatch && gVoiceWriteIndex == 0) if (gScheduleDualWatch && gVoiceWriteIndex == 0)
#else #else
if (gScheduleDualWatch) if (gScheduleDualWatch)
#endif #endif
{ {
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{ {
if (!gPttIsPressed && if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
!gFmRadioMode && !gFmRadioMode &&
#endif #endif
gDTMF_CallState == DTMF_CALL_STATE_NONE && gDTMF_CallState == DTMF_CALL_STATE_NONE &&
gCurrentFunction != FUNCTION_POWER_SAVE) gCurrentFunction != FUNCTION_POWER_SAVE)
{ {
@@ -1155,90 +1016,89 @@ void APP_Update(void)
} }
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gScheduleFM && if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF && gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT) gCurrentFunction != FUNCTION_TRANSMIT)
{ // switch to FM radio mode { // switch to FM radio mode
FM_Play(); FM_Play();
gScheduleFM = false; gScheduleFM = false;
} }
#endif #endif
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH)
APP_HandleVox(); APP_HandleVox();
#endif #endif
if (gSchedulePowerSave) if (gSchedulePowerSave)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if ( if (
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
gFmRadioMode || gFmRadioMode ||
#endif #endif
gPttIsPressed || gPttIsPressed ||
gKeyBeingHeld || gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 || gEeprom.BATTERY_SAVE == 0 ||
gScanStateDir != SCAN_OFF || gScanStateDir != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF || gCssScanMode != CSS_SCAN_MODE_OFF ||
gScreenToDisplay != DISPLAY_MAIN || gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE) gDTMF_CallState != DTMF_CALL_STATE_NONE)
{ {
gBatterySaveCountdown_10ms = battery_save_count_10ms; gBatterySaveCountdown_10ms = battery_save_count_10ms;
} }
else else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) {
{ //if (gCurrentFunction != FUNCTION_POWER_SAVE)
//if (gCurrentFunction != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE);
FUNCTION_Select(FUNCTION_POWER_SAVE); }
} else
else {
{ gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdown_10ms = battery_save_count_10ms; }
} #else
#else if (
if ( #ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO gFmRadioMode ||
gFmRadioMode || #endif
#endif gPttIsPressed ||
gPttIsPressed || gKeyBeingHeld ||
gKeyBeingHeld || gEeprom.BATTERY_SAVE == 0 ||
gEeprom.BATTERY_SAVE == 0 || gScanStateDir != SCAN_OFF ||
gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF || gScreenToDisplay != DISPLAY_MAIN ||
gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE)
gDTMF_CallState != DTMF_CALL_STATE_NONE) {
{ gBatterySaveCountdown_10ms = battery_save_count_10ms;
gBatterySaveCountdown_10ms = battery_save_count_10ms; }
} else
else {
{ //if (gCurrentFunction != FUNCTION_POWER_SAVE)
//if (gCurrentFunction != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE);
FUNCTION_Select(FUNCTION_POWER_SAVE); }
}
gSchedulePowerSave = false; gSchedulePowerSave = false;
#endif #endif
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0) if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0)
#else #else
if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE) if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE)
#endif #endif
{ // wake up, enable RX then go back to sleep { // wake up, enable RX then go back to sleep
if (gRxIdleMode) if (gRxIdleMode)
{ {
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH)
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD); BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD);
#endif #endif
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanStateDir == SCAN_OFF && gScanStateDir == SCAN_OFF &&
@@ -1288,16 +1148,15 @@ void APP_Update(void)
// called every 10ms // called every 10ms
void APP_CheckKeys(void) void APP_CheckKeys(void)
{ {
KEY_Code_t Key; #ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
#ifdef ENABLE_AIRCOPY return;
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) #else
return; if (gSetting_KILLED)
#else return;
if (gSetting_KILLED) #endif
return;
#endif
// -------------------- PTT ------------------------
if (gPttIsPressed) if (gPttIsPressed)
{ {
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0) if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0)
@@ -1313,8 +1172,7 @@ void APP_CheckKeys(void)
else else
gPttDebounceCounter = 0; gPttDebounceCounter = 0;
} }
else else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0)
{ // PTT pressed { // PTT pressed
if (++gPttDebounceCounter >= 3) // 30ms if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting { // start transmitting
@@ -1327,16 +1185,16 @@ void APP_CheckKeys(void)
else else
gPttDebounceCounter = 0; gPttDebounceCounter = 0;
// ***************** // --------------------- OTHER KEYS ----------------------------
// scan the hardware keys // scan the hardware keys
Key = KEYBOARD_Poll(); KEY_Code_t Key = KEYBOARD_Poll();
if (Key != KEY_INVALID) if (Key != KEY_INVALID) // any key pressed
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed
if (gKeyReading0 != Key) if (gKeyReading0 != Key) // new key pressed
{ // new key pressed {
if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID) if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
@@ -1346,18 +1204,19 @@ void APP_CheckKeys(void)
return; return;
} }
if (++gDebounceCounter == key_debounce_10ms) gDebounceCounter++;
{ // debounced new key pressed
if (Key == KEY_INVALID) if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
{
if (Key == KEY_INVALID) //all PTT keys released
{ {
if (gKeyReading1 != KEY_INVALID) if (gKeyReading1 != KEY_INVALID) // some button was pressed before
{ {
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // process last button released event
gKeyReading1 = KEY_INVALID; gKeyReading1 = KEY_INVALID;
} }
} }
else else // process new key pressed
{ {
gKeyReading1 = Key; gKeyReading1 = Key;
APP_ProcessKey(Key, true, false); APP_ProcessKey(Key, true, false);
@@ -1367,21 +1226,19 @@ void APP_CheckKeys(void)
return; return;
} }
if (gDebounceCounter < key_repeat_delay_10ms) if (gDebounceCounter < key_repeat_delay_10ms || Key == KEY_INVALID) // the button is not held long enough for repeat yet, or not really pressed
return; return;
// key is being held pressed if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
{
if (gDebounceCounter == key_repeat_delay_10ms)
{ // initial key repeat delay after pressed
if (Key != KEY_PTT) if (Key != KEY_PTT)
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true); APP_ProcessKey(Key, true, true);
} }
} }
else else //subsequent fast key repeats
{ // key repeat {
if (Key == KEY_UP || Key == KEY_DOWN) if (Key == KEY_UP || Key == KEY_DOWN)
{ {
gKeyBeingHeld = true; gKeyBeingHeld = true;
@@ -1392,7 +1249,7 @@ void APP_CheckKeys(void)
if (gDebounceCounter < 0xFFFF) if (gDebounceCounter < 0xFFFF)
return; return;
gDebounceCounter = key_repeat_delay_10ms; gDebounceCounter = key_repeat_delay_10ms+1;
} }
} }
@@ -1451,6 +1308,35 @@ void APP_TimeSlice10ms(void)
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0)
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
else if(gFlashLightState == FLASHLIGHT_SOS) {
const uint16_t u = 15;
static uint8_t c;
static uint16_t next;
if(gFlashLightBlinkCounter - next > 7*u) {
c = 0;
next = gFlashLightBlinkCounter+1;
}
else if(gFlashLightBlinkCounter == next) {
if(c==0) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
else
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
if(c == 18) {
next += 7*u;
c = 0;
}
else if(c==7 || c==9 || c==11)
next += 3*u;
else
next += u;
c++;
}
}
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (gVoxResumeCountdown > 0) if (gVoxResumeCountdown > 0)
@@ -1763,7 +1649,7 @@ void APP_TimeSlice500ms(void)
#endif #endif
if (gBacklightCountdown > 0 && !gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF) if (gBacklightCountdown > 0 && !gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF)
if (gScreenToDisplay != DISPLAY_MENU || gMenuCursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option if (gScreenToDisplay != DISPLAY_MENU || GetCurrentMenuId() != MENU_ABR) // don't turn off backlight if user is in backlight menu option
if (--gBacklightCountdown == 0) if (--gBacklightCountdown == 0)
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
@@ -1827,7 +1713,7 @@ void APP_TimeSlice500ms(void)
if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#endif #endif
{ {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU)
{ {
if (--gKeyLockCountdown == 0) if (--gKeyLockCountdown == 0)
gEeprom.KEY_LOCK = true; // lock the keyboard gEeprom.KEY_LOCK = true; // lock the keyboard
@@ -1899,24 +1785,24 @@ void APP_TimeSlice500ms(void)
if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT)
updateRSSI(gEeprom.RX_VFO); updateRSSI(gEeprom.RX_VFO);
#ifdef ENABLE_FMRADIO if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0)
if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) {
if (--gVFOStateResumeCountdown_500ms == 0)
{ {
if (--gFM_ResumeCountdown_500ms == 0) RADIO_SetVfoState(VFO_STATE_NORMAL);
{ #ifdef ENABLE_FMRADIO
RADIO_SetVfoState(VFO_STATE_NORMAL); if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT &&
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT && gFmRadioMode)
gCurrentFunction != FUNCTION_MONITOR && { // switch back to FM radio mode
gFmRadioMode) FM_Start();
{ // switch back to FM radio mode GUI_SelectNextDisplay(DISPLAY_FM);
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
} }
#endif
} }
#endif }
if (gLowBattery) if (gLowBattery)
{ {
@@ -2054,33 +1940,7 @@ void APP_TimeSlice500ms(void)
} }
#endif #endif
void CHANNEL_Next(const bool bFlag, const int8_t scan_direction)
{
RADIO_SelectVfos();
gNextMrChannel = gRxVfo->CHANNEL_SAVE;
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gScanStateDir = scan_direction;
if (gNextMrChannel <= MR_CHANNEL_LAST)
{ // channel mode
if (bFlag)
gRestoreMrChannel = gNextMrChannel;
MR_NextChannel();
}
else
{ // frequency mode
if (bFlag)
gRestoreFrequency = gRxVfo->freq_config_RX.Frequency;
FREQ_NextChannel();
}
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
}
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
@@ -2204,7 +2064,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F) if (Key <= KEY_9 || Key == KEY_F)
{ {
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
{ // FREQ/CTCSS/DCS scanning { // FREQ/CTCSS/DCS scanning
@@ -2226,8 +2086,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
} }
else else if (gPttWasReleased)
if (gPttWasReleased)
{ {
if (bKeyHeld) if (bKeyHeld)
bFlag = true; bFlag = true;
@@ -2249,9 +2108,9 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF) if (gAlarmState == ALARM_STATE_OFF)
#endif #endif
{ {
char Code; char Code;
@@ -2306,7 +2165,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code); BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code);
} }
} }
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
else else
if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed))
{ {
@@ -2323,7 +2182,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!bKeyHeld) if (!bKeyHeld)
gPttWasReleased = true; gPttWasReleased = true;
} }
#endif #endif
} }
else else
if (Key != KEY_SIDE1 && Key != KEY_SIDE2) if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
@@ -2331,6 +2190,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
switch (gScreenToDisplay) switch (gScreenToDisplay)
{ {
case DISPLAY_MAIN: case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
// bKeyHeld = false; // allow the channel setting to be saved // bKeyHeld = false; // allow the channel setting to be saved
break; break;
@@ -2361,16 +2221,15 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
else else
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY) if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY)
#else #else
if (gScreenToDisplay != DISPLAY_SCANNER) if (gScreenToDisplay != DISPLAY_SCANNER)
#endif #endif
{ {
ACTION_Handle(Key, bKeyPressed, bKeyHeld); ACTION_Handle(Key, bKeyPressed, bKeyHeld);
} }
else else if (!bKeyHeld && bKeyPressed)
if (!bKeyHeld && bKeyPressed)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }

View File

@@ -29,7 +29,6 @@ extern const uint8_t orig_mixer;
extern const uint8_t orig_pga; extern const uint8_t orig_pga;
void APP_EndTransmission(void); void APP_EndTransmission(void);
void CHANNEL_Next(const bool bFlag, const int8_t scan_direction);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step); uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step);
void APP_Update(void); void APP_Update(void);

View File

@@ -356,13 +356,11 @@ void DTMF_HandleRequest(void)
gUpdateDisplay = true; gUpdateDisplay = true;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gEeprom.DTMF_DECODE_RESPONSE) switch (gEeprom.DTMF_DECODE_RESPONSE)
{ {
case DTMF_DEC_RESPONSE_BOTH: case DTMF_DEC_RESPONSE_BOTH:
gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms;
[[fallthrough]];
case DTMF_DEC_RESPONSE_REPLY: case DTMF_DEC_RESPONSE_REPLY:
gDTMF_ReplyState = DTMF_REPLY_AAAAA; gDTMF_ReplyState = DTMF_REPLY_AAAAA;
break; break;
@@ -376,8 +374,6 @@ void DTMF_HandleRequest(void)
break; break;
} }
#pragma GCC diagnostic pop
if (gDTMF_IsGroupCall) if (gDTMF_IsGroupCall)
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
} }

View File

@@ -45,7 +45,6 @@ bool gFM_AutoScan;
uint8_t gFM_ChannelPosition; uint8_t gFM_ChannelPosition;
bool gFM_FoundFrequency; bool gFM_FoundFrequency;
bool gFM_AutoScan; bool gFM_AutoScan;
uint8_t gFM_ResumeCountdown_500ms;
uint16_t gFM_RestoreCountdown_10ms; uint16_t gFM_RestoreCountdown_10ms;
bool FM_CheckValidChannel(uint8_t Channel) bool FM_CheckValidChannel(uint8_t Channel)

View File

@@ -39,7 +39,6 @@ extern uint8_t gFM_ChannelPosition;
extern uint16_t gFM_FrequencyDeviation; extern uint16_t gFM_FrequencyDeviation;
extern bool gFM_FoundFrequency; extern bool gFM_FoundFrequency;
extern bool gFM_AutoScan; extern bool gFM_AutoScan;
extern uint8_t gFM_ResumeCountdown_500ms;
extern uint16_t gFM_RestoreCountdown_10ms; extern uint16_t gFM_RestoreCountdown_10ms;
bool FM_CheckValidChannel(uint8_t Channel); bool FM_CheckValidChannel(uint8_t Channel);

View File

@@ -37,26 +37,22 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{ {
if (gInputBoxIndex > 0) if (gInputBoxIndex > 0)
{ {
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed) // short pressed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (bKeyHeld || !bKeyPressed) if (bKeyHeld || !bKeyPressed) // held or released
{ {
if (bKeyHeld || bKeyPressed) if (bKeyHeld || bKeyPressed) // held or pressed (cannot be held and not pressed I guess, so it checks only if HELD?)
{ {
if (!bKeyHeld) if (!bKeyHeld) // won't ever pass
return; return;
if (!bKeyPressed) if (!bKeyPressed) // won't ever pass
return; return;
if (gScreenToDisplay != DISPLAY_MENU && if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT) gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock { // toggle the keyboad lock
@@ -69,7 +65,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
} }
else else // released
{ {
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM) if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM)
@@ -79,7 +75,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return; return;
#endif #endif
gWasFKeyPressed = !gWasFKeyPressed; gWasFKeyPressed = !gWasFKeyPressed; // toggle F function
if (gWasFKeyPressed) if (gWasFKeyPressed)
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
@@ -92,7 +88,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
gUpdateStatus = true; gUpdateStatus = true;
} }
} }
else else // short pressed
{ {
if (gScreenToDisplay != DISPLAY_FM) if (gScreenToDisplay != DISPLAY_FM)
{ {
@@ -101,7 +97,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState == FM_SCAN_OFF) if (gFM_ScanState == FM_SCAN_OFF) // not scanning
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
@@ -120,7 +116,6 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (!bKeyPressed || gSerialConfigCountDown_500ms > 0) if (!bKeyPressed || gSerialConfigCountDown_500ms > 0)
{ // PTT released { // PTT released
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // we are transmitting .. stop { // we are transmitting .. stop
@@ -185,22 +180,22 @@ void GENERIC_Key_PTT(bool bKeyPressed)
goto cancel_tx; goto cancel_tx;
} }
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFM_ScanState != FM_SCAN_OFF) if (gFM_ScanState != FM_SCAN_OFF)
{ // FM radio is scanning .. stop { // FM radio is scanning .. stop
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx; goto cancel_tx;
} }
#endif #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gScreenToDisplay == DISPLAY_FM) if (gScreenToDisplay == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing goto start_tx; // listening to the FM radio .. start TX'ing
#endif #endif
if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0) if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0)
{ // already transmitting { // already transmitting
@@ -259,7 +254,6 @@ start_tx:
cancel_tx: cancel_tx:
if (gPttIsPressed) if (gPttIsPressed)
{ {
gPttIsPressed = false;
gPttWasPressed = true; gPttWasPressed = true;
} }

View File

@@ -130,19 +130,12 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_2: case KEY_2:
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A) gEeprom.TX_VFO ^= 1;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_B;
else if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) gEeprom.CROSS_BAND_RX_TX = gEeprom.TX_VFO + 1;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_A; if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
else gEeprom.DUAL_WATCH = gEeprom.TX_VFO + 1;
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_B;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A;
else
gEeprom.TX_VFO = (Vfo + 1) & 1u;
gRequestSaveSettings = 1; gRequestSaveSettings = 1;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
@@ -209,7 +202,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_5: case KEY_5:
if(beep) { if(beep) {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ {
@@ -218,9 +211,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
else else
{ {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO]; gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE;
#endif #endif
} }
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@@ -230,9 +223,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
#endif #endif
} }
else { else {
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
toggle_chan_scanlist(); toggle_chan_scanlist();
#endif #endif
} }
break; break;
@@ -242,11 +235,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_7: case KEY_7:
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
ACTION_Vox(); ACTION_Vox();
#else #else
toggle_chan_scanlist(); toggle_chan_scanlist();
#endif #endif
break; break;
case KEY_8: case KEY_8:
@@ -259,11 +252,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
{ {
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL; gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL; gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1); AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE; gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif #endif
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break; break;
@@ -513,6 +506,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
} }
else else
{ {
bScanKeepFrequency = false;
SCANNER_Stop(); SCANNER_Stop();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@@ -586,7 +580,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
} }
} }
const unsigned int vfo = get_rx_VFO(); const uint8_t vfo = gEeprom.TX_VFO;
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
{ // copy channel to VFO, then swap to the VFO { // copy channel to VFO, then swap to the VFO
@@ -654,28 +648,28 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (bKeyHeld && !gWasFKeyPressed) if (bKeyHeld && !gWasFKeyPressed) // long press
{ // long press .. toggle scanning {
if (!bKeyPressed) if (!bKeyPressed) // released
return; // released return;
ACTION_Scan(false); ACTION_Scan(false);// toggle scanning
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }
if (bKeyPressed) if (bKeyPressed) // just pressed
{ // just pressed {
// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL;
return; return;
} }
// just released // just released
if (!gWasFKeyPressed) if (!gWasFKeyPressed) // pressed without the F-key
{ // pressed without the F-key {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
@@ -810,7 +804,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
} }
// jump to the next channel // jump to the next channel
CHANNEL_Next(false, Direction); SCANNER_NextChannel(false, Direction);
gScanPauseDelayIn_10ms = 1; gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false; gScheduleScanListen = false;

View File

@@ -98,9 +98,9 @@ void MENU_StopCssScan(void)
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
} }
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
{ {
switch (Cursor) switch (menu_id)
{ {
case MENU_SQL: case MENU_SQL:
*pMin = 0; *pMin = 0;
@@ -139,12 +139,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_TDR: case MENU_TDR:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_CHAN) - 1; *pMax = ARRAY_SIZE(gSubMenu_RXMode) - 1;
break;
case MENU_XB:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_XB) - 1;
break; break;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@@ -285,7 +280,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_S_LIST: case MENU_S_LIST:
*pMin = 0; *pMin = 0;
// *pMax = 1;
*pMax = 2; *pMax = 2;
break; break;
@@ -331,6 +325,14 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = 2200; // 2300 *pMax = 2200; // 2300
break; break;
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
*pMin = 0;
*pMax = gSubMenu_SIDEFUNCTIONS_size-1;
break;
default: default:
return -1; return -1;
} }
@@ -345,14 +347,14 @@ void MENU_AcceptSetting(void)
uint8_t Code; uint8_t Code;
FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX; FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX;
if (!MENU_GetLimits(gMenuCursor, &Min, &Max)) if (!MENU_GetLimits(GetCurrentMenuId(), &Min, &Max))
{ {
if (gSubMenuSelection < Min) gSubMenuSelection = Min; if (gSubMenuSelection < Min) gSubMenuSelection = Min;
else else
if (gSubMenuSelection > Max) gSubMenuSelection = Max; if (gSubMenuSelection > Max) gSubMenuSelection = Max;
} }
switch (gMenuCursor) switch (GetCurrentMenuId())
{ {
default: default:
return; return;
@@ -408,11 +410,9 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
case MENU_T_CTCS: case MENU_T_CTCS:
pConfig = &gTxVfo->freq_config_TX; pConfig = &gTxVfo->freq_config_TX;
[[fallthrough]];
case MENU_R_CTCS: case MENU_R_CTCS:
if (gSubMenuSelection == 0) if (gSubMenuSelection == 0)
{ {
@@ -439,8 +439,6 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
#pragma GCC diagnostic pop
case MENU_SFT_D: case MENU_SFT_D:
gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection; gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
@@ -510,7 +508,7 @@ void MENU_AcceptSetting(void)
gEeprom.VOX_SWITCH = gSubMenuSelection != 0; gEeprom.VOX_SWITCH = gSubMenuSelection != 0;
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH)
gEeprom.VOX_LEVEL = gSubMenuSelection - 1; gEeprom.VOX_LEVEL = gSubMenuSelection - 1;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
break; break;
@@ -525,24 +523,13 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_TDR: case MENU_TDR:
gEeprom.DUAL_WATCH = gSubMenuSelection; gEeprom.DUAL_WATCH = (gEeprom.TX_VFO + 1) * (gSubMenuSelection & 1);
gEeprom.CROSS_BAND_RX_TX = (gEeprom.TX_VFO + 1) * ((gSubMenuSelection & 2) > 0);
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
break; break;
case MENU_XB:
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]))
return;
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
return;
#endif
gEeprom.CROSS_BAND_RX_TX = gSubMenuSelection;
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;
case MENU_BEEP: case MENU_BEEP:
gEeprom.BEEP_CONTROL = gSubMenuSelection; gEeprom.BEEP_CONTROL = gSubMenuSelection;
break; break;
@@ -595,7 +582,7 @@ void MENU_AcceptSetting(void)
case MENU_MIC: case MENU_MIC:
gEeprom.MIC_SENSITIVITY = gSubMenuSelection; gEeprom.MIC_SENSITIVITY = gSubMenuSelection;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
break; break;
@@ -765,23 +752,30 @@ void MENU_AcceptSetting(void)
case MENU_BATCAL: case MENU_BATCAL:
{ {
uint16_t buf[4];
gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value
gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value
gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value
gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value
gBatteryCalibration[5] = 2300; gBatteryCalibration[5] = 2300;
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); SETTINGS_SaveBatteryCalibration(gBatteryCalibration);
return;
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = gBatteryCalibration[4];
buf[1] = gBatteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf);
break;
} }
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
{
uint8_t * fun[]= {
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
&gEeprom.KEY_1_LONG_PRESS_ACTION,
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION};
*fun[GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id;
}
break;
} }
gRequestSaveSettings = true; gRequestSaveSettings = true;
@@ -791,18 +785,17 @@ void MENU_SelectNextCode(void)
{ {
int32_t UpperLimit; int32_t UpperLimit;
if (gMenuCursor == MENU_R_DCS) if (GetCurrentMenuId() == MENU_R_DCS)
UpperLimit = 208; UpperLimit = 208;
//UpperLimit = ARRAY_SIZE(DCS_Options); //UpperLimit = ARRAY_SIZE(DCS_Options);
else else if (GetCurrentMenuId() == MENU_R_CTCS)
if (gMenuCursor == MENU_R_CTCS)
UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1; UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1;
else else
return; return;
gSubMenuSelection = NUMBER_AddWithWraparound(gSubMenuSelection, gMenuScrollDirection, 1, UpperLimit); gSubMenuSelection = NUMBER_AddWithWraparound(gSubMenuSelection, gMenuScrollDirection, 1, UpperLimit);
if (gMenuCursor == MENU_R_DCS) if (GetCurrentMenuId() == MENU_R_DCS)
{ {
if (gSubMenuSelection > 104) if (gSubMenuSelection > 104)
{ {
@@ -834,7 +827,7 @@ static void MENU_ClampSelection(int8_t Direction)
int32_t Min; int32_t Min;
int32_t Max; int32_t Max;
if (!MENU_GetLimits(gMenuCursor, &Min, &Max)) if (!MENU_GetLimits(GetCurrentMenuId(), &Min, &Max))
{ {
int32_t Selection = gSubMenuSelection; int32_t Selection = gSubMenuSelection;
if (Selection < Min) Selection = Min; if (Selection < Min) Selection = Min;
@@ -846,7 +839,7 @@ static void MENU_ClampSelection(int8_t Direction)
void MENU_ShowCurrentSetting(void) void MENU_ShowCurrentSetting(void)
{ {
switch (gMenuCursor) switch (GetCurrentMenuId())
{ {
case MENU_SQL: case MENU_SQL:
gSubMenuSelection = gEeprom.SQUELCH_LEVEL; gSubMenuSelection = gEeprom.SQUELCH_LEVEL;
@@ -956,11 +949,7 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_TDR: case MENU_TDR:
gSubMenuSelection = gEeprom.DUAL_WATCH; gSubMenuSelection = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
break;
case MENU_XB:
gSubMenuSelection = gEeprom.CROSS_BAND_RX_TX;
break; break;
case MENU_BEEP: case MENU_BEEP:
@@ -1153,6 +1142,28 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gBatteryCalibration[3]; gSubMenuSelection = gBatteryCalibration[3];
break; break;
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
{
uint8_t * fun[]= {
&gEeprom.KEY_1_SHORT_PRESS_ACTION,
&gEeprom.KEY_1_LONG_PRESS_ACTION,
&gEeprom.KEY_2_SHORT_PRESS_ACTION,
&gEeprom.KEY_2_LONG_PRESS_ACTION};
uint8_t id = *fun[GetCurrentMenuId()-MENU_F1SHRT];
for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) {
if(gSubMenu_SIDEFUNCTIONS[i].id==id) {
gSubMenuSelection = i;
break;
}
}
break;
}
default: default:
return; return;
} }
@@ -1170,12 +1181,12 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (edit_index < 10) if (edit_index < 10)
{ {
if (Key >= KEY_0 && Key <= KEY_9) if (Key <= KEY_9)
{ {
edit[edit_index] = '0' + Key - KEY_0; edit[edit_index] = '0' + Key - KEY_0;
@@ -1198,9 +1209,6 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!gIsInSubMenu) if (!gIsInSubMenu)
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gInputBoxIndex) switch (gInputBoxIndex)
{ {
case 2: case 2:
@@ -1220,7 +1228,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBox[0] = gInputBox[1]; gInputBox[0] = gInputBox[1];
gInputBoxIndex = 1; gInputBoxIndex = 1;
[[fallthrough]];
case 1: case 1:
Value = gInputBox[0]; Value = gInputBox[0];
if (Value > 0 && Value <= gMenuListCount) if (Value > 0 && Value <= gMenuListCount)
@@ -1232,15 +1240,13 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
break; break;
} }
#pragma GCC diagnostic pop
gInputBoxIndex = 0; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (gMenuCursor == MENU_OFFSET) if (GetCurrentMenuId() == MENU_OFFSET)
{ {
uint32_t Frequency; uint32_t Frequency;
@@ -1262,8 +1268,11 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0; gInputBoxIndex = 0;
return; return;
} }
if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL || gMenuCursor == MENU_MEM_NAME) if (GetCurrentMenuId() == MENU_MEM_CH ||
GetCurrentMenuId() == MENU_DEL_CH ||
GetCurrentMenuId() == MENU_1_CALL ||
GetCurrentMenuId() == MENU_MEM_NAME)
{ // enter 3-digit channel number { // enter 3-digit channel number
if (gInputBoxIndex < 3) if (gInputBoxIndex < 3)
@@ -1292,7 +1301,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (MENU_GetLimits(gMenuCursor, &Min, &Max)) if (MENU_GetLimits(GetCurrentMenuId(), &Min, &Max))
{ {
gInputBoxIndex = 0; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@@ -1337,7 +1346,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{ {
if (gIsInSubMenu) if (gIsInSubMenu)
{ {
if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET) if (gInputBoxIndex == 0 || GetCurrentMenuId() != MENU_OFFSET)
{ {
gAskForConfirmation = 0; gAskForConfirmation = 0;
gIsInSubMenu = false; gIsInSubMenu = false;
@@ -1394,12 +1403,12 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (!gIsInSubMenu) if (!gIsInSubMenu)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR) if (GetCurrentMenuId() != MENU_SCR)
gAnotherVoiceID = MenuList[gMenuCursor].voice_id; gAnotherVoiceID = MenuList[gMenuCursor].voice_id;
#endif #endif
#if 1 #if 1
if (gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_MEM_NAME) if (GetCurrentMenuId() == MENU_DEL_CH || GetCurrentMenuId() == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel return; // invalid channel
#endif #endif
@@ -1407,7 +1416,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gAskForConfirmation = 0; gAskForConfirmation = 0;
gIsInSubMenu = true; gIsInSubMenu = true;
// if (gMenuCursor != MENU_D_LIST) // if (GetCurrentMenuId() != MENU_D_LIST)
{ {
gInputBoxIndex = 0; gInputBoxIndex = 0;
edit_index = -1; edit_index = -1;
@@ -1416,7 +1425,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
return; return;
} }
if (gMenuCursor == MENU_MEM_NAME) if (GetCurrentMenuId() == MENU_MEM_NAME)
{ {
if (edit_index < 0) if (edit_index < 0)
{ // enter channel name edit mode { // enter channel name edit mode
@@ -1463,10 +1472,10 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (gIsInSubMenu) if (gIsInSubMenu)
{ {
if (gMenuCursor == MENU_RESET || if (GetCurrentMenuId() == MENU_RESET ||
gMenuCursor == MENU_MEM_CH || GetCurrentMenuId() == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH || GetCurrentMenuId() == MENU_DEL_CH ||
gMenuCursor == MENU_MEM_NAME) GetCurrentMenuId() == MENU_MEM_NAME)
{ {
switch (gAskForConfirmation) switch (gAskForConfirmation)
{ {
@@ -1479,7 +1488,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
UI_DisplayMenu(); UI_DisplayMenu();
if (gMenuCursor == MENU_RESET) if (GetCurrentMenuId() == MENU_RESET)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
@@ -1514,7 +1523,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR) if (GetCurrentMenuId() == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else else
gAnotherVoiceID = VOICE_ID_CONFIRM; gAnotherVoiceID = VOICE_ID_CONFIRM;
@@ -1530,7 +1539,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (edit_index < 10) if (edit_index < 10)
@@ -1557,7 +1566,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
if (gRxVfo->AM_mode == 0) if (gRxVfo->AM_mode == 0)
#endif #endif
{ {
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) if (GetCurrentMenuId() == MENU_R_CTCS || GetCurrentMenuId() == MENU_R_DCS)
{ // scan CTCSS or DCS to find the tone/code of the incoming signal { // scan CTCSS or DCS to find the tone/code of the incoming signal
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
@@ -1592,7 +1601,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Channel; uint8_t Channel;
bool bCheckScanList; bool bCheckScanList;
if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) if (GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character { // change the character
if (bKeyPressed && edit_index < 10 && Direction != 0) if (bKeyPressed && edit_index < 10 && Direction != 0)
{ {
@@ -1644,7 +1653,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
if (gMenuCursor != MENU_ABR && gEeprom.BACKLIGHT == 0) if (GetCurrentMenuId() != MENU_ABR && gEeprom.BACKLIGHT == 0)
{ {
gBacklightCountdown = 0; gBacklightCountdown = 0;
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
@@ -1653,7 +1662,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return; return;
} }
if (gMenuCursor == MENU_OFFSET) if (GetCurrentMenuId() == MENU_OFFSET)
{ {
int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection; int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection;
if (Offset < 99999990) if (Offset < 99999990)
@@ -1671,10 +1680,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
VFO = 0; VFO = 0;
#pragma GCC diagnostic push switch (GetCurrentMenuId())
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gMenuCursor)
{ {
case MENU_DEL_CH: case MENU_DEL_CH:
case MENU_1_CALL: case MENU_1_CALL:
@@ -1684,6 +1690,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
case MENU_SLIST2: case MENU_SLIST2:
VFO = 1; VFO = 1;
[[fallthrough]];
case MENU_SLIST1: case MENU_SLIST1:
bCheckScanList = true; bCheckScanList = true;
break; break;
@@ -1694,8 +1701,6 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return; return;
} }
#pragma GCC diagnostic pop
Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO); Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO);
if (Channel != 0xFF) if (Channel != 0xFF)
gSubMenuSelection = Channel; gSubMenuSelection = Channel;
@@ -1735,7 +1740,7 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
MENU_Key_STAR(bKeyPressed, bKeyHeld); MENU_Key_STAR(bKeyPressed, bKeyHeld);
break; break;
case KEY_F: case KEY_F:
if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) if (GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0)
{ // currently editing the channel name { // currently editing the channel name
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
@@ -1767,11 +1772,11 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gScreenToDisplay == DISPLAY_MENU) if (gScreenToDisplay == DISPLAY_MENU)
{ {
if (gMenuCursor == MENU_VOL || if (GetCurrentMenuId() == MENU_VOL ||
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
gMenuCursor == MENU_F_CALI || GetCurrentMenuId() == MENU_F_CALI ||
#endif #endif
gMenuCursor == MENU_BATCAL) GetCurrentMenuId() == MENU_BATCAL)
{ {
gMenuCountdown = menu_timeout_long_500ms; gMenuCountdown = menu_timeout_long_500ms;
} }

View File

@@ -23,7 +23,7 @@
void writeXtalFreqCal(const int32_t value, const bool update_eeprom); void writeXtalFreqCal(const int32_t value, const bool update_eeprom);
#endif #endif
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax); int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax);
void MENU_AcceptSetting(void); void MENU_AcceptSetting(void);
void MENU_SelectNextCode(void); void MENU_SelectNextCode(void);
void MENU_ShowCurrentSetting(void); void MENU_ShowCurrentSetting(void);

View File

@@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "app/app.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#include "app/generic.h" #include "app/generic.h"
#include "app/scanner.h" #include "app/scanner.h"
@@ -43,6 +44,8 @@ uint8_t gScanHitCount;
bool gScanUseCssResult; bool gScanUseCssResult;
int8_t gScanStateDir; int8_t gScanStateDir;
bool bScanKeepFrequency; bool bScanKeepFrequency;
uint8_t gRestoreMrChannel;
uint8_t gRestoreCROSS_BAND_RX_TX;
static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
@@ -362,10 +365,10 @@ void SCANNER_Start(void)
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz; gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz;
#endif #endif
BackupStep = gRxVfo->STEP_SETTING; BackupStep = gRxVfo->STEP_SETTING;
BackupFrequency = gRxVfo->StepFrequency; BackupFrequency = gRxVfo->StepFrequency;
@@ -377,9 +380,9 @@ void SCANNER_Start(void)
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
gIsNoaaMode = false; gIsNoaaMode = false;
#endif #endif
if (gScanSingleFrequency) if (gScanSingleFrequency)
{ {
@@ -414,9 +417,9 @@ void SCANNER_Start(void)
g_CDCSS_Lost = false; g_CDCSS_Lost = false;
gCDCSSCodeType = 0; gCDCSSCodeType = 0;
g_CTCSS_Lost = false; g_CTCSS_Lost = false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_VOX_Lost = false; g_VOX_Lost = false;
#endif #endif
g_SquelchLost = false; g_SquelchLost = false;
gScannerEditState = 0; gScannerEditState = 0;
gScanProgressIndicator = 0; gScanProgressIndicator = 0;
@@ -424,8 +427,11 @@ void SCANNER_Start(void)
void SCANNER_Stop(void) void SCANNER_Stop(void)
{ {
const uint8_t Previous = gRestoreMrChannel; if(gRestoreCROSS_BAND_RX_TX != CROSS_BAND_OFF) {
gEeprom.CROSS_BAND_RX_TX = gRestoreCROSS_BAND_RX_TX;
gRestoreCROSS_BAND_RX_TX = CROSS_BAND_OFF;
}
gScanStateDir = SCAN_OFF; gScanStateDir = SCAN_OFF;
if (!bScanKeepFrequency) if (!bScanKeepFrequency)
@@ -433,7 +439,7 @@ void SCANNER_Stop(void)
if (gNextMrChannel <= MR_CHANNEL_LAST) if (gNextMrChannel <= MR_CHANNEL_LAST)
{ {
gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel; gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = Previous; gEeprom.ScreenChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
} }
@@ -460,3 +466,175 @@ void SCANNER_Stop(void)
gUpdateStatus = true; gUpdateStatus = true;
} }
static void SCANNER_NextFreqChannel(void)
{
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
gScanPauseDelayIn_10ms = 9; // 90ms
#else
gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
#endif
bScanKeepFrequency = false;
gUpdateDisplay = true;
}
static void SCANNER_NextMemChannel(void)
{
static unsigned int prev_mr_chan = 0;
const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true;
const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1;
const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1;
const unsigned int prev_chan = gNextMrChannel;
unsigned int chan = 0;
if (enabled)
{
switch (gCurrentScanList)
{
case SCAN_NEXT_CHAN_SCANLIST1:
prev_mr_chan = gNextMrChannel;
if (chan1 >= 0)
{
if (RADIO_CheckValidChannel(chan1, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
break;
}
}
[[fallthrough]];
case SCAN_NEXT_CHAN_SCANLIST2:
if (chan2 >= 0)
{
if (RADIO_CheckValidChannel(chan2, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2;
gNextMrChannel = chan2;
break;
}
}
[[fallthrough]];
// this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
// {
// chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan];
// if (chan <= MR_CHANNEL_LAST)
// {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan;
// break;
// }
// }
default:
case SCAN_NEXT_CHAN_MR:
gCurrentScanList = SCAN_NEXT_CHAN_MR;
gNextMrChannel = prev_mr_chan;
chan = 0xff;
break;
}
}
if (!enabled || chan == 0xff)
{
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF)
{ // no valid channel found
chan = MR_CHANNEL_FIRST;
// return;
}
gNextMrChannel = chan;
}
if (gNextMrChannel != prev_chan)
{
gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
RADIO_SetupRegisters(true);
gUpdateDisplay = true;
}
#ifdef ENABLE_FASTER_CHANNEL_SCAN
gScanPauseDelayIn_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
#else
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
#endif
bScanKeepFrequency = false;
if (enabled)
if (++gCurrentScanList >= SCAN_NEXT_NUM)
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
}
void SCANNER_NextChannel(const bool storeBackupSettings, const int8_t scan_direction)
{
if (storeBackupSettings) {
gRestoreCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
}
RADIO_SelectVfos();
gNextMrChannel = gRxVfo->CHANNEL_SAVE;
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gScanStateDir = scan_direction;
if (gNextMrChannel <= MR_CHANNEL_LAST)
{ // channel mode
if (storeBackupSettings)
gRestoreMrChannel = gNextMrChannel;
SCANNER_NextMemChannel();
}
else
{ // frequency mode
if (storeBackupSettings)
gRestoreFrequency = gRxVfo->freq_config_RX.Frequency;
SCANNER_NextFreqChannel();
}
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
}
void SCANNER_ContinueScanning()
{
if (IS_FREQ_CHANNEL(gNextMrChannel))
{
if (gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
SCANNER_NextFreqChannel(); // switch to next frequency
}
else
{
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
SCANNER_NextMemChannel(); // switch to next channel
}
gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
}

View File

@@ -58,6 +58,8 @@ extern bool bScanKeepFrequency;
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void SCANNER_Start(void); void SCANNER_Start(void);
void SCANNER_Stop(void); void SCANNER_Stop(void);
void SCANNER_NextChannel(const bool storeBackupSettings, const int8_t scan_direction);
void SCANNER_ContinueScanning();
#endif #endif

View File

@@ -142,9 +142,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (Beep) switch (Beep)
{ {
case BEEP_880HZ_60MS_TRIPLE_BEEP: case BEEP_880HZ_60MS_TRIPLE_BEEP:
@@ -152,14 +149,14 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
[[fallthrough]];
case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL: case BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL:
case BEEP_500HZ_60MS_DOUBLE_BEEP: case BEEP_500HZ_60MS_DOUBLE_BEEP:
BK4819_ExitTxMute(); BK4819_ExitTxMute();
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
[[fallthrough]];
case BEEP_1KHZ_60MS_OPTIONAL: case BEEP_1KHZ_60MS_OPTIONAL:
BK4819_ExitTxMute(); BK4819_ExitTxMute();
Duration = 60; Duration = 60;
@@ -184,8 +181,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
break; break;
} }
#pragma GCC diagnostic pop
SYSTEM_DelayMs(Duration); SYSTEM_DelayMs(Duration);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);

View File

@@ -197,26 +197,27 @@ const uint8_t BITMAP_F_Key[6] =
}; };
#endif #endif
const uint8_t BITMAP_TDR1[12] = const uint8_t BITMAP_TDR1[15] =
{ // "DW" { // "DWR"
0b00000000,
0b01111111, 0b01111111,
0b01000001, 0b01000001,
0b01000001, 0b01000001,
0b01000001,
0b00111110, 0b00111110,
0b00000000, 0b00000000,
0b01111111, 0b01111111,
0b00100000, 0b00100000,
0b00011000, 0b00011000,
0b00100000, 0b00100000,
0b01111111 0b01111111,
0b00000000,
0b01111111,
0b00011001,
0b00101001,
0b01000110
}; };
const uint8_t BITMAP_TDR2[12] = const uint8_t BITMAP_TDR2[9] =
{ // "><" .. DW on hold { // "><" .. DW on hold
0b00000000,
0b00000000,
0b00100010, 0b00100010,
0b00110110, 0b00110110,
0b00011100, 0b00011100,
@@ -226,7 +227,6 @@ const uint8_t BITMAP_TDR2[12] =
0b00011100, 0b00011100,
0b00110110, 0b00110110,
0b00100010, 0b00100010,
0b00000000
}; };
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@@ -244,27 +244,8 @@ const uint8_t BITMAP_TDR2[12] =
}; };
#endif #endif
#ifdef ENABLE_FMRADIO
const uint8_t BITMAP_FM[12] =
{ // "FM"
0b00000000,
0b01111111,
0b00001001,
0b00001001,
0b00001001,
0b00000001,
0b00000000,
0b01111111,
0b00000010,
0b00001100,
0b00000010,
0b01111111
};
#endif
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
const uint8_t BITMAP_NOAA[12] = const uint8_t BITMAP_NOAA[11] =
{ // "NS" { // "NS"
0b00000000, 0b00000000,
0b01111111, 0b01111111,
@@ -272,12 +253,10 @@ const uint8_t BITMAP_TDR2[12] =
0b00001000, 0b00001000,
0b00010000, 0b00010000,
0b01111111, 0b01111111,
0b00000000, 0b00000000,
0b01000110, 0b01000110,
0b01001001, 0b01001001,
0b01001001, 0b01001001,
0b01001001,
0b00110001 0b00110001
}; };
#endif #endif

View File

@@ -25,25 +25,17 @@ extern const uint8_t BITMAP_F_Key[6];
extern const uint8_t BITMAP_VOX[18]; extern const uint8_t BITMAP_VOX[18];
#endif #endif
#if 0 extern const uint8_t BITMAP_XB[12];
extern const uint8_t BITMAP_WX[12];
#else
extern const uint8_t BITMAP_XB[12];
#endif
extern const uint8_t BITMAP_TDR1[12]; extern const uint8_t BITMAP_TDR1[15];
extern const uint8_t BITMAP_TDR2[12]; extern const uint8_t BITMAP_TDR2[9];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
extern const uint8_t BITMAP_VoicePrompt[9]; extern const uint8_t BITMAP_VoicePrompt[9];
#endif #endif
#ifdef ENABLE_FMRADIO
extern const uint8_t BITMAP_FM[12];
#endif
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
extern const uint8_t BITMAP_NOAA[12]; extern const uint8_t BITMAP_NOAA[11];
#endif #endif
extern const uint8_t BITMAP_Antenna[5]; extern const uint8_t BITMAP_Antenna[5];

10
board.c
View File

@@ -739,14 +739,14 @@ void BOARD_EEPROM_Init(void)
} }
} }
void BOARD_EEPROM_LoadMoreSettings(void) void BOARD_EEPROM_LoadCalibration(void)
{ {
// uint8_t Mic; // uint8_t Mic;
EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8); EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[4], gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[5], gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[6], gEEPROM_RSSI_CALIB[3], 8);
// 8 * 16-bit values // 8 * 16-bit values
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8); EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8);

View File

@@ -27,7 +27,7 @@ void BOARD_ADC_Init(void);
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent); void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void); void BOARD_Init(void);
void BOARD_EEPROM_Init(void); void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void); void BOARD_EEPROM_LoadCalibration(void);
uint32_t BOARD_fetchChannelFrequency(const int channel); uint32_t BOARD_fetchChannelFrequency(const int channel);
void BOARD_fetchChannelName(char *s, const int channel); void BOARD_fetchChannelName(char *s, const int channel);
void BOARD_FactoryReset(bool bIsAll); void BOARD_FactoryReset(bool bIsAll);

2
compile-with-docker.sh Normal file → Executable file
View File

@@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
docker build -t uvk5 . docker build -t uvk5 .
docker run -v $(PWD)/compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make && cp firmware* compiled-firmware/" docker run -v ${PWD}/compiled-firmware:/app/compiled-firmware uvk5 /bin/bash -c "cd /app && make && cp firmware* compiled-firmware/"

View File

@@ -106,7 +106,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3];
if ((gScreenToDisplay == DISPLAY_MENU) && gMenuCursor == MENU_VOL) if ((gScreenToDisplay == DISPLAY_MENU) && GetCurrentMenuId() == MENU_VOL)
gUpdateDisplay = true; gUpdateDisplay = true;
if (gBatteryCurrent < 501) if (gBatteryCurrent < 501)

58
main.c
View File

@@ -84,7 +84,7 @@ void Main(void)
BOARD_EEPROM_Init(); BOARD_EEPROM_Init();
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
@@ -103,26 +103,21 @@ void Main(void)
#endif #endif
BootMode = BOOT_GetMode(); BootMode = BOOT_GetMode();
// count the number of menu items
gMenuListCount = 0;
while (MenuList[gMenuListCount].name[0] != '\0')
gMenuListCount++;
if (BootMode == BOOT_MODE_F_LOCK) if (BootMode == BOOT_MODE_F_LOCK)
{ {
gF_LOCK = true; // flag to say include the hidden menu items gF_LOCK = true; // flag to say include the hidden menu items
} }
else
{ // hide the hidden menu items
gMenuListCount -= 9; // count the number of menu items
gMenuListCount = 0;
while (MenuList[gMenuListCount].name[0] != '\0') {
if(!gF_LOCK && MenuList[gMenuListCount].menu_id == FIRST_HIDDEN_MENU_ITEM)
break;
#ifndef ENABLE_F_CAL_MENU gMenuListCount++;
gMenuListCount++;
#endif
} }
// wait for user to release all butts before moving on // wait for user to release all butts before moving on
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
KEYBOARD_Poll() != KEY_INVALID || KEYBOARD_Poll() != KEY_INVALID ||
@@ -167,21 +162,21 @@ void Main(void)
boot_counter_10ms = 0; boot_counter_10ms = 0;
break; break;
} }
#ifdef ENABLE_BOOT_BEEPS #ifdef ENABLE_BOOT_BEEPS
if ((boot_counter_10ms % 25) == 0) if ((boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif #endif
} }
} }
#ifdef ENABLE_PWRON_PASSWORD #ifdef ENABLE_PWRON_PASSWORD
if (gEeprom.POWER_ON_PASSWORD < 1000000) if (gEeprom.POWER_ON_PASSWORD < 1000000)
{ {
bIsInLockScreen = true; bIsInLockScreen = true;
UI_DisplayLock(); UI_DisplayLock();
bIsInLockScreen = false; bIsInLockScreen = false;
} }
#endif #endif
BOOT_ProcessMode(BootMode); BOOT_ProcessMode(BootMode);
@@ -189,7 +184,7 @@ void Main(void)
gUpdateStatus = true; gUpdateStatus = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
{ {
uint8_t Channel; uint8_t Channel;
@@ -201,17 +196,16 @@ void Main(void)
AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(2, Channel + 1); AUDIO_SetDigitVoice(2, Channel + 1);
} }
else else if (IS_FREQ_CHANNEL(Channel))
if (IS_FREQ_CHANNEL(Channel))
AUDIO_SetVoiceID(1, VOICE_ID_FREQUENCY_MODE); AUDIO_SetVoiceID(1, VOICE_ID_FREQUENCY_MODE);
AUDIO_PlaySingleVoice(0); AUDIO_PlaySingleVoice(0);
} }
#endif #endif
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
RADIO_ConfigureNOAA(); RADIO_ConfigureNOAA();
#endif #endif
// ****************** // ******************
} }

47
misc.c
View File

@@ -19,12 +19,13 @@
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms
const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds
const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds
const uint8_t vfo_state_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes
@@ -109,12 +110,7 @@ bool bHasCustomAesKey;
uint32_t gChallenge[4]; uint32_t gChallenge[4];
uint8_t gTryCount; uint8_t gTryCount;
uint8_t gEEPROM_1EC0_0[8]; uint16_t gEEPROM_RSSI_CALIB[7][4];
uint8_t gEEPROM_1EC0_1[8];
uint8_t gEEPROM_1EC0_2[8];
uint8_t gEEPROM_1EC0_3[8];
uint16_t gEEPROM_RSSI_CALIB[2][4];
uint16_t gEEPROM_1F8A; uint16_t gEEPROM_1F8A;
uint16_t gEEPROM_1F8C; uint16_t gEEPROM_1F8C;
@@ -141,6 +137,8 @@ volatile bool gTxTimeoutReached;
volatile uint16_t gTailNoteEliminationCountdown_10ms; volatile uint16_t gTailNoteEliminationCountdown_10ms;
volatile uint8_t gVFOStateResumeCountdown_500ms;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
volatile uint16_t gNOAA_Countdown_10ms; volatile uint16_t gNOAA_Countdown_10ms;
#endif #endif
@@ -207,7 +205,6 @@ uint16_t gLowBatteryCountdown;
uint8_t gNextMrChannel; uint8_t gNextMrChannel;
ReceptionMode_t gRxReceptionMode; ReceptionMode_t gRxReceptionMode;
uint8_t gRestoreMrChannel;
enum scan_next_chan_t gCurrentScanList; enum scan_next_chan_t gCurrentScanList;
uint32_t gRestoreFrequency; uint32_t gRestoreFrequency;
@@ -260,40 +257,6 @@ int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO
uint8_t gIsLocked = 0xFF; uint8_t gIsLocked = 0xFF;
unsigned int get_rx_VFO(void)
{
unsigned int rx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
rx_vfo = 0;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
rx_vfo = 0;
return rx_vfo;
}
unsigned int get_tx_VFO(void)
{
unsigned int tx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
tx_vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
tx_vfo = 0;
return tx_vfo;
}
void NUMBER_Get(char *pDigits, uint32_t *pInteger) void NUMBER_Get(char *pDigits, uint32_t *pInteger)
{ {
unsigned int i; unsigned int i;

22
misc.h
View File

@@ -32,12 +32,12 @@
#define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) #define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
#endif #endif
#define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST) #define IS_MR_CHANNEL(x) ((x) <= MR_CHANNEL_LAST)
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL) #define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST) #define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_NOT_NOAA_CHANNEL(x) ((x) <= FREQ_CHANNEL_LAST)
enum { enum {
MR_CHANNEL_FIRST = 0, MR_CHANNEL_FIRST = 0,
@@ -52,7 +52,8 @@ enum {
enum { enum {
FLASHLIGHT_OFF = 0, FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON, FLASHLIGHT_ON,
FLASHLIGHT_BLINK FLASHLIGHT_BLINK,
FLASHLIGHT_SOS
}; };
enum { enum {
@@ -93,12 +94,13 @@ enum scan_next_chan_t {
}; };
typedef enum scan_next_chan_t scan_next_chan_t; typedef enum scan_next_chan_t scan_next_chan_t;
extern const uint8_t fm_resume_countdown_500ms;
extern const uint8_t fm_radio_countdown_500ms; extern const uint8_t fm_radio_countdown_500ms;
extern const uint16_t fm_play_countdown_scan_10ms; extern const uint16_t fm_play_countdown_scan_10ms;
extern const uint16_t fm_play_countdown_noscan_10ms; extern const uint16_t fm_play_countdown_noscan_10ms;
extern const uint16_t fm_restore_countdown_10ms; extern const uint16_t fm_restore_countdown_10ms;
extern const uint8_t vfo_state_resume_countdown_500ms;
extern const uint8_t menu_timeout_500ms; extern const uint8_t menu_timeout_500ms;
extern const uint16_t menu_timeout_long_500ms; extern const uint16_t menu_timeout_long_500ms;
@@ -182,12 +184,7 @@ extern bool bHasCustomAesKey;
extern uint32_t gChallenge[4]; extern uint32_t gChallenge[4];
extern uint8_t gTryCount; extern uint8_t gTryCount;
extern uint8_t gEEPROM_1EC0_0[8]; extern uint16_t gEEPROM_RSSI_CALIB[7][4];
extern uint8_t gEEPROM_1EC0_1[8];
extern uint8_t gEEPROM_1EC0_2[8];
extern uint8_t gEEPROM_1EC0_3[8];
extern uint16_t gEEPROM_RSSI_CALIB[2][4];
extern uint16_t gEEPROM_1F8A; extern uint16_t gEEPROM_1F8A;
extern uint16_t gEEPROM_1F8C; extern uint16_t gEEPROM_1F8C;
@@ -280,7 +277,6 @@ extern uint16_t gLowBatteryCountdown;
extern uint8_t gNextMrChannel; extern uint8_t gNextMrChannel;
extern ReceptionMode_t gRxReceptionMode; extern ReceptionMode_t gRxReceptionMode;
extern uint8_t gRestoreMrChannel;
extern scan_next_chan_t gCurrentScanList; extern scan_next_chan_t gCurrentScanList;
extern uint32_t gRestoreFrequency; extern uint32_t gRestoreFrequency;
@@ -319,6 +315,7 @@ extern volatile bool gNextTimeslice40ms;
extern volatile bool gScheduleNOAA; extern volatile bool gScheduleNOAA;
#endif #endif
extern volatile bool gFlagTailNoteEliminationComplete; extern volatile bool gFlagTailNoteEliminationComplete;
extern volatile uint8_t gVFOStateResumeCountdown_500ms;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
extern volatile bool gScheduleFM; extern volatile bool gScheduleFM;
#endif #endif
@@ -326,9 +323,6 @@ extern int16_t gCurrentRSSI[2]; // now one per VFO
extern uint8_t gIsLocked; extern uint8_t gIsLocked;
extern volatile uint8_t boot_counter_10ms; extern volatile uint8_t boot_counter_10ms;
unsigned int get_tx_VFO(void);
unsigned int get_rx_VFO(void);
void NUMBER_Get(char *pDigits, uint32_t *pInteger); void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits); void NUMBER_ToDigits(uint32_t Value, char *pDigits);
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);

48
radio.c
View File

@@ -161,20 +161,20 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (IS_VALID_CHANNEL(Channel)) if (IS_VALID_CHANNEL(Channel))
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (Channel >= NOAA_CHANNEL_FIRST) if (Channel >= NOAA_CHANNEL_FIRST)
{ {
RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]); RADIO_InitInfo(pRadio, gEeprom.ScreenChannel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]);
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF)
return;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gUpdateStatus = true;
return; return;
}
#endif gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
gUpdateStatus = true;
return;
}
#endif
if (Channel <= MR_CHANNEL_LAST) if (Channel <= MR_CHANNEL_LAST)
{ {
@@ -560,8 +560,7 @@ static void RADIO_SelectCurrentVfo(void)
void RADIO_SelectVfos(void) void RADIO_SelectVfos(void)
{ {
gEeprom.TX_VFO = get_tx_VFO(); gEeprom.RX_VFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : !gEeprom.TX_VFO;
gEeprom.RX_VFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : (gEeprom.TX_VFO + 1) & 1u;
gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO];
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO];
@@ -581,13 +580,11 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (Bandwidth) switch (Bandwidth)
{ {
default: default:
Bandwidth = BK4819_FILTER_BW_WIDE; Bandwidth = BK4819_FILTER_BW_WIDE;
[[fallthrough]];
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@@ -599,8 +596,6 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
break; break;
} }
#pragma GCC diagnostic pop
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false);
BK4819_SetupPowerAmplifier(0, 0); BK4819_SetupPowerAmplifier(0, 0);
@@ -835,13 +830,11 @@ void RADIO_SetTxParameters(void)
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (Bandwidth) switch (Bandwidth)
{ {
default: default:
Bandwidth = BK4819_FILTER_BW_WIDE; Bandwidth = BK4819_FILTER_BW_WIDE;
[[fallthrough]];
case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW: case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@@ -853,8 +846,6 @@ void RADIO_SetTxParameters(void)
break; break;
} }
#pragma GCC diagnostic pop
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);
// TX compressor // TX compressor
@@ -898,10 +889,7 @@ void RADIO_SetVfoState(VfoState_t State)
{ {
VfoState[0] = VFO_STATE_NORMAL; VfoState[0] = VFO_STATE_NORMAL;
VfoState[1] = VFO_STATE_NORMAL; VfoState[1] = VFO_STATE_NORMAL;
gVFOStateResumeCountdown_500ms = 0;
#ifdef ENABLE_FMRADIO
gFM_ResumeCountdown_500ms = 0;
#endif
} }
else else
{ {
@@ -916,9 +904,7 @@ void RADIO_SetVfoState(VfoState_t State)
VfoState[vfo] = State; VfoState[vfo] = State;
} }
#ifdef ENABLE_FMRADIO gVFOStateResumeCountdown_500ms = vfo_state_resume_countdown_500ms;
gFM_ResumeCountdown_500ms = fm_resume_countdown_500ms;
#endif
} }
gUpdateDisplay = true; gUpdateDisplay = true;

View File

@@ -251,6 +251,16 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
} }
} }
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
{
uint16_t buf[4];
EEPROM_WriteBuffer(0x1F40, batteryCalibration);
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = batteryCalibration[4];
buf[1] = batteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf);
}
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA

View File

@@ -220,6 +220,7 @@ typedef struct {
uint8_t _pad[1]; uint8_t _pad[1];
} EEPROM_Config_t; } EEPROM_Config_t;
extern EEPROM_Config_t gEeprom; extern EEPROM_Config_t gEeprom;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@@ -228,6 +229,7 @@ extern EEPROM_Config_t gEeprom;
void SETTINGS_SaveVfoIndices(void); void SETTINGS_SaveVfoIndices(void);
void SETTINGS_SaveSettings(void); void SETTINGS_SaveSettings(void);
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode);
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration);
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep); void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep);
#endif #endif

View File

@@ -24,34 +24,33 @@
void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink) void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink)
{ {
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); if (level < 2 && blink == 1) {
memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1));
if (level >= 1) }
else
{ {
unsigned int i; memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
uint8_t bars = level > 0 ? level - 1 : 0; if (level > 1)
if(bars>4) bars = 4;
for (i = 0; i < bars; i++)
{ {
#ifndef ENABLE_REVERSE_BAT_SYMBOL unsigned int i;
memcpy(bitmap + sizeof(bitmap) - 4 - (i * 3), BITMAP_BatteryLevel, 2); uint8_t bars = level - 1;
#else if (bars > 4)
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); bars = 4;
#endif for (i = 0; i < bars; i++)
{
#ifndef ENABLE_REVERSE_BAT_SYMBOL
memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2);
#else
memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2);
#endif
}
} }
} }
else
if (blink == 0)
memset(bitmap, 0, sizeof(bitmap));
} }
void UI_DisplayBattery(uint8_t level, uint8_t blink) void UI_DisplayBattery(uint8_t level, uint8_t blink)
{ {
if (gCurrentFunction != FUNCTION_TRANSMIT) { uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; UI_DrawBattery(bitmap, level, blink);
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
UI_DrawBattery(bitmap, level, blink);
memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
}
} }

View File

@@ -29,7 +29,7 @@ void INPUTBOX_Append(const KEY_Code_t Digit)
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
memset(gInputBox, 10, sizeof(gInputBox)); memset(gInputBox, 10, sizeof(gInputBox));
if (Digit >= KEY_0 && Digit != KEY_INVALID) if (Digit != KEY_INVALID)
gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0); gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0);
} }

View File

@@ -14,10 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
#pragma GCC diagnostic pop
#include <string.h> #include <string.h>
#include <stdlib.h> // abs() #include <stdlib.h> // abs()
@@ -46,23 +42,18 @@ center_line_t center_line = CENTER_LINE_NONE;
void UI_drawBars(uint8_t *p, const unsigned int level) void UI_drawBars(uint8_t *p, const unsigned int level)
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (level) switch (level)
{ {
default: default:
case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); [[fallthrough]];
case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); [[fallthrough]];
case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); [[fallthrough]];
case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); [[fallthrough]];
case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); [[fallthrough]];
case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); [[fallthrough]];
case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); break;
case 0: break; case 0: memset( p + 0, 0, sizeof(BITMAP_Antenna)); break;
} }
#pragma GCC diagnostic pop
} }
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
@@ -218,24 +209,13 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
const uint8_t Line = (vfo == 0) ? 3 : 7; const uint8_t Line = (vfo == 0) ? 3 : 7;
uint8_t *p_line = gFrameBuffer[Line - 1]; uint8_t *p_line = gFrameBuffer[Line - 1];
// TODO: sort out all 8 values from the eeprom
#if 0 const unsigned int band = gRxVfo->Band;
// dBm -105 -100 -95 -90 -70 -65 -60 -55 const int16_t level0 = gEEPROM_RSSI_CALIB[band][0];
// RSSI 110 120 130 140 180 190 200 210 const int16_t level1 = gEEPROM_RSSI_CALIB[band][1];
// 0000C0 6E 00 78 00 82 00 8C 00 B4 00 BE 00 C8 00 D2 00 const int16_t level2 = gEEPROM_RSSI_CALIB[band][2];
// const int16_t level3 = gEEPROM_RSSI_CALIB[band][3];
const unsigned int band = 1;
const int16_t level0 = gEEPROM_RSSI_CALIB[band][0];
const int16_t level1 = gEEPROM_RSSI_CALIB[band][1];
const int16_t level2 = gEEPROM_RSSI_CALIB[band][2];
const int16_t level3 = gEEPROM_RSSI_CALIB[band][3];
#else
const int16_t level0 = (-115 + 160) * 2; // dB
const int16_t level1 = ( -89 + 160) * 2; // dB
const int16_t level2 = ( -64 + 160) * 2; // dB
const int16_t level3 = ( -39 + 160) * 2; // dB
#endif
const int16_t level01 = (level0 + level1) / 2; const int16_t level01 = (level0 + level1) / 2;
const int16_t level12 = (level1 + level2) / 2; const int16_t level12 = (level1 + level2) / 2;
const int16_t level23 = (level2 + level3) / 2; const int16_t level23 = (level2 + level3) / 2;
@@ -314,30 +294,23 @@ void UI_DisplayMain(void)
return; return;
} }
unsigned int activeTxVFO = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
for (vfo_num = 0; vfo_num < 2; vfo_num++) for (vfo_num = 0; vfo_num < 2; vfo_num++)
{ {
const unsigned int line = (vfo_num == 0) ? line0 : line1; const unsigned int line = (vfo_num == 0) ? line0 : line1;
unsigned int channel = gEeprom.TX_VFO; const bool isTxVFO = (vfo_num == gEeprom.TX_VFO);
// unsigned int tx_channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
const bool same_vfo = (channel == vfo_num) ? true : false;
uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1]; uint8_t *p_line1 = gFrameBuffer[line + 1];
unsigned int mode = 0; unsigned int mode = 0;
unsigned int state;
if (single_vfo) if (single_vfo)
{ // we're in single VFO mode - screen is dedicated to just one VFO { // we're in single VFO mode - screen is dedicated to just one VFO
if (!isTxVFO)
if (!same_vfo)
continue; // skip the unused vfo continue; // skip the unused vfo
} }
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) if (activeTxVFO != vfo_num)
channel = gEeprom.RX_VFO; // we're currently monitoring the other VFO
if (channel != vfo_num)
{ {
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode)
{ // show DTMF stuff { // show DTMF stuff
@@ -382,19 +355,14 @@ void UI_DisplayMain(void)
} }
// highlight the selected/used VFO with a marker // highlight the selected/used VFO with a marker
if (!single_vfo && same_vfo) if (!single_vfo && isTxVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
} }
else else if (!single_vfo)
if (!single_vfo)
{ // highlight the selected/used VFO with a marker { // highlight the selected/used VFO with a marker
if (same_vfo) if (isTxVFO)
memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default));
else else
//if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
} }
@@ -407,8 +375,8 @@ void UI_DisplayMain(void)
else else
#endif #endif
{ {
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; activeTxVFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (activeTxVFO == vfo_num)
{ // show the TX symbol { // show the TX symbol
mode = 1; mode = 1;
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
@@ -472,12 +440,12 @@ void UI_DisplayMain(void)
// ************ // ************
state = VfoState[vfo_num]; unsigned int state = VfoState[vfo_num];
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM)
{ {
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; uint8_t channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (channel == vfo_num)
state = VFO_STATE_ALARM; state = VFO_STATE_ALARM;
} }
@@ -501,8 +469,8 @@ void UI_DisplayMain(void)
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; activeTxVFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
if (channel == vfo_num) if (activeTxVFO == vfo_num)
frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
} }
@@ -524,8 +492,6 @@ void UI_DisplayMain(void)
#endif #endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gEeprom.CHANNEL_DISPLAY_MODE) switch (gEeprom.CHANNEL_DISPLAY_MODE)
{ {
@@ -576,8 +542,6 @@ void UI_DisplayMain(void)
break; break;
} }
#pragma GCC diagnostic pop
} }
else else
{ // frequency mode { // frequency mode

259
ui/menu.c
View File

@@ -36,106 +36,108 @@
#include "ui/menu.h" #include "ui/menu.h"
#include "ui/ui.h" #include "ui/ui.h"
// NOTE. this menu list is half way through a change, what might seem
// pointless at this time is for there for a reason.
//
const t_menu_item MenuList[] = const t_menu_item MenuList[] =
{ {
// text, voice ID, menu ID // text, voice ID, menu ID
{"Step", VOICE_ID_FREQUENCY_STEP, MENU_STEP },
{"SQL", VOICE_ID_SQUELCH, MENU_SQL }, {"TxPwr", VOICE_ID_POWER, MENU_TXP }, // was "TXP"
{"STEP", VOICE_ID_FREQUENCY_STEP, MENU_STEP }, {"RxDCS", VOICE_ID_DCS, MENU_R_DCS }, // was "R_DCS"
{"T PWR", VOICE_ID_POWER, MENU_TXP }, // was "TXP" {"RxCTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS"
{"R DCS", VOICE_ID_DCS, MENU_R_DCS }, // was "R_DCS" {"TxDCS", VOICE_ID_DCS, MENU_T_DCS }, // was "T_DCS"
{"R CTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS" {"TxCTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS"
{"T DCS", VOICE_ID_DCS, MENU_T_DCS }, // was "T_DCS" {"TxODir", VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, MENU_SFT_D }, // was "SFT_D"
{"T CTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS" {"TxOffs", VOICE_ID_TX_OFFSET_FREQUENCY, MENU_OFFSET }, // was "OFFSET"
{"T DIR", VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, MENU_SFT_D }, // was "SFT_D"
{"T OFFS", VOICE_ID_TX_OFFSET_FREQUENCY, MENU_OFFSET }, // was "OFFSET"
{"T VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX"
{"T TOUT", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
{"W/N", VOICE_ID_CHANNEL_BANDWIDTH, MENU_W_N }, {"W/N", VOICE_ID_CHANNEL_BANDWIDTH, MENU_W_N },
{"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR" {"Scramb", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR"
{"BUSYCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL }, // was "BCL" {"BusyCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL }, // was "BCL"
{"CH SAV", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH" {"Compnd", VOICE_ID_INVALID, MENU_COMPAND },
{"CH DEL", VOICE_ID_DELETE_CHANNEL, MENU_DEL_CH }, // was "DEL-CH" {"Demodu", VOICE_ID_INVALID, MENU_AM }, // was "AM"
{"CH NAM", VOICE_ID_INVALID, MENU_MEM_NAME }, {"ScAdd1", VOICE_ID_INVALID, MENU_S_ADD1 },
{"CH DIS", VOICE_ID_INVALID, MENU_MDF }, // was "MDF" {"ScAdd2", VOICE_ID_INVALID, MENU_S_ADD2 },
{"BATSAV", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE" {"ChSave", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH"
#ifdef ENABLE_VOX {"ChDele", VOICE_ID_DELETE_CHANNEL, MENU_DEL_CH }, // was "DEL-CH"
{"VOX", VOICE_ID_VOX, MENU_VOX }, {"ChName", VOICE_ID_INVALID, MENU_MEM_NAME },
{"SList", VOICE_ID_INVALID, MENU_S_LIST },
{"SList1", VOICE_ID_INVALID, MENU_SLIST1 },
{"SList2", VOICE_ID_INVALID, MENU_SLIST2 },
{"ScnRev", VOICE_ID_INVALID, MENU_SC_REV },
#ifdef ENABLE_NOAA
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S },
#endif #endif
{"BLT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR"
{"BLTTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX }, {"F1Shrt", VOICE_ID_INVALID, MENU_F1SHRT },
{"DUALRX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR" {"F1Long", VOICE_ID_INVALID, MENU_F1LONG },
{"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP }, {"F2Shrt", VOICE_ID_INVALID, MENU_F2SHRT },
{"F2Long", VOICE_ID_INVALID, MENU_F2LONG },
{"KeyLck", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk"
{"TxTOut", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
{"BatSav", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE"
{"Mic", VOICE_ID_INVALID, MENU_MIC },
#ifdef ENABLE_AUDIO_BAR
{"MicBar", VOICE_ID_INVALID, MENU_MIC_BAR },
#endif
{"ChDisp", VOICE_ID_INVALID, MENU_MDF }, // was "MDF"
{"POnMsg", VOICE_ID_INVALID, MENU_PONMSG },
{"BatTxt", VOICE_ID_INVALID, MENU_BAT_TXT },
{"BackLt", VOICE_ID_INVALID, MENU_ABR }, // was "ABR"
{"BltTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX },
{"Beep", VOICE_ID_BEEP_PROMPT, MENU_BEEP },
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
{"VOICE", VOICE_ID_VOICE_PROMPT, MENU_VOICE }, {"Voice", VOICE_ID_VOICE_PROMPT, MENU_VOICE },
#endif #endif
{"SC REV", VOICE_ID_INVALID, MENU_SC_REV }, {"Roger", VOICE_ID_INVALID, MENU_ROGER },
{"KEYLOC", VOICE_ID_INVALID, MENU_AUTOLK }, // was "AUTOLk"
{"S ADD1", VOICE_ID_INVALID, MENU_S_ADD1 },
{"S ADD2", VOICE_ID_INVALID, MENU_S_ADD2 },
{"STE", VOICE_ID_INVALID, MENU_STE }, {"STE", VOICE_ID_INVALID, MENU_STE },
{"RP STE", VOICE_ID_INVALID, MENU_RP_STE }, {"RP STE", VOICE_ID_INVALID, MENU_RP_STE },
{"MIC", VOICE_ID_INVALID, MENU_MIC }, {"1 Call", VOICE_ID_INVALID, MENU_1_CALL },
#ifdef ENABLE_AUDIO_BAR
{"MICBAR", VOICE_ID_INVALID, MENU_MIC_BAR },
#endif
{"COMPND", VOICE_ID_INVALID, MENU_COMPAND },
{"1 CALL", VOICE_ID_INVALID, MENU_1_CALL },
{"SLIST", VOICE_ID_INVALID, MENU_S_LIST },
{"SLIST1", VOICE_ID_INVALID, MENU_SLIST1 },
{"SLIST2", VOICE_ID_INVALID, MENU_SLIST2 },
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
{"AL-MOD", VOICE_ID_INVALID, MENU_AL_MOD }, {"AlarmT", VOICE_ID_INVALID, MENU_AL_MOD },
#endif #endif
{"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID }, {"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID },
{"UPCODE", VOICE_ID_INVALID, MENU_UPCODE }, {"UPCode", VOICE_ID_INVALID, MENU_UPCODE },
{"DWCODE", VOICE_ID_INVALID, MENU_DWCODE }, {"DWCode", VOICE_ID_INVALID, MENU_DWCODE },
{"PTT ID", VOICE_ID_INVALID, MENU_PTT_ID }, {"PTT ID", VOICE_ID_INVALID, MENU_PTT_ID },
{"D ST", VOICE_ID_INVALID, MENU_D_ST }, {"D ST", VOICE_ID_INVALID, MENU_D_ST },
{"D RSP", VOICE_ID_INVALID, MENU_D_RSP }, {"D Resp", VOICE_ID_INVALID, MENU_D_RSP },
{"D HOLD", VOICE_ID_INVALID, MENU_D_HOLD }, {"D Hold", VOICE_ID_INVALID, MENU_D_HOLD },
{"D PRE", VOICE_ID_INVALID, MENU_D_PRE }, {"D Prel", VOICE_ID_INVALID, MENU_D_PRE },
{"D DCD", VOICE_ID_INVALID, MENU_D_DCD }, {"D Decd", VOICE_ID_INVALID, MENU_D_DCD },
{"D LIST", VOICE_ID_INVALID, MENU_D_LIST }, {"D List", VOICE_ID_INVALID, MENU_D_LIST },
{"D LIVE", VOICE_ID_INVALID, MENU_D_LIVE_DEC }, // live DTMF decoder {"D Live", VOICE_ID_INVALID, MENU_D_LIVE_DEC }, // live DTMF decoder
{"PONMSG", VOICE_ID_INVALID, MENU_PONMSG },
{"ROGER", VOICE_ID_INVALID, MENU_ROGER },
{"BATVOL", VOICE_ID_INVALID, MENU_VOL }, // was "VOL"
{"BATTXT", VOICE_ID_INVALID, MENU_BAT_TXT },
{"MODE", VOICE_ID_INVALID, MENU_AM }, // was "AM"
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
{"AM FIX", VOICE_ID_INVALID, MENU_AM_FIX }, {"AM Fix", VOICE_ID_INVALID, MENU_AM_FIX },
#endif #endif
#ifdef ENABLE_AM_FIX_TEST1 #ifdef ENABLE_AM_FIX_TEST1
{"AM FT1", VOICE_ID_INVALID, MENU_AM_FIX_TEST1 }, {"AM FT1", VOICE_ID_INVALID, MENU_AM_FIX_TEST1 },
#endif #endif
#ifdef ENABLE_NOAA #ifdef ENABLE_VOX
{"NOAA-S", VOICE_ID_INVALID, MENU_NOAA_S }, {"VOX", VOICE_ID_VOX, MENU_VOX },
#endif #endif
{"RESET", VOICE_ID_INITIALISATION, MENU_RESET }, // might be better to move this to the hidden menu items ? {"BatVol", VOICE_ID_INVALID, MENU_VOL }, // was "VOL"
{"RxMode", VOICE_ID_DUAL_STANDBY, MENU_TDR },
{"Sql", VOICE_ID_SQUELCH, MENU_SQL },
// hidden menu items from here on // hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on // enabled if pressing both the PTT and upper side button at power-on
{"F Lock", VOICE_ID_INVALID, MENU_F_LOCK },
{"F LOCK", VOICE_ID_INVALID, MENU_F_LOCK }, {"Tx 200", VOICE_ID_INVALID, MENU_200TX }, // was "200TX"
{"TX 200", VOICE_ID_INVALID, MENU_200TX }, // was "200TX" {"Tx 350", VOICE_ID_INVALID, MENU_350TX }, // was "350TX"
{"TX 350", VOICE_ID_INVALID, MENU_350TX }, // was "350TX" {"Tx 500", VOICE_ID_INVALID, MENU_500TX }, // was "500TX"
{"TX 500", VOICE_ID_INVALID, MENU_500TX }, // was "500TX" {"350 En", VOICE_ID_INVALID, MENU_350EN }, // was "350EN"
{"350 EN", VOICE_ID_INVALID, MENU_350EN }, // was "350EN" {"ScraEn", VOICE_ID_INVALID, MENU_SCREN }, // was "SCREN"
{"SCR EN", VOICE_ID_INVALID, MENU_SCREN }, // was "SCREN" {"TxEnab", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX
{"TX EN", VOICE_ID_INVALID, MENU_TX_EN }, // enable TX
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
{"F CALI", VOICE_ID_INVALID, MENU_F_CALI }, // reference xtal calibration {"FrCali", VOICE_ID_INVALID, MENU_F_CALI }, // reference xtal calibration
#endif #endif
{"BATCAL", VOICE_ID_INVALID, MENU_BATCAL }, // battery voltage calibration {"BatCal", VOICE_ID_INVALID, MENU_BATCAL }, // battery voltage calibration
{"Reset", VOICE_ID_INITIALISATION, MENU_RESET }, // might be better to move this to the hidden menu items ?
{"", VOICE_ID_INVALID, 0xff } // end of list - DO NOT delete or move this this {"", VOICE_ID_INVALID, 0xff } // end of list - DO NOT delete or move this this
}; };
const uint8_t FIRST_HIDDEN_MENU_ITEM = MENU_F_LOCK;
const char gSubMenu_TXP[3][5] = const char gSubMenu_TXP[3][5] =
{ {
"LOW", "LOW",
@@ -186,18 +188,12 @@ const char gSubMenu_TOT[11][7] =
"15 min" "15 min"
}; };
const char gSubMenu_CHAN[3][10] = const char* gSubMenu_RXMode[4] =
{ {
"OFF", "MAIN\nONLY", // TX and RX on main only
"UPPER\nVFO", "DUAL RX\nRESPOND", // Watch both and respond
"LOWER\nVFO" "CROSS\nBAND", // TX on main, RX on secondary
}; "MAIN TX\nDUAL RX" // always TX on main, but RX on both
const char gSubMenu_XB[3][10] =
{
"RX\nVFO",
"UPPER\nVFO",
"LOWER\nVFO"
}; };
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@@ -209,14 +205,14 @@ const char gSubMenu_XB[3][10] =
}; };
#endif #endif
const char gSubMenu_SC_REV[3][13] = const char gSubMenu_SC_REV[3][8] =
{ {
"TIME", "TIME",
"CARRIER", "CARRIER",
"SEARCH" "SEARCH"
}; };
const char gSubMenu_MDF[4][15] = const char* gSubMenu_MDF[4] =
{ {
"FREQ", "FREQ",
"CHANNEL\nNUMBER", "CHANNEL\nNUMBER",
@@ -240,7 +236,7 @@ const char gSubMenu_D_RSP[4][11] =
"BOTH" "BOTH"
}; };
const char gSubMenu_PTT_ID[5][15] = const char* gSubMenu_PTT_ID[5] =
{ {
"OFF", "OFF",
"KEY\nUP", "KEY\nUP",
@@ -257,7 +253,7 @@ const char gSubMenu_PONMSG[4][8] =
"NONE" "NONE"
}; };
const char gSubMenu_ROGER[3][9] = const char* gSubMenu_ROGER[3] =
{ {
"OFF", "OFF",
"ROGER", "ROGER",
@@ -332,8 +328,38 @@ const char gSubMenu_SCRAMBLER[11][7] =
"3500Hz" "3500Hz"
}; };
const t_sidefunction SIDEFUNCTIONS[] =
{
{"NONE", ACTION_OPT_NONE},
{"FLASH\nLIGHT", ACTION_OPT_FLASHLIGHT},
{"POWER", ACTION_OPT_POWER},
{"MONITOR", ACTION_OPT_MONITOR},
{"SCAN", ACTION_OPT_SCAN},
#ifdef ENABLE_VOX
{"VOX", ACTION_OPT_VOX},
#endif
#ifdef ENABLE_ALARM
{"ALARM", ACTION_OPT_ALARM},
#endif
#ifdef ENABLE_FMRADIO
{"FM RADIO", ACTION_OPT_FM},
#endif
#ifdef ENABLE_TX1750
{"1750HZ", ACTION_OPT_1750},
#endif
};
const t_sidefunction* gSubMenu_SIDEFUNCTIONS = SIDEFUNCTIONS;
const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(SIDEFUNCTIONS);
bool gIsInSubMenu; bool gIsInSubMenu;
uint8_t gMenuCursor; uint8_t gMenuCursor;
int GetCurrentMenuId() {
if(gMenuCursor < ARRAY_SIZE(MenuList))
return MenuList[gMenuCursor].menu_id;
else
return MenuList[ARRAY_SIZE(MenuList)-1].menu_id;
}
int8_t gMenuScrollDirection; int8_t gMenuScrollDirection;
int32_t gSubMenuSelection; int32_t gSubMenuSelection;
@@ -437,10 +463,7 @@ void UI_DisplayMenu(void)
bool already_printed = false; bool already_printed = false;
#pragma GCC diagnostic push switch (GetCurrentMenuId())
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gMenuCursor)
{ {
case MENU_SQL: case MENU_SQL:
sprintf(String, "%d", gSubMenuSelection); sprintf(String, "%d", gSubMenuSelection);
@@ -483,7 +506,7 @@ void UI_DisplayMenu(void)
{ {
#if 1 #if 1
unsigned int Code; unsigned int Code;
FREQ_Config_t *pConfig = (gMenuCursor == MENU_R_CTCS) ? &gTxVfo->freq_config_RX : &gTxVfo->freq_config_TX; FREQ_Config_t *pConfig = (GetCurrentMenuId() == MENU_R_CTCS) ? &gTxVfo->freq_config_RX : &gTxVfo->freq_config_TX;
if (gSubMenuSelection == 0) if (gSubMenuSelection == 0)
{ {
strcpy(String, "OFF"); strcpy(String, "OFF");
@@ -680,11 +703,7 @@ void UI_DisplayMenu(void)
break; break;
case MENU_TDR: case MENU_TDR:
strcpy(String, gSubMenu_CHAN[gSubMenuSelection]); strcpy(String, gSubMenu_RXMode[gSubMenuSelection]);
break;
case MENU_XB:
strcpy(String, gSubMenu_XB[gSubMenuSelection]);
break; break;
case MENU_TOT: case MENU_TOT:
@@ -808,9 +827,15 @@ void UI_DisplayMenu(void)
sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection);
break; break;
} }
}
case MENU_F1SHRT:
case MENU_F1LONG:
case MENU_F2SHRT:
case MENU_F2LONG:
strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name);
break;
#pragma GCC diagnostic pop }
if (!already_printed) if (!already_printed)
{ // we now do multi-line text in a single string { // we now do multi-line text in a single string
@@ -866,9 +891,9 @@ void UI_DisplayMenu(void)
} }
} }
if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2) if (GetCurrentMenuId() == MENU_SLIST1 || GetCurrentMenuId() == MENU_SLIST2)
{ {
i = (gMenuCursor == MENU_SLIST1) ? 0 : 1; i = (GetCurrentMenuId() == MENU_SLIST1) ? 0 : 1;
// if (gSubMenuSelection == 0xFF) // if (gSubMenuSelection == 0xFF)
if (gSubMenuSelection < 0) if (gSubMenuSelection < 0)
@@ -913,9 +938,9 @@ void UI_DisplayMenu(void)
} }
} }
if (gMenuCursor == MENU_MEM_CH || if (GetCurrentMenuId() == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH || GetCurrentMenuId() == MENU_DEL_CH ||
gMenuCursor == MENU_1_CALL) GetCurrentMenuId() == MENU_1_CALL)
{ // display the channel name { // display the channel name
char s[11]; char s[11];
BOARD_fetchChannelName(s, gSubMenuSelection); BOARD_fetchChannelName(s, gSubMenuSelection);
@@ -924,18 +949,18 @@ void UI_DisplayMenu(void)
UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8); UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8);
} }
if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF) if ((GetCurrentMenuId() == MENU_R_CTCS || GetCurrentMenuId() == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF)
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8); UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
if (gMenuCursor == MENU_UPCODE) if (GetCurrentMenuId() == MENU_UPCODE)
if (strlen(gEeprom.DTMF_UP_CODE) > 8) if (strlen(gEeprom.DTMF_UP_CODE) > 8)
UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
if (gMenuCursor == MENU_DWCODE) if (GetCurrentMenuId() == MENU_DWCODE)
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) if (strlen(gEeprom.DTMF_DOWN_CODE) > 8)
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8);
if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid) if (GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid)
{ {
Contact[11] = 0; Contact[11] = 0;
memmove(&gDTMF_ID, Contact + 8, 4); memmove(&gDTMF_ID, Contact + 8, 4);
@@ -943,22 +968,22 @@ void UI_DisplayMenu(void)
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
} }
if (gMenuCursor == MENU_R_CTCS || if (GetCurrentMenuId() == MENU_R_CTCS ||
gMenuCursor == MENU_T_CTCS || GetCurrentMenuId() == MENU_T_CTCS ||
gMenuCursor == MENU_R_DCS || GetCurrentMenuId() == MENU_R_DCS ||
gMenuCursor == MENU_T_DCS || GetCurrentMenuId() == MENU_T_DCS ||
gMenuCursor == MENU_D_LIST) GetCurrentMenuId() == MENU_D_LIST)
{ {
unsigned int Offset; unsigned int Offset;
NUMBER_ToDigits(gSubMenuSelection, String); NUMBER_ToDigits(gSubMenuSelection, String);
Offset = (gMenuCursor == MENU_D_LIST) ? 2 : 3; Offset = (GetCurrentMenuId() == MENU_D_LIST) ? 2 : 3;
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false); UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
} }
if ((gMenuCursor == MENU_RESET || if ((GetCurrentMenuId() == MENU_RESET ||
gMenuCursor == MENU_MEM_CH || GetCurrentMenuId() == MENU_MEM_CH ||
gMenuCursor == MENU_MEM_NAME || GetCurrentMenuId() == MENU_MEM_NAME ||
gMenuCursor == MENU_DEL_CH) && gAskForConfirmation) GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation)
{ // display confirmation { // display confirmation
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"); strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);

View File

@@ -39,7 +39,6 @@ enum
MENU_T_CTCS, MENU_T_CTCS,
MENU_SFT_D, MENU_SFT_D,
MENU_OFFSET, MENU_OFFSET,
MENU_XB,
MENU_TOT, MENU_TOT,
MENU_W_N, MENU_W_N,
MENU_SCR, MENU_SCR,
@@ -103,9 +102,6 @@ enum
MENU_NOAA_S, MENU_NOAA_S,
#endif #endif
MENU_RESET, MENU_RESET,
// items after here are normally hidden
MENU_F_LOCK, MENU_F_LOCK,
MENU_200TX, MENU_200TX,
MENU_350TX, MENU_350TX,
@@ -117,9 +113,14 @@ enum
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
MENU_F_CALI, // reference xtal calibration MENU_F_CALI, // reference xtal calibration
#endif #endif
MENU_BATCAL // battery voltage calibration MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT,
MENU_F1LONG,
MENU_F2SHRT,
MENU_F2LONG
}; };
extern const uint8_t FIRST_HIDDEN_MENU_ITEM;
extern const t_menu_item MenuList[]; extern const t_menu_item MenuList[];
extern const char gSubMenu_TXP[3][5]; extern const char gSubMenu_TXP[3][5];
@@ -128,20 +129,20 @@ extern const char gSubMenu_W_N[2][7];
extern const char gSubMenu_OFF_ON[2][4]; extern const char gSubMenu_OFF_ON[2][4];
extern const char gSubMenu_SAVE[5][4]; extern const char gSubMenu_SAVE[5][4];
extern const char gSubMenu_TOT[11][7]; extern const char gSubMenu_TOT[11][7];
extern const char gSubMenu_CHAN[3][10]; extern const char* gSubMenu_RXMode[4];
extern const char gSubMenu_XB[3][10];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
extern const char gSubMenu_VOICE[3][4]; extern const char gSubMenu_VOICE[3][4];
#endif #endif
extern const char gSubMenu_SC_REV[3][13]; extern const char gSubMenu_SC_REV[3][8];
extern const char gSubMenu_MDF[4][15]; extern const char* gSubMenu_MDF[4];
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
extern const char gSubMenu_AL_MOD[2][5]; extern const char gSubMenu_AL_MOD[2][5];
#endif #endif
extern const char gSubMenu_D_RSP[4][11]; extern const char gSubMenu_D_RSP[4][11];
extern const char gSubMenu_PTT_ID[5][15]; extern const char* gSubMenu_PTT_ID[5];
extern const char gSubMenu_PONMSG[4][8]; extern const char gSubMenu_PONMSG[4][8];
extern const char gSubMenu_ROGER[3][9]; extern const char* gSubMenu_ROGER[3];
extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_RESET[2][4];
extern const char gSubMenu_F_LOCK[6][4]; extern const char gSubMenu_F_LOCK[6][4];
extern const char gSubMenu_BACKLIGHT[8][7]; extern const char gSubMenu_BACKLIGHT[8][7];
@@ -152,10 +153,15 @@ extern const char gSubMenu_RX_TX[4][6];
extern const char gSubMenu_BAT_TXT[3][8]; extern const char gSubMenu_BAT_TXT[3][8];
extern const char gSubMenu_SCRAMBLER[11][7]; extern const char gSubMenu_SCRAMBLER[11][7];
typedef struct {char* name; uint8_t id;} t_sidefunction;
extern const uint8_t gSubMenu_SIDEFUNCTIONS_size;
extern const t_sidefunction* gSubMenu_SIDEFUNCTIONS;
extern bool gIsInSubMenu; extern bool gIsInSubMenu;
extern uint8_t gMenuCursor; extern uint8_t gMenuCursor;
int GetCurrentMenuId();
extern int8_t gMenuScrollDirection; extern int8_t gMenuScrollDirection;
extern int32_t gSubMenuSelection; extern int32_t gSubMenuSelection;

View File

@@ -85,19 +85,10 @@ void UI_DisplayStatus(const bool test_display)
x1 = x + 10; x1 = x + 10;
} }
else else
#ifdef ENABLE_FMRADIO
// FM indicator
if (gFmRadioMode || test_display)
{
memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM));
x1 = x + sizeof(BITMAP_FM);
}
else
#endif
// SCAN indicator // SCAN indicator
if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display) if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display)
{ {
if (gNextMrChannel <= MR_CHANNEL_LAST) if (gNextMrChannel <= MR_CHANNEL_LAST && gScreenToDisplay != DISPLAY_SCANNER)
{ // channel mode { // channel mode
if (gEeprom.SCAN_LIST_DEFAULT == 0) if (gEeprom.SCAN_LIST_DEFAULT == 0)
UI_PrintStringSmallBuffer("1", line + x); UI_PrintStringSmallBuffer("1", line + x);
@@ -123,28 +114,25 @@ void UI_DisplayStatus(const bool test_display)
memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
x1 = x + sizeof(BITMAP_VoicePrompt); x1 = x + sizeof(BITMAP_VoicePrompt);
} }
x += sizeof(BITMAP_VoicePrompt); x += sizeof(BITMAP_VoicePrompt) + 1;
#else #else
// hmmm, what to put in it's place // hmmm, what to put in it's place
#endif #endif
// DUAL-WATCH indicator x++;
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display) if(gScreenToDisplay != DISPLAY_SCANNER) {
{ uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
if (gDualWatchActive || test_display) if(dw == 1 || dw == 3 || test_display) { // DWR - dual watch + respond
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1)); if(gDualWatchActive || test_display)
else memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5));
memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2)); else
memmove(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2));
}
else if(dw == 2) { // XB - crossband
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
}
} }
x += sizeof(BITMAP_TDR1); x += sizeof(BITMAP_TDR1) + 2;
// CROSS-VFO indicator
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
{
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
x1 = x + sizeof(BITMAP_XB);
}
x += sizeof(BITMAP_XB);
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
// VOX indicator // VOX indicator
@@ -153,9 +141,12 @@ void UI_DisplayStatus(const bool test_display)
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
x1 = x + sizeof(BITMAP_VOX); x1 = x + sizeof(BITMAP_VOX);
} }
x += sizeof(BITMAP_VOX); x += sizeof(BITMAP_VOX) + 2;
#endif #endif
x = MAX(x, 61u);
x1 = x;
// KEY-LOCK indicator // KEY-LOCK indicator
if (gEeprom.KEY_LOCK || test_display) if (gEeprom.KEY_LOCK || test_display)
{ {
@@ -218,7 +209,7 @@ void UI_DisplayStatus(const bool test_display)
x += sizeof(BITMAP_USB_C); x += sizeof(BITMAP_USB_C);
// BATTERY LEVEL indicator // BATTERY LEVEL indicator
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBattery); UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
// ************** // **************