This commit is contained in:
Krzysiek Egzmont 2023-10-24 18:35:27 +02:00
parent 77d58eb8f5
commit 72eddd009b
16 changed files with 159 additions and 178 deletions

View File

@ -116,55 +116,53 @@ void ACTION_Monitor(void)
void ACTION_Scan(bool bRestart)
{
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
{
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
{
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT)
GUI_SelectNextDisplay(DISPLAY_FM);
gMonitor = false;
if (gFM_ScanState != FM_SCAN_OFF)
{
GUI_SelectNextDisplay(DISPLAY_FM);
FM_PlayAndUpdate();
gMonitor = false;
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
}
else
{
uint16_t Frequency;
if (gFM_ScanState != FM_SCAN_OFF)
if (bRestart)
{
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif
gFM_AutoScan = true;
gFM_ChannelPosition = 0;
FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit;
}
else
{
uint16_t Frequency;
if (bRestart)
{
gFM_AutoScan = true;
gFM_ChannelPosition = 0;
FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit;
}
else
{
gFM_AutoScan = false;
gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying;
}
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
#endif
gFM_AutoScan = false;
gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying;
}
}
return;
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
#ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
#endif
}
}
#endif
return;
}
#endif
if (gScreenToDisplay != DISPLAY_SCANNER)
{ // not scanning
@ -178,23 +176,23 @@ void ACTION_Scan(bool bRestart)
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
#ifdef ENABLE_NOAA
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
if (gScanStateDir != SCAN_OFF)
{ // already scanning
if (gNextMrChannel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gNextMrChannel))
{ // channel mode
// keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel
SCANNER_NextChannel(false, gScanStateDir);
SCANNER_ScanChannels(false, gScanStateDir);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
@ -213,7 +211,7 @@ void ACTION_Scan(bool bRestart)
else
{ // start scanning
SCANNER_NextChannel(true, SCAN_FWD);
SCANNER_ScanChannels(true, SCAN_FWD);
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
@ -231,12 +229,12 @@ void ACTION_Scan(bool bRestart)
}
else
// if (!bRestart)
if (!bRestart && gNextMrChannel <= MR_CHANNEL_LAST)
if (!bRestart && IS_MR_CHANNEL(gNextMrChannel))
{ // channel mode, keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3;
// jump to the next channel
SCANNER_NextChannel(false, gScanStateDir);
SCANNER_ScanChannels(false, gScanStateDir);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;

View File

@ -62,12 +62,6 @@
#include "ui/status.h"
#include "ui/ui.h"
// original QS front end register settings
const uint8_t orig_lna_short = 3; // 0dB
const uint8_t orig_lna = 2; // -14dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
static void updateRSSI(const int vfo)
@ -308,7 +302,7 @@ static void APP_HandleReceive(void)
if (g_SquelchLost)
{
#ifdef ENABLE_NOAA
if (!gEndOfRxDetectedMaybe && IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
if (!gEndOfRxDetectedMaybe && !IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#else
if (!gEndOfRxDetectedMaybe)
#endif
@ -482,7 +476,6 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gVFO_RSSI_bar_level[(chan + 1) & 1u] = 0;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
if (gSetting_backlight_on_tx_rx >= BACKLIGHT_ON_TR_RX)
@ -508,7 +501,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
break;
}
bScanKeepFrequency = true;
gScanKeepResult = true;
}
#ifdef ENABLE_NOAA
@ -545,12 +538,11 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
}
{ // RF RX front end gain
// original setting
uint16_t lna_short = orig_lna_short;
uint16_t lna = orig_lna;
uint16_t mixer = orig_mixer;
uint16_t pga = orig_pga;
// original QS front end register settings
const uint8_t orig_lna_short = 3; // 0dB
const uint8_t orig_lna = 2; // -14dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
#ifdef ENABLE_AM_FIX
if (gRxVfo->AM_mode && gSetting_AM_fix)
@ -561,10 +553,10 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
}
else
{ // FM RX mode
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
BK4819_WriteRegister(BK4819_REG_13, (orig_lna_short << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
}
#else
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
BK4819_WriteRegister(BK4819_REG_13, (orig_lna_short << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
#endif
}
@ -622,7 +614,7 @@ static void DUALWATCH_Alternate(void)
#ifdef ENABLE_NOAA
if (gIsNoaaMode)
{
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
if (!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1;
else
gEeprom.RX_VFO = 0;
@ -1038,7 +1030,7 @@ void APP_Update(void)
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
else if ((!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);

View File

@ -23,11 +23,6 @@
#include "frequencies.h"
#include "radio.h"
extern const uint8_t orig_lna_short;
extern const uint8_t orig_lna;
extern const uint8_t orig_mixer;
extern const uint8_t orig_pga;
void APP_EndTransmission(void);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);

View File

@ -39,7 +39,7 @@ void COMMON_SwitchVFOs()
void COMMON_SwitchVFOMode()
{
#ifdef ENABLE_NOAA
if (gEeprom.VFO_OPEN && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (gEeprom.VFO_OPEN && !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else
if (gEeprom.VFO_OPEN)
#endif

View File

@ -207,7 +207,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if(beep) {
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO];
}
@ -358,7 +358,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
// #ifdef ENABLE_NOAA
// if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
// if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
// #endif
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering a frequency
@ -505,7 +505,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
}
else
{
bScanKeepFrequency = false;
gScanKeepResult = false;
SCANNER_Stop();
#ifdef ENABLE_VOICE
@ -564,7 +564,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gWasFKeyPressed = false;
gUpdateStatus = true;
ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld);
ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld);
}
}
@ -632,7 +632,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
{
#ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
if (gScanStateDir == SCAN_OFF && !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#else
if (gScanStateDir == SCAN_OFF)
#endif
@ -710,7 +710,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gScanStateDir == SCAN_OFF)
{
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
if (!IS_NOAA_CHANNEL(Channel))
#endif
{
uint8_t Next;
@ -764,7 +764,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
}
// jump to the next channel
SCANNER_NextChannel(false, Direction);
SCANNER_ScanChannels(false, Direction);
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;

View File

@ -1293,7 +1293,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 (Value <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Value))
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@ -1566,7 +1566,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0)
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0)
#else
if (gRxVfo->AM_mode == 0)
#endif

View File

@ -43,9 +43,20 @@ uint8_t gScanProgressIndicator;
uint8_t gScanHitCount;
bool gScanUseCssResult;
int8_t gScanStateDir;
bool bScanKeepFrequency;
uint8_t gRestoreMrChannel;
uint8_t gRestoreCROSS_BAND_RX_TX;
bool gScanKeepResult;
typedef enum {
SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2,
SCAN_NEXT_CHAN_DUAL_WATCH,
SCAN_NEXT_CHAN_MR,
SCAN_NEXT_NUM
} scan_next_chan_t;
scan_next_chan_t currentScanList;
uint8_t restoreMrChannel;
uint32_t restoreFrequency;
uint8_t initialCROSS_BAND_RX_TX;
static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
@ -72,7 +83,7 @@ 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 (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
@ -183,7 +194,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
}
}
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
gScannerEditState = 1;
gScanChannel = gTxVfo->CHANNEL_SAVE;
@ -237,7 +248,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gTxVfo->freq_config_TX.Code = gScanCssResultCode;
}
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{
Channel = gScanChannel;
gEeprom.MrChannel[gEeprom.TX_VFO] = Channel;
@ -412,47 +423,42 @@ void SCANNER_Start(void)
void SCANNER_Stop(void)
{
if(gRestoreCROSS_BAND_RX_TX != CROSS_BAND_OFF) {
gEeprom.CROSS_BAND_RX_TX = gRestoreCROSS_BAND_RX_TX;
gRestoreCROSS_BAND_RX_TX = CROSS_BAND_OFF;
if(initialCROSS_BAND_RX_TX != CROSS_BAND_OFF) {
gEeprom.CROSS_BAND_RX_TX = initialCROSS_BAND_RX_TX;
initialCROSS_BAND_RX_TX = CROSS_BAND_OFF;
}
gScanStateDir = SCAN_OFF;
if (!bScanKeepFrequency)
{
if (gNextMrChannel <= MR_CHANNEL_LAST)
{
gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = gRestoreMrChannel;
if (gScanKeepResult) {
if (IS_MR_CHANNEL(gRxVfo->CHANNEL_SAVE)) {
SETTINGS_SaveVfoIndices();
gUpdateStatus = true;
}
else {
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_VFO, gRxVfo, 1);
}
}
else {
if (IS_MR_CHANNEL(gNextMrChannel)) {
gEeprom.MrChannel[gEeprom.RX_VFO] = restoreMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = restoreMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD);
}
else
{
gRxVfo->freq_config_RX.Frequency = gRestoreFrequency;
else {
gRxVfo->freq_config_RX.Frequency = restoreFrequency;
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
}
RADIO_SetupRegisters(true);
gUpdateDisplay = true;
return;
}
if (gRxVfo->CHANNEL_SAVE > MR_CHANNEL_LAST)
{
RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_VFO, gRxVfo, 1);
return;
}
SETTINGS_SaveVfoIndices();
gUpdateStatus = true;
}
static void SCANNER_NextFreqChannel(void)
static void NextFreqChannel(void)
{
gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir);
@ -466,11 +472,11 @@ static void SCANNER_NextFreqChannel(void)
gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms;
#endif
bScanKeepFrequency = false;
gScanKeepResult = false;
gUpdateDisplay = true;
}
static void SCANNER_NextMemChannel(void)
static void 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;
@ -481,7 +487,7 @@ static void SCANNER_NextMemChannel(void)
if (enabled)
{
switch (gCurrentScanList)
switch (currentScanList)
{
case SCAN_NEXT_CHAN_SCANLIST1:
prev_mr_chan = gNextMrChannel;
@ -490,7 +496,7 @@ static void SCANNER_NextMemChannel(void)
{
if (RADIO_CheckValidChannel(chan1, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1;
currentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gNextMrChannel = chan1;
break;
}
@ -501,7 +507,7 @@ static void SCANNER_NextMemChannel(void)
{
if (RADIO_CheckValidChannel(chan2, false, 0))
{
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2;
currentScanList = SCAN_NEXT_CHAN_SCANLIST2;
gNextMrChannel = chan2;
break;
}
@ -515,9 +521,9 @@ static void SCANNER_NextMemChannel(void)
// {
// chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan];
// if (chan <= MR_CHANNEL_LAST)
// if (IS_MR_CHANNEL(chan))
// {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// currentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan;
// break;
// }
@ -525,7 +531,7 @@ static void SCANNER_NextMemChannel(void)
default:
case SCAN_NEXT_CHAN_MR:
gCurrentScanList = SCAN_NEXT_CHAN_MR;
currentScanList = SCAN_NEXT_CHAN_MR;
gNextMrChannel = prev_mr_chan;
chan = 0xff;
break;
@ -562,44 +568,44 @@ static void SCANNER_NextMemChannel(void)
gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms;
#endif
bScanKeepFrequency = false;
gScanKeepResult = false;
if (enabled)
if (++gCurrentScanList >= SCAN_NEXT_NUM)
gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
if (++currentScanList >= SCAN_NEXT_NUM)
currentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
}
void SCANNER_NextChannel(const bool storeBackupSettings, const int8_t scan_direction)
void SCANNER_ScanChannels(const bool storeBackupSettings, const int8_t scan_direction)
{
if (storeBackupSettings) {
gRestoreCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
initialCROSS_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;
currentScanList = SCAN_NEXT_CHAN_SCANLIST1;
gScanStateDir = scan_direction;
if (gNextMrChannel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gNextMrChannel))
{ // channel mode
if (storeBackupSettings)
gRestoreMrChannel = gNextMrChannel;
SCANNER_NextMemChannel();
restoreMrChannel = gNextMrChannel;
NextMemChannel();
}
else
{ // frequency mode
if (storeBackupSettings)
gRestoreFrequency = gRxVfo->freq_config_RX.Frequency;
SCANNER_NextFreqChannel();
restoreFrequency = gRxVfo->freq_config_RX.Frequency;
NextFreqChannel();
}
gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms;
gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false;
bScanKeepFrequency = false;
gScanKeepResult = false;
}
void SCANNER_ContinueScanning()
@ -609,14 +615,14 @@ void SCANNER_ContinueScanning()
if (gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
else
SCANNER_NextFreqChannel(); // switch to next frequency
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
NextMemChannel(); // switch to next channel
}
gScanPauseMode = false;

View File

@ -53,12 +53,12 @@ extern uint8_t gScanProgressIndicator;
extern uint8_t gScanHitCount;
extern bool gScanUseCssResult;
extern int8_t gScanStateDir;
extern bool bScanKeepFrequency;
extern bool gScanKeepResult;
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void SCANNER_Start(void);
void SCANNER_Stop(void);
void SCANNER_NextChannel(const bool storeBackupSettings, const int8_t scan_direction);
void SCANNER_ScanChannels(const bool storeBackupSettings, const int8_t scan_direction);
void SCANNER_ContinueScanning();
#endif

View File

@ -43,7 +43,7 @@ FUNCTION_Type_t gCurrentFunction;
void FUNCTION_Init(void)
{
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
gCurrentCodeType = gSelectedCodeType;

3
misc.c
View File

@ -201,9 +201,6 @@ uint16_t gLowBatteryCountdown;
uint8_t gNextMrChannel;
ReceptionMode_t gRxReceptionMode;
enum scan_next_chan_t gCurrentScanList;
uint32_t gRestoreFrequency;
bool gRxVfoIsActive;
#ifdef ENABLE_ALARM
uint8_t gAlarmToneCounter;

14
misc.h
View File

@ -35,9 +35,7 @@
#define IS_MR_CHANNEL(x) ((x) <= MR_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_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
#define IS_NOT_NOAA_CHANNEL(x) ((x) <= FREQ_CHANNEL_LAST)
enum {
MR_CHANNEL_FIRST = 0,
@ -85,15 +83,6 @@ enum CssScanMode_t
};
typedef enum CssScanMode_t CssScanMode_t;
enum scan_next_chan_t {
SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2,
SCAN_NEXT_CHAN_DUAL_WATCH,
SCAN_NEXT_CHAN_MR,
SCAN_NEXT_NUM
};
typedef enum scan_next_chan_t scan_next_chan_t;
enum BacklightOnRxTx_t {
BACKLIGHT_ON_TR_OFF,
BACKLIGHT_ON_TR_TX,
@ -283,9 +272,6 @@ extern uint16_t gLowBatteryCountdown;
extern uint8_t gNextMrChannel;
extern ReceptionMode_t gRxReceptionMode;
extern scan_next_chan_t gCurrentScanList;
extern uint32_t gRestoreFrequency;
//TRUE when dual watch is momentarly suspended and RX_VFO is locked to either last TX or RX
extern bool gRxVfoIsActive;
extern uint8_t gAlarmToneCounter;

30
radio.c
View File

@ -51,7 +51,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
uint8_t PriorityCh1;
uint8_t PriorityCh2;
if (Channel > MR_CHANNEL_LAST)
if (!IS_MR_CHANNEL(Channel))
return false;
Attributes = gMR_ChannelAttributes[Channel];
@ -97,12 +97,12 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
{
unsigned int i;
for (i = 0; i <= MR_CHANNEL_LAST; i++)
for (i = 0; IS_MR_CHANNEL(i); i++)
{
if (Channel == 0xFF)
Channel = MR_CHANNEL_LAST;
else
if (Channel > MR_CHANNEL_LAST)
if (!IS_MR_CHANNEL(Channel))
Channel = MR_CHANNEL_FIRST;
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO))
@ -176,7 +176,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
}
#endif
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{
Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO);
if (Channel == 0xFF)
@ -200,7 +200,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
uint8_t Index;
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{
Channel = gEeprom.FreqChannel[VFO];
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
@ -218,7 +218,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Band = BAND6_400MHz;
}
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{
gEeprom.VfoInfo[VFO].Band = Band;
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = !!(Attributes & MR_CH_SCANLIST1);
@ -235,7 +235,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
gEeprom.VfoInfo[VFO].SCANLIST2_PARTICIPATION = bParticipation2;
gEeprom.VfoInfo[VFO].CHANNEL_SAVE = Channel;
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
Base = Channel * 16;
else
Base = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
@ -377,13 +377,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (Frequency >= frequencyBandTable[BAND2_108MHz].upper && Frequency < frequencyBandTable[BAND2_108MHz].upper)
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF;
else if (Channel > MR_CHANNEL_LAST)
else if (!IS_MR_CHANNEL(Channel))
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = FREQUENCY_RoundToStep(gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY, gEeprom.VfoInfo[VFO].StepFrequency);
RADIO_ApplyOffset(pRadio);
memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name));
if (Channel < MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{ // 16 bytes allocated to the channel name but only 10 used, the rest are 0's
EEPROM_ReadBuffer(0x0F50 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 8, 2);
@ -619,7 +619,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f));
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode)
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode)
Frequency = gRxVfo->pRX->Frequency;
else
Frequency = NoaaFrequencyTable[gNoaaChannel];
@ -644,7 +644,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
#endif
{
if (gRxVfo->AM_mode == 0)
@ -723,9 +723,9 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#ifdef ENABLE_VOX
#ifdef ENABLE_NOAA
#ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
if (gEeprom.VOX_SWITCH && !gFmRadioMode && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
#else
if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
if (gEeprom.VOX_SWITCH && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0)
#endif
#else
#ifdef ENABLE_FMRADIO
@ -788,9 +788,9 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
{
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]))
if (!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]))
{
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
if (!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))
{
gIsNoaaMode = false;
return;

View File

@ -73,7 +73,14 @@ typedef struct VFO_Info_t
{
FREQ_Config_t freq_config_RX;
FREQ_Config_t freq_config_TX;
// this is for a purpose of the FrequencyReverse function
// it points to freq_config_RX normally and to freq_config_TX if reverse function is active
//
FREQ_Config_t *pRX;
// this is for a purpose of the FrequencyReverse function
// it points to freq_config_TX normally and to freq_config_RX if reverse function is active
FREQ_Config_t *pTX;
uint32_t TX_OFFSET_FREQUENCY;

View File

@ -190,19 +190,19 @@ void SETTINGS_SaveSettings(void)
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)
{
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
if (!IS_NOAA_CHANNEL(Channel))
#endif
{
const uint16_t OffsetMR = Channel * 16;
uint16_t OffsetVFO = OffsetMR;
if (Channel > MR_CHANNEL_LAST)
if (!IS_MR_CHANNEL(Channel))
{ // it's a VFO, not a channel
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
}
if (Mode >= 2 || Channel > MR_CHANNEL_LAST)
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
{ // copy VFO to a channel
uint8_t State[8];
@ -227,7 +227,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
SETTINGS_UpdateChannel(Channel, pVFO, true);
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{ // it's a memory channel
#ifndef ENABLE_KEEP_MEM_NAME
@ -265,7 +265,7 @@ void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
{
#ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel))
if (!IS_NOAA_CHANNEL(Channel))
#endif
{
uint8_t State[8];
@ -290,7 +290,7 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
gMR_ChannelAttributes[Channel] = Attributes;
// #ifndef ENABLE_KEEP_MEM_NAME
if (Channel <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(Channel))
{ // it's a memory channel
const uint16_t OffsetMR = Channel * 16;

View File

@ -389,7 +389,7 @@ void UI_DisplayMain(void)
}
}
if (gEeprom.ScreenChannel[vfo_num] <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // channel mode
const unsigned int x = 2;
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true;
@ -471,7 +471,7 @@ void UI_DisplayMain(void)
frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
}
if (gEeprom.ScreenChannel[vfo_num] <= MR_CHANNEL_LAST)
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // it's a channel
// show the scan list assigment symbols

View File

@ -88,7 +88,7 @@ void UI_DisplayStatus(const bool test_display)
// SCAN indicator
if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display)
{
if (gNextMrChannel <= MR_CHANNEL_LAST && gScreenToDisplay != DISPLAY_SCANNER)
if (IS_MR_CHANNEL(gNextMrChannel) && gScreenToDisplay != DISPLAY_SCANNER)
{ // channel mode
if (gEeprom.SCAN_LIST_DEFAULT == 0)
UI_PrintStringSmallBuffer("1", line + x);