Merge remote-tracking branch 'remotes/OneOfEleven/main'

This commit is contained in:
Krzysiek Egzmont
2023-10-06 11:21:10 +02:00
50 changed files with 955 additions and 664 deletions

View File

@@ -84,11 +84,11 @@ void ACTION_Monitor(void)
gMonitor = false;
if (gScanState != SCAN_OFF)
if (gScanStateDir != SCAN_OFF)
{
ScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
gScheduleScanListen = false;
gScanPauseMode = true;
gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
gScheduleScanListen = false;
gScanPauseMode = true;
}
#ifdef ENABLE_NOAA
@@ -182,23 +182,36 @@ void ACTION_Scan(bool bRestart)
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
if (gScanState != SCAN_OFF)
{
#if 1
if (gScanStateDir != SCAN_OFF)
{ // already scanning
if (gNextMrChannel <= MR_CHANNEL_LAST)
{ // channel mode
// keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel
CHANNEL_Next(true, gScanStateDir);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
gUpdateStatus = true;
#else
}
else
{ // stop scanning
SCANNER_Stop();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
#endif
}
}
else
{
CHANNEL_Next(true, 1);
{ // start scanning
CHANNEL_Next(true, SCAN_FWD);
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
@@ -215,9 +228,16 @@ void ACTION_Scan(bool bRestart)
}
}
else
if (!bRestart)
{ // keep scanning but toggle between scan lists
// if (!bRestart)
if (!bRestart && gNextMrChannel <= MR_CHANNEL_LAST)
{ // channel mode, keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel
CHANNEL_Next(true, gScanStateDir);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
gUpdateStatus = true;
}
else
@@ -313,6 +333,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed)
{
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gDTMF_InputIndex > 0)
{
gDTMF_InputBox[--gDTMF_InputIndex] = '-';

116
app/app.c
View File

@@ -95,15 +95,15 @@ static void APP_CheckForIncoming(void)
// squelch is open
if (gScanState == SCAN_OFF)
if (gScanStateDir == SCAN_OFF)
{ // not RF scanning
if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE)
{ // CTCSS/DTS scanning
ScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED;
gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED;
}
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
@@ -166,8 +166,8 @@ static void APP_CheckForIncoming(void)
return;
}
ScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
gScheduleScanListen = false;
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
gScheduleScanListen = false;
}
gRxReceptionMode = RX_MODE_DETECTED;
@@ -200,7 +200,7 @@ static void APP_HandleIncoming(void)
return;
}
bFlag = (gScanState == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0)
@@ -224,7 +224,7 @@ static void APP_HandleIncoming(void)
if (!bFlag)
return;
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{ // not scanning
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED)
{ // DTMF DCD is enabled
@@ -268,7 +268,7 @@ static void APP_HandleReceive(void)
goto Skip;
}
if (gScanState != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel))
if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel))
{
if (g_SquelchLost)
return;
@@ -399,7 +399,7 @@ Skip:
gUpdateDisplay = true;
if (gScanState != SCAN_OFF)
if (gScanStateDir != SCAN_OFF)
{
switch (gEeprom.SCAN_RESUME_MODE)
{
@@ -407,8 +407,8 @@ Skip:
break;
case SCAN_RESUME_CO:
ScanPauseDelayIn_10ms = scan_pause_delay_in_7_10ms;
gScheduleScanListen = false;
gScanPauseDelayIn_10ms = scan_pause_delay_in_7_10ms;
gScheduleScanListen = false;
break;
case SCAN_RESUME_SE:
@@ -488,23 +488,23 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
if (gSetting_backlight_on_tx_rx >= 2)
BACKLIGHT_TurnOn();
if (gScanState != SCAN_OFF)
if (gScanStateDir != SCAN_OFF)
{
switch (gEeprom.SCAN_RESUME_MODE)
{
case SCAN_RESUME_TO:
if (!gScanPauseMode)
{
ScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
gScheduleScanListen = false;
gScanPauseMode = true;
gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms;
gScheduleScanListen = false;
gScanPauseMode = true;
}
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_SE:
ScanPauseDelayIn_10ms = 0;
gScheduleScanListen = false;
gScanPauseDelayIn_10ms = 0;
gScheduleScanListen = false;
break;
}
@@ -527,7 +527,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
if (gCssScanMode != CSS_SCAN_MODE_OFF)
gCssScanMode = CSS_SCAN_MODE_FOUND;
if (gScanState == SCAN_OFF &&
if (gScanStateDir == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF &&
gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{ // not scanning, dual watch is enabled
@@ -623,14 +623,17 @@ uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
static void FREQ_NextChannel(void)
{
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanState);
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true);
// ScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
ScanPauseDelayIn_10ms = 10; // 100ms .. it don't like any faster :(
#ifdef ENABLE_FASTER_CHANNEL_SCAN
gScanPauseDelayIn_10ms = 9; // 90ms
#else
gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
#endif
bScanKeepFrequency = false;
gUpdateDisplay = true;
@@ -647,6 +650,9 @@ static void MR_NextChannel(void)
if (enabled)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gCurrentScanList)
{
case SCAN_NEXT_CHAN_SCANLIST1:
@@ -657,7 +663,7 @@ static void MR_NextChannel(void)
if (RADIO_CheckValidChannel(chan1, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
gNextMrChannel = chan1;
break;
}
}
@@ -680,7 +686,7 @@ static void MR_NextChannel(void)
// {
// chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan];
// if (IS_MR_CHANNEL(chan))
// if (chan <= MR_CHANNEL_LAST)
// {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan;
@@ -695,11 +701,13 @@ static void MR_NextChannel(void)
chan = 0xff;
break;
}
#pragma GCC diagnostic pop
}
if (!enabled || chan == 0xff)
{
chan = RADIO_FindNextChannel(gNextMrChannel + gScanState, gScanState, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT);
if (chan == 0xFF)
{ // no valid channel found
@@ -722,9 +730,9 @@ static void MR_NextChannel(void)
}
#ifdef ENABLE_FASTER_CHANNEL_SCAN
ScanPauseDelayIn_10ms = 8; // 80ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
gScanPauseDelayIn_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
#else
ScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
#endif
bScanKeepFrequency = false;
@@ -971,7 +979,7 @@ void APP_EndTransmission(void)
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
return;
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
return;
if (gVOX_NoiseDetected)
@@ -1063,9 +1071,9 @@ void APP_Update(void)
#endif
#ifdef ENABLE_VOICE
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0)
#else
if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed)
#endif
{ // scanning
@@ -1074,14 +1082,14 @@ void APP_Update(void)
if (gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
FREQ_NextChannel();
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();
MR_NextChannel(); // switch to next channel
}
gScanPauseMode = false;
@@ -1124,7 +1132,7 @@ void APP_Update(void)
if (gScheduleDualWatch)
#endif
{
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (!gPttIsPressed &&
#ifdef ENABLE_FMRADIO
@@ -1174,7 +1182,7 @@ void APP_Update(void)
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
gScanStateDir != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
@@ -1199,7 +1207,7 @@ void APP_Update(void)
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
gScanStateDir != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF ||
gScreenToDisplay != DISPLAY_MAIN ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
@@ -1233,7 +1241,7 @@ void APP_Update(void)
#endif
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF &&
gScanState == SCAN_OFF &&
gScanStateDir == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // dual watch mode, toggle between the two VFO's
DUALWATCH_Alternate();
@@ -1247,7 +1255,7 @@ void APP_Update(void)
gRxIdleMode = false; // RX is awake
}
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI)
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI)
{ // dual watch mode, go back to sleep
updateRSSI(gEeprom.RX_VFO);
@@ -1371,7 +1379,7 @@ void APP_CheckKeys(void)
Key == KEY_DOWN ||
Key == KEY_EXIT ||
Key == KEY_MENU ||
Key <= KEY_9) // keys 0-9 can be held down to bypass pressing the F-Key
(Key >= KEY_0 && Key <= KEY_9)) // keys 0-9 can be held down to bypass pressing the F-Key
{
gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true);
@@ -1812,9 +1820,9 @@ void APP_TimeSlice500ms(void)
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
#ifdef ENABLE_AIRCOPY
if (gScanState == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#else
if (gScanState == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND))
#endif
{
bool exit_menu = false;
@@ -2034,32 +2042,32 @@ void APP_TimeSlice500ms(void)
}
#endif
void CHANNEL_Next(bool bFlag, int8_t Direction)
void CHANNEL_Next(const bool bFlag, const int8_t scan_direction)
{
RADIO_SelectVfos();
gNextMrChannel = gRxVfo->CHANNEL_SAVE;
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gScanState = Direction;
gScanStateDir = scan_direction;
if (IS_MR_CHANNEL(gNextMrChannel))
{
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();
}
ScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
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)
@@ -2190,7 +2198,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Key != KEY_STAR &&
Key != KEY_MENU)
{
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
{ // FREQ/CTCSS/DCS scanning
if (bKeyPressed && !bKeyHeld)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
@@ -2248,14 +2256,16 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
char Code;
if (Key == KEY_SIDE2)
{
{ // transmit 1750Hz tone
Code = 0xFE;
}
else
{
Code = DTMF_GetCharacter(Key);
Code = DTMF_GetCharacter(Key - KEY_0);
if (Code == 0xFF)
goto Skip;
// transmit DTMF keys
}
if (!bKeyPressed || bKeyHeld)

View File

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

View File

@@ -184,7 +184,7 @@ void DTMF_HandleRequest(void)
if (!gDTMF_RX_pending)
return; // nothing new received
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
{ // we're busy scanning
DTMF_clear_RX();
return;
@@ -331,6 +331,9 @@ void DTMF_HandleRequest(void)
gUpdateDisplay = true;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gEeprom.DTMF_DECODE_RESPONSE)
{
case DTMF_DEC_RESPONSE_BOTH:
@@ -348,6 +351,8 @@ void DTMF_HandleRequest(void)
break;
}
#pragma GCC diagnostic pop
if (gDTMF_IsGroupCall)
gDTMF_ReplyState = DTMF_REPLY_NONE;
}
@@ -385,8 +390,9 @@ void DTMF_Reply(void)
default:
case DTMF_REPLY_NONE:
if (gDTMF_CallState != DTMF_CALL_STATE_NONE ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF ||
if (gDTMF_CallState != DTMF_CALL_STATE_NONE ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_OFF ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN)
{
gDTMF_ReplyState = DTMF_REPLY_NONE;

View File

@@ -154,7 +154,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
return;
}
if (gScanState != SCAN_OFF)
if (gScanStateDir != SCAN_OFF)
{
SCANNER_Stop();

View File

@@ -37,6 +37,9 @@
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
#ifdef ENABLE_SPECTRUM
// #include "app/spectrum.h"
#endif
void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting
@@ -71,8 +74,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
uint8_t Vfo = gEeprom.TX_VFO;
if (gScreenToDisplay == DISPLAY_MENU)
{
// if (beep)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
// if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
switch (Key)
{
case KEY_0:
@@ -355,7 +365,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
// #endif
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering frequency
{ // user is entering a frequency
uint32_t Frequency;
@@ -488,7 +498,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
if (!gFmRadioMode)
#endif
{
if (gScanState == SCAN_OFF)
if (gScanStateDir == SCAN_OFF)
{
if (gInputBoxIndex == 0)
return;
@@ -538,6 +548,10 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{
if (bKeyPressed && !bKeyHeld)
// menu key pressed
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bKeyHeld)
{ // menu key held down (long press)
@@ -560,11 +574,11 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (gEeprom.VFO_OPEN && gCssScanMode == CSS_SCAN_MODE_OFF)
{
if (gScanState != SCAN_OFF)
if (gScanStateDir != SCAN_OFF)
{
if (gCurrentFunction != FUNCTION_INCOMING ||
gRxReceptionMode == RX_MODE_NONE ||
ScanPauseDelayIn_10ms == 0)
gScanPauseDelayIn_10ms == 0)
{ // scan is running (not paused)
return;
}
@@ -611,14 +625,10 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
const bool bFlag = (gInputBoxIndex == 0);
gInputBoxIndex = 0;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (bFlag)
{
gFlagRefreshSetting = true;
gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MENU;
#endif
@@ -640,7 +650,8 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
}
if (bKeyHeld || !bKeyPressed)
{
{ // long press
if (bKeyHeld || bKeyPressed)
{
if (!bKeyHeld)
@@ -655,9 +666,9 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
}
#ifdef ENABLE_NOAA
if (gScanState == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else
if (gScanState == SCAN_OFF)
if (gScanStateDir == SCAN_OFF)
#endif
{
gKeyInputCountdown = key_input_timeout_500ms;
@@ -740,7 +751,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
if (gScanState == SCAN_OFF)
if (gScanStateDir == SCAN_OFF)
{
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
@@ -796,7 +807,10 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return;
}
// jump to the next channel
CHANNEL_Next(false, Direction);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
gPttWasReleased = true;
}
@@ -816,7 +830,7 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (!bKeyHeld)
{
const char Character = DTMF_GetCharacter(Key);
const char Character = DTMF_GetCharacter(Key - KEY_0);
if (Character != 0xFF)
{ // add key to DTMF string
DTMF_Append(Character);
@@ -835,7 +849,7 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
// TODO: ???
if (Key > KEY_PTT)
{
Key = KEY_SIDE2;
Key = KEY_SIDE2; // what's this doing ???
}
switch (Key)

View File

@@ -86,8 +86,8 @@ void MENU_StartCssScan(int8_t Direction)
MENU_SelectNextCode();
ScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
}
void MENU_StopCssScan(void)
@@ -408,6 +408,9 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1;
return;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
case MENU_T_CTCS:
pConfig = &gTxVfo->freq_config_TX;
case MENU_R_CTCS:
@@ -436,6 +439,8 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1;
return;
#pragma GCC diagnostic pop
case MENU_SFT_D:
gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection;
gRequestSaveChannel = 1;
@@ -819,7 +824,7 @@ void MENU_SelectNextCode(void)
RADIO_SetupRegisters(true);
ScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
gScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
gUpdateDisplay = true;
}
@@ -1193,6 +1198,9 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (!gIsInSubMenu)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gInputBoxIndex)
{
case 2:
@@ -1224,6 +1232,8 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
break;
}
#pragma GCC diagnostic pop
gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@@ -1269,7 +1279,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (IS_MR_CHANNEL(Value))
if (Value <= MR_CHANNEL_LAST)
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@@ -1661,6 +1671,9 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
VFO = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gMenuCursor)
{
case MENU_DEL_CH:
@@ -1681,6 +1694,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return;
}
#pragma GCC diagnostic pop
Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO);
if (Channel != 0xFF)
gSubMenuSelection = Channel;

View File

@@ -37,11 +37,11 @@ uint32_t gScanFrequency;
bool gScanPauseMode;
SCAN_CssState_t gScanCssState;
volatile bool gScheduleScanListen = true;
volatile uint16_t ScanPauseDelayIn_10ms;
volatile uint16_t gScanPauseDelayIn_10ms;
uint8_t gScanProgressIndicator;
uint8_t gScanHitCount;
bool gScanUseCssResult;
int8_t gScanState;
int8_t gScanStateDir;
bool bScanKeepFrequency;
static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
@@ -53,7 +53,9 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
uint16_t Channel;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_SCANNER;
if (gInputBoxIndex < 3)
@@ -65,9 +67,9 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (IS_MR_CHANNEL(Channel))
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (Channel <= MR_CHANNEL_LAST)
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@@ -193,7 +195,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
}
}
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST)
{
gScannerEditState = 1;
gScanChannel = gTxVfo->CHANNEL_SAVE;
@@ -247,7 +249,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gTxVfo->freq_config_TX.Code = gScanCssResultCode;
}
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST)
{
Channel = gScanChannel;
gEeprom.MrChannel[gEeprom.TX_VFO] = Channel;
@@ -424,11 +426,11 @@ void SCANNER_Stop(void)
{
const uint8_t Previous = gRestoreMrChannel;
gScanState = SCAN_OFF;
gScanStateDir = SCAN_OFF;
if (!bScanKeepFrequency)
{
if (IS_MR_CHANNEL(gNextMrChannel))
if (gNextMrChannel <= MR_CHANNEL_LAST)
{
gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = Previous;
@@ -446,7 +448,7 @@ void SCANNER_Stop(void)
return;
}
if (!IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE))
if (gRxVfo->CHANNEL_SAVE > MR_CHANNEL_LAST)
{
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);

View File

@@ -32,7 +32,9 @@ typedef enum SCAN_CssState_t SCAN_CssState_t;
enum
{
SCAN_OFF = 0,
SCAN_REV = -1,
SCAN_OFF = 0,
SCAN_FWD = +1
};
extern DCS_CodeType_t gScanCssResultType;
@@ -46,11 +48,11 @@ extern uint32_t gScanFrequency;
extern bool gScanPauseMode;
extern SCAN_CssState_t gScanCssState;
extern volatile bool gScheduleScanListen;
extern volatile uint16_t ScanPauseDelayIn_10ms;
extern volatile uint16_t gScanPauseDelayIn_10ms;
extern uint8_t gScanProgressIndicator;
extern uint8_t gScanHitCount;
extern bool gScanUseCssResult;
extern int8_t gScanState;
extern int8_t gScanStateDir;
extern bool bScanKeepFrequency;
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

View File

@@ -48,7 +48,7 @@ typedef struct {
} Header_t;
typedef struct {
uint8_t Padding[2];
uint8_t Padding[2];
uint16_t ID;
} Footer_t;
@@ -60,10 +60,10 @@ typedef struct {
typedef struct {
Header_t Header;
struct {
char Version[16];
bool bHasCustomAesKey;
bool bIsInLockScreen;
uint8_t Padding[2];
char Version[16];
bool bHasCustomAesKey;
bool bIsInLockScreen;
uint8_t Padding[2];
uint32_t Challenge[4];
} Data;
} REPLY_0514_t;
@@ -71,8 +71,8 @@ typedef struct {
typedef struct {
Header_t Header;
uint16_t Offset;
uint8_t Size;
uint8_t Padding;
uint8_t Size;
uint8_t Padding;
uint32_t Timestamp;
} CMD_051B_t;
@@ -80,19 +80,19 @@ typedef struct {
Header_t Header;
struct {
uint16_t Offset;
uint8_t Size;
uint8_t Padding;
uint8_t Data[128];
uint8_t Size;
uint8_t Padding;
uint8_t Data[128];
} Data;
} REPLY_051B_t;
typedef struct {
Header_t Header;
uint16_t Offset;
uint8_t Size;
bool bAllowPassword;
uint8_t Size;
bool bAllowPassword;
uint32_t Timestamp;
uint8_t Data[0];
uint8_t Data[0];
} CMD_051D_t;
typedef struct {
@@ -106,8 +106,8 @@ typedef struct {
Header_t Header;
struct {
uint16_t RSSI;
uint8_t ExNoiseIndicator;
uint8_t GlitchIndicator;
uint8_t ExNoiseIndicator;
uint8_t GlitchIndicator;
} Data;
} REPLY_0527_t;
@@ -137,7 +137,10 @@ typedef struct {
uint32_t Timestamp;
} CMD_052F_t;
static const uint8_t Obfuscation[16] = { 0x16, 0x6C, 0x14, 0xE6, 0x2E, 0x91, 0x0D, 0x40, 0x21, 0x35, 0xD5, 0x40, 0x13, 0x03, 0xE9, 0x80 };
static const uint8_t Obfuscation[16] =
{
0x16, 0x6C, 0x14, 0xE6, 0x2E, 0x91, 0x0D, 0x40, 0x21, 0x35, 0xD5, 0x40, 0x13, 0x03, 0xE9, 0x80
};
static union
{
@@ -157,12 +160,11 @@ static void SendReply(void *pReply, uint16_t Size)
{
Header_t Header;
Footer_t Footer;
uint8_t *pBytes;
uint16_t i;
if (bIsEncrypted)
{
pBytes = (uint8_t *)pReply;
uint8_t *pBytes = (uint8_t *)pReply;
unsigned int i;
for (i = 0; i < Size; i++)
pBytes[i] ^= Obfuscation[i % 16];
}
@@ -171,6 +173,7 @@ static void SendReply(void *pReply, uint16_t Size)
Header.Size = Size;
UART_Send(&Header, sizeof(Header));
UART_Send(pReply, Size);
if (bIsEncrypted)
{
Footer.Padding[0] = Obfuscation[(Size + 0) % 16] ^ 0xFF;
@@ -205,14 +208,16 @@ static void SendVersion(void)
static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint32_t *pResponse)
{
uint8_t i;
uint32_t IV[4];
unsigned int i;
uint32_t IV[4];
IV[0] = 0;
IV[1] = 0;
IV[2] = 0;
IV[3] = 0;
AES_Encrypt(pKey, IV, pIn, IV, true);
for (i = 0; i < 4; i++)
if (IV[i] != pResponse[i])
return true;
@@ -254,10 +259,10 @@ static void CMD_051B(const uint8_t *pBuffer)
#endif
memset(&Reply, 0, sizeof(Reply));
Reply.Header.ID = 0x051C;
Reply.Header.ID = 0x051C;
Reply.Header.Size = pCmd->Size + 4;
Reply.Data.Offset = pCmd->Offset;
Reply.Data.Size = pCmd->Size;
Reply.Data.Size = pCmd->Size;
if (bHasCustomAesKey)
bLocked = gIsLocked;
@@ -294,7 +299,7 @@ static void CMD_051D(const uint8_t *pBuffer)
if (!bIsLocked)
{
uint16_t i;
unsigned int i;
for (i = 0; i < (pCmd->Size / 8); i++)
{
const uint16_t Offset = pCmd->Offset + (i * 8U);
@@ -331,23 +336,25 @@ static void CMD_0529(void)
{
REPLY_0529_t Reply;
Reply.Header.ID = 0x52A;
Reply.Header.ID = 0x52A;
Reply.Header.Size = sizeof(Reply.Data);
// Original doesn't actually send current!
BOARD_ADC_GetBatteryInfo(&Reply.Data.Voltage, &Reply.Data.Current);
SendReply(&Reply, sizeof(Reply));
}
static void CMD_052D(const uint8_t *pBuffer)
{
const CMD_052D_t *pCmd = (const CMD_052D_t *)pBuffer;
REPLY_052D_t Reply;
bool bIsLocked;
REPLY_052D_t Reply;
bool bIsLocked;
#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
#endif
Reply.Header.ID = 0x052E;
Reply.Header.ID = 0x052E;
Reply.Header.Size = sizeof(Reply.Data);
bIsLocked = bHasCustomAesKey;
@@ -413,15 +420,13 @@ static void CMD_052F(const uint8_t *pBuffer)
bool UART_IsCommandAvailable(void)
{
uint16_t DmaLength;
uint16_t CommandLength;
uint16_t Index;
uint16_t TailIndex;
uint16_t Size;
uint16_t CRC;
uint16_t i;
uint16_t CommandLength;
uint16_t DmaLength = DMA_CH0->ST & 0xFFFU;
DmaLength = DMA_CH0->ST & 0xFFFU;
while (1)
{
if (gUART_WriteIndex == DmaLength)
@@ -450,7 +455,7 @@ bool UART_IsCommandAvailable(void)
Index = DMA_INDEX(gUART_WriteIndex, 2);
Size = (UART_DMA_Buffer[DMA_INDEX(Index, 1)] << 8) | UART_DMA_Buffer[Index];
if ((Size + 8) > sizeof(UART_DMA_Buffer))
if ((Size + 8u) > sizeof(UART_DMA_Buffer))
{
gUART_WriteIndex = DmaLength;
return false;
@@ -495,9 +500,12 @@ bool UART_IsCommandAvailable(void)
bIsEncrypted = true;
if (bIsEncrypted)
for (i = 0; i < Size + 2; i++)
{
unsigned int i;
for (i = 0; i < (Size + 2u); i++)
UART_Command.Buffer[i] ^= Obfuscation[i % 16];
}
CRC = UART_Command.Buffer[Size] | (UART_Command.Buffer[Size + 1] << 8);
return (CRC_Calculate(UART_Command.Buffer, Size) != CRC) ? false : true;