0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +03:00

lots of renames

This commit is contained in:
OneOfEleven 2023-10-08 17:14:13 +01:00
parent 83c3c8ce1c
commit 1ab74dcba1
56 changed files with 1874 additions and 1871 deletions

View File

@ -10,12 +10,12 @@ ENABLE_LTO := 1
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_AIRCOPY := 0 ENABLE_AIRCOPY := 0
ENABLE_FMRADIO := 1 ENABLE_FMRADIO := 1
ENABLE_NOAA := 0 ENABLE_NOAA := 1
ENABLE_VOICE := 1 ENABLE_VOICE := 1
ENABLE_VOX := 1 ENABLE_VOX := 1
ENABLE_ALARM := 0 ENABLE_ALARM := 1
ENABLE_TX1750 := 1 ENABLE_TX1750 := 1
ENABLE_PWRON_PASSWORD := 0 ENABLE_PWRON_PASSWORD := 1
ENABLE_BIG_FREQ := 0 ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1 ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
@ -33,8 +33,8 @@ ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1 ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_FASTER_CHANNEL_SCAN := 1 ENABLE_FASTER_CHANNEL_SCAN := 1
ENABLE_RSSI_BAR := 1 ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 0
ENABLE_SHOW_TX_TIMEOUT := 1 ENABLE_SHOW_TX_TIMEOUT := 1
ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1 ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_PANADAPTER := 1 #ENABLE_PANADAPTER := 1
#ENABLE_SINGLE_VFO_CHAN := 1 #ENABLE_SINGLE_VFO_CHAN := 1
@ -53,6 +53,11 @@ ifeq ($(ENABLE_LTO),1)
ENABLE_OVERLAY := 0 ENABLE_OVERLAY := 0
endif endif
ifeq ($(ENABLE_SHOW_TX_TIMEOUT),1)
# can't have ENABLE_SHOW_TX_TIMEOUT and ENABLE_AUDIO_BAR enabled at same time
ENABLE_AUDIO_BAR := 0
endif
BSP_DEFINITIONS := $(wildcard hardware/*/*.def) BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS)) BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS)) BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
@ -108,6 +113,9 @@ OBJS += app/generic.o
OBJS += app/main.o OBJS += app/main.o
OBJS += app/menu.o OBJS += app/menu.o
OBJS += app/scanner.o OBJS += app/scanner.o
ifeq ($(ENABLE_PANADAPTER),1)
OBJS += app/spectrum.o
endif
ifeq ($(ENABLE_UART),1) ifeq ($(ENABLE_UART),1)
OBJS += app/uart.o OBJS += app/uart.o
endif endif
@ -295,8 +303,8 @@ endif
ifeq ($(ENABLE_FASTER_CHANNEL_SCAN),1) ifeq ($(ENABLE_FASTER_CHANNEL_SCAN),1)
CFLAGS += -DENABLE_FASTER_CHANNEL_SCAN CFLAGS += -DENABLE_FASTER_CHANNEL_SCAN
endif endif
ifeq ($(ENABLE_BACKLIGHT_ON_RX),1) ifeq ($(ENABLE_backlight_ON_RX),1)
CFLAGS += -DENABLE_BACKLIGHT_ON_RX CFLAGS += -DENABLE_backlight_ON_RX
endif endif
ifeq ($(ENABLE_RSSI_BAR),1) ifeq ($(ENABLE_RSSI_BAR),1)
CFLAGS += -DENABLE_RSSI_BAR CFLAGS += -DENABLE_RSSI_BAR

View File

@ -55,14 +55,14 @@ static void ACTION_FlashLight(void)
void ACTION_Power(void) void ACTION_Power(void)
{ {
if (++gTxVfo->OUTPUT_POWER > OUTPUT_POWER_HIGH) if (++gTxVfo->output_power > OUTPUT_POWER_HIGH)
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW; gTxVfo->output_power = OUTPUT_POWER_LOW;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
//gRequestSaveChannel = 2; // auto save the channel //gRequestSaveChannel = 2; // auto save the channel
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_POWER; g_another_voice_id = VOICE_ID_POWER;
#endif #endif
gRequestDisplayScreen = gScreenToDisplay; gRequestDisplayScreen = gScreenToDisplay;
@ -74,8 +74,8 @@ void ACTION_Monitor(void)
{ // enable the monitor { // enable the monitor
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode) if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST && gIsNoaaMode)
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST;
#endif #endif
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
APP_StartListening(FUNCTION_MONITOR, false); APP_StartListening(FUNCTION_MONITOR, false);
@ -92,7 +92,7 @@ void ACTION_Monitor(void)
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode)
{ {
gNOAA_Countdown_10ms = NOAA_countdown_10ms; gNOAA_Countdown_10ms = NOAA_countdown_10ms;
gScheduleNOAA = false; gScheduleNOAA = false;
@ -130,7 +130,7 @@ void ACTION_Scan(bool bRestart)
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
else else
@ -142,20 +142,20 @@ void ACTION_Scan(bool bRestart)
gFM_AutoScan = true; gFM_AutoScan = true;
gFM_ChannelPosition = 0; gFM_ChannelPosition = 0;
FM_EraseChannels(); FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit; Frequency = g_eeprom.fm_lower_limit;
} }
else else
{ {
gFM_AutoScan = false; gFM_AutoScan = false;
gFM_ChannelPosition = 0; gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying; Frequency = g_eeprom.fm_frequency_playing;
} }
BK1080_GetFrequencyDeviation(Frequency); BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart); FM_Tune(Frequency, 1, bRestart);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN; g_another_voice_id = VOICE_ID_SCANNING_BEGIN;
#endif #endif
} }
} }
@ -177,7 +177,7 @@ void ACTION_Scan(bool bRestart)
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save))
#endif #endif
{ {
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
@ -185,11 +185,11 @@ void ACTION_Scan(bool bRestart)
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF)
{ // already scanning { // already scanning
if (gNextMrChannel <= MR_CHANNEL_LAST) if (gNextChannel <= USER_CHANNEL_LAST)
{ // channel mode { // channel mode
// keep scanning but toggle between scan lists // keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3;
// jump to the next channel // jump to the next channel
CHANNEL_Next(true, gScanStateDir); CHANNEL_Next(true, gScanStateDir);
@ -204,7 +204,7 @@ void ACTION_Scan(bool bRestart)
SCANNER_Stop(); SCANNER_Stop();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
} }
@ -219,7 +219,7 @@ void ACTION_Scan(bool bRestart)
#endif #endif
// clear the other vfo's rssi level (to hide the antenna symbol) // clear the other vfo's rssi level (to hide the antenna symbol)
gVFO_RSSI_bar_level[(gEeprom.RX_VFO + 1) & 1u] = 0; gVFO_RSSI_bar_level[(g_eeprom.rx_vfo + 1) & 1u] = 0;
// let the user see DW is not active // let the user see DW is not active
gDualWatchActive = false; gDualWatchActive = false;
@ -229,9 +229,9 @@ void ACTION_Scan(bool bRestart)
} }
else else
// if (!bRestart) // if (!bRestart)
if (!bRestart && gNextMrChannel <= MR_CHANNEL_LAST) if (!bRestart && gNextChannel <= USER_CHANNEL_LAST)
{ // channel mode, keep scanning but toggle between scan lists { // channel mode, keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 3; g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3;
// jump to the next channel // jump to the next channel
CHANNEL_Next(true, gScanStateDir); CHANNEL_Next(true, gScanStateDir);
@ -247,7 +247,7 @@ void ACTION_Scan(bool bRestart)
SCANNER_Stop(); SCANNER_Stop();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
@ -257,11 +257,11 @@ void ACTION_Scan(bool bRestart)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
void ACTION_Vox(void) void ACTION_Vox(void)
{ {
gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH; g_eeprom.vox_switch = !g_eeprom.vox_switch;
gRequestSaveSettings = true; gRequestSaveSettings = true;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_VOX; g_another_voice_id = VOICE_ID_VOX;
#endif #endif
gUpdateStatus = true; gUpdateStatus = true;
} }
@ -323,7 +323,7 @@ void ACTION_Scan(bool bRestart)
} }
#endif #endif
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; uint8_t Short = ACTION_OPT_NONE;
uint8_t Long = ACTION_OPT_NONE; uint8_t Long = ACTION_OPT_NONE;
@ -346,7 +346,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
@ -359,14 +359,14 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Key == KEY_SIDE1) if (Key == KEY_SIDE1)
{ {
Short = gEeprom.KEY_1_SHORT_PRESS_ACTION; Short = g_eeprom.key1_short_press_action;
Long = gEeprom.KEY_1_LONG_PRESS_ACTION; Long = g_eeprom.key1_long_press_action;
} }
else else
if (Key == KEY_SIDE2) if (Key == KEY_SIDE2)
{ {
Short = gEeprom.KEY_2_SHORT_PRESS_ACTION; Short = g_eeprom.key2_short_press_action;
Long = gEeprom.KEY_2_LONG_PRESS_ACTION; Long = g_eeprom.key2_long_press_action;
} }
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)

View File

@ -33,7 +33,7 @@ void ACTION_Scan(bool bFlag);
void ACTION_FM(void); void ACTION_FM(void);
#endif #endif
void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void ACTION_Handle(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
#endif #endif

View File

@ -113,7 +113,7 @@ void AIRCOPY_StorePacket(void)
gErrorsDuringAirCopy++; gErrorsDuringAirCopy++;
} }
static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
@ -125,7 +125,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; return;
} }
@ -139,13 +139,13 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper) if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gRxVfo->Band = i; gRxVfo->band = i;
Frequency += 75; Frequency += 75;
Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->StepFrequency, 0); Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->step_freq, 0);
gRxVfo->freq_config_RX.Frequency = Frequency; gRxVfo->freq_config_rx.frequency = Frequency;
gRxVfo->freq_config_TX.Frequency = Frequency; gRxVfo->freq_config_tx.frequency = Frequency;
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
gCurrentVfo = gRxVfo; gCurrentVfo = gRxVfo;
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
@ -202,7 +202,7 @@ static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
} }
} }
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
switch (Key) switch (Key)
{ {

View File

@ -21,25 +21,24 @@
#include "driver/keyboard.h" #include "driver/keyboard.h"
enum AIRCOPY_State_t enum aircopy_state_e
{ {
AIRCOPY_READY = 0, AIRCOPY_READY = 0,
AIRCOPY_TRANSFER, AIRCOPY_TRANSFER,
AIRCOPY_COMPLETE AIRCOPY_COMPLETE
}; };
typedef enum aircopy_state_e aircopy_state_t;
typedef enum AIRCOPY_State_t AIRCOPY_State_t; extern aircopy_state_t g_aircopy_state;
extern uint16_t g_air_copy_block_number;
extern uint16_t g_errors_during_air_copyy;
extern uint8_t g_air_copy_is_send_mode;
extern AIRCOPY_State_t gAircopyState; extern uint16_t g_fsk_buffer[36];
extern uint16_t gAirCopyBlockNumber;
extern uint16_t gErrorsDuringAirCopy;
extern uint8_t gAirCopyIsSendMode;
extern uint16_t g_FSK_Buffer[36];
void AIRCOPY_SendMessage(void); void AIRCOPY_SendMessage(void);
void AIRCOPY_StorePacket(void); void AIRCOPY_StorePacket(void);
void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
#endif #endif

408
app/app.c

File diff suppressed because it is too large Load Diff

View File

@ -162,7 +162,7 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned
{ {
if (pMsg[i] != pTemplate[i]) if (pMsg[i] != pTemplate[i])
{ {
if (!bCheckGroup || pMsg[i] != gEeprom.DTMF_GROUP_CALL_CODE) if (!bCheckGroup || pMsg[i] != g_eeprom.DTMF_group_call_code)
return false; return false;
gDTMF_IsGroupCall = true; gDTMF_IsGroupCall = true;
} }
@ -175,7 +175,7 @@ DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE) if (pMsg[i] == g_eeprom.DTMF_group_call_code)
break; break;
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP; return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
@ -215,7 +215,7 @@ void DTMF_HandleRequest(void)
return; return;
} }
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED)
{ // D-DCD is disabled or we're alive { // D-DCD is disabled or we're alive
DTMF_clear_RX(); DTMF_clear_RX();
return; return;
@ -226,14 +226,14 @@ void DTMF_HandleRequest(void)
if (gDTMF_RX_index >= 9) if (gDTMF_RX_index >= 9)
{ // look for the KILL code { // look for the KILL code
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE); sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code, g_eeprom.kill_code);
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true))
{ // bugger { // bugger
if (gEeprom.PERMIT_REMOTE_KILL) if (g_eeprom.permit_remote_kill)
{ {
gSetting_KILLED = true; // oooerr ! gSetting_KILLED = true; // oooerr !
@ -267,7 +267,7 @@ void DTMF_HandleRequest(void)
if (gDTMF_RX_index >= 9) if (gDTMF_RX_index >= 9)
{ // look for the REVIVE code { // look for the REVIVE code
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE); sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code, g_eeprom.revive_code);
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
@ -316,7 +316,7 @@ void DTMF_HandleRequest(void)
gDTMF_RX_index >= 9) gDTMF_RX_index >= 9)
{ // waiting for a reply { // waiting for a reply
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); sprintf(String, "%s%c%s", gDTMF_String, g_eeprom.DTMF_separate_code, "AAAAA");
Offset = gDTMF_RX_index - strlen(String); Offset = gDTMF_RX_index - strlen(String);
@ -338,7 +338,7 @@ void DTMF_HandleRequest(void)
gDTMF_IsGroupCall = false; gDTMF_IsGroupCall = false;
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE); sprintf(String, "%s%c", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code);
Offset = gDTMF_RX_index - strlen(String) - 3; Offset = gDTMF_RX_index - strlen(String) - 3;
@ -359,7 +359,7 @@ void DTMF_HandleRequest(void)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gEeprom.DTMF_DECODE_RESPONSE) switch (g_eeprom.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;
@ -399,7 +399,7 @@ void DTMF_Reply(void)
} }
else else
{ // append our ID code onto the end of the DTMF code to send { // append our ID code onto the end of the DTMF code to send
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, gEeprom.ANI_DTMF_ID); sprintf(String, "%s%c%s", gDTMF_String, g_eeprom.DTMF_separate_code, g_eeprom.ani_DTMF_id);
pString = String; pString = String;
} }
break; break;
@ -409,23 +409,23 @@ void DTMF_Reply(void)
break; break;
case DTMF_REPLY_AAAAA: case DTMF_REPLY_AAAAA:
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code, "AAAAA");
pString = String; pString = String;
break; break;
default: default:
case DTMF_REPLY_NONE: case DTMF_REPLY_NONE:
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || if (gDTMF_CallState != DTMF_CALL_STATE_NONE ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO || 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_OFF ||
gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN) gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_TX_DOWN)
{ {
gDTMF_ReplyState = DTMF_REPLY_NONE; gDTMF_ReplyState = DTMF_REPLY_NONE;
return; return;
} }
// send TX-UP DTMF // send TX-UP DTMF
pString = gEeprom.DTMF_UP_CODE; pString = g_eeprom.DTMF_up_code;
break; break;
} }
@ -434,9 +434,9 @@ void DTMF_Reply(void)
if (pString == NULL) if (pString == NULL)
return; return;
Delay = (gEeprom.DTMF_PRELOAD_TIME < 200) ? 200 : gEeprom.DTMF_PRELOAD_TIME; Delay = (g_eeprom.DTMF_preload_time < 200) ? 200 : g_eeprom.DTMF_preload_time;
if (gEeprom.DTMF_SIDE_TONE) if (g_eeprom.DTMF_side_tone)
{ // the user will also hear the transmitted tones { // the user will also hear the transmitted tones
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
@ -444,15 +444,15 @@ void DTMF_Reply(void)
SYSTEM_DelayMs(Delay); SYSTEM_DelayMs(Delay);
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE); BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone);
BK4819_PlayDTMFString( BK4819_PlayDTMFString(
pString, pString,
1, 1,
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME, g_eeprom.DTMF_first_code_persist_time,
gEeprom.DTMF_HASH_CODE_PERSIST_TIME, g_eeprom.DTMF_hash_code_persist_time,
gEeprom.DTMF_CODE_PERSIST_TIME, g_eeprom.DTMF_code_persist_time,
gEeprom.DTMF_CODE_INTERVAL_TIME); g_eeprom.DTMF_code_interval_time);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

128
app/fm.c
View File

@ -74,18 +74,18 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
int FM_ConfigureChannelState(void) int FM_ConfigureChannelState(void)
{ {
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
if (gEeprom.FM_IsMrMode) if (g_eeprom.fm_is_channel_mode)
{ {
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP); const uint8_t Channel = FM_FindNextChannel(g_eeprom.fm_selected_channel, FM_CHANNEL_UP);
if (Channel == 0xFF) if (Channel == 0xFF)
{ {
gEeprom.FM_IsMrMode = false; g_eeprom.fm_is_channel_mode = false;
return -1; return -1;
} }
gEeprom.FM_SelectedChannel = Channel; g_eeprom.fm_selected_channel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; g_eeprom.fm_frequency_playing = gFM_Channels[Channel];
} }
return 0; return 0;
@ -130,23 +130,23 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
gFM_FoundFrequency = false; gFM_FoundFrequency = false;
gAskToSave = false; gAskToSave = false;
gAskToDelete = false; gAskToDelete = false;
gEeprom.FM_FrequencyPlaying = Frequency; g_eeprom.fm_frequency_playing = Frequency;
if (!bFlag) if (!bFlag)
{ {
Frequency += Step; Frequency += Step;
if (Frequency < gEeprom.FM_LowerLimit) if (Frequency < g_eeprom.fm_lower_limit)
Frequency = gEeprom.FM_UpperLimit; Frequency = g_eeprom.fm_upper_limit;
else else
if (Frequency > gEeprom.FM_UpperLimit) if (Frequency > g_eeprom.fm_upper_limit)
Frequency = gEeprom.FM_LowerLimit; Frequency = g_eeprom.fm_lower_limit;
gEeprom.FM_FrequencyPlaying = Frequency; g_eeprom.fm_frequency_playing = Frequency;
} }
gFM_ScanState = Step; gFM_ScanState = Step;
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
} }
void FM_PlayAndUpdate(void) void FM_PlayAndUpdate(void)
@ -155,12 +155,12 @@ void FM_PlayAndUpdate(void)
if (gFM_AutoScan) if (gFM_AutoScan)
{ {
gEeprom.FM_IsMrMode = true; g_eeprom.fm_is_channel_mode = true;
gEeprom.FM_SelectedChannel = 0; g_eeprom.fm_selected_channel = 0;
} }
FM_ConfigureChannelState(); FM_ConfigureChannelState();
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
SETTINGS_SaveFM(); SETTINGS_SaveFM();
gFmPlayCountdown_10ms = 0; gFmPlayCountdown_10ms = 0;
@ -224,15 +224,15 @@ Bail:
return ret; return ret;
} }
static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
#define STATE_FREQ_MODE 0 #define STATE_FREQ_MODE 0
#define STATE_MR_MODE 1 #define STATE_USER_MODE 1
#define STATE_SAVE 2 #define STATE_SAVE 2
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
if (!gWasFKeyPressed) if (!g_was_f_key_pressed)
{ {
uint8_t State; uint8_t State;
@ -254,7 +254,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
State = gEeprom.FM_IsMrMode ? STATE_MR_MODE : STATE_FREQ_MODE; State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
} }
INPUTBOX_Append(Key); INPUTBOX_Append(Key);
@ -281,21 +281,21 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
NUMBER_Get(gInputBox, &Frequency); NUMBER_Get(gInputBox, &Frequency);
Frequency /= 10000; Frequency /= 10000;
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) if (Frequency < g_eeprom.fm_lower_limit || g_eeprom.fm_upper_limit < Frequency)
{ {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; g_eeprom.fm_selected_frequency = (uint16_t)Frequency;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
gRequestSaveFM = true; gRequestSaveFM = true;
return; return;
} }
@ -308,16 +308,16 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
if (State == STATE_MR_MODE) if (State == STATE_USER_MODE)
{ {
if (FM_CheckValidChannel(Channel)) if (FM_CheckValidChannel(Channel))
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gEeprom.FM_SelectedChannel = Channel; g_eeprom.fm_selected_channel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; g_eeprom.fm_frequency_playing = gFM_Channels[Channel];
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
gRequestSaveFM = true; gRequestSaveFM = true;
return; return;
} }
@ -326,7 +326,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (Channel < 20) if (Channel < 20)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gInputBoxIndex = 0; gInputBoxIndex = 0;
@ -339,14 +339,14 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; return;
} }
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
@ -357,11 +357,11 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
break; break;
case KEY_1: case KEY_1:
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode;
if (!FM_ConfigureChannelState()) if (!FM_ConfigureChannelState())
{ {
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
gRequestSaveFM = true; gRequestSaveFM = true;
} }
else else
@ -429,14 +429,14 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
} }
else else
{ {
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
@ -456,11 +456,11 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (gFM_ScanState == FM_SCAN_OFF) if (gFM_ScanState == FM_SCAN_OFF)
{ {
if (!gEeprom.FM_IsMrMode) if (!g_eeprom.fm_is_channel_mode)
{ {
if (gAskToSave) if (gAskToSave)
{ {
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing;
gAskToSave = false; gAskToSave = false;
gRequestSaveFM = true; gRequestSaveFM = true;
} }
@ -471,10 +471,10 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
{ {
if (gAskToDelete) if (gAskToDelete)
{ {
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF; gFM_Channels[g_eeprom.fm_selected_channel] = 0xFFFF;
FM_ConfigureChannelState(); FM_ConfigureChannelState();
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
gRequestSaveFM = true; gRequestSaveFM = true;
gAskToDelete = false; gAskToDelete = false;
@ -494,7 +494,7 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
if (gAskToSave) if (gAskToSave)
{ {
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing;
gAskToSave = false; gAskToSave = false;
gRequestSaveFM = true; gRequestSaveFM = true;
} }
@ -539,42 +539,42 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
return; return;
} }
FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false); FM_Tune(g_eeprom.fm_frequency_playing, Step, false);
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
if (gEeprom.FM_IsMrMode) if (g_eeprom.fm_is_channel_mode)
{ {
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); const uint8_t Channel = FM_FindNextChannel(g_eeprom.fm_selected_channel + Step, Step);
if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) if (Channel == 0xFF || g_eeprom.fm_selected_channel == Channel)
goto Bail; goto Bail;
gEeprom.FM_SelectedChannel = Channel; g_eeprom.fm_selected_channel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; g_eeprom.fm_frequency_playing = gFM_Channels[Channel];
} }
else else
{ {
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step; uint16_t Frequency = g_eeprom.fm_selected_frequency + Step;
if (Frequency < gEeprom.FM_LowerLimit) if (Frequency < g_eeprom.fm_lower_limit)
Frequency = gEeprom.FM_UpperLimit; Frequency = g_eeprom.fm_upper_limit;
else else
if (Frequency > gEeprom.FM_UpperLimit) if (Frequency > g_eeprom.fm_upper_limit)
Frequency = gEeprom.FM_LowerLimit; Frequency = g_eeprom.fm_lower_limit;
gEeprom.FM_FrequencyPlaying = Frequency; g_eeprom.fm_frequency_playing = Frequency;
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
} }
gRequestSaveFM = true; gRequestSaveFM = true;
Bail: Bail:
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
} }
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void FM_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
switch (Key) switch (Key)
{ {
@ -617,15 +617,15 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
void FM_Play(void) void FM_Play(void)
{ {
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit)) if (!FM_CheckFrequencyLock(g_eeprom.fm_frequency_playing, g_eeprom.fm_lower_limit))
{ {
if (!gFM_AutoScan) if (!gFM_AutoScan)
{ {
gFmPlayCountdown_10ms = 0; gFmPlayCountdown_10ms = 0;
gFM_FoundFrequency = true; gFM_FoundFrequency = true;
if (!gEeprom.FM_IsMrMode) if (!g_eeprom.fm_is_channel_mode)
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
@ -635,7 +635,7 @@ void FM_Play(void)
} }
if (gFM_ChannelPosition < 20) if (gFM_ChannelPosition < 20)
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition++] = g_eeprom.fm_frequency_playing;
if (gFM_ChannelPosition >= 20) if (gFM_ChannelPosition >= 20)
{ {
@ -645,10 +645,10 @@ void FM_Play(void)
} }
} }
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit) if (gFM_AutoScan && g_eeprom.fm_frequency_playing >= g_eeprom.fm_upper_limit)
FM_PlayAndUpdate(); FM_PlayAndUpdate();
else else
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false); FM_Tune(g_eeprom.fm_frequency_playing, gFM_ScanState, false);
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
} }
@ -659,7 +659,7 @@ void FM_Start(void)
gFM_ScanState = FM_SCAN_OFF; gFM_ScanState = FM_SCAN_OFF;
gFM_RestoreCountdown_10ms = 0; gFM_RestoreCountdown_10ms = 0;
BK1080_Init(gEeprom.FM_FrequencyPlaying, true); BK1080_Init(g_eeprom.fm_frequency_playing, true);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

View File

@ -52,7 +52,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag);
void FM_PlayAndUpdate(void); void FM_PlayAndUpdate(void);
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit); int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit);
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void FM_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
void FM_Play(void); void FM_Play(void);
void FM_Start(void); void FM_Start(void);

View File

@ -61,10 +61,10 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
{ // toggle the keyboad lock { // toggle the keyboad lock
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK; g_another_voice_id = g_eeprom.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif #endif
gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK; g_eeprom.key_lock = !g_eeprom.key_lock;
gRequestSaveSettings = true; gRequestSaveSettings = true;
} }
@ -79,14 +79,14 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
return; return;
#endif #endif
gWasFKeyPressed = !gWasFKeyPressed; g_was_f_key_pressed = !g_was_f_key_pressed;
if (gWasFKeyPressed) if (g_was_f_key_pressed)
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (!gWasFKeyPressed) if (!g_was_f_key_pressed)
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
gUpdateStatus = true; gUpdateStatus = true;
@ -132,10 +132,10 @@ void GENERIC_Key_PTT(bool bKeyPressed)
{ {
APP_EndTransmission(); APP_EndTransmission();
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) if (g_eeprom.repeater_tail_tone_elimination == 0)
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
else else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10;
} }
gFlagEndTransmission = false; gFlagEndTransmission = false;
@ -162,7 +162,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
if (gScreenToDisplay == DISPLAY_SCANNER) if (gScreenToDisplay == DISPLAY_SCANNER)
{ // CTCSS/CDCSS scanning .. stop { // CTCSS/CDCSS scanning .. stop
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX; g_eeprom.cross_vfo_rx_tx = gBackup_cross_vfo_rx_tx;
gFlagStopScan = true; gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true; gFlagResetVfos = true;
@ -178,7 +178,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
MENU_StopCssScan(); MENU_StopCssScan();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
@ -190,7 +190,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
{ // 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; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
goto cancel_tx; goto cancel_tx;
@ -235,7 +235,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
#else #else
// append our DTMF ID to the inputted DTMF code - // append our DTMF ID to the inputted DTMF code -
// IF the user inputted code is exactly 3 digits long and D-DCD is enabled // IF the user inputted code is exactly 3 digits long and D-DCD is enabled
if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_DECODING_ENABLE > 0) if (gDTMF_InputBox_Index == 3 && gTxVfo->DTMF_decoding_enable > 0)
gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3);
else else
gDTMF_CallMode = DTMF_CALL_MODE_DTMF; gDTMF_CallMode = DTMF_CALL_MODE_DTMF;

View File

@ -41,34 +41,34 @@
void toggle_chan_scanlist(void) void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting { // toggle the selected channels scanlist setting
if (gScreenToDisplay == DISPLAY_SCANNER || !IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (gScreenToDisplay == DISPLAY_SCANNER || !IS_USER_CHANNEL(gTxVfo->channel_save))
return; return;
if (gTxVfo->SCANLIST1_PARTICIPATION) if (gTxVfo->scanlist_1_participation)
{ {
if (gTxVfo->SCANLIST2_PARTICIPATION) if (gTxVfo->scanlist_2_participation)
gTxVfo->SCANLIST1_PARTICIPATION = 0; gTxVfo->scanlist_1_participation = 0;
else else
gTxVfo->SCANLIST2_PARTICIPATION = 1; gTxVfo->scanlist_2_participation = 1;
} }
else else
{ {
if (gTxVfo->SCANLIST2_PARTICIPATION) if (gTxVfo->scanlist_2_participation)
gTxVfo->SCANLIST2_PARTICIPATION = 0; gTxVfo->scanlist_2_participation = 0;
else else
gTxVfo->SCANLIST1_PARTICIPATION = 1; gTxVfo->scanlist_1_participation = 1;
} }
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true; gFlagResetVfos = true;
} }
static void processFKeyFunction(const KEY_Code_t Key, const bool beep) static void processFKeyFunction(const key_code_t Key, const bool beep)
{ {
uint8_t Band; uint8_t Band;
uint8_t Vfo = gEeprom.TX_VFO; uint8_t Vfo = g_eeprom.tx_vfo;
if (gScreenToDisplay == DISPLAY_MENU) if (gScreenToDisplay == DISPLAY_MENU)
{ {
@ -95,15 +95,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_1: case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (!IS_FREQ_CHANNEL(gTxVfo->channel_save))
{ {
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }
Band = gTxVfo->Band + 1; Band = gTxVfo->band + 1;
if (gSetting_350EN || Band != BAND5_350MHz) if (gSetting_350EN || Band != BAND5_350MHz)
{ {
if (Band > BAND7_470MHz) if (Band > BAND7_470MHz)
@ -111,10 +111,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
} }
else else
Band = BAND6_400MHz; Band = BAND6_400MHz;
gTxVfo->Band = Band; gTxVfo->band = Band;
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; g_eeprom.screen_channel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; g_eeprom.freq_channel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -127,19 +127,19 @@ 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) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A)
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_B; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_B;
else else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B)
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_A; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_A;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_B; g_eeprom.dual_watch = DUAL_WATCH_CHAN_B;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B)
gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A; g_eeprom.dual_watch = DUAL_WATCH_CHAN_A;
else else
gEeprom.TX_VFO = (Vfo + 1) & 1u; g_eeprom.tx_vfo = (Vfo + 1) & 1u;
gRequestSaveSettings = 1; gRequestSaveSettings = 1;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
@ -153,32 +153,32 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_3: case KEY_3:
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gEeprom.VFO_OPEN && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (g_eeprom.vfo_open && IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save))
#else #else
if (gEeprom.VFO_OPEN) if (g_eeprom.vfo_open)
#endif #endif
{ {
uint8_t Channel; uint8_t Channel;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_USER_CHANNEL(gTxVfo->channel_save))
{ // swap to frequency mode { // swap to frequency mode
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO]; g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
#endif #endif
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break; break;
} }
Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 0); Channel = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 0);
if (Channel != 0xFF) if (Channel != 0xFF)
{ // swap to channel mode { // swap to channel mode
gEeprom.ScreenChannel[Vfo] = Channel; g_eeprom.screen_channel[Vfo] = Channel;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, Channel + 1); AUDIO_SetDigitVoice(1, Channel + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE; g_another_voice_id = (voice_id_t)0xFE;
#endif #endif
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -192,11 +192,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_4: case KEY_4:
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gFlagStartScan = true; gFlagStartScan = true;
gScanSingleFrequency = false; gScanSingleFrequency = false;
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
gUpdateStatus = true; gUpdateStatus = true;
// if (beep) // if (beep)
@ -207,15 +207,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
case KEY_5: case KEY_5:
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save))
{ {
gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO]; g_eeprom.screen_channel[Vfo] = g_eeprom.noaa_channel[g_eeprom.tx_vfo];
} }
else else
{ {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO]; g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
#endif #endif
} }
gRequestSaveVFO = true; gRequestSaveVFO = true;
@ -242,19 +242,19 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
break; break;
case KEY_8: case KEY_8:
gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false; gTxVfo->frequency_reverse = gTxVfo->frequency_reverse == false;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
break; break;
case KEY_9: case KEY_9:
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) if (RADIO_CheckValidChannel(g_eeprom.chan_1_call, false, 0))
{ {
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL; g_eeprom.user_channel[Vfo] = g_eeprom.chan_1_call;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL; g_eeprom.screen_channel[Vfo] = g_eeprom.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, g_eeprom.chan_1_call + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE; g_another_voice_id = (voice_id_t)0xFE;
#endif #endif
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -267,7 +267,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
default: default:
gUpdateStatus = true; gUpdateStatus = true;
gWasFKeyPressed = false; g_was_f_key_pressed = false;
if (beep) if (beep)
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@ -275,7 +275,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
} }
} }
static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
if (bKeyHeld) if (bKeyHeld)
{ // key held down { // key held down
@ -290,7 +290,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
} }
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
processFKeyFunction(Key, false); processFKeyFunction(Key, false);
@ -306,10 +306,10 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; // don't use the key till it's released return; // don't use the key till it's released
} }
if (!gWasFKeyPressed) if (!g_was_f_key_pressed)
{ // F-key wasn't pressed { // F-key wasn't pressed
const uint8_t Vfo = gEeprom.TX_VFO; const uint8_t Vfo = g_eeprom.tx_vfo;
gKeyInputCountdown = key_input_timeout_500ms; gKeyInputCountdown = key_input_timeout_500ms;
@ -317,7 +317,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_USER_CHANNEL(gTxVfo->channel_save))
{ // user is entering channel number { // user is entering channel number
uint16_t Channel; uint16_t Channel;
@ -325,7 +325,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex != 3) if (gInputBoxIndex != 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
return; return;
@ -342,11 +342,11 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gEeprom.MrChannel[Vfo] = (uint8_t)Channel; g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; g_eeprom.screen_channel[Vfo] = (uint8_t)Channel;
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -354,9 +354,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
// #ifdef ENABLE_NOAA // #ifdef ENABLE_NOAA
// if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) // if (IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save))
// #endif // #endif
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_FREQ_CHANNEL(gTxVfo->channel_save))
{ // user is entering a frequency { // user is entering a frequency
uint32_t Frequency; uint32_t Frequency;
@ -364,7 +364,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; return;
@ -395,14 +395,14 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency); const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
if (gTxVfo->Band != band) if (gTxVfo->band != band)
{ {
gTxVfo->Band = band; gTxVfo->band = band;
gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST; g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST; g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
SETTINGS_SaveVfoIndices(); SETTINGS_SaveVfoIndices();
@ -410,17 +410,17 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
// Frequency += 75; // is this meant to be rounding ? // Frequency += 75; // is this meant to be rounding ?
Frequency += gTxVfo->StepFrequency / 2; // no idea, but this is Frequency += gTxVfo->step_freq / 2; // no idea, but this is
Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, frequencyBandTable[gTxVfo->Band].lower); Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->step_freq, frequencyBandTable[gTxVfo->band].lower);
if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower)
{ // clamp the frequency to the limit { // clamp the frequency to the limit
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2; const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_band1.upper - gTxVfo->StepFrequency : BX4819_band2.lower; Frequency = (Frequency < center) ? BX4819_band1.upper - gTxVfo->step_freq : BX4819_band2.lower;
} }
gTxVfo->freq_config_RX.Frequency = Frequency; gTxVfo->freq_config_rx.frequency = Frequency;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -429,7 +429,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOAA_CHANNEL(gTxVfo->channel_save))
{ // user is entering NOAA channel { // user is entering NOAA channel
uint8_t Channel; uint8_t Channel;
@ -437,7 +437,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex != 2) if (gInputBoxIndex != 2)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
return; return;
@ -450,10 +450,10 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
Channel += NOAA_CHANNEL_FIRST; Channel += NOAA_CHANNEL_FIRST;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gEeprom.NoaaChannel[Vfo] = Channel; g_eeprom.noaa_channel[Vfo] = Channel;
gEeprom.ScreenChannel[Vfo] = Channel; g_eeprom.screen_channel[Vfo] = Channel;
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
return; return;
@ -466,7 +466,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
processFKeyFunction(Key, true); processFKeyFunction(Key, true);
@ -500,7 +500,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
} }
else else
@ -508,7 +508,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
SCANNER_Stop(); SCANNER_Stop();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
@ -550,7 +550,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
if (bKeyPressed) if (bKeyPressed)
{ // long press MENU key { // long press MENU key
gWasFKeyPressed = false; g_was_f_key_pressed = false;
if (gScreenToDisplay == DISPLAY_MAIN) if (gScreenToDisplay == DISPLAY_MAIN)
{ {
@ -560,12 +560,12 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
} }
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
#ifdef ENABLE_COPY_CHAN_TO_VFO #ifdef ENABLE_COPY_CHAN_TO_VFO
if (gEeprom.VFO_OPEN && gCssScanMode == CSS_SCAN_MODE_OFF) if (g_eeprom.vfo_open && gCssScanMode == CSS_SCAN_MODE_OFF)
{ {
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF)
@ -580,21 +580,21 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
const unsigned int vfo = get_rx_VFO(); const unsigned int vfo = get_rx_VFO();
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy channel to VFO, then swap to the VFO { // copy channel to VFO, then swap to the VFO
const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band; const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.VfoInfo[vfo].band;
gEeprom.ScreenChannel[vfo] = channel; g_eeprom.screen_channel[vfo] = channel;
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel; g_eeprom.VfoInfo[vfo].channel_save = channel;
gEeprom.TX_VFO = vfo; g_eeprom.tx_vfo = vfo;
RADIO_SelectVfos(); RADIO_SelectVfos();
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
//SETTINGS_SaveChannel(channel, gEeprom.RX_VFO, gRxVfo, 1); //SETTINGS_SaveChannel(channel, g_eeprom.rx_vfo, gRxVfo, 1);
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@ -624,7 +624,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gFlagRefreshSetting = true; gFlagRefreshSetting = true;
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MENU; g_another_voice_id = VOICE_ID_MENU;
#endif #endif
} }
else else
@ -646,7 +646,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
return; return;
} }
if (bKeyHeld && !gWasFKeyPressed) if (bKeyHeld && !g_was_f_key_pressed)
{ // long press .. toggle scanning { // long press .. toggle scanning
if (!bKeyPressed) if (!bKeyPressed)
return; // released return; // released
@ -666,11 +666,11 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
// just released // just released
if (!gWasFKeyPressed) if (!g_was_f_key_pressed)
{ // 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))
#else #else
if (gScanStateDir == SCAN_OFF) if (gScanStateDir == SCAN_OFF)
#endif #endif
@ -687,10 +687,10 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
} }
else else
{ // with the F-key { // with the F-key
gWasFKeyPressed = false; g_was_f_key_pressed = false;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_NOAA_CHANNEL(gTxVfo->channel_save))
{ {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -700,8 +700,8 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
// scan the CTCSS/DCS code // scan the CTCSS/DCS code
gFlagStartScan = true; gFlagStartScan = true;
gScanSingleFrequency = true; gScanSingleFrequency = true;
gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
} }
gPttWasReleased = true; gPttWasReleased = true;
@ -711,7 +711,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld)
static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{ {
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO]; uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
if (bKeyHeld || !bKeyPressed) if (bKeyHeld || !bKeyPressed)
{ // long press { // long press
@ -728,8 +728,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return; return;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1); AUDIO_SetDigitVoice(0, gTxVfo->channel_save + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE; g_another_voice_id = (voice_id_t)0xFE;
#endif #endif
return; return;
@ -764,7 +764,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return; return;
} }
gTxVfo->freq_config_RX.Frequency = frequency; gTxVfo->freq_config_rx.frequency = frequency;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -777,23 +777,23 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (Channel == Next) if (Channel == Next)
return; return;
gEeprom.MrChannel[gEeprom.TX_VFO] = Next; g_eeprom.user_channel[g_eeprom.tx_vfo] = Next;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next; g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next;
if (!bKeyHeld) if (!bKeyHeld)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, Next + 1); AUDIO_SetDigitVoice(0, Next + 1);
gAnotherVoiceID = (VOICE_ID_t)0xFE; g_another_voice_id = (voice_id_t)0xFE;
#endif #endif
} }
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9); Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(g_eeprom.screen_channel[g_eeprom.tx_vfo] - NOAA_CHANNEL_FIRST, Direction, 0, 9);
gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel; g_eeprom.noaa_channel[g_eeprom.tx_vfo] = Channel;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel; g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
} }
#endif #endif
@ -810,7 +810,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gPttWasReleased = true; gPttWasReleased = true;
} }
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void MAIN_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT)

View File

@ -19,7 +19,7 @@
#include "driver/keyboard.h" #include "driver/keyboard.h"
void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void MAIN_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
#endif #endif

View File

@ -59,11 +59,11 @@
int16_t BK4819_XtalFreqLow; int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A; uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C; uint16_t EEPROM_1F8C;
uint8_t VOLUME_GAIN; uint8_t volume_gain;
uint8_t DAC_GAIN; uint8_t dac_gain;
} __attribute__((packed)) misc; } __attribute__((packed)) misc;
gEeprom.BK4819_XTAL_FREQ_LOW = value; g_eeprom.BK4819_xtal_freq_low = value;
// radio 1 .. 04 00 46 00 50 00 2C 0E // radio 1 .. 04 00 46 00 50 00 2C 0E
// radio 2 .. 05 00 46 00 50 00 2C 0E // radio 2 .. 05 00 46 00 50 00 2C 0E
@ -114,7 +114,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_ABR: case MENU_ABR:
*pMin = 0; *pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1; *pMax = ARRAY_SIZE(gSubMenu_backlight) - 1;
break; break;
case MENU_F_LOCK: case MENU_F_LOCK:
@ -273,13 +273,13 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_DEL_CH: case MENU_DEL_CH:
case MENU_MEM_NAME: case MENU_MEM_NAME:
*pMin = 0; *pMin = 0;
*pMax = MR_CHANNEL_LAST; *pMax = USER_CHANNEL_LAST;
break; break;
case MENU_SLIST1: case MENU_SLIST1:
case MENU_SLIST2: case MENU_SLIST2:
*pMin = -1; *pMin = -1;
*pMax = MR_CHANNEL_LAST; *pMax = USER_CHANNEL_LAST;
break; break;
case MENU_SAVE: case MENU_SAVE:
@ -352,7 +352,7 @@ void MENU_AcceptSetting(void)
int32_t Min; int32_t Min;
int32_t Max; int32_t Max;
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(gMenuCursor, &Min, &Max))
{ {
@ -367,13 +367,13 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_SQL: case MENU_SQL:
gEeprom.SQUELCH_LEVEL = gSubMenuSelection; g_eeprom.squelch_level = gSubMenuSelection;
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
break; break;
case MENU_STEP: case MENU_STEP:
gTxVfo->STEP_SETTING = gSubMenuSelection; gTxVfo->step_setting = gSubMenuSelection;
if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_FREQ_CHANNEL(gTxVfo->channel_save))
{ {
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -381,39 +381,39 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_TXP: case MENU_TXP:
gTxVfo->OUTPUT_POWER = gSubMenuSelection; gTxVfo->output_power = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_T_DCS: case MENU_T_DCS:
pConfig = &gTxVfo->freq_config_TX; pConfig = &gTxVfo->freq_config_tx;
// Fallthrough // Fallthrough
case MENU_R_DCS: case MENU_R_DCS:
if (gSubMenuSelection == 0) if (gSubMenuSelection == 0)
{ {
if (pConfig->CodeType != CODE_TYPE_DIGITAL && pConfig->CodeType != CODE_TYPE_REVERSE_DIGITAL) if (pConfig->code_type != CODE_TYPE_DIGITAL && pConfig->code_type != CODE_TYPE_REVERSE_DIGITAL)
{ {
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
} }
Code = 0; Code = 0;
pConfig->CodeType = CODE_TYPE_OFF; pConfig->code_type = CODE_TYPE_OFF;
} }
else else
if (gSubMenuSelection < 105) if (gSubMenuSelection < 105)
{ {
pConfig->CodeType = CODE_TYPE_DIGITAL; pConfig->code_type = CODE_TYPE_DIGITAL;
Code = gSubMenuSelection - 1; Code = gSubMenuSelection - 1;
} }
else else
{ {
pConfig->CodeType = CODE_TYPE_REVERSE_DIGITAL; pConfig->code_type = CODE_TYPE_REVERSE_DIGITAL;
Code = gSubMenuSelection - 105; Code = gSubMenuSelection - 105;
} }
pConfig->Code = Code; pConfig->code = Code;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -421,26 +421,26 @@ void MENU_AcceptSetting(void)
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
case MENU_T_CTCS: case MENU_T_CTCS:
pConfig = &gTxVfo->freq_config_TX; pConfig = &gTxVfo->freq_config_tx;
case MENU_R_CTCS: case MENU_R_CTCS:
if (gSubMenuSelection == 0) if (gSubMenuSelection == 0)
{ {
if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE)
{ {
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
} }
Code = 0; Code = 0;
pConfig->Code = Code; pConfig->code = Code;
pConfig->CodeType = CODE_TYPE_OFF; pConfig->code_type = CODE_TYPE_OFF;
BK4819_ExitSubAu(); BK4819_ExitSubAu();
} }
else else
{ {
pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE;
Code = gSubMenuSelection - 1; Code = gSubMenuSelection - 1;
pConfig->Code = Code; pConfig->code = Code;
BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); BK4819_SetCTCSSFrequency(CTCSS_Options[Code]);
} }
@ -451,22 +451,22 @@ void MENU_AcceptSetting(void)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
case MENU_SFT_D: case MENU_SFT_D:
gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection; gTxVfo->tx_offset_freq_dir = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_OFFSET: case MENU_OFFSET:
gTxVfo->TX_OFFSET_FREQUENCY = gSubMenuSelection; gTxVfo->tx_offset_freq = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_W_N: case MENU_W_N:
gTxVfo->CHANNEL_BANDWIDTH = gSubMenuSelection; gTxVfo->channel_bandwidth = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_SCR: case MENU_SCR:
gTxVfo->SCRAMBLING_TYPE = gSubMenuSelection; gTxVfo->scrambling_type = gSubMenuSelection;
#if 0 #if 0
if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) if (gSubMenuSelection > 0 && gSetting_ScrambleEnable)
BK4819_EnableScramble(gSubMenuSelection - 1); BK4819_EnableScramble(gSubMenuSelection - 1);
@ -477,16 +477,16 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_BCL: case MENU_BCL:
gTxVfo->BUSY_CHANNEL_LOCK = gSubMenuSelection; gTxVfo->busy_channel_lock = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
case MENU_MEM_CH: case MENU_MEM_CH:
gTxVfo->CHANNEL_SAVE = gSubMenuSelection; gTxVfo->channel_save = gSubMenuSelection;
#if 0 #if 0
gEeprom.MrChannel[0] = gSubMenuSelection; g_eeprom.user_channel[0] = gSubMenuSelection;
#else #else
gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection; g_eeprom.user_channel[g_eeprom.tx_vfo] = gSubMenuSelection;
#endif #endif
gRequestSaveChannel = 2; gRequestSaveChannel = 2;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
@ -504,21 +504,21 @@ void MENU_AcceptSetting(void)
} }
// save the channel name // save the channel name
memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name)); memset(gTxVfo->name, 0, sizeof(gTxVfo->name));
memmove(gTxVfo->Name, edit, 10); memmove(gTxVfo->name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_VFO, gTxVfo, 3); SETTINGS_SaveChannel(gSubMenuSelection, g_eeprom.tx_vfo, gTxVfo, 3);
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
return; return;
case MENU_SAVE: case MENU_SAVE:
gEeprom.BATTERY_SAVE = gSubMenuSelection; g_eeprom.battery_save = gSubMenuSelection;
break; break;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
case MENU_VOX: case MENU_VOX:
gEeprom.VOX_SWITCH = gSubMenuSelection != 0; g_eeprom.vox_switch = gSubMenuSelection != 0;
if (gEeprom.VOX_SWITCH) if (g_eeprom.vox_switch)
gEeprom.VOX_LEVEL = gSubMenuSelection - 1; g_eeprom.vox_level = gSubMenuSelection - 1;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadMoreSettings();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
@ -526,7 +526,7 @@ void MENU_AcceptSetting(void)
#endif #endif
case MENU_ABR: case MENU_ABR:
gEeprom.BACKLIGHT = gSubMenuSelection; g_eeprom.backlight = gSubMenuSelection;
break; break;
case MENU_ABR_ON_TX_RX: case MENU_ABR_ON_TX_RX:
@ -534,8 +534,8 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_TDR: case MENU_TDR:
// gEeprom.DUAL_WATCH = gSubMenuSelection; // g_eeprom.dual_watch = gSubMenuSelection;
gEeprom.DUAL_WATCH = (gSubMenuSelection > 0) ? 1 + gEeprom.TX_VFO : DUAL_WATCH_OFF; g_eeprom.dual_watch = (gSubMenuSelection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
@ -543,69 +543,69 @@ void MENU_AcceptSetting(void)
case MENU_XB: case MENU_XB:
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0])) if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
return; return;
if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
return; return;
#endif #endif
gEeprom.CROSS_BAND_RX_TX = gSubMenuSelection; g_eeprom.cross_vfo_rx_tx = gSubMenuSelection;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
break; break;
case MENU_BEEP: case MENU_BEEP:
gEeprom.BEEP_CONTROL = gSubMenuSelection; g_eeprom.beep_control = gSubMenuSelection;
break; break;
case MENU_TOT: case MENU_TOT:
gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection; g_eeprom.tx_timeout_timer = gSubMenuSelection;
break; break;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
case MENU_VOICE: case MENU_VOICE:
gEeprom.VOICE_PROMPT = gSubMenuSelection; g_eeprom.voice_prompt = gSubMenuSelection;
gUpdateStatus = true; gUpdateStatus = true;
break; break;
#endif #endif
case MENU_SC_REV: case MENU_SC_REV:
gEeprom.SCAN_RESUME_MODE = gSubMenuSelection; g_eeprom.scan_resume_mode = gSubMenuSelection;
break; break;
case MENU_MDF: case MENU_MDF:
gEeprom.CHANNEL_DISPLAY_MODE = gSubMenuSelection; g_eeprom.channel_display_mode = gSubMenuSelection;
break; break;
case MENU_AUTOLK: case MENU_AUTOLK:
gEeprom.AUTO_KEYPAD_LOCK = gSubMenuSelection; g_eeprom.auto_keypad_lock = gSubMenuSelection;
gKeyLockCountdown = 30; gKeyLockCountdown = 30;
break; break;
case MENU_S_ADD1: case MENU_S_ADD1:
gTxVfo->SCANLIST1_PARTICIPATION = gSubMenuSelection; gTxVfo->scanlist_1_participation = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true; gFlagResetVfos = true;
return; return;
case MENU_S_ADD2: case MENU_S_ADD2:
gTxVfo->SCANLIST2_PARTICIPATION = gSubMenuSelection; gTxVfo->scanlist_2_participation = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true; gFlagResetVfos = true;
return; return;
case MENU_STE: case MENU_STE:
gEeprom.TAIL_NOTE_ELIMINATION = gSubMenuSelection; g_eeprom.tail_note_elimination = gSubMenuSelection;
break; break;
case MENU_RP_STE: case MENU_RP_STE:
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = gSubMenuSelection; g_eeprom.repeater_tail_tone_elimination = gSubMenuSelection;
break; break;
case MENU_MIC: case MENU_MIC:
gEeprom.MIC_SENSITIVITY = gSubMenuSelection; g_eeprom.mic_sensitivity = gSubMenuSelection;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadMoreSettings();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
break; break;
@ -617,45 +617,45 @@ void MENU_AcceptSetting(void)
#endif #endif
case MENU_COMPAND: case MENU_COMPAND:
gTxVfo->Compander = gSubMenuSelection; gTxVfo->compander = gSubMenuSelection;
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE; gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true; gFlagResetVfos = true;
// gRequestSaveChannel = 1; // gRequestSaveChannel = 1;
return; return;
case MENU_1_CALL: case MENU_1_CALL:
gEeprom.CHAN_1_CALL = gSubMenuSelection; g_eeprom.chan_1_call = gSubMenuSelection;
break; break;
case MENU_S_LIST: case MENU_S_LIST:
gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection; g_eeprom.scan_list_default = gSubMenuSelection;
break; break;
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
case MENU_AL_MOD: case MENU_AL_MOD:
gEeprom.ALARM_MODE = gSubMenuSelection; g_eeprom.alarm_mode = gSubMenuSelection;
break; break;
#endif #endif
case MENU_D_ST: case MENU_D_ST:
gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; g_eeprom.DTMF_side_tone = gSubMenuSelection;
break; break;
case MENU_D_RSP: case MENU_D_RSP:
gEeprom.DTMF_DECODE_RESPONSE = gSubMenuSelection; g_eeprom.DTMF_decode_response = gSubMenuSelection;
break; break;
case MENU_D_HOLD: case MENU_D_HOLD:
gEeprom.DTMF_auto_reset_time = gSubMenuSelection; g_eeprom.DTMF_auto_reset_time = gSubMenuSelection;
break; break;
case MENU_D_PRE: case MENU_D_PRE:
gEeprom.DTMF_PRELOAD_TIME = gSubMenuSelection * 10; g_eeprom.DTMF_preload_time = gSubMenuSelection * 10;
break; break;
case MENU_PTT_ID: case MENU_PTT_ID:
gTxVfo->DTMF_PTT_ID_TX_MODE = gSubMenuSelection; gTxVfo->DTMF_ptt_id_tx_mode = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -664,7 +664,7 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_D_DCD: case MENU_D_DCD:
gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection; gTxVfo->DTMF_decoding_enable = gSubMenuSelection;
DTMF_clear_RX(); DTMF_clear_RX();
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -692,15 +692,15 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_PONMSG: case MENU_PONMSG:
gEeprom.POWER_ON_DISPLAY_MODE = gSubMenuSelection; g_eeprom.pwr_on_display_mode = gSubMenuSelection;
break; break;
case MENU_ROGER: case MENU_ROGER:
gEeprom.ROGER = gSubMenuSelection; g_eeprom.roger_mode = gSubMenuSelection;
break; break;
case MENU_AM: case MENU_AM:
gTxVfo->AM_mode = gSubMenuSelection; gTxVfo->am_mode = gSubMenuSelection;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
@ -722,7 +722,7 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_S: case MENU_NOAA_S:
gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection; g_eeprom.NOAA_auto_scan = gSubMenuSelection;
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
break; break;
#endif #endif
@ -734,19 +734,19 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_SIDE1_SHORT: case MENU_SIDE1_SHORT:
gEeprom.KEY_1_SHORT_PRESS_ACTION = gSubMenuSelection; g_eeprom.key1_short_press_action = gSubMenuSelection;
break; break;
case MENU_SIDE1_LONG: case MENU_SIDE1_LONG:
gEeprom.KEY_1_LONG_PRESS_ACTION = gSubMenuSelection; g_eeprom.key1_long_press_action = gSubMenuSelection;
break; break;
case MENU_SIDE2_SHORT: case MENU_SIDE2_SHORT:
gEeprom.KEY_2_SHORT_PRESS_ACTION = gSubMenuSelection; g_eeprom.key2_short_press_action = gSubMenuSelection;
break; break;
case MENU_SIDE2_LONG: case MENU_SIDE2_LONG:
gEeprom.KEY_2_LONG_PRESS_ACTION = gSubMenuSelection; g_eeprom.key2_long_press_action = gSubMenuSelection;
break; break;
case MENU_RESET: case MENU_RESET:
@ -833,25 +833,25 @@ void MENU_SelectNextCode(void)
{ {
if (gSubMenuSelection > 104) if (gSubMenuSelection > 104)
{ {
gSelectedCodeType = CODE_TYPE_REVERSE_DIGITAL; gSelectedcode_type = CODE_TYPE_REVERSE_DIGITAL;
gSelectedCode = gSubMenuSelection - 105; gSelectedCode = gSubMenuSelection - 105;
} }
else else
{ {
gSelectedCodeType = CODE_TYPE_DIGITAL; gSelectedcode_type = CODE_TYPE_DIGITAL;
gSelectedCode = gSubMenuSelection - 1; gSelectedCode = gSubMenuSelection - 1;
} }
} }
else else
{ {
gSelectedCodeType = CODE_TYPE_CONTINUOUS_TONE; gSelectedcode_type = CODE_TYPE_CONTINUOUS_TONE;
gSelectedCode = gSubMenuSelection - 1; gSelectedCode = gSubMenuSelection - 1;
} }
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
gScanPauseDelayIn_10ms = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms; gScanPauseDelayIn_10ms = (gSelectedcode_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
gUpdateDisplay = true; gUpdateDisplay = true;
} }
@ -876,25 +876,25 @@ void MENU_ShowCurrentSetting(void)
switch (gMenuCursor) switch (gMenuCursor)
{ {
case MENU_SQL: case MENU_SQL:
gSubMenuSelection = gEeprom.SQUELCH_LEVEL; gSubMenuSelection = g_eeprom.squelch_level;
break; break;
case MENU_STEP: case MENU_STEP:
gSubMenuSelection = gTxVfo->STEP_SETTING; gSubMenuSelection = gTxVfo->step_setting;
break; break;
case MENU_TXP: case MENU_TXP:
gSubMenuSelection = gTxVfo->OUTPUT_POWER; gSubMenuSelection = gTxVfo->output_power;
break; break;
case MENU_R_DCS: case MENU_R_DCS:
switch (gTxVfo->freq_config_RX.CodeType) switch (gTxVfo->freq_config_rx.code_type)
{ {
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_RX.Code + 1; gSubMenuSelection = gTxVfo->freq_config_rx.code + 1;
break; break;
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_RX.Code + 105; gSubMenuSelection = gTxVfo->freq_config_rx.code + 105;
break; break;
default: default:
gSubMenuSelection = 0; gSubMenuSelection = 0;
@ -907,17 +907,17 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_R_CTCS: case MENU_R_CTCS:
gSubMenuSelection = (gTxVfo->freq_config_RX.CodeType == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_RX.Code + 1 : 0; gSubMenuSelection = (gTxVfo->freq_config_rx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_rx.code + 1 : 0;
break; break;
case MENU_T_DCS: case MENU_T_DCS:
switch (gTxVfo->freq_config_TX.CodeType) switch (gTxVfo->freq_config_tx.code_type)
{ {
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_TX.Code + 1; gSubMenuSelection = gTxVfo->freq_config_tx.code + 1;
break; break;
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
gSubMenuSelection = gTxVfo->freq_config_TX.Code + 105; gSubMenuSelection = gTxVfo->freq_config_tx.code + 105;
break; break;
default: default:
gSubMenuSelection = 0; gSubMenuSelection = 0;
@ -926,53 +926,53 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_T_CTCS: case MENU_T_CTCS:
gSubMenuSelection = (gTxVfo->freq_config_TX.CodeType == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_TX.Code + 1 : 0; gSubMenuSelection = (gTxVfo->freq_config_tx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_tx.code + 1 : 0;
break; break;
case MENU_SFT_D: case MENU_SFT_D:
gSubMenuSelection = gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION; gSubMenuSelection = gTxVfo->tx_offset_freq_dir;
break; break;
case MENU_OFFSET: case MENU_OFFSET:
gSubMenuSelection = gTxVfo->TX_OFFSET_FREQUENCY; gSubMenuSelection = gTxVfo->tx_offset_freq;
break; break;
case MENU_W_N: case MENU_W_N:
gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH; gSubMenuSelection = gTxVfo->channel_bandwidth;
break; break;
case MENU_SCR: case MENU_SCR:
gSubMenuSelection = gTxVfo->SCRAMBLING_TYPE; gSubMenuSelection = gTxVfo->scrambling_type;
break; break;
case MENU_BCL: case MENU_BCL:
gSubMenuSelection = gTxVfo->BUSY_CHANNEL_LOCK; gSubMenuSelection = gTxVfo->busy_channel_lock;
break; break;
case MENU_MEM_CH: case MENU_MEM_CH:
#if 0 #if 0
gSubMenuSelection = gEeprom.MrChannel[0]; gSubMenuSelection = g_eeprom.user_channel[0];
#else #else
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo];
#endif #endif
break; break;
case MENU_MEM_NAME: case MENU_MEM_NAME:
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo];
break; break;
case MENU_SAVE: case MENU_SAVE:
gSubMenuSelection = gEeprom.BATTERY_SAVE; gSubMenuSelection = g_eeprom.battery_save;
break; break;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
case MENU_VOX: case MENU_VOX:
gSubMenuSelection = gEeprom.VOX_SWITCH ? gEeprom.VOX_LEVEL + 1 : 0; gSubMenuSelection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0;
break; break;
#endif #endif
case MENU_ABR: case MENU_ABR:
gSubMenuSelection = gEeprom.BACKLIGHT; gSubMenuSelection = g_eeprom.backlight;
gBacklightCountdown = 0; gBacklightCountdown = 0;
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu
@ -983,58 +983,58 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_TDR: case MENU_TDR:
// gSubMenuSelection = gEeprom.DUAL_WATCH; // gSubMenuSelection = g_eeprom.dual_watch;
gSubMenuSelection = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? 0 : 1; gSubMenuSelection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;
break; break;
case MENU_XB: case MENU_XB:
gSubMenuSelection = gEeprom.CROSS_BAND_RX_TX; gSubMenuSelection = g_eeprom.cross_vfo_rx_tx;
break; break;
case MENU_BEEP: case MENU_BEEP:
gSubMenuSelection = gEeprom.BEEP_CONTROL; gSubMenuSelection = g_eeprom.beep_control;
break; break;
case MENU_TOT: case MENU_TOT:
gSubMenuSelection = gEeprom.TX_TIMEOUT_TIMER; gSubMenuSelection = g_eeprom.tx_timeout_timer;
break; break;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
case MENU_VOICE: case MENU_VOICE:
gSubMenuSelection = gEeprom.VOICE_PROMPT; gSubMenuSelection = g_eeprom.voice_prompt;
break; break;
#endif #endif
case MENU_SC_REV: case MENU_SC_REV:
gSubMenuSelection = gEeprom.SCAN_RESUME_MODE; gSubMenuSelection = g_eeprom.scan_resume_mode;
break; break;
case MENU_MDF: case MENU_MDF:
gSubMenuSelection = gEeprom.CHANNEL_DISPLAY_MODE; gSubMenuSelection = g_eeprom.channel_display_mode;
break; break;
case MENU_AUTOLK: case MENU_AUTOLK:
gSubMenuSelection = gEeprom.AUTO_KEYPAD_LOCK; gSubMenuSelection = g_eeprom.auto_keypad_lock;
break; break;
case MENU_S_ADD1: case MENU_S_ADD1:
gSubMenuSelection = gTxVfo->SCANLIST1_PARTICIPATION; gSubMenuSelection = gTxVfo->scanlist_1_participation;
break; break;
case MENU_S_ADD2: case MENU_S_ADD2:
gSubMenuSelection = gTxVfo->SCANLIST2_PARTICIPATION; gSubMenuSelection = gTxVfo->scanlist_2_participation;
break; break;
case MENU_STE: case MENU_STE:
gSubMenuSelection = gEeprom.TAIL_NOTE_ELIMINATION; gSubMenuSelection = g_eeprom.tail_note_elimination;
break; break;
case MENU_RP_STE: case MENU_RP_STE:
gSubMenuSelection = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; gSubMenuSelection = g_eeprom.repeater_tail_tone_elimination;
break; break;
case MENU_MIC: case MENU_MIC:
gSubMenuSelection = gEeprom.MIC_SENSITIVITY; gSubMenuSelection = g_eeprom.mic_sensitivity;
break; break;
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
@ -1044,15 +1044,15 @@ void MENU_ShowCurrentSetting(void)
#endif #endif
case MENU_COMPAND: case MENU_COMPAND:
gSubMenuSelection = gTxVfo->Compander; gSubMenuSelection = gTxVfo->compander;
return; return;
case MENU_1_CALL: case MENU_1_CALL:
gSubMenuSelection = gEeprom.CHAN_1_CALL; gSubMenuSelection = g_eeprom.chan_1_call;
break; break;
case MENU_S_LIST: case MENU_S_LIST:
gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT; gSubMenuSelection = g_eeprom.scan_list_default;
break; break;
case MENU_SLIST1: case MENU_SLIST1:
@ -1065,20 +1065,20 @@ void MENU_ShowCurrentSetting(void)
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
case MENU_AL_MOD: case MENU_AL_MOD:
gSubMenuSelection = gEeprom.ALARM_MODE; gSubMenuSelection = g_eeprom.alarm_mode;
break; break;
#endif #endif
case MENU_D_ST: case MENU_D_ST:
gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; gSubMenuSelection = g_eeprom.DTMF_side_tone;
break; break;
case MENU_D_RSP: case MENU_D_RSP:
gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE; gSubMenuSelection = g_eeprom.DTMF_decode_response;
break; break;
case MENU_D_HOLD: case MENU_D_HOLD:
gSubMenuSelection = gEeprom.DTMF_auto_reset_time; gSubMenuSelection = g_eeprom.DTMF_auto_reset_time;
if (gSubMenuSelection <= DTMF_HOLD_MIN) if (gSubMenuSelection <= DTMF_HOLD_MIN)
gSubMenuSelection = DTMF_HOLD_MIN; gSubMenuSelection = DTMF_HOLD_MIN;
@ -1106,11 +1106,11 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_D_PRE: case MENU_D_PRE:
gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10; gSubMenuSelection = g_eeprom.DTMF_preload_time / 10;
break; break;
case MENU_PTT_ID: case MENU_PTT_ID:
gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE; gSubMenuSelection = gTxVfo->DTMF_ptt_id_tx_mode;
break; break;
case MENU_BAT_TXT: case MENU_BAT_TXT:
@ -1118,7 +1118,7 @@ void MENU_ShowCurrentSetting(void)
return; return;
case MENU_D_DCD: case MENU_D_DCD:
gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE; gSubMenuSelection = gTxVfo->DTMF_decoding_enable;
break; break;
case MENU_D_LIST: case MENU_D_LIST:
@ -1130,15 +1130,15 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_PONMSG: case MENU_PONMSG:
gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE; gSubMenuSelection = g_eeprom.pwr_on_display_mode;
break; break;
case MENU_ROGER: case MENU_ROGER:
gSubMenuSelection = gEeprom.ROGER; gSubMenuSelection = g_eeprom.roger_mode;
break; break;
case MENU_AM: case MENU_AM:
gSubMenuSelection = gTxVfo->AM_mode; gSubMenuSelection = gTxVfo->am_mode;
break; break;
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
@ -1155,32 +1155,32 @@ void MENU_ShowCurrentSetting(void)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_S: case MENU_NOAA_S:
gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN; gSubMenuSelection = g_eeprom.NOAA_auto_scan;
break; break;
#endif #endif
case MENU_DEL_CH: case MENU_DEL_CH:
#if 0 #if 0
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1); gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1);
#else #else
gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 1); gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 1);
#endif #endif
break; break;
case MENU_SIDE1_SHORT: case MENU_SIDE1_SHORT:
gSubMenuSelection = gEeprom.KEY_1_SHORT_PRESS_ACTION; gSubMenuSelection = g_eeprom.key1_short_press_action;
break; break;
case MENU_SIDE1_LONG: case MENU_SIDE1_LONG:
gSubMenuSelection = gEeprom.KEY_1_LONG_PRESS_ACTION; gSubMenuSelection = g_eeprom.key1_long_press_action;
break; break;
case MENU_SIDE2_SHORT: case MENU_SIDE2_SHORT:
gSubMenuSelection = gEeprom.KEY_2_SHORT_PRESS_ACTION; gSubMenuSelection = g_eeprom.key2_short_press_action;
break; break;
case MENU_SIDE2_LONG: case MENU_SIDE2_LONG:
gSubMenuSelection = gEeprom.KEY_2_LONG_PRESS_ACTION; gSubMenuSelection = g_eeprom.key2_long_press_action;
break; break;
case MENU_350TX: case MENU_350TX:
@ -1213,7 +1213,7 @@ void MENU_ShowCurrentSetting(void)
#ifdef ENABLE_F_CAL_MENU #ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI: case MENU_F_CALI:
gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW; gSubMenuSelection = g_eeprom.BK4819_xtal_freq_low;
break; break;
#endif #endif
@ -1226,7 +1226,7 @@ void MENU_ShowCurrentSetting(void)
} }
} }
static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void MENU_Key_0_to_9(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
uint8_t Offset; uint8_t Offset;
int32_t Min; int32_t Min;
@ -1315,17 +1315,17 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6)
{ // invalid frequency { // invalid frequency
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; return;
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
NUMBER_Get(gInputBox, &Frequency); NUMBER_Get(gInputBox, &Frequency);
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->StepFrequency, 0); gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->step_freq, 0);
gInputBoxIndex = 0; gInputBoxIndex = 0;
return; return;
@ -1337,7 +1337,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 3) if (gInputBoxIndex < 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
return; return;
@ -1347,10 +1347,10 @@ 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; Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (Value <= MR_CHANNEL_LAST) if (Value <= USER_CHANNEL_LAST)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gSubMenuSelection = Value; gSubMenuSelection = Value;
return; return;
@ -1413,7 +1413,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gFlagRefreshSetting = true; gFlagRefreshSetting = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
} }
else else
@ -1426,12 +1426,12 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
if (gEeprom.BACKLIGHT == 0) if (g_eeprom.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
@ -1442,7 +1442,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
MENU_StopCssScan(); MENU_StopCssScan();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
@ -1463,7 +1463,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gMenuCursor != MENU_SCR) if (gMenuCursor != MENU_SCR)
gAnotherVoiceID = MenuList[MenuList_sorted[gMenuCursor]].voice_id; g_another_voice_id = MenuList[MenuList_sorted[gMenuCursor]].voice_id;
#endif #endif
#if 1 #if 1
@ -1583,9 +1583,9 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gMenuCursor == MENU_SCR) if (gMenuCursor == MENU_SCR)
gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; g_another_voice_id = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON;
else else
gAnotherVoiceID = VOICE_ID_CONFIRM; g_another_voice_id = VOICE_ID_CONFIRM;
#endif #endif
gInputBoxIndex = 0; gInputBoxIndex = 0;
@ -1620,9 +1620,9 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0) if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save) && gRxVfo->am_mode == 0)
#else #else
if (gRxVfo->AM_mode == 0) if (gRxVfo->am_mode == 0)
#endif #endif
{ {
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS)
@ -1642,7 +1642,7 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
MENU_StopCssScan(); MENU_StopCssScan();
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
} }
@ -1712,7 +1712,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 (gMenuCursor != MENU_ABR && g_eeprom.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
@ -1723,7 +1723,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gMenuCursor == MENU_OFFSET) if (gMenuCursor == MENU_OFFSET)
{ {
int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection; int32_t Offset = (Direction * gTxVfo->step_freq) + gSubMenuSelection;
if (Offset < 99999990) if (Offset < 99999990)
{ {
if (Offset < 0) if (Offset < 0)
@ -1732,7 +1732,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
else else
Offset = 0; Offset = 0;
gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->StepFrequency, 0); gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->step_freq, 0);
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
return; return;
} }
@ -1771,7 +1771,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
} }
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void MENU_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
switch (Key) switch (Key)
{ {

View File

@ -30,7 +30,7 @@ void MENU_ShowCurrentSetting(void);
void MENU_StartCssScan(int8_t Direction); void MENU_StartCssScan(int8_t Direction);
void MENU_StopCssScan(void); void MENU_StopCssScan(void);
void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void MENU_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
#endif #endif

View File

@ -26,7 +26,7 @@
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/ui.h" #include "ui/ui.h"
DCS_CodeType_t gScanCssResultType; dcs_code_type_t gScanCssResultType;
uint8_t gScanCssResultCode; uint8_t gScanCssResultCode;
bool gFlagStartScan; bool gFlagStartScan;
bool gFlagStopScan; bool gFlagStopScan;
@ -44,7 +44,7 @@ bool gScanUseCssResult;
int8_t gScanStateDir; int8_t gScanStateDir;
bool bScanKeepFrequency; bool bScanKeepFrequency;
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)
{ {
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
@ -61,7 +61,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex < 3) if (gInputBoxIndex < 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; return;
} }
@ -69,10 +69,10 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0); gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0);
gScanChannel = (uint8_t)Channel; gScanChannel = (uint8_t)Channel;
@ -95,13 +95,13 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
case SCAN_EDIT_STATE_NONE: case SCAN_EDIT_STATE_NONE:
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
gEeprom.CROSS_BAND_RX_TX = gBackup_CROSS_BAND_RX_TX; g_eeprom.cross_vfo_rx_tx = gBackup_cross_vfo_rx_tx;
gUpdateStatus = true; gUpdateStatus = true;
gFlagStopScan = true; gFlagStopScan = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gFlagResetVfos = true; gFlagResetVfos = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
break; break;
@ -118,7 +118,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
case SCAN_EDIT_STATE_DONE: case SCAN_EDIT_STATE_DONE:
gScannerEditState = SCAN_EDIT_STATE_NONE; gScannerEditState = SCAN_EDIT_STATE_NONE;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; g_another_voice_id = VOICE_ID_CANCEL;
#endif #endif
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
break; break;
@ -199,11 +199,11 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
#else #else
#ifdef ENABLE_1250HZ_STEP #ifdef ENABLE_1250HZ_STEP
const STEP_Setting_t small_step = STEP_1_25kHz; const step_setting_t small_step = STEP_1_25kHz;
const STEP_Setting_t big_step = STEP_6_25kHz; const step_setting_t big_step = STEP_6_25kHz;
#else #else
const STEP_Setting_t small_step = STEP_2_5kHz; const step_setting_t small_step = STEP_2_5kHz;
const STEP_Setting_t big_step = STEP_6_25kHz; const step_setting_t big_step = STEP_6_25kHz;
#endif #endif
const uint32_t small_step_freq = StepFrequencyTable[small_step]; const uint32_t small_step_freq = StepFrequencyTable[small_step];
@ -242,11 +242,11 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
#endif #endif
} }
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST) if (gTxVfo->channel_save <= USER_CHANNEL_LAST)
{ {
gScannerEditState = SCAN_EDIT_STATE_BUSY; gScannerEditState = SCAN_EDIT_STATE_BUSY;
gScanChannel = gTxVfo->CHANNEL_SAVE; gScanChannel = gTxVfo->channel_save;
gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->CHANNEL_SAVE, false, 0); gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->channel_save, false, 0);
} }
else else
{ {
@ -256,7 +256,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gScanCssState = SCAN_CSS_STATE_FOUND; gScanCssState = SCAN_CSS_STATE_FOUND;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_MEMORY_CHANNEL; g_another_voice_id = VOICE_ID_MEMORY_CHANNEL;
#endif #endif
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
@ -275,45 +275,45 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
case SCAN_EDIT_STATE_DONE: case SCAN_EDIT_STATE_DONE:
if (!gScanSingleFrequency) if (!gScanSingleFrequency)
{ {
RADIO_InitInfo(gTxVfo, gTxVfo->CHANNEL_SAVE, gScanFrequency); RADIO_InitInfo(gTxVfo, gTxVfo->channel_save, gScanFrequency);
if (gScanUseCssResult) if (gScanUseCssResult)
{ {
gTxVfo->freq_config_RX.CodeType = gScanCssResultType; gTxVfo->freq_config_rx.code_type = gScanCssResultType;
gTxVfo->freq_config_RX.Code = gScanCssResultCode; gTxVfo->freq_config_rx.code = gScanCssResultCode;
} }
gTxVfo->freq_config_TX = gTxVfo->freq_config_RX; gTxVfo->freq_config_tx = gTxVfo->freq_config_rx;
gTxVfo->STEP_SETTING = gStepSetting; gTxVfo->step_setting = gStepSetting;
} }
else else
{ {
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
gTxVfo->freq_config_RX.CodeType = gScanCssResultType; gTxVfo->freq_config_rx.code_type = gScanCssResultType;
gTxVfo->freq_config_RX.Code = gScanCssResultCode; gTxVfo->freq_config_rx.code = gScanCssResultCode;
gTxVfo->freq_config_TX.CodeType = gScanCssResultType; gTxVfo->freq_config_tx.code_type = gScanCssResultType;
gTxVfo->freq_config_TX.Code = gScanCssResultCode; gTxVfo->freq_config_tx.code = gScanCssResultCode;
} }
if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST) if (gTxVfo->channel_save <= USER_CHANNEL_LAST)
{ {
Channel = gScanChannel; Channel = gScanChannel;
gEeprom.MrChannel[gEeprom.TX_VFO] = Channel; g_eeprom.user_channel[g_eeprom.tx_vfo] = Channel;
} }
else else
{ {
Channel = gTxVfo->Band + FREQ_CHANNEL_FIRST; Channel = gTxVfo->band + FREQ_CHANNEL_FIRST;
gEeprom.FreqChannel[gEeprom.TX_VFO] = Channel; g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel;
} }
gTxVfo->CHANNEL_SAVE = Channel; gTxVfo->channel_save = Channel;
gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel; g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel;
gRequestSaveChannel = 2; gRequestSaveChannel = 2;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CONFIRM; g_another_voice_id = VOICE_ID_CONFIRM;
#endif #endif
gScannerEditState = SCAN_EDIT_STATE_NONE; gScannerEditState = SCAN_EDIT_STATE_NONE;
@ -355,7 +355,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
if (gScannerEditState == SCAN_EDIT_STATE_BUSY) if (gScannerEditState == SCAN_EDIT_STATE_BUSY)
{ {
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST); gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, USER_CHANNEL_LAST);
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0); gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
} }
@ -363,7 +363,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }
void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void SCANNER_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
switch (Key) switch (Key)
{ {
@ -414,17 +414,17 @@ 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;
BackupStepFreq = gRxVfo->StepFrequency; BackupStepFreq = gRxVfo->step_freq;
RADIO_InitInfo(gRxVfo, gRxVfo->CHANNEL_SAVE, gRxVfo->pRX->Frequency); RADIO_InitInfo(gRxVfo, gRxVfo->channel_save, gRxVfo->pRX->frequency);
gRxVfo->STEP_SETTING = BackupStep; gRxVfo->step_setting = BackupStep;
gRxVfo->StepFrequency = BackupStepFreq; gRxVfo->step_freq = BackupStepFreq;
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
@ -435,8 +435,8 @@ void SCANNER_Start(void)
if (gScanSingleFrequency) if (gScanSingleFrequency)
{ {
gScanCssState = SCAN_CSS_STATE_SCANNING; gScanCssState = SCAN_CSS_STATE_SCANNING;
gScanFrequency = gRxVfo->pRX->Frequency; gScanFrequency = gRxVfo->pRX->frequency;
gStepSetting = gRxVfo->STEP_SETTING; gStepSetting = gRxVfo->step_setting;
BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency); BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency);
BK4819_SetScanFrequency(gScanFrequency); BK4819_SetScanFrequency(gScanFrequency);
@ -457,12 +457,12 @@ void SCANNER_Start(void)
gScanCssResultType = 0xFF; gScanCssResultType = 0xFF;
gScanHitCount = 0; gScanHitCount = 0;
gScanUseCssResult = false; gScanUseCssResult = false;
g_CxCSS_TAIL_Found = false; g_CxCSS_tailL_found = false;
g_CDCSS_Lost = false; g_CDCSS_lost = false;
gCDCSSCodeType = 0; g_CDCSS_code_type = 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 = SCAN_EDIT_STATE_NONE; gScannerEditState = SCAN_EDIT_STATE_NONE;
@ -474,7 +474,7 @@ void SCANNER_Start(void)
void SCANNER_Stop(void) void SCANNER_Stop(void)
{ {
const uint8_t Previous = gRestoreMrChannel; const uint8_t Previous = gRestoreUSER_CHANNEL;
if (gScanStateDir == SCAN_OFF) if (gScanStateDir == SCAN_OFF)
return; // but, but, we weren't ! return; // but, but, we weren't !
@ -483,16 +483,16 @@ void SCANNER_Stop(void)
if (!bScanKeepFrequency) if (!bScanKeepFrequency)
{ {
if (gNextMrChannel <= MR_CHANNEL_LAST) if (gNextChannel <= USER_CHANNEL_LAST)
{ {
gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel; g_eeprom.user_channel[g_eeprom.rx_vfo] = gRestoreUSER_CHANNEL;
gEeprom.ScreenChannel[gEeprom.RX_VFO] = Previous; g_eeprom.screen_channel[g_eeprom.rx_vfo] = Previous;
RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
} }
else else
{ {
gRxVfo->freq_config_RX.Frequency = gRestoreFrequency; gRxVfo->freq_config_rx.frequency = gRestoreFrequency;
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
} }
@ -501,11 +501,11 @@ void SCANNER_Stop(void)
return; return;
} }
if (gRxVfo->CHANNEL_SAVE > MR_CHANNEL_LAST) if (gRxVfo->channel_save > USER_CHANNEL_LAST)
{ {
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
SETTINGS_SaveChannel(gRxVfo->CHANNEL_SAVE, gEeprom.RX_VFO, gRxVfo, 1); SETTINGS_SaveChannel(gRxVfo->channel_save, g_eeprom.rx_vfo, gRxVfo, 1);
return; return;
} }

View File

@ -42,7 +42,7 @@ enum SCAN_edit_state_e {
}; };
typedef enum SCAN_edit_state_e SCAN_edit_state_t; typedef enum SCAN_edit_state_e SCAN_edit_state_t;
extern DCS_CodeType_t gScanCssResultType; extern dcs_code_type_t gScanCssResultType;
extern uint8_t gScanCssResultCode; extern uint8_t gScanCssResultCode;
extern bool gFlagStartScan; extern bool gFlagStartScan;
extern bool gFlagStopScan; extern bool gFlagStopScan;
@ -60,7 +60,7 @@ extern bool gScanUseCssResult;
extern int8_t gScanStateDir; extern int8_t gScanStateDir;
extern bool bScanKeepFrequency; 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);

View File

@ -22,169 +22,181 @@
const uint16_t RSSI_MAX_VALUE = 65535; const uint16_t RSSI_MAX_VALUE = 65535;
static uint32_t initialFreq; static uint32_t initialFreq;
static char String[32]; static char String[32];
bool isInitialized = false; bool isInitialized = false;
bool monitorMode = false; bool monitorMode = false;
bool redrawStatus = true; bool redrawStatus = true;
bool redrawScreen = false; bool redrawScreen = false;
bool newScanStart = true; bool newScanStart = true;
bool preventKeypress = true; bool preventKeypress = true;
bool isListening = false; bool isListening = false;
bool isTransmitting = false; bool isTransmitting = false;
State currentState = SPECTRUM, previousState = SPECTRUM; State currentState = SPECTRUM, previousState = SPECTRUM;
PeakInfo peak; PeakInfo peak;
ScanInfo scanInfo; ScanInfo scanInfo;
KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0}; KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0};
const char *bwOptions[] = {" 25k", "12.5k", "6.25k"}; const char *bwOptions[] = {" 25k", "12.5k", "6.25k"};
const char *modulationTypeOptions[] = {" FM", " AM", "USB"}; const char *modulationTypeOptions[] = {" FM", " AM", "USB"};
const uint8_t modulationTypeTuneSteps[] = {100, 50, 10}; const uint8_t modulationTypeTuneSteps[] = {100, 50, 10};
const uint8_t modTypeReg47Values[] = {1, 7, 5}; const uint8_t modTypeReg47Values[] = {1, 7, 5};
SpectrumSettings settings = { SpectrumSettings settings = {
.stepsCount = STEPS_64, .stepsCount = STEPS_64,
.scanStepIndex = S_STEP_25_0kHz, .scanStepIndex = S_STEP_25_0kHz,
.frequencyChangeStep = 80000, .frequencyChangeStep = 80000,
.scanDelay = 3200, .scanDelay = 3200,
.rssiTriggerLevel = 150, .rssiTriggerLevel = 150,
.backlightState = true, .backlightState = true,
.bw = BK4819_FILTER_BW_WIDE, .bw = BK4819_FILTER_BW_WIDE,
.listenBw = BK4819_FILTER_BW_WIDE, .listenBw = BK4819_FILTER_BW_WIDE,
.modulationType = false, .modulationType = false,
}; };
uint32_t fMeasure = 0; uint32_t fMeasure = 0;
uint32_t fTx = 0; uint32_t fTx = 0;
uint32_t currentFreq, tempFreq; uint32_t currentFreq;
uint32_t tempFreq;
uint16_t rssiHistory[128] = {0}; uint16_t rssiHistory[128] = {0};
bool blacklist[128] = {false}; bool blacklist[128] = {false};
static const RegisterSpec afOutRegSpec = {"AF OUT", 0x47, 8, 0xF, 1}; static const RegisterSpec afOutRegSpec = {"AF OUT", 0x47, 8, 0xF, 1};
static const RegisterSpec afDacGainRegSpec = {"AF DAC G", 0x48, 0, 0xF, 1}; static const RegisterSpec afDacGainRegSpec = {"AF DAC G", 0x48, 0, 0xF, 1};
static const RegisterSpec registerSpecs[] = { static const RegisterSpec registerSpecs[] = {
{}, {},
{"LNAs", 0x13, 8, 0b11, 1}, {"LNAs", 0x13, 8, 0b11, 1},
{"LNA", 0x13, 5, 0b111, 1}, {"LNA", 0x13, 5, 0b111, 1},
{"PGA", 0x13, 0, 0b111, 1}, {"PGA", 0x13, 0, 0b111, 1},
{"MIX", 0x13, 3, 0b11, 1}, {"MIX", 0x13, 3, 0b11, 1},
{"DEV", 0x40, 0, 4095, 1},
{"DEV", 0x40, 0, 4095, 1}, {"CMP", 0x31, 3, 1, 1},
{"CMP", 0x31, 3, 1, 1}, {"MIC", 0x7D, 0, 0x1F, 1},
{"MIC", 0x7D, 0, 0x1F, 1},
}; };
static uint16_t registersBackup[128]; static uint16_t registersBackup[128];
static const uint8_t registersToBackup[] = { static const uint8_t registersToBackup[] = {
0x13, 0x30, 0x31, 0x37, 0x3D, 0x40, 0x43, 0x47, 0x48, 0x7D, 0x7E, 0x13, 0x30, 0x31, 0x37, 0x3D, 0x40, 0x43, 0x47, 0x48, 0x7D, 0x7E,
}; };
static MovingAverage mov = {{128}, {}, 255, 128, 0, 0}; static MovingAverage mov = {{128}, {}, 255, 128, 0, 0};
static const uint8_t MOV_N = ARRAY_SIZE(mov.buf); static const uint8_t MOV_N = ARRAY_SIZE(mov.buf);
const uint8_t FREQ_INPUT_LENGTH = 10; const uint8_t FREQ_INPUT_LENGTH = 10;
uint8_t freqInputIndex = 0; uint8_t freqInputIndex = 0;
uint8_t freqInputDotIndex = 0; uint8_t freqInputDotIndex = 0;
KEY_Code_t freqInputArr[10]; key_code_t freqInputArr[10];
char freqInputString[] = "----------"; // XXXX.XXXXX char freqInputString[] = "----------"; // XXXX.XXXXX
uint8_t menuState = 0; uint8_t menuState = 0;
uint16_t listenT = 0; uint16_t listenT = 0;
uint16_t batteryUpdateTimer = 0; uint16_t batteryUpdateTimer = 0;
bool isMovingInitialized = false; bool isMovingInitialized = false;
uint8_t lastStepsCount = 0; uint8_t lastStepsCount = 0;
uint8_t CountBits(uint16_t n) { uint8_t CountBits(uint16_t n)
uint8_t count = 0; {
while (n) { uint8_t count = 0;
count++; while (n)
n >>= 1; {
} count++;
return count; n >>= 1;
}
return count;
} }
static uint16_t GetRegMask(RegisterSpec s) { static uint16_t GetRegMask(RegisterSpec s)
return (1 << CountBits(s.maxValue)) - 1; {
return (1 << CountBits(s.maxValue)) - 1;
} }
static uint16_t GetRegValue(RegisterSpec s) { static uint16_t GetRegValue(RegisterSpec s)
return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue; {
return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue;
} }
static void SetRegValue(RegisterSpec s, uint16_t v) { static void SetRegValue(RegisterSpec s, uint16_t v)
uint16_t reg = BK4819_ReadRegister(s.num); {
reg &= ~(GetRegMask(s) << s.offset); uint16_t reg = BK4819_ReadRegister(s.num);
BK4819_WriteRegister(s.num, reg | (v << s.offset)); reg &= ~(GetRegMask(s) << s.offset);
BK4819_WriteRegister(s.num, reg | (v << s.offset));
} }
static void UpdateRegMenuValue(RegisterSpec s, bool add) { static void UpdateRegMenuValue(RegisterSpec s, bool add)
uint16_t v = GetRegValue(s); {
uint16_t v = GetRegValue(s);
if (add && v <= s.maxValue - s.inc) {
v += s.inc; if (add && v <= s.maxValue - s.inc)
} else if (!add && v >= 0 + s.inc) { v += s.inc;
v -= s.inc; else
} if (!add && v >= 0 + s.inc)
v -= s.inc;
SetRegValue(s, v);
redrawScreen = true; SetRegValue(s, v);
redrawScreen = true;
} }
// Utility functions // Utility functions
KEY_Code_t GetKey() { key_code_t GetKey()
KEY_Code_t btn = KEYBOARD_Poll(); {
if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) { key_code_t btn = KEYBOARD_Poll();
btn = KEY_PTT; if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
} btn = KEY_PTT;
return btn; return btn;
} }
void SetState(State state) { void SetState(State state)
previousState = currentState; {
currentState = state; previousState = currentState;
redrawScreen = true; currentState = state;
redrawStatus = true; redrawScreen = true;
redrawStatus = true;
} }
// Radio functions // Radio functions
static void BackupRegisters() { static void BackupRegisters()
for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) { {
uint8_t regNum = registersToBackup[i]; for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i)
registersBackup[regNum] = BK4819_ReadRegister(regNum); {
} uint8_t regNum = registersToBackup[i];
registersBackup[regNum] = BK4819_ReadRegister(regNum);
}
} }
static void RestoreRegisters() { static void RestoreRegisters()
for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) { {
uint8_t regNum = registersToBackup[i]; for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i)
BK4819_WriteRegister(regNum, registersBackup[regNum]); {
} uint8_t regNum = registersToBackup[i];
BK4819_WriteRegister(regNum, registersBackup[regNum]);
}
} }
static void SetModulation(ModulationType type) { static void SetModulation(ModulationType type)
// restore only registers, which we affect here fully {
BK4819_WriteRegister(0x37, registersBackup[0x37]); // restore only registers, which we affect here fully
BK4819_WriteRegister(0x3D, registersBackup[0x3D]); BK4819_WriteRegister(0x37, registersBackup[0x37]);
BK4819_WriteRegister(0x48, registersBackup[0x48]); BK4819_WriteRegister(0x3D, registersBackup[0x3D]);
BK4819_WriteRegister(0x48, registersBackup[0x48]);
SetRegValue(afOutRegSpec, modTypeReg47Values[type]);
SetRegValue(afOutRegSpec, modTypeReg47Values[type]);
if (type == MOD_USB) {
BK4819_WriteRegister(0x37, 0b0001011000001111); if (type == MOD_USB)
BK4819_WriteRegister(0x3D, 0b0010101101000101); {
BK4819_WriteRegister(0x48, 0b0000001110101000); BK4819_WriteRegister(0x37, 0b0001011000001111);
} BK4819_WriteRegister(0x3D, 0b0010101101000101);
BK4819_WriteRegister(0x48, 0b0000001110101000);
if (type == MOD_AM) { }
SetRegValue(afDacGainRegSpec, 0xE);
} if (type == MOD_AM)
SetRegValue(afDacGainRegSpec, 0xE);
} }
static void SetF(uint32_t f) { static void SetF(uint32_t f) {
@ -646,7 +658,7 @@ static void FreqInput() {
SetState(FREQ_INPUT); SetState(FREQ_INPUT);
} }
static void UpdateFreqInput(KEY_Code_t key) { static void UpdateFreqInput(key_code_t key) {
if (key != KEY_EXIT && freqInputIndex >= 10) { if (key != KEY_EXIT && freqInputIndex >= 10) {
return; return;
} }
@ -667,7 +679,7 @@ static void UpdateFreqInput(KEY_Code_t key) {
uint8_t dotIndex = uint8_t dotIndex =
freqInputDotIndex == 0 ? freqInputIndex : freqInputDotIndex; freqInputDotIndex == 0 ? freqInputIndex : freqInputDotIndex;
KEY_Code_t digitKey; key_code_t digitKey;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
if (i < freqInputIndex) { if (i < freqInputIndex) {
digitKey = freqInputArr[i]; digitKey = freqInputArr[i];
@ -965,7 +977,7 @@ static void OnKeyDownFreqInput(uint8_t key) {
} }
} }
void OnKeyDownStill(KEY_Code_t key) { void OnKeyDownStill(key_code_t key) {
switch (key) { switch (key) {
case KEY_3: case KEY_3:
break; break;
@ -1315,7 +1327,7 @@ static void AutomaticPresetChoose(uint32_t f) {
void APP_RunSpectrum() { void APP_RunSpectrum() {
BackupRegisters(); BackupRegisters();
// TX here coz it always? set to active VFO // TX here coz it always? set to active VFO
VFO_Info_t vfo = gEeprom.VfoInfo[gEeprom.TX_CHANNEL]; VFO_Info_t vfo = g_eeprom.VfoInfo[g_eeprom.TX_CHANNEL];
initialFreq = vfo.pRX->Frequency; initialFreq = vfo.pRX->Frequency;
currentFreq = initialFreq; currentFreq = initialFreq;
settings.scanStepIndex = gStepSettingToIndex[vfo.STEP_SETTING]; settings.scanStepIndex = gStepSettingToIndex[vfo.STEP_SETTING];

View File

@ -17,6 +17,10 @@
#ifndef SPECTRUM_H #ifndef SPECTRUM_H
#define SPECTRUM_H #define SPECTRUM_H
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "../bitmaps.h" #include "../bitmaps.h"
#include "../board.h" #include "../board.h"
#include "../bsp/dp32g030/gpio.h" #include "../bsp/dp32g030/gpio.h"
@ -36,184 +40,164 @@
#include "../radio.h" #include "../radio.h"
#include "../settings.h" #include "../settings.h"
#include "../ui/helper.h" #include "../ui/helper.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
static const uint8_t DrawingEndY = 40; static const uint8_t DrawingEndY = 40;
static const uint16_t scanStepValues[] = { static const uint16_t scanStepValues[] = {
1, 10, 50, 100, 1, 10, 50, 100, 250, 500, 625, 833, 1000, 1250, 2500, 10000,
250, 500, 625, 833, 1000, 1250, 2500, 10000,
}; };
static const uint8_t gStepSettingToIndex[] = { static const uint8_t gStepSettingToIndex[] = {
[STEP_2_5kHz] = 4, [STEP_5_0kHz] = 5, [STEP_6_25kHz] = 6, [STEP_2_5kHz] = 4, [STEP_5_0kHz] = 5, [STEP_6_25kHz] = 6,
[STEP_10_0kHz] = 8, [STEP_12_5kHz] = 9, [STEP_25_0kHz] = 10, [STEP_10_0kHz] = 8, [STEP_12_5kHz] = 9, [STEP_25_0kHz] = 10,
[STEP_8_33kHz] = 7, [STEP_8_33kHz] = 7,
}; };
static const uint16_t scanStepBWRegValues[12] = { static const uint16_t scanStepBWRegValues[12] = {
// RX RXw TX BW // RX RXw TX BW
// 0b0 000 000 001 01 1000 // 0b0 000 000 001 01 1000
// 1 // 1
0b0000000001011000, // 6.25 0b0000000001011000, // 6.25
// 10 // 10
0b0000000001011000, // 6.25 0b0000000001011000, // 6.25
// 50 // 50
0b0000000001011000, // 6.25 0b0000000001011000, // 6.25
// 100 // 100
0b0000000001011000, // 6.25 0b0000000001011000, // 6.25
// 250 // 250
0b0000000001011000, // 6.25 0b0000000001011000, // 6.25
// 500 // 500
0b0010010001011000, // 6.25 0b0010010001011000, // 6.25
// 625 // 625
0b0100100001011000, // 6.25 0b0100100001011000, // 6.25
// 833 // 833
0b0110110001001000, // 6.25 0b0110110001001000, // 6.25
// 1000 // 1000
0b0110110001001000, // 6.25 0b0110110001001000, // 6.25
// 1250 // 1250
0b0111111100001000, // 6.25 0b0111111100001000, // 6.25
// 2500 // 2500
0b0011011000101000, // 25 0b0011011000101000, // 25
// 10000 // 10000
0b0011011000101000, // 25 0b0011011000101000, // 25
}; };
static const uint16_t listenBWRegValues[] = { static const uint16_t listenBWRegValues[] = {
0b0011011000101000, // 25 0b0011011000101000, // 25
0b0111111100001000, // 12.5 0b0111111100001000, // 12.5
0b0100100001011000, // 6.25 0b0100100001011000, // 6.25
}; };
typedef enum State { typedef enum State {
SPECTRUM, SPECTRUM,
FREQ_INPUT, FREQ_INPUT,
STILL, STILL,
} State; } State;
typedef enum StepsCount { typedef enum StepsCount {
STEPS_128, STEPS_128,
STEPS_64, STEPS_64,
STEPS_32, STEPS_32,
STEPS_16, STEPS_16,
} StepsCount; } StepsCount;
typedef enum ModulationType { typedef enum ModulationType {
MOD_FM, MOD_FM,
MOD_AM, MOD_AM,
MOD_USB, MOD_USB,
} ModulationType; } ModulationType;
typedef enum ScanStep { typedef enum ScanStep {
S_STEP_0_01kHz, S_STEP_0_01kHz,
S_STEP_0_1kHz, S_STEP_0_1kHz,
S_STEP_0_5kHz, S_STEP_0_5kHz,
S_STEP_1_0kHz, S_STEP_1_0kHz,
S_STEP_2_5kHz, S_STEP_2_5kHz,
S_STEP_5_0kHz, S_STEP_5_0kHz,
S_STEP_6_25kHz, S_STEP_6_25kHz,
S_STEP_8_33kHz, S_STEP_8_33kHz,
S_STEP_10_0kHz, S_STEP_10_0kHz,
S_STEP_12_5kHz, S_STEP_12_5kHz,
S_STEP_25_0kHz, S_STEP_25_0kHz,
S_STEP_100_0kHz, S_STEP_100_0kHz,
} ScanStep; } ScanStep;
typedef struct SpectrumSettings { typedef struct SpectrumSettings {
StepsCount stepsCount; StepsCount stepsCount;
ScanStep scanStepIndex; ScanStep scanStepIndex;
uint32_t frequencyChangeStep; uint32_t frequencyChangeStep;
uint16_t scanDelay; uint16_t scanDelay;
uint16_t rssiTriggerLevel; uint16_t rssiTriggerLevel;
bool backlightState; bool backlightState;
BK4819_FilterBandwidth_t bw; BK4819_FilterBandwidth_t bw;
BK4819_FilterBandwidth_t listenBw; BK4819_FilterBandwidth_t listenBw;
ModulationType modulationType; ModulationType modulationType;
} SpectrumSettings; } SpectrumSettings;
typedef struct KeyboardState { typedef struct KeyboardState {
KEY_Code_t current; KEY_Code_t current;
KEY_Code_t prev; KEY_Code_t prev;
uint8_t counter; uint8_t counter;
} KeyboardState; } KeyboardState;
typedef struct ScanInfo { typedef struct ScanInfo {
uint16_t rssi, rssiMin, rssiMax; uint16_t rssi, rssiMin, rssiMax;
uint8_t i, iPeak; uint8_t i, iPeak;
uint32_t f, fPeak; uint32_t f, fPeak;
uint16_t scanStep; uint16_t scanStep;
uint8_t measurementsCount; uint8_t measurementsCount;
} ScanInfo; } ScanInfo;
typedef struct RegisterSpec { typedef struct RegisterSpec {
const char *name; const char *name;
uint8_t num; uint8_t num;
uint8_t offset; uint8_t offset;
uint16_t maxValue; uint16_t maxValue;
uint16_t inc; uint16_t inc;
} RegisterSpec; } RegisterSpec;
typedef struct PeakInfo { typedef struct PeakInfo {
uint16_t t; uint16_t t;
uint16_t rssi; uint16_t rssi;
uint8_t i; uint8_t i;
uint32_t f; uint32_t f;
} PeakInfo; } PeakInfo;
typedef struct MovingAverage { typedef struct MovingAverage {
uint16_t mean[128]; uint16_t mean[128];
uint16_t buf[4][128]; uint16_t buf[4][128];
uint16_t min, mid, max; uint16_t min, mid, max;
uint16_t t; uint16_t t;
} MovingAverage; } MovingAverage;
typedef struct FreqPreset { typedef struct FreqPreset {
char name[16]; char name[16];
uint32_t fStart; uint32_t fStart;
uint32_t fEnd; uint32_t fEnd;
StepsCount stepsCountIndex; StepsCount stepsCountIndex;
uint8_t stepSizeIndex; uint8_t stepSizeIndex;
ModulationType modulationType; ModulationType modulationType;
BK4819_FilterBandwidth_t listenBW; BK4819_FilterBandwidth_t listenBW;
} FreqPreset; } FreqPreset;
static const FreqPreset freqPresets[] = { static const FreqPreset freqPresets[] = {
{"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB, {"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
BK4819_FILTER_BW_NARROWER}, {"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
{"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB, {"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
BK4819_FILTER_BW_NARROWER}, {"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB, {"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
BK4819_FILTER_BW_NARROWER}, {"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM, BK4819_FILTER_BW_NARROW },
{"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM, {"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
BK4819_FILTER_BW_NARROW}, {"JD1", 15175000, 15400000, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB, {"JD2", 15500000, 15600000, STEPS_64, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
BK4819_FILTER_BW_NARROWER}, {"LPD", 43307500, 43477500, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_WIDE },
{"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM, {"PMR", 44600625, 44620000, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
BK4819_FILTER_BW_NARROW}, {"FRS/GM 462", 46256250, 46272500, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM, {"FRS/GM 467", 46756250, 46771250, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
BK4819_FILTER_BW_NARROW},
{"JD1", 15175000, 15400000, STEPS_128, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"JD2", 15500000, 15600000, STEPS_64, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"LPD", 43307500, 43477500, STEPS_128, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_WIDE},
{"PMR", 44600625, 44620000, STEPS_16, S_STEP_12_5kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"FRS/GM 462", 46256250, 46272500, STEPS_16, S_STEP_12_5kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"FRS/GM 467", 46756250, 46771250, STEPS_16, S_STEP_12_5kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
}; };
void APP_RunSpectrum(void); void APP_RunSpectrum(void);
#endif /* ifndef SPECTRUM_H */ #endif
// vim: ft=c

View File

@ -390,16 +390,16 @@ static void CMD_052F(const uint8_t *pBuffer)
{ {
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer; const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF; g_eeprom.dual_watch = DUAL_WATCH_OFF;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
gEeprom.RX_VFO = 0; g_eeprom.rx_vfo = 0;
gEeprom.DTMF_SIDE_TONE = false; g_eeprom.DTMF_side_tone = false;
gEeprom.VfoInfo[0].FrequencyReverse = false; g_eeprom.VfoInfo[0].frequency_reverse = false;
gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX; g_eeprom.VfoInfo[0].pRX = &g_eeprom.VfoInfo[0].freq_config_rx;
gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX; g_eeprom.VfoInfo[0].pTX = &g_eeprom.VfoInfo[0].freq_config_tx;
gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; g_eeprom.VfoInfo[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;
gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; g_eeprom.VfoInfo[0].DTMF_ptt_id_tx_mode = PTT_ID_OFF;
gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false; g_eeprom.VfoInfo[0].DTMF_decoding_enable = false;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
gIsNoaaMode = false; gIsNoaaMode = false;

84
audio.c
View File

@ -59,12 +59,12 @@
0x41, 0x32, 0x3C, 0x37, 0x41, 0x32, 0x3C, 0x37,
}; };
VOICE_ID_t gVoiceID[8]; voice_id_t g_voice_id[8];
uint8_t gVoiceReadIndex; uint8_t g_voice_read_index;
uint8_t gVoiceWriteIndex; uint8_t g_voice_write_index;
volatile uint16_t gCountdownToPlayNextVoice_10ms; volatile uint16_t g_count_down_to_play_next_voice_10ms;
volatile bool gFlagPlayQueuedVoice; volatile bool g_flag_play_queued_voice;
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID; voice_id_t g_another_voice_id = VOICE_ID_INVALID;
#endif #endif
@ -81,7 +81,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
Beep != BEEP_440HZ_500MS && Beep != BEEP_440HZ_500MS &&
Beep != BEEP_880HZ_200MS && Beep != BEEP_880HZ_200MS &&
Beep != BEEP_880HZ_500MS && Beep != BEEP_880HZ_500MS &&
!gEeprom.BEEP_CONTROL) !g_eeprom.beep_control)
return; return;
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
@ -99,7 +99,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode) if (gCurrentFunction == FUNCTION_POWER_SAVE && g_rx_idle_mode)
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -209,7 +209,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
BK1080_Mute(false); BK1080_Mute(false);
#endif #endif
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode) if (gCurrentFunction == FUNCTION_POWER_SAVE && g_rx_idle_mode)
BK4819_Sleep(); BK4819_Sleep();
} }
@ -244,11 +244,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
uint8_t VoiceID; uint8_t VoiceID;
uint8_t Delay; uint8_t Delay;
VoiceID = gVoiceID[0]; VoiceID = g_voice_id[0];
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0) if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF && g_voice_write_index > 0)
{ {
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) if (g_eeprom.voice_prompt == VOICE_PROMPT_CHINESE)
{ // Chinese { // Chinese
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese)) if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese))
goto Bailout; goto Bailout;
@ -284,7 +284,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
SYSTEM_DelayMs(5); SYSTEM_DelayMs(5);
AUDIO_PlayVoice(VoiceID); AUDIO_PlayVoice(VoiceID);
if (gVoiceWriteIndex == 1) if (g_voice_write_index == 1)
Delay += 3; Delay += 3;
if (bFlag) if (bFlag)
@ -294,7 +294,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE || if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11 gCurrentFunction == FUNCTION_INCOMING) // 1of11
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM); BK4819_SetAF(gRxVfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode)
@ -304,8 +304,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (!gEnableSpeaker) if (!gEnableSpeaker)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gVoiceWriteIndex = 0; g_voice_write_index = 0;
gVoiceReadIndex = 0; g_voice_read_index = 0;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
gVoxResumeCountdown = 80; gVoxResumeCountdown = 80;
@ -314,32 +314,32 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
return; return;
} }
gVoiceReadIndex = 1; g_voice_read_index = 1;
gCountdownToPlayNextVoice_10ms = Delay; g_count_down_to_play_next_voice_10ms = Delay;
gFlagPlayQueuedVoice = false; g_flag_play_queued_voice = false;
return; return;
} }
Bailout: Bailout:
gVoiceReadIndex = 0; g_voice_read_index = 0;
gVoiceWriteIndex = 0; g_voice_write_index = 0;
} }
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID) void AUDIO_SetVoiceID(uint8_t Index, voice_id_t VoiceID)
{ {
if (Index >= ARRAY_SIZE(gVoiceID)) if (Index >= ARRAY_SIZE(g_voice_id))
return; return;
if (Index == 0) if (Index == 0)
{ {
gVoiceWriteIndex = 0; g_voice_write_index = 0;
gVoiceReadIndex = 0; g_voice_read_index = 0;
} }
gVoiceID[Index] = VoiceID; g_voice_id[Index] = VoiceID;
gVoiceWriteIndex++; g_voice_write_index++;
} }
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value) uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
@ -350,8 +350,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (Index == 0) if (Index == 0)
{ {
gVoiceWriteIndex = 0; g_voice_write_index = 0;
gVoiceReadIndex = 0; g_voice_read_index = 0;
} }
Count = 0; Count = 0;
@ -365,17 +365,17 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
else else
{ {
Result = Remainder / 100U; Result = Remainder / 100U;
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result; g_voice_id[g_voice_write_index++] = (voice_id_t)Result;
Count++; Count++;
Remainder -= Result * 100U; Remainder -= Result * 100U;
} }
Result = Remainder / 10U; Result = Remainder / 10U;
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result; g_voice_id[g_voice_write_index++] = (voice_id_t)Result;
Count++; Count++;
Remainder -= Result * 10U; Remainder -= Result * 10U;
Skip: Skip:
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder; g_voice_id[g_voice_write_index++] = (voice_id_t)Remainder;
return Count + 1U; return Count + 1U;
} }
@ -388,10 +388,10 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
Skip = false; Skip = false;
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF) if (g_voice_read_index != g_voice_write_index && g_eeprom.voice_prompt != VOICE_PROMPT_OFF)
{ {
VoiceID = gVoiceID[gVoiceReadIndex]; VoiceID = g_voice_id[g_voice_read_index];
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) if (g_eeprom.voice_prompt == VOICE_PROMPT_CHINESE)
{ {
if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese)) if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese))
{ {
@ -412,17 +412,17 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
Skip = true; Skip = true;
} }
gVoiceReadIndex++; g_voice_read_index++;
if (!Skip) if (!Skip)
{ {
if (gVoiceReadIndex == gVoiceWriteIndex) if (g_voice_read_index == g_voice_write_index)
Delay += 3; Delay += 3;
AUDIO_PlayVoice(VoiceID); AUDIO_PlayVoice(VoiceID);
gCountdownToPlayNextVoice_10ms = Delay; g_count_down_to_play_next_voice_10ms = Delay;
gFlagPlayQueuedVoice = false; g_flag_play_queued_voice = false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
gVoxResumeCountdown = 2000; gVoxResumeCountdown = 2000;
@ -435,7 +435,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE || if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11 gCurrentFunction == FUNCTION_INCOMING) // 1of11
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM); BK4819_SetAF(gRxVfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gFmRadioMode) if (gFmRadioMode)
@ -449,8 +449,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
gVoxResumeCountdown = 80; gVoxResumeCountdown = 80;
#endif #endif
gVoiceWriteIndex = 0; g_voice_write_index = 0;
gVoiceReadIndex = 0; g_voice_read_index = 0;
} }
#endif #endif

175
audio.h
View File

@ -46,101 +46,100 @@ enum
VOICE_ID_ENG_BASE = 0x60U, VOICE_ID_ENG_BASE = 0x60U,
}; };
enum VOICE_ID_t enum voice_id_e
{ {
VOICE_ID_0 = 0x00U, VOICE_ID_0 = 0x00U,
VOICE_ID_1 = 0x01U, VOICE_ID_1 = 0x01U,
VOICE_ID_2 = 0x02U, VOICE_ID_2 = 0x02U,
VOICE_ID_3 = 0x03U, VOICE_ID_3 = 0x03U,
VOICE_ID_4 = 0x04U, VOICE_ID_4 = 0x04U,
VOICE_ID_5 = 0x05U, VOICE_ID_5 = 0x05U,
VOICE_ID_6 = 0x06U, VOICE_ID_6 = 0x06U,
VOICE_ID_7 = 0x07U, VOICE_ID_7 = 0x07U,
VOICE_ID_8 = 0x08U, VOICE_ID_8 = 0x08U,
VOICE_ID_9 = 0x09U, VOICE_ID_9 = 0x09U,
VOICE_ID_10 = 0x0AU, VOICE_ID_10 = 0x0AU,
VOICE_ID_100 = 0x0BU, VOICE_ID_100 = 0x0BU,
VOICE_ID_WELCOME = 0x0CU, VOICE_ID_WELCOME = 0x0CU,
VOICE_ID_LOCK = 0x0DU, VOICE_ID_LOCK = 0x0DU,
VOICE_ID_UNLOCK = 0x0EU, VOICE_ID_UNLOCK = 0x0EU,
VOICE_ID_SCANNING_BEGIN = 0x0FU, VOICE_ID_SCANNING_BEGIN = 0x0FU,
VOICE_ID_SCANNING_STOP = 0x10U, VOICE_ID_SCANNING_STOP = 0x10U,
VOICE_ID_SCRAMBLER_ON = 0x11U, VOICE_ID_SCRAMBLER_ON = 0x11U,
VOICE_ID_SCRAMBLER_OFF = 0x12U, VOICE_ID_SCRAMBLER_OFF = 0x12U,
VOICE_ID_FUNCTION = 0x13U, VOICE_ID_FUNCTION = 0x13U,
VOICE_ID_CTCSS = 0x14U, VOICE_ID_CTCSS = 0x14U,
VOICE_ID_DCS = 0x15U, VOICE_ID_DCS = 0x15U,
VOICE_ID_POWER = 0x16U, VOICE_ID_POWER = 0x16U,
VOICE_ID_SAVE_MODE = 0x17U, VOICE_ID_SAVE_MODE = 0x17U,
VOICE_ID_MEMORY_CHANNEL = 0x18U, VOICE_ID_MEMORY_CHANNEL = 0x18U,
VOICE_ID_DELETE_CHANNEL = 0x19U, VOICE_ID_DELETE_CHANNEL = 0x19U,
VOICE_ID_FREQUENCY_STEP = 0x1AU, VOICE_ID_FREQUENCY_STEP = 0x1AU,
VOICE_ID_SQUELCH = 0x1BU, VOICE_ID_SQUELCH = 0x1BU,
VOICE_ID_TRANSMIT_OVER_TIME = 0x1CU, voice_id_tRANSMIT_OVER_TIME = 0x1CU,
VOICE_ID_BACKLIGHT_SELECTION = 0x1DU, VOICE_ID_BACKLIGHT_SELECTION = 0x1DU,
VOICE_ID_VOX = 0x1EU, VOICE_ID_VOX = 0x1EU,
VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION = 0x1FU, voice_id_tX_OFFSET_FREQ_DIR = 0x1FU,
VOICE_ID_TX_OFFSET_FREQUENCY = 0x20U, voice_id_tX_OFFSET_FREQ = 0x20U,
VOICE_ID_TRANSMITING_MEMORY = 0x21U, voice_id_tRANSMITING_MEMORY = 0x21U,
VOICE_ID_RECEIVING_MEMORY = 0x22U, VOICE_ID_RECEIVING_MEMORY = 0x22U,
VOICE_ID_EMERGENCY_CALL = 0x23U, VOICE_ID_EMERGENCY_CALL = 0x23U,
VOICE_ID_LOW_VOLTAGE = 0x24U, VOICE_ID_LOW_VOLTAGE = 0x24U,
VOICE_ID_CHANNEL_MODE = 0x25U, VOICE_ID_CHANNEL_MODE = 0x25U,
VOICE_ID_FREQUENCY_MODE = 0x26U, VOICE_ID_FREQUENCY_MODE = 0x26U,
VOICE_ID_VOICE_PROMPT = 0x27U, VOICE_ID_VOICE_PROMPT = 0x27U,
VOICE_ID_BAND_SELECTION = 0x28U, VOICE_ID_BAND_SELECTION = 0x28U,
VOICE_ID_DUAL_STANDBY = 0x29U, VOICE_ID_DUAL_STANDBY = 0x29U,
VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU, VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU,
VOICE_ID_OPTIONAL_SIGNAL = 0x2BU, VOICE_ID_OPTIONAL_SIGNAL = 0x2BU,
VOICE_ID_MUTE_MODE = 0x2CU, VOICE_ID_MUTE_MODE = 0x2CU,
VOICE_ID_BUSY_LOCKOUT = 0x2DU, VOICE_ID_BUSY_LOCKOUT = 0x2DU,
VOICE_ID_BEEP_PROMPT = 0x2EU, VOICE_ID_BEEP_PROMPT = 0x2EU,
VOICE_ID_ANI_CODE = 0x2FU, VOICE_ID_ANI_CODE = 0x2FU,
VOICE_ID_INITIALISATION = 0x30U, VOICE_ID_INITIALISATION = 0x30U,
VOICE_ID_CONFIRM = 0x31U, VOICE_ID_CONFIRM = 0x31U,
VOICE_ID_CANCEL = 0x32U, VOICE_ID_CANCEL = 0x32U,
VOICE_ID_ON = 0x33U, VOICE_ID_ON = 0x33U,
VOICE_ID_OFF = 0x34U, VOICE_ID_OFF = 0x34U,
VOICE_ID_2_TONE = 0x35U, VOICE_ID_2_TONE = 0x35U,
VOICE_ID_5_TONE = 0x36U, VOICE_ID_5_TONE = 0x36U,
VOICE_ID_DIGITAL_SIGNAL = 0x37U, VOICE_ID_DIGITAL_SIGNAL = 0x37U,
VOICE_ID_REPEATER = 0x38U, VOICE_ID_REPEATER = 0x38U,
VOICE_ID_MENU = 0x39U, VOICE_ID_MENU = 0x39U,
VOICE_ID_11 = 0x3AU, VOICE_ID_11 = 0x3AU,
VOICE_ID_12 = 0x3BU, VOICE_ID_12 = 0x3BU,
VOICE_ID_13 = 0x3CU, VOICE_ID_13 = 0x3CU,
VOICE_ID_14 = 0x3DU, VOICE_ID_14 = 0x3DU,
VOICE_ID_15 = 0x3EU, VOICE_ID_15 = 0x3EU,
VOICE_ID_16 = 0x3FU, VOICE_ID_16 = 0x3FU,
VOICE_ID_17 = 0x40U, VOICE_ID_17 = 0x40U,
VOICE_ID_18 = 0x41U, VOICE_ID_18 = 0x41U,
VOICE_ID_19 = 0x42U, VOICE_ID_19 = 0x42U,
VOICE_ID_20 = 0x43U, VOICE_ID_20 = 0x43U,
VOICE_ID_30 = 0x44U, VOICE_ID_30 = 0x44U,
VOICE_ID_40 = 0x45U, VOICE_ID_40 = 0x45U,
VOICE_ID_50 = 0x46U, VOICE_ID_50 = 0x46U,
VOICE_ID_60 = 0x47U, VOICE_ID_60 = 0x47U,
VOICE_ID_70 = 0x48U, VOICE_ID_70 = 0x48U,
VOICE_ID_80 = 0x49U, VOICE_ID_80 = 0x49U,
VOICE_ID_90 = 0x4AU, VOICE_ID_90 = 0x4AU,
VOICE_ID_END = 0x4BU, VOICE_ID_END = 0x4BU,
VOICE_ID_INVALID = 0xFFU, VOICE_ID_INVALID = 0xFFU,
}; };
typedef enum voice_id_e voice_id_t;
typedef enum VOICE_ID_t VOICE_ID_t;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
extern VOICE_ID_t gVoiceID[8]; extern voice_id_t g_voice_id[8];
extern uint8_t gVoiceReadIndex; extern uint8_t g_voice_read_index;
extern uint8_t gVoiceWriteIndex; extern uint8_t g_voice_write_index;
extern volatile uint16_t gCountdownToPlayNextVoice_10ms; extern volatile uint16_t g_count_down_to_play_next_voice_10ms;
extern volatile bool gFlagPlayQueuedVoice; extern volatile bool g_flag_play_queued_voice;
extern VOICE_ID_t gAnotherVoiceID; extern voice_id_t g_another_voice_id;
void AUDIO_PlayVoice(uint8_t VoiceID); void AUDIO_PlayVoice(uint8_t VoiceID);
void AUDIO_PlaySingleVoice(bool bFlag); void AUDIO_PlaySingleVoice(bool bFlag);
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID); void AUDIO_SetVoiceID(uint8_t Index, voice_id_t VoiceID);
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value); uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
void AUDIO_PlayQueuedVoice(void); void AUDIO_PlayQueuedVoice(void);
#endif #endif

206
board.c
View File

@ -525,40 +525,40 @@ void BOARD_EEPROM_Init(void)
// 0E70..0E77 // 0E70..0E77
EEPROM_ReadBuffer(0x0E70, Data, 8); EEPROM_ReadBuffer(0x0E70, Data, 8);
gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST; g_eeprom.chan_1_call = IS_USER_CHANNEL(Data[0]) ? Data[0] : USER_CHANNEL_FIRST;
gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1; g_eeprom.squelch_level = (Data[1] < 10) ? Data[1] : 1;
gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1; g_eeprom.tx_timeout_timer = (Data[2] < 11) ? Data[2] : 1;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false; g_eeprom.NOAA_auto_scan = (Data[3] < 2) ? Data[3] : false;
#endif #endif
gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; g_eeprom.key_lock = (Data[4] < 2) ? Data[4] : false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false; g_eeprom.vox_switch = (Data[5] < 2) ? Data[5] : false;
gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1; g_eeprom.vox_level = (Data[6] < 10) ? Data[6] : 1;
#endif #endif
gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4; g_eeprom.mic_sensitivity = (Data[7] < 5) ? Data[7] : 4;
// 0E78..0E7F // 0E78..0E7F
EEPROM_ReadBuffer(0x0E78, Data, 8); EEPROM_ReadBuffer(0x0E78, Data, 8);
gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode g_eeprom.channel_display_mode = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; g_eeprom.battery_save = (Data[3] < 5) ? Data[3] : 4;
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; g_eeprom.dual_watch = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A;
gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3; g_eeprom.backlight = (Data[5] < ARRAY_SIZE(gSubMenu_backlight)) ? Data[5] : 3;
gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; g_eeprom.tail_note_elimination = (Data[6] < 2) ? Data[6] : false;
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; g_eeprom.vfo_open = (Data[7] < 2) ? Data[7] : true;
// 0E80..0E87 // 0E80..0E87
EEPROM_ReadBuffer(0x0E80, Data, 8); EEPROM_ReadBuffer(0x0E80, Data, 8);
gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); g_eeprom.screen_channel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); g_eeprom.screen_channel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST; g_eeprom.user_channel[0] = IS_USER_CHANNEL(Data[1]) ? Data[1] : USER_CHANNEL_FIRST;
gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST; g_eeprom.user_channel[1] = IS_USER_CHANNEL(Data[4]) ? Data[4] : USER_CHANNEL_FIRST;
gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); g_eeprom.freq_channel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); g_eeprom.freq_channel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST; g_eeprom.noaa_channel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST;
gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST; g_eeprom.noaa_channel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
#endif #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -572,15 +572,15 @@ void BOARD_EEPROM_Init(void)
} __attribute__((packed)) FM; } __attribute__((packed)) FM;
EEPROM_ReadBuffer(0x0E88, &FM, 8); EEPROM_ReadBuffer(0x0E88, &FM, 8);
gEeprom.FM_LowerLimit = 760; g_eeprom.fm_lower_limit = 760;
gEeprom.FM_UpperLimit = 1080; g_eeprom.fm_upper_limit = 1080;
if (FM.SelectedFrequency < gEeprom.FM_LowerLimit || FM.SelectedFrequency > gEeprom.FM_UpperLimit) if (FM.SelectedFrequency < g_eeprom.fm_lower_limit || FM.SelectedFrequency > g_eeprom.fm_upper_limit)
gEeprom.FM_SelectedFrequency = 960; g_eeprom.fm_selected_frequency = 960;
else else
gEeprom.FM_SelectedFrequency = FM.SelectedFrequency; g_eeprom.fm_selected_frequency = FM.SelectedFrequency;
gEeprom.FM_SelectedChannel = FM.SelectedChannel; g_eeprom.fm_selected_channel = FM.SelectedChannel;
gEeprom.FM_IsMrMode = (FM.IsMrMode < 2) ? FM.IsMrMode : false; g_eeprom.fm_is_channel_mode = (FM.IsMrMode < 2) ? FM.IsMrMode : false;
} }
// 0E40..0E67 // 0E40..0E67
@ -590,111 +590,111 @@ void BOARD_EEPROM_Init(void)
// 0E90..0E97 // 0E90..0E97
EEPROM_ReadBuffer(0x0E90, Data, 8); EEPROM_ReadBuffer(0x0E90, Data, 8);
gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true; g_eeprom.beep_control = (Data[0] < 2) ? Data[0] : true;
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; g_eeprom.key1_short_press_action = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT; g_eeprom.key1_long_press_action = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; g_eeprom.key2_short_press_action = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; g_eeprom.key2_long_press_action = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; g_eeprom.scan_resume_mode = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false; g_eeprom.auto_keypad_lock = (Data[6] < 2) ? Data[6] : false;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE; g_eeprom.pwr_on_display_mode = (Data[7] < 4) ? Data[7] : PWR_ON_DISPLAY_MODE_VOLTAGE;
// 0E98..0E9F // 0E98..0E9F
EEPROM_ReadBuffer(0x0E98, Data, 8); EEPROM_ReadBuffer(0x0E98, Data, 8);
memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4); memmove(&g_eeprom.power_on_password, Data, 4);
// 0EA0..0EA7 // 0EA0..0EA7
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
EEPROM_ReadBuffer(0x0EA0, Data, 8); EEPROM_ReadBuffer(0x0EA0, Data, 8);
gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; g_eeprom.voice_prompt = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH;
#endif #endif
// 0EA8..0EAF // 0EA8..0EAF
EEPROM_ReadBuffer(0x0EA8, Data, 8); EEPROM_ReadBuffer(0x0EA8, Data, 8);
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true; g_eeprom.alarm_mode = (Data[0] < 2) ? Data[0] : true;
#endif #endif
gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; g_eeprom.roger_mode = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF;
gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0; g_eeprom.repeater_tail_tone_elimination = (Data[2] < 11) ? Data[2] : 0;
gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0; g_eeprom.tx_vfo = (Data[3] < 2) ? Data[3] : 0;
// 0ED0..0ED7 // 0ED0..0ED7
EEPROM_ReadBuffer(0x0ED0, Data, 8); EEPROM_ReadBuffer(0x0ED0, Data, 8);
gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; g_eeprom.DTMF_side_tone = (Data[0] < 2) ? Data[0] : true;
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; g_eeprom.DTMF_separate_code = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#'; g_eeprom.DTMF_group_call_code = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : DTMF_DEC_RESPONSE_RING; g_eeprom.DTMF_decode_response = (Data[3] < 4) ? Data[3] : DTMF_DEC_RESPONSE_RING;
gEeprom.DTMF_auto_reset_time = (Data[4] <= DTMF_HOLD_MAX) ? Data[4] : (Data[4] >= DTMF_HOLD_MIN) ? Data[4] : DTMF_HOLD_MAX; g_eeprom.DTMF_auto_reset_time = (Data[4] <= DTMF_HOLD_MAX) ? Data[4] : (Data[4] >= DTMF_HOLD_MIN) ? Data[4] : DTMF_HOLD_MAX;
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 200; g_eeprom.DTMF_preload_time = (Data[5] < 101) ? Data[5] * 10 : 200;
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 70; g_eeprom.DTMF_first_code_persist_time = (Data[6] < 101) ? Data[6] * 10 : 70;
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 70; g_eeprom.DTMF_hash_code_persist_time = (Data[7] < 101) ? Data[7] * 10 : 70;
// 0ED8..0EDF // 0ED8..0EDF
EEPROM_ReadBuffer(0x0ED8, Data, 8); EEPROM_ReadBuffer(0x0ED8, Data, 8);
gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 70; g_eeprom.DTMF_code_persist_time = (Data[0] < 101) ? Data[0] * 10 : 70;
gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 70; g_eeprom.DTMF_code_interval_time = (Data[1] < 101) ? Data[1] * 10 : 70;
gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : false; g_eeprom.permit_remote_kill = (Data[2] < 2) ? Data[2] : false;
// 0EE0..0EE7 // 0EE0..0EE7
EEPROM_ReadBuffer(0x0EE0, Data, 8); EEPROM_ReadBuffer(0x0EE0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.ANI_DTMF_ID, Data, 8); memmove(g_eeprom.ani_DTMF_id, Data, 8);
else else
{ {
memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID)); memset(g_eeprom.ani_DTMF_id, 0, sizeof(g_eeprom.ani_DTMF_id));
strcpy(gEeprom.ANI_DTMF_ID, "123"); strcpy(g_eeprom.ani_DTMF_id, "123");
} }
// 0EE8..0EEF // 0EE8..0EEF
EEPROM_ReadBuffer(0x0EE8, Data, 8); EEPROM_ReadBuffer(0x0EE8, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.KILL_CODE, Data, 8); memmove(g_eeprom.kill_code, Data, 8);
else else
{ {
memset(gEeprom.KILL_CODE, 0, sizeof(gEeprom.KILL_CODE)); memset(g_eeprom.kill_code, 0, sizeof(g_eeprom.kill_code));
strcpy(gEeprom.KILL_CODE, "ABCD9"); strcpy(g_eeprom.kill_code, "ABCD9");
} }
// 0EF0..0EF7 // 0EF0..0EF7
EEPROM_ReadBuffer(0x0EF0, Data, 8); EEPROM_ReadBuffer(0x0EF0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(gEeprom.REVIVE_CODE, Data, 8); memmove(g_eeprom.revive_code, Data, 8);
else else
{ {
memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE)); memset(g_eeprom.revive_code, 0, sizeof(g_eeprom.revive_code));
strcpy(gEeprom.REVIVE_CODE, "9DCBA"); strcpy(g_eeprom.revive_code, "9DCBA");
} }
// 0EF8..0F07 // 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16); EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(gEeprom.DTMF_UP_CODE, Data, 16); memmove(g_eeprom.DTMF_up_code, Data, 16);
else else
{ {
memset(gEeprom.DTMF_UP_CODE, 0, sizeof(gEeprom.DTMF_UP_CODE)); memset(g_eeprom.DTMF_up_code, 0, sizeof(g_eeprom.DTMF_up_code));
strcpy(gEeprom.DTMF_UP_CODE, "12345"); strcpy(g_eeprom.DTMF_up_code, "12345");
} }
// 0F08..0F17 // 0F08..0F17
EEPROM_ReadBuffer(0x0F08, Data, 16); EEPROM_ReadBuffer(0x0F08, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(gEeprom.DTMF_DOWN_CODE, Data, 16); memmove(g_eeprom.DTMF_down_code, Data, 16);
else else
{ {
memset(gEeprom.DTMF_DOWN_CODE, 0, sizeof(gEeprom.DTMF_DOWN_CODE)); memset(g_eeprom.DTMF_down_code, 0, sizeof(g_eeprom.DTMF_down_code));
strcpy(gEeprom.DTMF_DOWN_CODE, "54321"); strcpy(g_eeprom.DTMF_down_code, "54321");
} }
// 0F18..0F1F // 0F18..0F1F
EEPROM_ReadBuffer(0x0F18, Data, 8); EEPROM_ReadBuffer(0x0F18, Data, 8);
// gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 2) ? Data[0] : false; // g_eeprom.scan_list_default = (Data[0] < 2) ? Data[0] : false;
gEeprom.SCAN_LIST_DEFAULT = (Data[0] < 3) ? Data[0] : false; // we now have 'all' channel scan option g_eeprom.scan_list_default = (Data[0] < 3) ? Data[0] : false; // we now have 'all' channel scan option
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
const unsigned int j = 1 + (i * 3); const unsigned int j = 1 + (i * 3);
gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false; g_eeprom.scan_list_enabled[i] = (Data[j + 0] < 2) ? Data[j] : false;
gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1]; g_eeprom.scan_list_priority_ch1[i] = Data[j + 1];
gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2]; g_eeprom.scan_list_priority_ch2[i] = Data[j + 2];
} }
// 0F40..0F47 // 0F40..0F47
@ -717,14 +717,14 @@ void BOARD_EEPROM_Init(void)
#endif #endif
gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u;
if (!gEeprom.VFO_OPEN) if (!g_eeprom.vfo_open)
{ {
gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0]; g_eeprom.screen_channel[0] = g_eeprom.user_channel[0];
gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1]; g_eeprom.screen_channel[1] = g_eeprom.user_channel[1];
} }
// 0D60..0E27 // 0D60..0E27
EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes)); EEPROM_ReadBuffer(0x0D60, gUSER_ChannelAttributes, sizeof(gUSER_ChannelAttributes));
// 0F30..0F3F // 0F30..0F3F
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
@ -743,14 +743,14 @@ void BOARD_EEPROM_LoadMoreSettings(void)
{ {
// uint8_t Mic; // uint8_t Mic;
EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8); EEPROM_ReadBuffer(0x1EC0, g_eeprom_1EC0_0, 8);
memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); memmove(g_eeprom_1EC0_1, g_eeprom_1EC0_0, 8);
memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); memmove(g_eeprom_1EC0_2, g_eeprom_1EC0_0, 8);
memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); memmove(g_eeprom_1EC0_3, g_eeprom_1EC0_0, 8);
// 8 * 16-bit values // 8 * 16-bit values
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8); EEPROM_ReadBuffer(0x1EC0, g_eeprom_RSSI_CALIB[0], 8);
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[1], 8); EEPROM_ReadBuffer(0x1EC8, g_eeprom_RSSI_CALIB[1], 8);
EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12); EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
if (gBatteryCalibration[0] >= 5000) if (gBatteryCalibration[0] >= 5000)
@ -761,13 +761,13 @@ void BOARD_EEPROM_LoadMoreSettings(void)
gBatteryCalibration[5] = 2300; gBatteryCalibration[5] = 2300;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2); EEPROM_ReadBuffer(0x1F50 + (g_eeprom.vox_level * 2), &g_eeprom.vox1_threshold, 2);
EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2); EEPROM_ReadBuffer(0x1F68 + (g_eeprom.vox_level * 2), &g_eeprom.vox0_threshold, 2);
#endif #endif
//EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1); //EEPROM_ReadBuffer(0x1F80 + g_eeprom.mic_sensitivity, &Mic, 1);
//gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15; //g_eeprom.mic_sensitivity_tuning = (Mic < 32) ? Mic : 15;
gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY]; g_eeprom.mic_sensitivity_tuning = gMicGain_dB2[g_eeprom.mic_sensitivity];
{ {
struct struct
@ -775,22 +775,22 @@ void BOARD_EEPROM_LoadMoreSettings(void)
int16_t BK4819_XtalFreqLow; int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A; uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C; uint16_t EEPROM_1F8C;
uint8_t VOLUME_GAIN; uint8_t volume_gain;
uint8_t DAC_GAIN; uint8_t dac_gain;
} __attribute__((packed)) Misc; } __attribute__((packed)) Misc;
// radio 1 .. 04 00 46 00 50 00 2C 0E // radio 1 .. 04 00 46 00 50 00 2C 0E
// radio 2 .. 05 00 46 00 50 00 2C 0E // radio 2 .. 05 00 46 00 50 00 2C 0E
EEPROM_ReadBuffer(0x1F88, &Misc, 8); EEPROM_ReadBuffer(0x1F88, &Misc, 8);
gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0; g_eeprom.BK4819_xtal_freq_low = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0;
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF; g_eeprom_1F8A = Misc.EEPROM_1F8A & 0x01FF;
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF; g_eeprom_1F8C = Misc.EEPROM_1F8C & 0x01FF;
gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58; g_eeprom.volume_gain = (Misc.volume_gain < 64) ? Misc.volume_gain : 58;
gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8; g_eeprom.dac_gain = (Misc.dac_gain < 16) ? Misc.dac_gain : 8;
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW); BK4819_WriteRegister(BK4819_REG_3B, 22656 + g_eeprom.BK4819_xtal_freq_low);
// BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH); // BK4819_WriteRegister(BK4819_REG_3C, g_eeprom.BK4819_XTAL_FREQ_HIGH);
} }
} }
@ -873,10 +873,10 @@ void BOARD_FactoryReset(bool bIsAll)
for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++) for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++)
{ {
const uint32_t Frequency = gDefaultFrequencyTable[i]; const uint32_t Frequency = gDefaultFrequencyTable[i];
gRxVfo->freq_config_RX.Frequency = Frequency; gRxVfo->freq_config_rx.frequency = Frequency;
gRxVfo->freq_config_TX.Frequency = Frequency; gRxVfo->freq_config_tx.frequency = Frequency;
gRxVfo->Band = FREQUENCY_GetBand(Frequency); gRxVfo->band = FREQUENCY_GetBand(Frequency);
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2); SETTINGS_SaveChannel(USER_CHANNEL_FIRST + i, 0, gRxVfo, 2);
} }
} }
} }

10
dcs.c
View File

@ -58,12 +58,12 @@ static uint32_t DCS_CalculateGolay(uint32_t CodeWord)
return CodeWord | ((Word & 0x0FFE) << 11); return CodeWord | ((Word & 0x0FFE) << 11);
} }
uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option) uint32_t DCS_GetGolayCodeWord(dcs_code_type_t code_type, uint8_t Option)
{ {
uint32_t Code = DCS_CalculateGolay(DCS_Options[Option] + 0x800U); uint32_t code = DCS_CalculateGolay(DCS_Options[Option] + 0x800U);
if (CodeType == CODE_TYPE_REVERSE_DIGITAL) if (code_type == CODE_TYPE_REVERSE_DIGITAL)
Code ^= 0x7FFFFF; code ^= 0x7FFFFF;
return Code; return code;
} }
uint8_t DCS_GetCdcssCode(uint32_t Code) uint8_t DCS_GetCdcssCode(uint32_t Code)

6
dcs.h
View File

@ -19,7 +19,7 @@
#include <stdint.h> #include <stdint.h>
enum DCS_CodeType_t enum dcs_code_type_e
{ {
CODE_TYPE_OFF = 0, CODE_TYPE_OFF = 0,
CODE_TYPE_CONTINUOUS_TONE, CODE_TYPE_CONTINUOUS_TONE,
@ -27,7 +27,7 @@ enum DCS_CodeType_t
CODE_TYPE_REVERSE_DIGITAL CODE_TYPE_REVERSE_DIGITAL
}; };
typedef enum DCS_CodeType_t DCS_CodeType_t; typedef enum dcs_code_type_e dcs_code_type_t;
enum { enum {
CDCSS_POSITIVE_CODE = 1U, CDCSS_POSITIVE_CODE = 1U,
@ -37,7 +37,7 @@ enum {
extern const uint16_t CTCSS_Options[50]; extern const uint16_t CTCSS_Options[50];
extern const uint16_t DCS_Options[104]; extern const uint16_t DCS_Options[104];
uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option); uint32_t DCS_GetGolayCodeWord(dcs_code_type_t code_type, uint8_t Option);
uint8_t DCS_GetCdcssCode(uint32_t Code); uint8_t DCS_GetCdcssCode(uint32_t Code);
uint8_t DCS_GetCtcssCode(int Code); uint8_t DCS_GetCtcssCode(int Code);

View File

@ -22,15 +22,15 @@
// this is decremented once every 500ms // this is decremented once every 500ms
uint16_t gBacklightCountdown = 0; uint16_t gBacklightCountdown = 0;
void BACKLIGHT_TurnOn(void) void backlight_turn_on(void)
{ {
if (gEeprom.BACKLIGHT == 0) if (g_eeprom.backlight == 0)
return; return;
// turn the backlight ON // turn the backlight ON
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
switch (gEeprom.BACKLIGHT) switch (g_eeprom.backlight)
{ {
default: default:
case 1: // 5 sec case 1: // 5 sec

View File

@ -21,7 +21,7 @@
extern uint16_t gBacklightCountdown; extern uint16_t gBacklightCountdown;
void BACKLIGHT_TurnOn(void); void backlight_turn_on(void);
#endif #endif

View File

@ -31,7 +31,7 @@ static const uint16_t FSK_RogerTable[7] = {0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8
static uint16_t gBK4819_GpioOutState; static uint16_t gBK4819_GpioOutState;
bool gRxIdleMode; bool g_rx_idle_mode;
__inline uint16_t scale_freq(const uint16_t freq) __inline uint16_t scale_freq(const uint16_t freq)
{ {
@ -713,12 +713,12 @@ void BK4819_SetFrequency(uint32_t Frequency)
} }
void BK4819_SetupSquelch( void BK4819_SetupSquelch(
uint8_t SquelchOpenRSSIThresh, uint8_t squelch_open_RSSI_thresh,
uint8_t SquelchCloseRSSIThresh, uint8_t squelch_close_RSSI_thresh,
uint8_t SquelchOpenNoiseThresh, uint8_t squelch_open_noise_thresh,
uint8_t SquelchCloseNoiseThresh, uint8_t squelch_close_noise_thresh,
uint8_t SquelchCloseGlitchThresh, uint8_t squelch_close_glitch_thresh,
uint8_t SquelchOpenGlitchThresh) uint8_t squelch_open_glitch_thresh)
{ {
// REG_70 // REG_70
// //
@ -742,7 +742,7 @@ void BK4819_SetupSquelch(
// //
// 0 ~ 255 // 0 ~ 255
// //
BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | squelch_close_glitch_thresh);
// REG_4E // REG_4E
// //
@ -765,13 +765,13 @@ void BK4819_SetupSquelch(
(1u << 14) | // 1 ??? (1u << 14) | // 1 ???
(3u << 11) | // *5 squelch = open delay .. 0 ~ 7 (3u << 11) | // *5 squelch = open delay .. 0 ~ 7
(2u << 9) | // *3 squelch = close delay .. 0 ~ 3 (2u << 9) | // *3 squelch = close delay .. 0 ~ 3
SquelchOpenGlitchThresh); // 0 ~ 255 squelch_open_glitch_thresh); // 0 ~ 255
#else #else
// faster (but twitchier) // faster (but twitchier)
(1u << 14) | // 1 ??? (1u << 14) | // 1 ???
(2u << 11) | // *5 squelch = open delay .. 0 ~ 7 (2u << 11) | // *5 squelch = open delay .. 0 ~ 7
(1u << 9) | // *3 squelch = close delay .. 0 ~ 3 (1u << 9) | // *3 squelch = close delay .. 0 ~ 3
SquelchOpenGlitchThresh); // 0 ~ 255 squelch_open_glitch_thresh); // 0 ~ 255
#endif #endif
// REG_4F // REG_4F
@ -784,7 +784,7 @@ void BK4819_SetupSquelch(
// <6:0> 46 Ex-noise threshold for Squelch = open // <6:0> 46 Ex-noise threshold for Squelch = open
// 0 ~ 127 // 0 ~ 127
// //
BK4819_WriteRegister(BK4819_REG_4F, ((uint16_t)SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh); BK4819_WriteRegister(BK4819_REG_4F, ((uint16_t)squelch_close_noise_thresh << 8) | squelch_open_noise_thresh);
// REG_78 // REG_78
// //
@ -792,7 +792,7 @@ void BK4819_SetupSquelch(
// //
// <7:0> 70 RSSI threshold for Squelch = close 0.5dB/step // <7:0> 70 RSSI threshold for Squelch = close 0.5dB/step
// //
BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh); BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)squelch_open_RSSI_thresh << 8) | squelch_close_RSSI_thresh);
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
@ -1196,7 +1196,7 @@ void BK4819_ExitSubAu(void)
void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void) void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void)
{ {
if (gRxIdleMode) if (g_rx_idle_mode)
{ {
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true);
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
@ -1670,7 +1670,7 @@ uint8_t BK4819_GetDTMF_5TONE_Code(void)
return (BK4819_ReadRegister(BK4819_REG_0B) >> 8) & 0x0F; return (BK4819_ReadRegister(BK4819_REG_0B) >> 8) & 0x0F;
} }
uint8_t BK4819_GetCDCSSCodeType(void) uint8_t BK4819_get_CDCSS_code_type(void)
{ {
return (BK4819_ReadRegister(BK4819_REG_0C) >> 14) & 3u; return (BK4819_ReadRegister(BK4819_REG_0C) >> 14) & 3u;
} }

View File

@ -62,7 +62,7 @@ enum BK4819_CssScanResult_t
typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t; typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t;
extern bool gRxIdleMode; extern bool g_rx_idle_mode;
void BK4819_Init(void); void BK4819_Init(void);
uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register); uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register);
@ -150,7 +150,7 @@ void BK4819_StopScan(void);
uint8_t BK4819_GetDTMF_5TONE_Code(void); uint8_t BK4819_GetDTMF_5TONE_Code(void);
uint8_t BK4819_GetCDCSSCodeType(void); uint8_t BK4819_get_CDCSS_code_type(void);
uint8_t BK4819_GetCTCShift(void); uint8_t BK4819_GetCTCShift(void);
uint8_t BK4819_GetCTCType(void); uint8_t BK4819_GetCTCType(void);

View File

@ -22,10 +22,10 @@
#include "driver/i2c.h" #include "driver/i2c.h"
#include "misc.h" #include "misc.h"
KEY_Code_t gKeyReading0 = KEY_INVALID; key_code_t g_key_reading_0 = KEY_INVALID;
KEY_Code_t gKeyReading1 = KEY_INVALID; key_code_t g_key_reading_1 = KEY_INVALID;
uint16_t gDebounceCounter = 0; uint16_t g_debounce_counter = 0;
bool gWasFKeyPressed = false; bool g_was_f_key_pressed = false;
static const struct { static const struct {
@ -36,7 +36,7 @@ static const struct {
// We are very fortunate. // We are very fortunate.
// The key and pin defines fit together in a single u8, making this very efficient // The key and pin defines fit together in a single u8, making this very efficient
struct { struct {
KEY_Code_t key : 5; key_code_t key : 5;
uint8_t pin : 3; // Pin 6 is highest uint8_t pin : 3; // Pin 6 is highest
} pins[4]; } pins[4];
@ -92,9 +92,9 @@ static const struct {
} }
}; };
KEY_Code_t KEYBOARD_Poll(void) key_code_t KEYBOARD_Poll(void)
{ {
KEY_Code_t Key = KEY_INVALID; key_code_t Key = KEY_INVALID;
// if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) // if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
// return KEY_PTT; // return KEY_PTT;

View File

@ -21,7 +21,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
enum KEY_Code_e { enum key_code_e {
KEY_0 = 0, // 0 KEY_0 = 0, // 0
KEY_1, // 1 KEY_1, // 1
KEY_2, // 2 KEY_2, // 2
@ -43,14 +43,14 @@ enum KEY_Code_e {
KEY_SIDE1, // KEY_SIDE1, //
KEY_INVALID // KEY_INVALID //
}; };
typedef enum KEY_Code_e KEY_Code_t; typedef enum key_code_e key_code_t;
extern KEY_Code_t gKeyReading0; extern key_code_t g_key_reading_0;
extern KEY_Code_t gKeyReading1; extern key_code_t g_key_reading_1;
extern uint16_t gDebounceCounter; extern uint16_t g_debounce_counter;
extern bool gWasFKeyPressed; extern bool g_was_f_key_pressed;
KEY_Code_t KEYBOARD_Poll(void); key_code_t KEYBOARD_Poll(void);
#endif #endif

Binary file not shown.

Binary file not shown.

View File

@ -43,7 +43,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t;
#ifdef ENABLE_1250HZ_STEP #ifdef ENABLE_1250HZ_STEP
// includes 1.25kHz step // includes 1.25kHz step
enum STEP_Setting_t { enum step_setting_t {
STEP_1_25kHz = 0, STEP_1_25kHz = 0,
STEP_2_5kHz, STEP_2_5kHz,
STEP_6_25kHz, STEP_6_25kHz,
@ -54,7 +54,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t;
}; };
#else #else
// QS steps // QS steps
enum STEP_Setting_t { enum step_setting_t {
STEP_2_5kHz = 0, STEP_2_5kHz = 0,
STEP_5_0kHz, STEP_5_0kHz,
STEP_6_25kHz, STEP_6_25kHz,
@ -64,7 +64,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t;
STEP_8_33kHz STEP_8_33kHz
}; };
#endif #endif
typedef enum STEP_Setting_t STEP_Setting_t; typedef enum step_setting_t step_setting_t;
extern const uint16_t StepFrequencyTable[7]; extern const uint16_t StepFrequencyTable[7];

View File

@ -43,26 +43,26 @@ FUNCTION_Type_t gCurrentFunction;
void FUNCTION_Init(void) void FUNCTION_Init(void)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save))
#endif #endif
{ {
gCurrentCodeType = gSelectedCodeType; gCurrentcode_type = gSelectedcode_type;
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
gCurrentCodeType = gRxVfo->AM_mode ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType; gCurrentcode_type = gRxVfo->am_mode ? CODE_TYPE_OFF : gRxVfo->pRX->code_type;
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; gCurrentcode_type = CODE_TYPE_CONTINUOUS_TONE;
#endif #endif
DTMF_clear_RX(); DTMF_clear_RX();
g_CxCSS_TAIL_Found = false; g_CxCSS_tailL_found = false;
g_CDCSS_Lost = false; g_CDCSS_lost = false;
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;
@ -92,7 +92,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) if (bWasPowerSave && Function != FUNCTION_POWER_SAVE)
{ {
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
gRxIdleMode = false; g_rx_idle_mode = false;
UI_DisplayStatus(false); UI_DisplayStatus(false);
} }
@ -120,7 +120,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED ||
gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY)
{ {
gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2; gDTMF_auto_reset_time_500ms = g_eeprom.DTMF_auto_reset_time * 2;
} }
gUpdateStatus = true; gUpdateStatus = true;
@ -135,10 +135,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
break; break;
case FUNCTION_POWER_SAVE: case FUNCTION_POWER_SAVE:
gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; gPowerSave_10ms = g_eeprom.battery_save * 10;
gPowerSaveCountdownExpired = false; gPowerSaveCountdownExpired = false;
gRxIdleMode = true; g_rx_idle_mode = true;
gMonitor = false; gMonitor = false;
@ -173,7 +173,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
#endif #endif
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) if (gAlarmState == ALARM_STATE_TXALARM && g_eeprom.alarm_mode != ALARM_MODE_TONE)
{ {
gAlarmState = ALARM_STATE_ALARM; gAlarmState = ALARM_STATE_ALARM;
@ -208,8 +208,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
DTMF_Reply(); DTMF_Reply();
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) if (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO)
BK4819_PlaySingleTone(2525, 250, 0, gEeprom.DTMF_SIDE_TONE); BK4819_PlaySingleTone(2525, 250, 0, g_eeprom.DTMF_side_tone);
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState != ALARM_STATE_OFF) if (gAlarmState != ALARM_STATE_OFF)
@ -232,13 +232,13 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
} }
#endif #endif
if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) if (gCurrentVfo->scrambling_type > 0 && gSetting_ScrambleEnable)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); BK4819_EnableScramble(gCurrentVfo->scrambling_type - 1);
else else
BK4819_DisableScramble(); BK4819_DisableScramble();
if (gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3) if (gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3)
BACKLIGHT_TurnOn(); backlight_turn_on();
break; break;

View File

@ -125,7 +125,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
{ {
gUpdateStatus = true; gUpdateStatus = true;
gUpdateDisplay = true; gUpdateDisplay = true;
BACKLIGHT_TurnOn(); backlight_turn_on();
} }
gChargingWithTypeC = true; gChargingWithTypeC = true;

View File

@ -34,7 +34,7 @@
BOOT_Mode_t BOOT_GetMode(void) BOOT_Mode_t BOOT_GetMode(void)
{ {
unsigned int i; unsigned int i;
KEY_Code_t Keys[2]; key_code_t Keys[2];
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
@ -46,10 +46,10 @@ BOOT_Mode_t BOOT_GetMode(void)
if (Keys[0] == Keys[1]) if (Keys[0] == Keys[1])
{ {
gKeyReading0 = Keys[0]; g_key_reading_0 = Keys[0];
gKeyReading1 = Keys[0]; g_key_reading_1 = Keys[0];
gDebounceCounter = 2; g_debounce_counter = 2;
if (Keys[0] == KEY_SIDE1) if (Keys[0] == KEY_SIDE1)
return BOOT_MODE_F_LOCK; return BOOT_MODE_F_LOCK;
@ -73,22 +73,22 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
else else
if (Mode == BOOT_MODE_AIRCOPY) if (Mode == BOOT_MODE_AIRCOPY)
{ {
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF; g_eeprom.dual_watch = DUAL_WATCH_OFF;
gEeprom.BATTERY_SAVE = 0; g_eeprom.battery_save = 0;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
gEeprom.VOX_SWITCH = false; g_eeprom.vox_switch = false;
#endif #endif
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
gEeprom.AUTO_KEYPAD_LOCK = false; g_eeprom.auto_keypad_lock = false;
gEeprom.KEY_1_SHORT_PRESS_ACTION = ACTION_OPT_NONE; g_eeprom.key1_short_press_action = ACTION_OPT_NONE;
gEeprom.KEY_1_LONG_PRESS_ACTION = ACTION_OPT_NONE; g_eeprom.key1_long_press_action = ACTION_OPT_NONE;
gEeprom.KEY_2_SHORT_PRESS_ACTION = ACTION_OPT_NONE; g_eeprom.key2_short_press_action = ACTION_OPT_NONE;
gEeprom.KEY_2_LONG_PRESS_ACTION = ACTION_OPT_NONE; g_eeprom.key2_long_press_action = ACTION_OPT_NONE;
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500); RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500);
gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_WIDE; gRxVfo->channel_bandwidth = BANDWIDTH_WIDE;
gRxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW; gRxVfo->output_power = OUTPUT_POWER_LOW;
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);

22
main.c
View File

@ -73,7 +73,7 @@ void Main(void)
// Not implementing authentic device checks // Not implementing authentic device checks
memset(&gEeprom, 0, sizeof(gEeprom)); memset(&g_eeprom, 0, sizeof(g_eeprom));
memset(gDTMF_String, '-', sizeof(gDTMF_String)); memset(gDTMF_String, '-', sizeof(gDTMF_String));
gDTMF_String[sizeof(gDTMF_String) - 1] = 0; gDTMF_String[sizeof(gDTMF_String) - 1] = 0;
@ -115,23 +115,23 @@ void Main(void)
BootMode != BOOT_MODE_NORMAL) BootMode != BOOT_MODE_NORMAL)
{ // keys are pressed { // keys are pressed
UI_DisplayReleaseKeys(); UI_DisplayReleaseKeys();
BACKLIGHT_TurnOn(); backlight_turn_on();
i = 0; i = 0;
while (i < 50) // 500ms while (i < 50) // 500ms
{ {
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0; i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);
} }
gKeyReading0 = KEY_INVALID; g_key_reading_0 = KEY_INVALID;
gKeyReading1 = KEY_INVALID; g_key_reading_1 = KEY_INVALID;
gDebounceCounter = 0; g_debounce_counter = 0;
} }
if (!gChargingWithTypeC && gBatteryDisplayLevel == 0) if (!gChargingWithTypeC && gBatteryDisplayLevel == 0)
{ {
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
if (gEeprom.BACKLIGHT < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) if (g_eeprom.backlight < (ARRAY_SIZE(gSubMenu_backlight) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
else else
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
@ -142,9 +142,9 @@ void Main(void)
{ {
UI_DisplayWelcome(); UI_DisplayWelcome();
BACKLIGHT_TurnOn(); backlight_turn_on();
if (gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_NONE) if (g_eeprom.pwr_on_display_mode != PWR_ON_DISPLAY_MODE_NONE)
{ // 2.55 second boot-up screen { // 2.55 second boot-up screen
while (boot_counter_10ms > 0) while (boot_counter_10ms > 0)
{ {
@ -161,7 +161,7 @@ void Main(void)
} }
#ifdef ENABLE_PWRON_PASSWORD #ifdef ENABLE_PWRON_PASSWORD
if (gEeprom.POWER_ON_PASSWORD < 1000000) if (g_eeprom.power_on_password < 1000000)
{ {
bIsInLockScreen = true; bIsInLockScreen = true;
UI_DisplayLock(); UI_DisplayLock();
@ -181,8 +181,8 @@ void Main(void)
AUDIO_SetVoiceID(0, VOICE_ID_WELCOME); AUDIO_SetVoiceID(0, VOICE_ID_WELCOME);
Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO]; Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
if (IS_MR_CHANNEL(Channel)) if (IS_USER_CHANNEL(Channel))
{ {
AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(2, Channel + 1); AUDIO_SetDigitVoice(2, Channel + 1);

54
misc.c
View File

@ -113,17 +113,17 @@ bool bHasCustomAesKey;
uint32_t gChallenge[4]; uint32_t gChallenge[4];
uint8_t gTryCount; uint8_t gTryCount;
uint8_t gEEPROM_1EC0_0[8]; uint8_t g_eeprom_1EC0_0[8];
uint8_t gEEPROM_1EC0_1[8]; uint8_t g_eeprom_1EC0_1[8];
uint8_t gEEPROM_1EC0_2[8]; uint8_t g_eeprom_1EC0_2[8];
uint8_t gEEPROM_1EC0_3[8]; uint8_t g_eeprom_1EC0_3[8];
uint16_t gEEPROM_RSSI_CALIB[2][4]; uint16_t g_eeprom_RSSI_CALIB[2][4];
uint16_t gEEPROM_1F8A; uint16_t g_eeprom_1F8A;
uint16_t gEEPROM_1F8C; uint16_t g_eeprom_1F8C;
uint8_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1]; uint8_t gUSER_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms; volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
@ -193,25 +193,25 @@ bool gFlagSaveChannel;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
bool gFlagSaveFM; bool gFlagSaveFM;
#endif #endif
bool g_CDCSS_Lost; bool g_CDCSS_lost;
uint8_t gCDCSSCodeType; uint8_t g_CDCSS_code_type;
bool g_CTCSS_Lost; bool g_CTCSS_lost;
bool g_CxCSS_TAIL_Found; bool g_CxCSS_tailL_found;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
bool g_VOX_Lost; bool g_vox_lost;
bool gVOX_NoiseDetected; bool gVOX_NoiseDetected;
uint16_t gVoxResumeCountdown; uint16_t gVoxResumeCountdown;
uint16_t gVoxPauseCountdown; uint16_t g_vox_pause_count_down;
#endif #endif
bool g_SquelchLost; bool g_SquelchLost;
uint8_t gFlashLightState; uint8_t gFlashLightState;
volatile uint16_t gFlashLightBlinkCounter; volatile uint16_t gFlashLightBlinkCounter;
bool gFlagEndTransmission; bool gFlagEndTransmission;
uint16_t gLowBatteryCountdown; uint16_t gLowBatteryCountdown;
uint8_t gNextMrChannel; uint8_t gNextChannel;
ReceptionMode_t gRxReceptionMode; ReceptionMode_t gRxReceptionMode;
uint8_t gRestoreMrChannel; uint8_t gRestoreUSER_CHANNEL;
enum scan_next_chan_t gCurrentScanList; enum scan_next_chan_t gCurrentScanList;
uint32_t gRestoreFrequency; uint32_t gRestoreFrequency;
@ -224,7 +224,7 @@ bool gKeyBeingHeld;
bool gPttIsPressed; bool gPttIsPressed;
uint8_t gPttDebounceCounter; uint8_t gPttDebounceCounter;
uint8_t gMenuListCount; uint8_t gMenuListCount;
uint8_t gBackup_CROSS_BAND_RX_TX; uint8_t gBackup_cross_vfo_rx_tx;
uint8_t gScanDelay_10ms; uint8_t gScanDelay_10ms;
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
uint8_t gAircopySendCountdown; uint8_t gAircopySendCountdown;
@ -266,34 +266,34 @@ uint8_t gIsLocked = 0xFF;
unsigned int get_rx_VFO(void) unsigned int get_rx_VFO(void)
{ {
unsigned int rx_vfo = gEeprom.TX_VFO; unsigned int rx_vfo = g_eeprom.tx_vfo;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B)
rx_vfo = 0; rx_vfo = 0;
else else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A)
rx_vfo = 1; rx_vfo = 1;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B)
rx_vfo = 1; rx_vfo = 1;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A)
rx_vfo = 0; rx_vfo = 0;
return rx_vfo; return rx_vfo;
} }
unsigned int get_tx_VFO(void) unsigned int get_tx_VFO(void)
{ {
unsigned int tx_vfo = gEeprom.TX_VFO; unsigned int tx_vfo = g_eeprom.tx_vfo;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B)
tx_vfo = 1; tx_vfo = 1;
else else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A)
tx_vfo = 0; tx_vfo = 0;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B)
tx_vfo = 1; tx_vfo = 1;
else else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A)
tx_vfo = 0; tx_vfo = 0;
return tx_vfo; return tx_vfo;
} }

46
misc.h
View File

@ -32,16 +32,16 @@
#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_USER_CHANNEL(x) ((x) >= USER_CHANNEL_FIRST && (x) <= USER_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) >= USER_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
enum { enum {
MR_CHANNEL_FIRST = 0, USER_CHANNEL_FIRST = 0,
MR_CHANNEL_LAST = 199u, USER_CHANNEL_LAST = 199u,
FREQ_CHANNEL_FIRST = 200u, FREQ_CHANNEL_FIRST = 200u,
FREQ_CHANNEL_LAST = 206u, FREQ_CHANNEL_LAST = 206u,
NOAA_CHANNEL_FIRST = 207u, NOAA_CHANNEL_FIRST = 207u,
@ -87,8 +87,8 @@ typedef enum CssScanMode_t CssScanMode_t;
enum scan_next_chan_t { enum scan_next_chan_t {
SCAN_NEXT_CHAN_SCANLIST1 = 0, SCAN_NEXT_CHAN_SCANLIST1 = 0,
SCAN_NEXT_CHAN_SCANLIST2, SCAN_NEXT_CHAN_SCANLIST2,
SCAN_NEXT_CHAN_DUAL_WATCH, SCAN_NEXT_CHAN_dual_watch,
SCAN_NEXT_CHAN_MR, SCAN_NEXT_CHAN_USER,
SCAN_NEXT_NUM SCAN_NEXT_NUM
}; };
typedef enum scan_next_chan_t scan_next_chan_t; typedef enum scan_next_chan_t scan_next_chan_t;
@ -187,17 +187,17 @@ 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 uint8_t g_eeprom_1EC0_0[8];
extern uint8_t gEEPROM_1EC0_1[8]; extern uint8_t g_eeprom_1EC0_1[8];
extern uint8_t gEEPROM_1EC0_2[8]; extern uint8_t g_eeprom_1EC0_2[8];
extern uint8_t gEEPROM_1EC0_3[8]; extern uint8_t g_eeprom_1EC0_3[8];
extern uint16_t gEEPROM_RSSI_CALIB[2][4]; extern uint16_t g_eeprom_RSSI_CALIB[2][4];
extern uint16_t gEEPROM_1F8A; extern uint16_t g_eeprom_1F8A;
extern uint16_t gEEPROM_1F8C; extern uint16_t g_eeprom_1F8C;
extern uint8_t gMR_ChannelAttributes[207]; extern uint8_t gUSER_ChannelAttributes[207];
extern volatile uint16_t gBatterySaveCountdown_10ms; extern volatile uint16_t gBatterySaveCountdown_10ms;
@ -267,25 +267,25 @@ extern bool gFlagSaveChannel;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
extern bool gFlagSaveFM; extern bool gFlagSaveFM;
#endif #endif
extern bool g_CDCSS_Lost; extern bool g_CDCSS_lost;
extern uint8_t gCDCSSCodeType; extern uint8_t g_CDCSS_code_type;
extern bool g_CTCSS_Lost; extern bool g_CTCSS_lost;
extern bool g_CxCSS_TAIL_Found; extern bool g_CxCSS_tailL_found;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
extern bool g_VOX_Lost; extern bool g_vox_lost;
extern bool gVOX_NoiseDetected; extern bool gVOX_NoiseDetected;
extern uint16_t gVoxResumeCountdown; extern uint16_t gVoxResumeCountdown;
extern uint16_t gVoxPauseCountdown; extern uint16_t g_vox_pause_count_down;
#endif #endif
extern bool g_SquelchLost; extern bool g_SquelchLost;
extern uint8_t gFlashLightState; extern uint8_t gFlashLightState;
extern volatile uint16_t gFlashLightBlinkCounter; extern volatile uint16_t gFlashLightBlinkCounter;
extern bool gFlagEndTransmission; extern bool gFlagEndTransmission;
extern uint16_t gLowBatteryCountdown; extern uint16_t gLowBatteryCountdown;
extern uint8_t gNextMrChannel; extern uint8_t gNextChannel;
extern ReceptionMode_t gRxReceptionMode; extern ReceptionMode_t gRxReceptionMode;
extern uint8_t gRestoreMrChannel; extern uint8_t gRestoreUSER_CHANNEL;
extern scan_next_chan_t gCurrentScanList; extern scan_next_chan_t gCurrentScanList;
extern uint32_t gRestoreFrequency; extern uint32_t gRestoreFrequency;
@ -296,7 +296,7 @@ extern bool gKeyBeingHeld;
extern bool gPttIsPressed; extern bool gPttIsPressed;
extern uint8_t gPttDebounceCounter; extern uint8_t gPttDebounceCounter;
extern uint8_t gMenuListCount; extern uint8_t gMenuListCount;
extern uint8_t gBackup_CROSS_BAND_RX_TX; extern uint8_t gBackup_cross_vfo_rx_tx;
extern uint8_t gScanDelay_10ms; extern uint8_t gScanDelay_10ms;
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
extern uint8_t gAircopySendCountdown; extern uint8_t gAircopySendCountdown;

462
radio.c
View File

@ -35,14 +35,14 @@
#include "settings.h" #include "settings.h"
#include "ui/menu.h" #include "ui/menu.h"
VFO_Info_t *gTxVfo; VFO_Info_t *gTxVfo;
VFO_Info_t *gRxVfo; VFO_Info_t *gRxVfo;
VFO_Info_t *gCurrentVfo; VFO_Info_t *gCurrentVfo;
DCS_CodeType_t gSelectedCodeType; dcs_code_type_t gSelectedcode_type;
DCS_CodeType_t gCurrentCodeType; dcs_code_type_t gCurrentcode_type;
uint8_t gSelectedCode; uint8_t gSelectedCode;
STEP_Setting_t gStepSetting; step_setting_t gStepSetting;
VfoState_t VfoState[2]; VfoState_t VfoState[2];
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
{ // return true if the channel appears valid { // return true if the channel appears valid
@ -51,12 +51,12 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
uint8_t PriorityCh1; uint8_t PriorityCh1;
uint8_t PriorityCh2; uint8_t PriorityCh2;
if (Channel > MR_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
return false; return false;
Attributes = gMR_ChannelAttributes[Channel]; Attributes = gUSER_ChannelAttributes[Channel];
if ((Attributes & MR_CH_BAND_MASK) > BAND7_470MHz) if ((Attributes & USER_CH_BAND_MASK) > BAND7_470MHz)
return false; return false;
if (bCheckScanList) if (bCheckScanList)
@ -64,19 +64,19 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
switch (VFO) switch (VFO)
{ {
case 0: case 0:
if ((Attributes & MR_CH_SCANLIST1) == 0) if ((Attributes & USER_CH_SCANLIST1) == 0)
return false; return false;
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0]; PriorityCh1 = g_eeprom.scan_list_priority_ch1[0];
PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[0]; PriorityCh2 = g_eeprom.scan_list_priority_ch2[0];
break; break;
case 1: case 1:
if ((Attributes & MR_CH_SCANLIST2) == 0) if ((Attributes & USER_CH_SCANLIST2) == 0)
return false; return false;
PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1]; PriorityCh1 = g_eeprom.scan_list_priority_ch1[1];
PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[1]; PriorityCh2 = g_eeprom.scan_list_priority_ch2[1];
break; break;
default: default:
@ -97,13 +97,13 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
{ {
unsigned int i; unsigned int i;
for (i = 0; i <= MR_CHANNEL_LAST; i++) for (i = 0; i <= USER_CHANNEL_LAST; i++)
{ {
if (Channel == 0xFF) if (Channel == 0xFF)
Channel = MR_CHANNEL_LAST; Channel = USER_CHANNEL_LAST;
else else
if (Channel > MR_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
Channel = MR_CHANNEL_FIRST; Channel = USER_CHANNEL_FIRST;
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO))
return Channel; return Channel;
@ -118,22 +118,22 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t
{ {
memset(pInfo, 0, sizeof(*pInfo)); memset(pInfo, 0, sizeof(*pInfo));
pInfo->Band = FREQUENCY_GetBand(Frequency); pInfo->band = FREQUENCY_GetBand(Frequency);
pInfo->SCANLIST1_PARTICIPATION = true; pInfo->scanlist_1_participation = true;
pInfo->SCANLIST2_PARTICIPATION = true; pInfo->scanlist_2_participation = true;
pInfo->STEP_SETTING = STEP_12_5kHz; pInfo->step_setting = STEP_12_5kHz;
pInfo->StepFrequency = StepFrequencyTable[pInfo->STEP_SETTING]; pInfo->step_freq = StepFrequencyTable[pInfo->step_setting];
pInfo->CHANNEL_SAVE = ChannelSave; pInfo->channel_save = ChannelSave;
pInfo->FrequencyReverse = false; pInfo->frequency_reverse = false;
pInfo->OUTPUT_POWER = OUTPUT_POWER_LOW; pInfo->output_power = OUTPUT_POWER_LOW;
pInfo->freq_config_RX.Frequency = Frequency; pInfo->freq_config_rx.frequency = Frequency;
pInfo->freq_config_TX.Frequency = Frequency; pInfo->freq_config_tx.frequency = Frequency;
pInfo->pRX = &pInfo->freq_config_RX; pInfo->pRX = &pInfo->freq_config_rx;
pInfo->pTX = &pInfo->freq_config_TX; pInfo->pTX = &pInfo->freq_config_tx;
pInfo->Compander = 0; // off pInfo->compander = 0; // off
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
pInfo->AM_mode = 1; pInfo->am_mode = 1;
RADIO_ConfigureSquelchAndOutputPower(pInfo); RADIO_ConfigureSquelchAndOutputPower(pInfo);
} }
@ -146,64 +146,64 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
bool bParticipation2; bool bParticipation2;
uint16_t Base; uint16_t Base;
uint32_t Frequency; uint32_t Frequency;
VFO_Info_t *pRadio = &gEeprom.VfoInfo[VFO]; VFO_Info_t *pRadio = &g_eeprom.VfoInfo[VFO];
if (!gSetting_350EN) if (!gSetting_350EN)
{ {
if (gEeprom.FreqChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) if (g_eeprom.freq_channel[VFO] == (FREQ_CHANNEL_LAST - 2))
gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_LAST - 1; g_eeprom.freq_channel[VFO] = FREQ_CHANNEL_LAST - 1;
if (gEeprom.ScreenChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) if (g_eeprom.screen_channel[VFO] == (FREQ_CHANNEL_LAST - 2))
gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_LAST - 1; g_eeprom.screen_channel[VFO] = FREQ_CHANNEL_LAST - 1;
} }
Channel = gEeprom.ScreenChannel[VFO]; Channel = g_eeprom.screen_channel[VFO];
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, g_eeprom.screen_channel[VFO], NoaaFrequencyTable[Channel - NOAA_CHANNEL_FIRST]);
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF)
return; return;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
gUpdateStatus = true; gUpdateStatus = true;
return; return;
} }
#endif #endif
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ {
Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO); Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO);
if (Channel == 0xFF) if (Channel == 0xFF)
{ {
Channel = gEeprom.FreqChannel[VFO]; Channel = g_eeprom.freq_channel[VFO];
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO]; g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO];
} }
else else
{ {
gEeprom.ScreenChannel[VFO] = Channel; g_eeprom.screen_channel[VFO] = Channel;
gEeprom.MrChannel[VFO] = Channel; g_eeprom.user_channel[VFO] = Channel;
} }
} }
} }
else else
Channel = FREQ_CHANNEL_LAST - 1; Channel = FREQ_CHANNEL_LAST - 1;
Attributes = gMR_ChannelAttributes[Channel]; Attributes = gUSER_ChannelAttributes[Channel];
if (Attributes == 0xFF) if (Attributes == 0xFF)
{ // invalid/unused channel { // invalid/unused channel
uint8_t Index; uint8_t Index;
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ {
Channel = gEeprom.FreqChannel[VFO]; Channel = g_eeprom.freq_channel[VFO];
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO]; g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO];
} }
Index = Channel - FREQ_CHANNEL_FIRST; Index = Channel - FREQ_CHANNEL_FIRST;
@ -212,30 +212,30 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
return; return;
} }
Band = Attributes & MR_CH_BAND_MASK; Band = Attributes & USER_CH_BAND_MASK;
if (Band > BAND7_470MHz) if (Band > BAND7_470MHz)
{ {
Band = BAND6_400MHz; Band = BAND6_400MHz;
} }
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ {
gEeprom.VfoInfo[VFO].Band = Band; g_eeprom.VfoInfo[VFO].band = Band;
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = !!(Attributes & MR_CH_SCANLIST1); g_eeprom.VfoInfo[VFO].scanlist_1_participation = !!(Attributes & USER_CH_SCANLIST1);
bParticipation2 = !!(Attributes & MR_CH_SCANLIST2); bParticipation2 = !!(Attributes & USER_CH_SCANLIST2);
} }
else else
{ {
Band = Channel - FREQ_CHANNEL_FIRST; Band = Channel - FREQ_CHANNEL_FIRST;
gEeprom.VfoInfo[VFO].Band = Band; g_eeprom.VfoInfo[VFO].band = Band;
bParticipation2 = true; bParticipation2 = true;
gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = true; g_eeprom.VfoInfo[VFO].scanlist_1_participation = true;
} }
gEeprom.VfoInfo[VFO].SCANLIST2_PARTICIPATION = bParticipation2; g_eeprom.VfoInfo[VFO].scanlist_2_participation = bParticipation2;
gEeprom.VfoInfo[VFO].CHANNEL_SAVE = Channel; g_eeprom.VfoInfo[VFO].channel_save = Channel;
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
Base = Channel * 16; Base = Channel * 16;
else else
Base = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16); Base = 0x0C80 + ((Channel - FREQ_CHANNEL_FIRST) * 32) + (VFO * 16);
@ -250,31 +250,31 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data)); EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data));
Tmp = Data[3] & 0x0F; Tmp = Data[3] & 0x0F;
if (Tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB) if (Tmp > TX_OFFSET_FREQ_DIR_SUB)
Tmp = 0; Tmp = 0;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp; g_eeprom.VfoInfo[VFO].tx_offset_freq_dir = Tmp;
gEeprom.VfoInfo[VFO].AM_mode = (Data[3] >> 4) & 1u; g_eeprom.VfoInfo[VFO].am_mode = (Data[3] >> 4) & 1u;
Tmp = Data[6]; Tmp = Data[6];
if (Tmp >= ARRAY_SIZE(StepFrequencyTable)) if (Tmp >= ARRAY_SIZE(StepFrequencyTable))
Tmp = STEP_12_5kHz; Tmp = STEP_12_5kHz;
gEeprom.VfoInfo[VFO].STEP_SETTING = Tmp; g_eeprom.VfoInfo[VFO].step_setting = Tmp;
gEeprom.VfoInfo[VFO].StepFrequency = StepFrequencyTable[Tmp]; g_eeprom.VfoInfo[VFO].step_freq = StepFrequencyTable[Tmp];
Tmp = Data[7]; Tmp = Data[7];
if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1)) if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1))
Tmp = 0; Tmp = 0;
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = Tmp; g_eeprom.VfoInfo[VFO].scrambling_type = Tmp;
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = (Data[2] >> 0) & 0x0F; g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = (Data[2] >> 0) & 0x0F;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = (Data[2] >> 4) & 0x0F; g_eeprom.VfoInfo[VFO].freq_config_tx.code_type = (Data[2] >> 4) & 0x0F;
Tmp = Data[0]; Tmp = Data[0];
switch (gEeprom.VfoInfo[VFO].freq_config_RX.CodeType) switch (g_eeprom.VfoInfo[VFO].freq_config_rx.code_type)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF; g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = CODE_TYPE_OFF;
Tmp = 0; Tmp = 0;
break; break;
@ -289,14 +289,14 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Tmp = 0; Tmp = 0;
break; break;
} }
gEeprom.VfoInfo[VFO].freq_config_RX.Code = Tmp; g_eeprom.VfoInfo[VFO].freq_config_rx.code = Tmp;
Tmp = Data[1]; Tmp = Data[1];
switch (gEeprom.VfoInfo[VFO].freq_config_TX.CodeType) switch (g_eeprom.VfoInfo[VFO].freq_config_tx.code_type)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; g_eeprom.VfoInfo[VFO].freq_config_tx.code_type = CODE_TYPE_OFF;
Tmp = 0; Tmp = 0;
break; break;
@ -311,55 +311,55 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Tmp = 0; Tmp = 0;
break; break;
} }
gEeprom.VfoInfo[VFO].freq_config_TX.Code = Tmp; g_eeprom.VfoInfo[VFO].freq_config_tx.code = Tmp;
if (Data[4] == 0xFF) if (Data[4] == 0xFF)
{ {
gEeprom.VfoInfo[VFO].FrequencyReverse = false; g_eeprom.VfoInfo[VFO].frequency_reverse = false;
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE; g_eeprom.VfoInfo[VFO].channel_bandwidth = BK4819_FILTER_BW_WIDE;
gEeprom.VfoInfo[VFO].OUTPUT_POWER = OUTPUT_POWER_LOW; g_eeprom.VfoInfo[VFO].output_power = OUTPUT_POWER_LOW;
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = false; g_eeprom.VfoInfo[VFO].busy_channel_lock = false;
} }
else else
{ {
const uint8_t d4 = Data[4]; const uint8_t d4 = Data[4];
gEeprom.VfoInfo[VFO].FrequencyReverse = !!((d4 >> 0) & 1u); g_eeprom.VfoInfo[VFO].frequency_reverse = !!((d4 >> 0) & 1u);
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u); g_eeprom.VfoInfo[VFO].channel_bandwidth = !!((d4 >> 1) & 1u);
gEeprom.VfoInfo[VFO].OUTPUT_POWER = ((d4 >> 2) & 3u); g_eeprom.VfoInfo[VFO].output_power = ((d4 >> 2) & 3u);
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u); g_eeprom.VfoInfo[VFO].busy_channel_lock = !!((d4 >> 4) & 1u);
} }
if (Data[5] == 0xFF) if (Data[5] == 0xFF)
{ {
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = false;
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; g_eeprom.VfoInfo[VFO].DTMF_ptt_id_tx_mode = PTT_ID_OFF;
} }
else else
{ {
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = ((Data[5] >> 0) & 1u) ? true : false; g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = ((Data[5] >> 0) & 1u) ? true : false;
gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = ((Data[5] >> 1) & 7u); g_eeprom.VfoInfo[VFO].DTMF_ptt_id_tx_mode = ((Data[5] >> 1) & 7u);
} }
// *************** // ***************
struct struct
{ {
uint32_t Frequency; uint32_t frequency;
uint32_t Offset; uint32_t offset;
} __attribute__((packed)) Info; } __attribute__((packed)) info;
EEPROM_ReadBuffer(Base, &Info, sizeof(Info)); EEPROM_ReadBuffer(Base, &info, sizeof(info));
pRadio->freq_config_RX.Frequency = Info.Frequency; pRadio->freq_config_rx.frequency = info.frequency;
if (Info.Offset >= 100000000) if (info.offset >= 100000000)
Info.Offset = 1000000; info.offset = 1000000;
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset; g_eeprom.VfoInfo[VFO].tx_offset_freq = info.offset;
// *************** // ***************
} }
Frequency = pRadio->freq_config_RX.Frequency; Frequency = pRadio->freq_config_rx.frequency;
#if 1 #if 1
// fix previously set incorrect band // fix previously set incorrect band
@ -373,52 +373,52 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Frequency = frequencyBandTable[Band].upper; Frequency = frequencyBandTable[Band].upper;
else else
if (Channel >= FREQ_CHANNEL_FIRST) if (Channel >= FREQ_CHANNEL_FIRST)
Frequency = FREQUENCY_FloorToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency, frequencyBandTable[Band].lower); Frequency = FREQUENCY_FloorToStep(Frequency, g_eeprom.VfoInfo[VFO].step_freq, frequencyBandTable[Band].lower);
pRadio->freq_config_RX.Frequency = Frequency; pRadio->freq_config_rx.frequency = Frequency;
if (Frequency >= 10800000 && Frequency < 13600000) if (Frequency >= 10800000 && Frequency < 13600000)
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; g_eeprom.VfoInfo[VFO].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;
else else
if (Channel > MR_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = FREQUENCY_FloorToStep(gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY, gEeprom.VfoInfo[VFO].StepFrequency, 0); g_eeprom.VfoInfo[VFO].tx_offset_freq = FREQUENCY_FloorToStep(g_eeprom.VfoInfo[VFO].tx_offset_freq, g_eeprom.VfoInfo[VFO].step_freq, 0);
RADIO_ApplyOffset(pRadio); RADIO_ApplyOffset(pRadio);
memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name)); memset(g_eeprom.VfoInfo[VFO].name, 0, sizeof(g_eeprom.VfoInfo[VFO].name));
if (Channel < MR_CHANNEL_LAST) if (Channel < USER_CHANNEL_LAST)
{ // 16 bytes allocated to the channel name but only 10 used, the rest are 0's { // 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(0x0F50 + (Channel * 16), g_eeprom.VfoInfo[VFO].name + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 8, 2); EEPROM_ReadBuffer(0x0F58 + (Channel * 16), g_eeprom.VfoInfo[VFO].name + 8, 2);
} }
if (!gEeprom.VfoInfo[VFO].FrequencyReverse) if (!g_eeprom.VfoInfo[VFO].frequency_reverse)
{ {
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_RX; g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_rx;
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_TX; g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_tx;
} }
else else
{ {
gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_TX; g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_tx;
gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_RX; g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_rx;
} }
if (!gSetting_350EN) if (!gSetting_350EN)
{ {
FREQ_Config_t *pConfig = gEeprom.VfoInfo[VFO].pRX; FREQ_Config_t *pConfig = g_eeprom.VfoInfo[VFO].pRX;
if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000) if (pConfig->frequency >= 35000000 && pConfig->frequency < 40000000)
pConfig->Frequency = 43300000; pConfig->frequency = 43300000;
} }
if (gEeprom.VfoInfo[VFO].AM_mode) if (g_eeprom.VfoInfo[VFO].am_mode)
{ // freq/chan is in AM mode { // freq/chan is in AM mode
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0; g_eeprom.VfoInfo[VFO].scrambling_type = 0;
// gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB // g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = false; // no reason to disable DTMF decoding, aircraft use it on SSB
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF; g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = CODE_TYPE_OFF;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; g_eeprom.VfoInfo[VFO].freq_config_tx.code_type = CODE_TYPE_OFF;
} }
gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; g_eeprom.VfoInfo[VFO].compander = (Attributes & USER_CH_COMPAND) >> 4;
RADIO_ConfigureSquelchAndOutputPower(pRadio); RADIO_ConfigureSquelchAndOutputPower(pRadio);
} }
@ -431,38 +431,38 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
// ******************************* // *******************************
// squelch // squelch
Band = FREQUENCY_GetBand(pInfo->pRX->Frequency); Band = FREQUENCY_GetBand(pInfo->pRX->frequency);
uint16_t Base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00; uint16_t Base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00;
if (gEeprom.SQUELCH_LEVEL == 0) if (g_eeprom.squelch_level == 0)
{ // squelch == 0 (off) { // squelch == 0 (off)
pInfo->SquelchOpenRSSIThresh = 0; // 0 ~ 255 pInfo->squelch_open_RSSI_thresh = 0; // 0 ~ 255
pInfo->SquelchOpenNoiseThresh = 127; // 127 ~ 0 pInfo->squelch_open_noise_thresh = 127; // 127 ~ 0
pInfo->SquelchCloseGlitchThresh = 255; // 255 ~ 0 pInfo->squelch_close_glitch_thresh = 255; // 255 ~ 0
pInfo->SquelchCloseRSSIThresh = 0; // 0 ~ 255 pInfo->squelch_close_RSSI_thresh = 0; // 0 ~ 255
pInfo->SquelchCloseNoiseThresh = 127; // 127 ~ 0 pInfo->squelch_close_noise_thresh = 127; // 127 ~ 0
pInfo->SquelchOpenGlitchThresh = 255; // 255 ~ 0 pInfo->squelch_open_glitch_thresh = 255; // 255 ~ 0
} }
else else
{ // squelch >= 1 { // squelch >= 1
Base += gEeprom.SQUELCH_LEVEL; // my eeprom squelch-1 Base += g_eeprom.squelch_level; // my eeprom squelch-1
// VHF UHF // VHF UHF
EEPROM_ReadBuffer(Base + 0x00, &pInfo->SquelchOpenRSSIThresh, 1); // 50 10 EEPROM_ReadBuffer(Base + 0x00, &pInfo->squelch_open_RSSI_thresh, 1); // 50 10
EEPROM_ReadBuffer(Base + 0x10, &pInfo->SquelchCloseRSSIThresh, 1); // 40 5 EEPROM_ReadBuffer(Base + 0x10, &pInfo->squelch_close_RSSI_thresh, 1); // 40 5
EEPROM_ReadBuffer(Base + 0x20, &pInfo->SquelchOpenNoiseThresh, 1); // 65 90 EEPROM_ReadBuffer(Base + 0x20, &pInfo->squelch_open_noise_thresh, 1); // 65 90
EEPROM_ReadBuffer(Base + 0x30, &pInfo->SquelchCloseNoiseThresh, 1); // 70 100 EEPROM_ReadBuffer(Base + 0x30, &pInfo->squelch_close_noise_thresh, 1); // 70 100
EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90 EEPROM_ReadBuffer(Base + 0x40, &pInfo->squelch_close_glitch_thresh, 1); // 90 90
EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100 EEPROM_ReadBuffer(Base + 0x50, &pInfo->squelch_open_glitch_thresh, 1); // 100 100
uint16_t rssi_open = pInfo->SquelchOpenRSSIThresh; uint16_t rssi_open = pInfo->squelch_open_RSSI_thresh;
uint16_t rssi_close = pInfo->SquelchCloseRSSIThresh; uint16_t rssi_close = pInfo->squelch_close_RSSI_thresh;
uint16_t noise_open = pInfo->SquelchOpenNoiseThresh; uint16_t noise_open = pInfo->squelch_open_noise_thresh;
uint16_t noise_close = pInfo->SquelchCloseNoiseThresh; uint16_t noise_close = pInfo->squelch_close_noise_thresh;
uint16_t glitch_open = pInfo->SquelchOpenGlitchThresh; uint16_t glitch_open = pInfo->squelch_open_glitch_thresh;
uint16_t glitch_close = pInfo->SquelchCloseGlitchThresh; uint16_t glitch_close = pInfo->squelch_close_glitch_thresh;
#if ENABLE_SQUELCH_MORE_SENSITIVE #if ENABLE_SQUELCH_MORE_SENSITIVE
// make squelch a little more sensitive // make squelch a little more sensitive
@ -501,12 +501,12 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
if (glitch_close == glitch_open && glitch_close <= 253) if (glitch_close == glitch_open && glitch_close <= 253)
glitch_close += 2; glitch_close += 2;
pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open; pInfo->squelch_open_RSSI_thresh = (rssi_open > 255) ? 255 : rssi_open;
pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close; pInfo->squelch_close_RSSI_thresh = (rssi_close > 255) ? 255 : rssi_close;
pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open; pInfo->squelch_open_noise_thresh = (noise_open > 127) ? 127 : noise_open;
pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close; pInfo->squelch_close_noise_thresh = (noise_close > 127) ? 127 : noise_close;
pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open; pInfo->squelch_open_glitch_thresh = (glitch_open > 255) ? 255 : glitch_open;
pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close; pInfo->squelch_close_glitch_thresh = (glitch_close > 255) ? 255 : glitch_close;
} }
// ******************************* // *******************************
@ -522,35 +522,35 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
// 1F20 5A 5A 5A 64 64 64 8F 91 8A FF FF FF FF FF FF FF .. 400 MHz // 1F20 5A 5A 5A 64 64 64 8F 91 8A FF FF FF FF FF FF FF .. 400 MHz
// 1F30 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 470 MHz // 1F30 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 470 MHz
Band = FREQUENCY_GetBand(pInfo->pTX->Frequency); Band = FREQUENCY_GetBand(pInfo->pTX->frequency);
EEPROM_ReadBuffer(0x1ED0 + (Band * 16) + (pInfo->OUTPUT_POWER * 3), TX_power, 3); EEPROM_ReadBuffer(0x1ED0 + (Band * 16) + (pInfo->output_power * 3), TX_power, 3);
pInfo->TXP_CalculatedSetting = FREQUENCY_CalculateOutputPower( pInfo->txp_calculated_setting = FREQUENCY_CalculateOutputPower(
TX_power[0], TX_power[0],
TX_power[1], TX_power[1],
TX_power[2], TX_power[2],
frequencyBandTable[Band].lower, frequencyBandTable[Band].lower,
(frequencyBandTable[Band].lower + frequencyBandTable[Band].upper) / 2, (frequencyBandTable[Band].lower + frequencyBandTable[Band].upper) / 2,
frequencyBandTable[Band].upper, frequencyBandTable[Band].upper,
pInfo->pTX->Frequency); pInfo->pTX->frequency);
// ******************************* // *******************************
} }
void RADIO_ApplyOffset(VFO_Info_t *pInfo) void RADIO_ApplyOffset(VFO_Info_t *pInfo)
{ {
uint32_t Frequency = pInfo->freq_config_RX.Frequency; uint32_t Frequency = pInfo->freq_config_rx.frequency;
switch (pInfo->TX_OFFSET_FREQUENCY_DIRECTION) switch (pInfo->tx_offset_freq_dir)
{ {
case TX_OFFSET_FREQUENCY_DIRECTION_OFF: case TX_OFFSET_FREQ_DIR_OFF:
break; break;
case TX_OFFSET_FREQUENCY_DIRECTION_ADD: case TX_OFFSET_FREQ_DIR_ADD:
Frequency += pInfo->TX_OFFSET_FREQUENCY; Frequency += pInfo->tx_offset_freq;
break; break;
case TX_OFFSET_FREQUENCY_DIRECTION_SUB: case TX_OFFSET_FREQ_DIR_SUB:
Frequency -= pInfo->TX_OFFSET_FREQUENCY; Frequency -= pInfo->tx_offset_freq;
break; break;
} }
@ -560,28 +560,28 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo)
if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper) if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper; Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
pInfo->freq_config_TX.Frequency = Frequency; pInfo->freq_config_tx.frequency = Frequency;
} }
static void RADIO_SelectCurrentVfo(void) static void RADIO_SelectCurrentVfo(void)
{ {
gCurrentVfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gRxVfo : &gEeprom.VfoInfo[gEeprom.TX_VFO]; gCurrentVfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? gRxVfo : &g_eeprom.VfoInfo[g_eeprom.tx_vfo];
} }
void RADIO_SelectVfos(void) void RADIO_SelectVfos(void)
{ {
gEeprom.TX_VFO = get_tx_VFO(); g_eeprom.tx_vfo = get_tx_VFO();
gEeprom.RX_VFO = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.TX_VFO : (gEeprom.TX_VFO + 1) & 1u; g_eeprom.rx_vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.tx_vfo : (g_eeprom.tx_vfo + 1) & 1u;
gTxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gTxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo];
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo];
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
} }
void RADIO_SetupRegisters(bool bSwitchToFunction0) void RADIO_SetupRegisters(bool bSwitchToFunction0)
{ {
BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH; BK4819_FilterBandwidth_t Bandwidth = gRxVfo->channel_bandwidth;
uint16_t InterruptMask; uint16_t InterruptMask;
uint32_t Frequency; uint32_t Frequency;
@ -601,7 +601,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
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
// BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->AM_mode && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->am_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
@ -629,22 +629,22 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_WriteRegister(BK4819_REG_3F, 0); BK4819_WriteRegister(BK4819_REG_3F, 0);
// mic gain 0.5dB/step 0 to 31 // mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (gEeprom.MIC_SENSITIVITY_TUNING & 0x1f)); BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (g_eeprom.mic_sensitivity_tuning & 0x1f));
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode) if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save) || !gIsNoaaMode)
Frequency = gRxVfo->pRX->Frequency; Frequency = gRxVfo->pRX->frequency;
else else
Frequency = NoaaFrequencyTable[gNoaaChannel]; Frequency = NoaaFrequencyTable[gNoaaChannel];
#else #else
Frequency = gRxVfo->pRX->Frequency; Frequency = gRxVfo->pRX->frequency;
#endif #endif
BK4819_SetFrequency(Frequency); BK4819_SetFrequency(Frequency);
BK4819_SetupSquelch( BK4819_SetupSquelch(
gRxVfo->SquelchOpenRSSIThresh, gRxVfo->SquelchCloseRSSIThresh, gRxVfo->squelch_open_RSSI_thresh, gRxVfo->squelch_close_RSSI_thresh,
gRxVfo->SquelchOpenNoiseThresh, gRxVfo->SquelchCloseNoiseThresh, gRxVfo->squelch_open_noise_thresh, gRxVfo->squelch_close_noise_thresh,
gRxVfo->SquelchCloseGlitchThresh, gRxVfo->SquelchOpenGlitchThresh); gRxVfo->squelch_close_glitch_thresh, gRxVfo->squelch_open_glitch_thresh);
BK4819_PickRXFilterPathBasedOnFrequency(Frequency); BK4819_PickRXFilterPathBasedOnFrequency(Frequency);
@ -657,20 +657,20 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST; InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save))
#endif #endif
{ {
if (gRxVfo->AM_mode == 0) if (gRxVfo->am_mode == 0)
{ // FM { // FM
uint8_t CodeType = gSelectedCodeType; uint8_t code_type = gSelectedcode_type;
uint8_t Code = gSelectedCode; uint8_t Code = gSelectedCode;
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
{ {
CodeType = gRxVfo->pRX->CodeType; code_type = gRxVfo->pRX->code_type;
Code = gRxVfo->pRX->Code; Code = gRxVfo->pRX->code;
} }
switch (CodeType) switch (code_type)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
@ -705,7 +705,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(CodeType, Code)); BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code));
InterruptMask = 0 InterruptMask = 0
| BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CxCSS_TAIL
| BK4819_REG_3F_CDCSS_FOUND | BK4819_REG_3F_CDCSS_FOUND
@ -715,8 +715,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
break; break;
} }
if (gRxVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) if (gRxVfo->scrambling_type > 0 && gSetting_ScrambleEnable)
BK4819_EnableScramble(gRxVfo->SCRAMBLING_TYPE - 1); BK4819_EnableScramble(gRxVfo->scrambling_type - 1);
else else
BK4819_DisableScramble(); BK4819_DisableScramble();
} }
@ -736,19 +736,19 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0) if (g_eeprom.vox_switch && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0)
#else #else
if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0) if (g_eeprom.vox_switch && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0)
#endif #endif
#else #else
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->AM_mode == 0) if (g_eeprom.vox_switch && !gFmRadioMode && gCurrentVfo->am_mode == 0)
#else #else
if (gEeprom.VOX_SWITCH && gCurrentVfo->AM_mode == 0) if (g_eeprom.vox_switch && gCurrentVfo->am_mode == 0)
#endif #endif
#endif #endif
{ {
BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD); BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST; InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
} }
else else
@ -756,10 +756,10 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_DisableVox(); BK4819_DisableVox();
// RX expander // RX expander
BK4819_SetCompander((gRxVfo->AM_mode == 0 && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0); BK4819_SetCompander((gRxVfo->am_mode == 0 && gRxVfo->compander >= 2) ? gRxVfo->compander : 0);
#if 0 #if 0
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED)
{ {
BK4819_DisableDTMF(); BK4819_DisableDTMF();
} }
@ -797,13 +797,13 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
gUpdateStatus = true; gUpdateStatus = true;
if (gEeprom.NOAA_AUTO_SCAN) if (g_eeprom.NOAA_auto_scan)
{ {
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ {
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0])) if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
{ {
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1]))
{ {
gIsNoaaMode = false; gIsNoaaMode = false;
return; return;
@ -814,16 +814,16 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
ChanAB = 0; ChanAB = 0;
if (!gIsNoaaMode) if (!gIsNoaaMode)
gNoaaChannel = gEeprom.VfoInfo[ChanAB].CHANNEL_SAVE - NOAA_CHANNEL_FIRST; gNoaaChannel = g_eeprom.VfoInfo[ChanAB].channel_save - NOAA_CHANNEL_FIRST;
gIsNoaaMode = true; gIsNoaaMode = true;
return; return;
} }
if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST) if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST)
{ {
gIsNoaaMode = true; gIsNoaaMode = true;
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST;
gNOAA_Countdown_10ms = NOAA_countdown_2_10ms; gNOAA_Countdown_10ms = NOAA_countdown_2_10ms;
gScheduleNOAA = false; gScheduleNOAA = false;
} }
@ -837,7 +837,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
void RADIO_SetTxParameters(void) void RADIO_SetTxParameters(void)
{ {
BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->CHANNEL_BANDWIDTH; BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->channel_bandwidth;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
@ -855,7 +855,7 @@ void RADIO_SetTxParameters(void)
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
// BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->AM_mode && gSetting_AM_fix); // BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->am_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true); BK4819_SetFilterBandwidth(Bandwidth, true);
#else #else
BK4819_SetFilterBandwidth(Bandwidth, false); BK4819_SetFilterBandwidth(Bandwidth, false);
@ -865,26 +865,26 @@ void RADIO_SetTxParameters(void)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); BK4819_SetFrequency(gCurrentVfo->pTX->frequency);
// TX compressor // TX compressor
BK4819_SetCompander((gRxVfo->AM_mode == 0 && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0); BK4819_SetCompander((gRxVfo->am_mode == 0 && (gRxVfo->compander == 1 || gRxVfo->compander >= 3)) ? gRxVfo->compander : 0);
BK4819_PrepareTransmit(); BK4819_PrepareTransmit();
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);
BK4819_PickRXFilterPathBasedOnFrequency(gCurrentVfo->pTX->Frequency); BK4819_PickRXFilterPathBasedOnFrequency(gCurrentVfo->pTX->frequency);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, true); BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, true);
SYSTEM_DelayMs(5); SYSTEM_DelayMs(5);
BK4819_SetupPowerAmplifier(gCurrentVfo->TXP_CalculatedSetting, gCurrentVfo->pTX->Frequency); BK4819_SetupPowerAmplifier(gCurrentVfo->txp_calculated_setting, gCurrentVfo->pTX->frequency);
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);
switch (gCurrentVfo->pTX->CodeType) switch (gCurrentVfo->pTX->code_type)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
@ -892,12 +892,12 @@ void RADIO_SetTxParameters(void)
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->Code]); BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->code]);
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(gCurrentVfo->pTX->CodeType, gCurrentVfo->pTX->Code)); BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(gCurrentVfo->pTX->code_type, gCurrentVfo->pTX->code));
break; break;
} }
} }
@ -922,7 +922,7 @@ void RADIO_SetVfoState(VfoState_t State)
} }
else else
{ // 1of11 { // 1of11
const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; const unsigned int vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo;
VfoState[vfo] = State; VfoState[vfo] = State;
} }
@ -938,7 +938,7 @@ void RADIO_PrepareTX(void)
{ {
VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ // dual-RX is enabled { // dual-RX is enabled
gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms;
@ -947,16 +947,16 @@ void RADIO_PrepareTX(void)
#if 0 #if 0
if (gRxVfoIsActive) if (gRxVfoIsActive)
{ // use the TX vfo { // use the TX vfo
gEeprom.RX_VFO = gEeprom.TX_VFO; g_eeprom.rx_vfo = g_eeprom.tx_vfo;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo];
gRxVfoIsActive = false; gRxVfoIsActive = false;
} }
gCurrentVfo = gRxVfo; gCurrentVfo = gRxVfo;
#else #else
if (!gRxVfoIsActive) if (!gRxVfoIsActive)
{ // use the current RX vfo { // use the current RX vfo
gEeprom.RX_VFO = gEeprom.TX_VFO; g_eeprom.rx_vfo = g_eeprom.tx_vfo;
gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo];
gRxVfoIsActive = true; gRxVfoIsActive = true;
} }
gCurrentVfo = gRxVfo; gCurrentVfo = gRxVfo;
@ -970,7 +970,7 @@ void RADIO_PrepareTX(void)
RADIO_SelectCurrentVfo(); RADIO_SelectCurrentVfo();
#ifndef ENABLE_TX_WHEN_AM #ifndef ENABLE_TX_WHEN_AM
if (gCurrentVfo->AM_mode) if (gCurrentVfo->am_mode)
{ // not allowed to TX if in AM mode { // not allowed to TX if in AM mode
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
@ -981,9 +981,9 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else
if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) if (TX_freq_check(gCurrentVfo->pTX->frequency) == 0)
{ // TX frequency is allowed { // TX frequency is allowed
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentVfo->busy_channel_lock && gCurrentFunction == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; // busy RX'ing a station State = VFO_STATE_BUSY; // busy RX'ing a station
else else
if (gBatteryDisplayLevel == 0) if (gBatteryDisplayLevel == 0)
@ -1035,11 +1035,11 @@ void RADIO_PrepareTX(void)
if (gAlarmState == ALARM_STATE_OFF) if (gAlarmState == ALARM_STATE_OFF)
#endif #endif
{ {
if (gEeprom.TX_TIMEOUT_TIMER == 0) if (g_eeprom.tx_timeout_timer == 0)
gTxTimerCountdown_500ms = 60; // 30 sec gTxTimerCountdown_500ms = 60; // 30 sec
else else
if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1))
gTxTimerCountdown_500ms = 120 * gEeprom.TX_TIMEOUT_TIMER; // minutes gTxTimerCountdown_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes
else else
gTxTimerCountdown_500ms = 120 * 15; // 15 minutes gTxTimerCountdown_500ms = 120 * 15; // 15 minutes
} }
@ -1052,7 +1052,7 @@ void RADIO_PrepareTX(void)
void RADIO_EnableCxCSS(void) void RADIO_EnableCxCSS(void)
{ {
switch (gCurrentVfo->pTX->CodeType) switch (gCurrentVfo->pTX->code_type)
{ {
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
@ -1083,34 +1083,34 @@ void RADIO_PrepareCssTX(void)
void RADIO_SendEndOfTransmission(void) void RADIO_SendEndOfTransmission(void)
{ {
if (gEeprom.ROGER == ROGER_MODE_ROGER) if (g_eeprom.roger_mode == ROGER_MODE_ROGER)
BK4819_PlayRoger(); BK4819_PlayRoger();
else else
if (gEeprom.ROGER == ROGER_MODE_MDC) if (g_eeprom.roger_mode == ROGER_MODE_MDC)
BK4819_PlayRogerMDC(); BK4819_PlayRogerMDC();
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) if (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO)
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE); BK4819_PlaySingleTone(2475, 250, 28, g_eeprom.DTMF_side_tone);
if (gDTMF_CallState == DTMF_CALL_STATE_NONE && if (gDTMF_CallState == DTMF_CALL_STATE_NONE &&
(gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)) (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_BOTH))
{ // end-of-tx { // end-of-tx
if (gEeprom.DTMF_SIDE_TONE) if (g_eeprom.DTMF_side_tone)
{ {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
} }
BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE); BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone);
BK4819_PlayDTMFString( BK4819_PlayDTMFString(
gEeprom.DTMF_DOWN_CODE, g_eeprom.DTMF_down_code,
0, 0,
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME, g_eeprom.DTMF_first_code_persist_time,
gEeprom.DTMF_HASH_CODE_PERSIST_TIME, g_eeprom.DTMF_hash_code_persist_time,
gEeprom.DTMF_CODE_PERSIST_TIME, g_eeprom.DTMF_code_persist_time,
gEeprom.DTMF_CODE_INTERVAL_TIME); g_eeprom.DTMF_code_interval_time);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = false; gEnableSpeaker = false;

76
radio.h
View File

@ -24,10 +24,10 @@
#include "frequencies.h" #include "frequencies.h"
enum { enum {
MR_CH_BAND_MASK = 0x0F << 0, USER_CH_BAND_MASK = 0x0F << 0,
MR_CH_COMPAND = 3u << 4, // new USER_CH_COMPAND = 3u << 4, // new
MR_CH_SCANLIST2 = 1u << 6, USER_CH_SCANLIST2 = 1u << 6,
MR_CH_SCANLIST1 = 1u << 7 USER_CH_SCANLIST1 = 1u << 7
}; };
enum { enum {
@ -63,67 +63,67 @@ typedef enum VfoState_t VfoState_t;
typedef struct typedef struct
{ {
uint32_t Frequency; uint32_t frequency;
DCS_CodeType_t CodeType; dcs_code_type_t code_type;
uint8_t Code; uint8_t code;
uint8_t Padding[2]; uint8_t padding[2];
} FREQ_Config_t; } FREQ_Config_t;
typedef struct VFO_Info_t typedef struct VFO_Info_t
{ {
FREQ_Config_t freq_config_RX; FREQ_Config_t freq_config_rx;
FREQ_Config_t freq_config_TX; FREQ_Config_t freq_config_tx;
FREQ_Config_t *pRX; FREQ_Config_t *pRX;
FREQ_Config_t *pTX; FREQ_Config_t *pTX;
uint32_t TX_OFFSET_FREQUENCY; uint32_t tx_offset_freq;
uint16_t StepFrequency; uint16_t step_freq;
uint8_t CHANNEL_SAVE; uint8_t channel_save;
uint8_t TX_OFFSET_FREQUENCY_DIRECTION; uint8_t tx_offset_freq_dir;
uint8_t SquelchOpenRSSIThresh; uint8_t squelch_open_RSSI_thresh;
uint8_t SquelchOpenNoiseThresh; uint8_t squelch_open_noise_thresh;
uint8_t SquelchCloseGlitchThresh; uint8_t squelch_close_glitch_thresh;
uint8_t SquelchCloseRSSIThresh; uint8_t squelch_close_RSSI_thresh;
uint8_t SquelchCloseNoiseThresh; uint8_t squelch_close_noise_thresh;
uint8_t SquelchOpenGlitchThresh; uint8_t squelch_open_glitch_thresh;
STEP_Setting_t STEP_SETTING; step_setting_t step_setting;
uint8_t OUTPUT_POWER; uint8_t output_power;
uint8_t TXP_CalculatedSetting; uint8_t txp_calculated_setting;
bool FrequencyReverse; bool frequency_reverse;
uint8_t SCRAMBLING_TYPE; uint8_t scrambling_type;
uint8_t CHANNEL_BANDWIDTH; uint8_t channel_bandwidth;
uint8_t SCANLIST1_PARTICIPATION; uint8_t scanlist_1_participation;
uint8_t SCANLIST2_PARTICIPATION; uint8_t scanlist_2_participation;
uint8_t Band; uint8_t band;
uint8_t DTMF_DECODING_ENABLE; uint8_t DTMF_decoding_enable;
PTT_ID_t DTMF_PTT_ID_TX_MODE; PTT_ID_t DTMF_ptt_id_tx_mode;
uint8_t BUSY_CHANNEL_LOCK; uint8_t busy_channel_lock;
uint8_t AM_mode; uint8_t am_mode;
uint8_t Compander; uint8_t compander;
char Name[16]; char name[16];
} VFO_Info_t; } VFO_Info_t;
extern VFO_Info_t *gTxVfo; extern VFO_Info_t *gTxVfo;
extern VFO_Info_t *gRxVfo; extern VFO_Info_t *gRxVfo;
extern VFO_Info_t *gCurrentVfo; extern VFO_Info_t *gCurrentVfo;
extern DCS_CodeType_t gSelectedCodeType; extern dcs_code_type_t gSelectedcode_type;
extern DCS_CodeType_t gCurrentCodeType; extern dcs_code_type_t gCurrentcode_type;
extern uint8_t gSelectedCode; extern uint8_t gSelectedCode;
extern STEP_Setting_t gStepSetting; extern step_setting_t gStepSetting;
extern VfoState_t VfoState[2]; extern VfoState_t VfoState[2];

View File

@ -78,12 +78,12 @@ void SystickHandler(void)
if (gCurrentFunction == FUNCTION_POWER_SAVE) if (gCurrentFunction == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired); DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired);
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch); DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch == DUAL_WATCH_OFF)
if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
if (gCurrentFunction != FUNCTION_RECEIVE) if (gCurrentFunction != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA); DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA);
@ -96,7 +96,7 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete); DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice); DECREMENT_AND_TRIGGER(g_count_down_to_play_next_voice_10ms, g_flag_play_queued_voice);
#endif #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO

View File

@ -24,7 +24,7 @@
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
EEPROM_Config_t gEeprom; EEPROM_Config_t g_eeprom;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
void SETTINGS_SaveFM(void) void SETTINGS_SaveFM(void)
@ -33,18 +33,19 @@ EEPROM_Config_t gEeprom;
struct struct
{ {
uint16_t Frequency; uint16_t frequency;
uint8_t Channel; uint8_t channel;
bool IsChannelSelected; bool is_channel_selected;
uint8_t Padding[4]; uint8_t padding[4];
} State; } state;
memset(&State, 0xFF, sizeof(State)); memset(&state, 0xFF, sizeof(state));
State.Channel = gEeprom.FM_SelectedChannel; state.channel = g_eeprom.fm_selected_channel;
State.Frequency = gEeprom.FM_SelectedFrequency; state.frequency = g_eeprom.fm_selected_frequency;
State.IsChannelSelected = gEeprom.FM_IsMrMode; state.is_channel_selected = g_eeprom.fm_is_channel_mode;
EEPROM_WriteBuffer(0x0E88, &state);
EEPROM_WriteBuffer(0x0E88, &State);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]); EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
} }
@ -58,15 +59,15 @@ void SETTINGS_SaveVfoIndices(void)
EEPROM_ReadBuffer(0x0E80, State, sizeof(State)); EEPROM_ReadBuffer(0x0E80, State, sizeof(State));
#endif #endif
State[0] = gEeprom.ScreenChannel[0]; State[0] = g_eeprom.screen_channel[0];
State[1] = gEeprom.MrChannel[0]; State[1] = g_eeprom.user_channel[0];
State[2] = gEeprom.FreqChannel[0]; State[2] = g_eeprom.freq_channel[0];
State[3] = gEeprom.ScreenChannel[1]; State[3] = g_eeprom.screen_channel[1];
State[4] = gEeprom.MrChannel[1]; State[4] = g_eeprom.user_channel[1];
State[5] = gEeprom.FreqChannel[1]; State[5] = g_eeprom.freq_channel[1];
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
State[6] = gEeprom.NoaaChannel[0]; State[6] = g_eeprom.noaa_channel[0];
State[7] = gEeprom.NoaaChannel[1]; State[7] = g_eeprom.noaa_channel[1];
#endif #endif
EEPROM_WriteBuffer(0x0E80, State); EEPROM_WriteBuffer(0x0E80, State);
@ -76,43 +77,43 @@ void SETTINGS_SaveSettings(void)
{ {
uint8_t State[8]; uint8_t State[8];
State[0] = gEeprom.CHAN_1_CALL; State[0] = g_eeprom.chan_1_call;
State[1] = gEeprom.SQUELCH_LEVEL; State[1] = g_eeprom.squelch_level;
State[2] = gEeprom.TX_TIMEOUT_TIMER; State[2] = g_eeprom.tx_timeout_timer;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
State[3] = gEeprom.NOAA_AUTO_SCAN; State[3] = g_eeprom.NOAA_auto_scan;
#else #else
State[3] = false; State[3] = false;
#endif #endif
State[4] = gEeprom.KEY_LOCK; State[4] = g_eeprom.key_lock;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
State[5] = gEeprom.VOX_SWITCH; State[5] = g_eeprom.vox_switch;
State[6] = gEeprom.VOX_LEVEL; State[6] = g_eeprom.vox_level;
#else #else
State[5] = false; State[5] = false;
State[6] = 0; State[6] = 0;
#endif #endif
State[7] = gEeprom.MIC_SENSITIVITY; State[7] = g_eeprom.mic_sensitivity;
EEPROM_WriteBuffer(0x0E70, State); EEPROM_WriteBuffer(0x0E70, State);
State[0] = 0xFF; State[0] = 0xFF;
State[1] = gEeprom.CHANNEL_DISPLAY_MODE; State[1] = g_eeprom.channel_display_mode;
State[2] = gEeprom.CROSS_BAND_RX_TX; State[2] = g_eeprom.cross_vfo_rx_tx;
State[3] = gEeprom.BATTERY_SAVE; State[3] = g_eeprom.battery_save;
State[4] = gEeprom.DUAL_WATCH; State[4] = g_eeprom.dual_watch;
State[5] = gEeprom.BACKLIGHT; State[5] = g_eeprom.backlight;
State[6] = gEeprom.TAIL_NOTE_ELIMINATION; State[6] = g_eeprom.tail_note_elimination;
State[7] = gEeprom.VFO_OPEN; State[7] = g_eeprom.vfo_open;
EEPROM_WriteBuffer(0x0E78, State); EEPROM_WriteBuffer(0x0E78, State);
State[0] = gEeprom.BEEP_CONTROL; State[0] = g_eeprom.beep_control;
State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION; State[1] = g_eeprom.key1_short_press_action;
State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION; State[2] = g_eeprom.key1_long_press_action;
State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION; State[3] = g_eeprom.key2_short_press_action;
State[4] = gEeprom.KEY_2_LONG_PRESS_ACTION; State[4] = g_eeprom.key2_long_press_action;
State[5] = gEeprom.SCAN_RESUME_MODE; State[5] = g_eeprom.scan_resume_mode;
State[6] = gEeprom.AUTO_KEYPAD_LOCK; State[6] = g_eeprom.auto_keypad_lock;
State[7] = gEeprom.POWER_ON_DISPLAY_MODE; State[7] = g_eeprom.pwr_on_display_mode;
EEPROM_WriteBuffer(0x0E90, State); EEPROM_WriteBuffer(0x0E90, State);
{ {
@ -123,7 +124,7 @@ void SETTINGS_SaveSettings(void)
memset(&array, 0xff, sizeof(array)); memset(&array, 0xff, sizeof(array));
#ifdef ENABLE_PWRON_PASSWORD #ifdef ENABLE_PWRON_PASSWORD
array.password = gEeprom.POWER_ON_PASSWORD; array.password = g_eeprom.power_on_password;
#endif #endif
EEPROM_WriteBuffer(0x0E98, &array); EEPROM_WriteBuffer(0x0E98, &array);
@ -131,43 +132,43 @@ void SETTINGS_SaveSettings(void)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gEeprom.VOICE_PROMPT; State[0] = g_eeprom.voice_prompt;
EEPROM_WriteBuffer(0x0EA0, State); EEPROM_WriteBuffer(0x0EA0, State);
#endif #endif
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
State[0] = gEeprom.ALARM_MODE; State[0] = g_eeprom.alarm_mode;
#else #else
State[0] = false; State[0] = false;
#endif #endif
State[1] = gEeprom.ROGER; State[1] = g_eeprom.roger_mode;
State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; State[2] = g_eeprom.repeater_tail_tone_elimination;
State[3] = gEeprom.TX_VFO; State[3] = g_eeprom.tx_vfo;
EEPROM_WriteBuffer(0x0EA8, State); EEPROM_WriteBuffer(0x0EA8, State);
State[0] = gEeprom.DTMF_SIDE_TONE; State[0] = g_eeprom.DTMF_side_tone;
State[1] = gEeprom.DTMF_SEPARATE_CODE; State[1] = g_eeprom.DTMF_separate_code;
State[2] = gEeprom.DTMF_GROUP_CALL_CODE; State[2] = g_eeprom.DTMF_group_call_code;
State[3] = gEeprom.DTMF_DECODE_RESPONSE; State[3] = g_eeprom.DTMF_decode_response;
State[4] = gEeprom.DTMF_auto_reset_time; State[4] = g_eeprom.DTMF_auto_reset_time;
State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U; State[5] = g_eeprom.DTMF_preload_time / 10U;
State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U; State[6] = g_eeprom.DTMF_first_code_persist_time / 10U;
State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U; State[7] = g_eeprom.DTMF_hash_code_persist_time / 10U;
EEPROM_WriteBuffer(0x0ED0, State); EEPROM_WriteBuffer(0x0ED0, State);
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U; State[0] = g_eeprom.DTMF_code_persist_time / 10U;
State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U; State[1] = g_eeprom.DTMF_code_interval_time / 10U;
State[2] = gEeprom.PERMIT_REMOTE_KILL; State[2] = g_eeprom.permit_remote_kill;
EEPROM_WriteBuffer(0x0ED8, State); EEPROM_WriteBuffer(0x0ED8, State);
State[0] = gEeprom.SCAN_LIST_DEFAULT; State[0] = g_eeprom.scan_list_default;
State[1] = gEeprom.SCAN_LIST_ENABLED[0]; State[1] = g_eeprom.scan_list_enabled[0];
State[2] = gEeprom.SCANLIST_PRIORITY_CH1[0]; State[2] = g_eeprom.scan_list_priority_ch1[0];
State[3] = gEeprom.SCANLIST_PRIORITY_CH2[0]; State[3] = g_eeprom.scan_list_priority_ch2[0];
State[4] = gEeprom.SCAN_LIST_ENABLED[1]; State[4] = g_eeprom.scan_list_enabled[1];
State[5] = gEeprom.SCANLIST_PRIORITY_CH1[1]; State[5] = g_eeprom.scan_list_priority_ch1[1];
State[6] = gEeprom.SCANLIST_PRIORITY_CH2[1]; State[6] = g_eeprom.scan_list_priority_ch2[1];
State[7] = 0xFF; State[7] = 0xFF;
EEPROM_WriteBuffer(0x0F18, State); EEPROM_WriteBuffer(0x0F18, State);
@ -202,38 +203,38 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
const uint16_t OffsetMR = Channel * 16; const uint16_t OffsetMR = Channel * 16;
uint16_t OffsetVFO = OffsetMR; uint16_t OffsetVFO = OffsetMR;
if (Channel > MR_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
{ // it's a VFO, not a channel { // it's a VFO, not a channel
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90; OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32; OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
} }
if (Mode >= 2 || Channel > MR_CHANNEL_LAST) if (Mode >= 2 || Channel > USER_CHANNEL_LAST)
{ // copy VFO to a channel { // copy VFO to a channel
uint8_t State[8]; uint8_t State[8];
((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency; ((uint32_t *)State)[0] = pVFO->freq_config_rx.frequency;
((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY; ((uint32_t *)State)[1] = pVFO->tx_offset_freq;
EEPROM_WriteBuffer(OffsetVFO + 0, State); EEPROM_WriteBuffer(OffsetVFO + 0, State);
State[0] = pVFO->freq_config_RX.Code; State[0] = pVFO->freq_config_rx.code;
State[1] = pVFO->freq_config_TX.Code; State[1] = pVFO->freq_config_tx.code;
State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType; State[2] = (pVFO->freq_config_tx.code_type << 4) | pVFO->freq_config_rx.code_type;
State[3] = ((pVFO->AM_mode & 1u) << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION; State[3] = ((pVFO->am_mode & 1u) << 4) | pVFO->tx_offset_freq_dir;
State[4] = 0 State[4] = 0
| (pVFO->BUSY_CHANNEL_LOCK << 4) | (pVFO->busy_channel_lock << 4)
| (pVFO->OUTPUT_POWER << 2) | (pVFO->output_power << 2)
| (pVFO->CHANNEL_BANDWIDTH << 1) | (pVFO->channel_bandwidth << 1)
| (pVFO->FrequencyReverse << 0); | (pVFO->frequency_reverse << 0);
State[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1) | ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0); State[5] = ((pVFO->DTMF_ptt_id_tx_mode & 7u) << 1) | ((pVFO->DTMF_decoding_enable & 1u) << 0);
State[6] = pVFO->STEP_SETTING; State[6] = pVFO->step_setting;
State[7] = pVFO->SCRAMBLING_TYPE; State[7] = pVFO->scrambling_type;
EEPROM_WriteBuffer(OffsetVFO + 8, State); EEPROM_WriteBuffer(OffsetVFO + 8, State);
SETTINGS_UpdateChannel(Channel, pVFO, true); SETTINGS_UpdateChannel(Channel, pVFO, true);
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ // it's a memory channel { // it's a memory channel
#ifndef ENABLE_KEEP_MEM_NAME #ifndef ENABLE_KEEP_MEM_NAME
@ -245,11 +246,11 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
#else #else
if (Mode >= 3) if (Mode >= 3)
{ // save the channel name { // save the channel name
memmove(State, pVFO->Name + 0, 8); memmove(State, pVFO->name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
//memset(State, 0xFF, sizeof(State)); //memset(State, 0xFF, sizeof(State));
memset(State, 0x00, sizeof(State)); // follow the QS way memset(State, 0x00, sizeof(State)); // follow the QS way
memmove(State, pVFO->Name + 8, 2); memmove(State, pVFO->name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
} }
#endif #endif
@ -268,13 +269,13 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
uint8_t Attributes = 0xFF; // default attributes uint8_t Attributes = 0xFF; // default attributes
uint16_t Offset = 0x0D60 + (Channel & ~7u); uint16_t Offset = 0x0D60 + (Channel & ~7u);
Attributes &= (uint8_t)(~MR_CH_COMPAND); // default to '0' = compander disabled Attributes &= (uint8_t)(~USER_CH_COMPAND); // default to '0' = compander disabled
EEPROM_ReadBuffer(Offset, State, sizeof(State)); EEPROM_ReadBuffer(Offset, State, sizeof(State));
if (keep) if (keep)
{ {
Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0); Attributes = (pVFO->scanlist_1_participation << 7) | (pVFO->scanlist_2_participation << 6) | (pVFO->compander << 4) | (pVFO->band << 0);
if (State[Channel & 7u] == Attributes) if (State[Channel & 7u] == Attributes)
return; // no change in the attributes return; // no change in the attributes
} }
@ -283,10 +284,10 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
EEPROM_WriteBuffer(Offset, State); EEPROM_WriteBuffer(Offset, State);
gMR_ChannelAttributes[Channel] = Attributes; gUSER_ChannelAttributes[Channel] = Attributes;
// #ifndef ENABLE_KEEP_MEM_NAME // #ifndef ENABLE_KEEP_MEM_NAME
if (Channel <= MR_CHANNEL_LAST) if (Channel <= USER_CHANNEL_LAST)
{ // it's a memory channel { // it's a memory channel
const uint16_t OffsetMR = Channel * 16; const uint16_t OffsetMR = Channel * 16;
@ -299,11 +300,11 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
} }
// else // else
// { // update the channel name // { // update the channel name
// memmove(State, pVFO->Name + 0, 8); // memmove(State, pVFO->name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); // EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// //memset(State, 0xFF, sizeof(State)); // //memset(State, 0xFF, sizeof(State));
// memset(State, 0x00, sizeof(State)); // follow the QS way // memset(State, 0x00, sizeof(State)); // follow the QS way
// memmove(State, pVFO->Name + 8, 2); // memmove(State, pVFO->name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); // EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// } // }
} }

View File

@ -23,13 +23,13 @@
#include "frequencies.h" #include "frequencies.h"
#include "radio.h" #include "radio.h"
enum POWER_OnDisplayMode_t { enum pwr_on_display_mode_e {
POWER_ON_DISPLAY_MODE_FULL_SCREEN = 0, PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0,
POWER_ON_DISPLAY_MODE_MESSAGE, PWR_ON_DISPLAY_MODE_MESSAGE,
POWER_ON_DISPLAY_MODE_VOLTAGE, PWR_ON_DISPLAY_MODE_VOLTAGE,
POWER_ON_DISPLAY_MODE_NONE PWR_ON_DISPLAY_MODE_NONE
}; };
typedef enum POWER_OnDisplayMode_t POWER_OnDisplayMode_t; typedef enum pwr_on_display_mode_e pwr_on_display_mode_t;
enum { enum {
F_LOCK_OFF = 0, F_LOCK_OFF = 0,
@ -59,9 +59,9 @@ enum {
}; };
enum { enum {
TX_OFFSET_FREQUENCY_DIRECTION_OFF = 0, TX_OFFSET_FREQ_DIR_OFF = 0,
TX_OFFSET_FREQUENCY_DIRECTION_ADD, TX_OFFSET_FREQ_DIR_ADD,
TX_OFFSET_FREQUENCY_DIRECTION_SUB TX_OFFSET_FREQ_DIR_SUB
}; };
enum { enum {
@ -84,79 +84,79 @@ enum {
}; };
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
enum VOICE_Prompt_t enum voice_prompt_e
{ {
VOICE_PROMPT_OFF = 0, VOICE_PROMPT_OFF = 0,
VOICE_PROMPT_CHINESE, VOICE_PROMPT_CHINESE,
VOICE_PROMPT_ENGLISH VOICE_PROMPT_ENGLISH
}; };
typedef enum VOICE_Prompt_t VOICE_Prompt_t; typedef enum voice_prompt_e voice_prompt_t;
#endif #endif
enum ALARM_Mode_t { enum alarm_mode_e {
ALARM_MODE_SITE = 0, alarm_mode_SITE = 0,
ALARM_MODE_TONE ALARM_MODE_TONE
}; };
typedef enum ALARM_Mode_t ALARM_Mode_t; typedef enum alarm_mode_e alarm_mode_t;
enum ROGER_Mode_t { enum roger_mode_e {
ROGER_MODE_OFF = 0, ROGER_MODE_OFF = 0,
ROGER_MODE_ROGER, ROGER_MODE_ROGER,
ROGER_MODE_MDC ROGER_MODE_MDC
}; };
typedef enum ROGER_Mode_t ROGER_Mode_t; typedef enum roger_mode_e roger_mode_t;
enum CHANNEL_DisplayMode_t { enum mdf_display_mode_e {
MDF_FREQUENCY = 0, MDF_FREQUENCY = 0,
MDF_CHANNEL, MDF_CHANNEL,
MDF_NAME, MDF_NAME,
MDF_NAME_FREQ MDF_NAME_FREQ
}; };
typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t; typedef enum mdf_display_mode_e mdf_display_mode_t;
typedef struct { typedef struct {
uint8_t ScreenChannel[2]; uint8_t screen_channel[2];
uint8_t FreqChannel[2]; uint8_t freq_channel[2];
uint8_t MrChannel[2]; uint8_t user_channel[2];
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
uint8_t NoaaChannel[2]; uint8_t noaa_channel[2];
#endif #endif
uint8_t RX_VFO; uint8_t rx_vfo;
uint8_t TX_VFO; uint8_t tx_vfo;
uint8_t field7_0xa; uint8_t field7_0xa;
uint8_t field8_0xb; uint8_t field8_0xb;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
uint16_t FM_SelectedFrequency; uint16_t fm_selected_frequency;
uint8_t FM_SelectedChannel; uint8_t fm_selected_channel;
bool FM_IsMrMode; bool fm_is_channel_mode;
uint16_t FM_FrequencyPlaying; uint16_t fm_frequency_playing;
uint16_t FM_LowerLimit; uint16_t fm_lower_limit;
uint16_t FM_UpperLimit; uint16_t fm_upper_limit;
#endif #endif
uint8_t SQUELCH_LEVEL; uint8_t squelch_level;
uint8_t TX_TIMEOUT_TIMER; uint8_t tx_timeout_timer;
bool KEY_LOCK; bool key_lock;
bool VOX_SWITCH; bool vox_switch;
uint8_t VOX_LEVEL; uint8_t vox_level;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
VOICE_Prompt_t VOICE_PROMPT; voice_prompt_t voice_prompt;
#endif #endif
bool BEEP_CONTROL; bool beep_control;
uint8_t CHANNEL_DISPLAY_MODE; uint8_t channel_display_mode;
bool TAIL_NOTE_ELIMINATION; bool tail_note_elimination;
bool VFO_OPEN; bool vfo_open;
uint8_t DUAL_WATCH; uint8_t dual_watch;
uint8_t CROSS_BAND_RX_TX; uint8_t cross_vfo_rx_tx;
uint8_t BATTERY_SAVE; uint8_t battery_save;
uint8_t BACKLIGHT; uint8_t backlight;
uint8_t SCAN_RESUME_MODE; uint8_t scan_resume_mode;
uint8_t SCAN_LIST_DEFAULT; uint8_t scan_list_default;
bool SCAN_LIST_ENABLED[2]; bool scan_list_enabled[2];
uint8_t SCANLIST_PRIORITY_CH1[2]; uint8_t scan_list_priority_ch1[2];
uint8_t SCANLIST_PRIORITY_CH2[2]; uint8_t scan_list_priority_ch2[2];
uint8_t field29_0x26; uint8_t field29_0x26;
uint8_t field30_0x27; uint8_t field30_0x27;
@ -164,55 +164,54 @@ typedef struct {
uint8_t field37_0x32; uint8_t field37_0x32;
uint8_t field38_0x33; uint8_t field38_0x33;
bool AUTO_KEYPAD_LOCK; bool auto_keypad_lock;
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
ALARM_Mode_t ALARM_MODE; alarm_mode_t alarm_mode;
#endif #endif
POWER_OnDisplayMode_t POWER_ON_DISPLAY_MODE; pwr_on_display_mode_t pwr_on_display_mode;
ROGER_Mode_t ROGER; roger_mode_t roger_mode;
uint8_t REPEATER_TAIL_TONE_ELIMINATION; uint8_t repeater_tail_tone_elimination;
uint8_t KEY_1_SHORT_PRESS_ACTION; uint8_t key1_short_press_action;
uint8_t KEY_1_LONG_PRESS_ACTION; uint8_t key1_long_press_action;
uint8_t KEY_2_SHORT_PRESS_ACTION; uint8_t key2_short_press_action;
uint8_t KEY_2_LONG_PRESS_ACTION; uint8_t key2_long_press_action;
uint8_t MIC_SENSITIVITY; uint8_t mic_sensitivity;
uint8_t MIC_SENSITIVITY_TUNING; uint8_t mic_sensitivity_tuning;
uint8_t CHAN_1_CALL; uint8_t chan_1_call;
char ANI_DTMF_ID[8]; char ani_DTMF_id[8];
char KILL_CODE[8]; char kill_code[8];
char REVIVE_CODE[8]; char revive_code[8];
char DTMF_UP_CODE[16]; char DTMF_up_code[16];
char DTMF_down_code[16];
uint8_t field57_0x6c; uint8_t field57_0x6c;
uint8_t field58_0x6d; uint8_t field58_0x6d;
char DTMF_DOWN_CODE[16];
uint8_t field60_0x7e; uint8_t field60_0x7e;
uint8_t field61_0x7f; uint8_t field61_0x7f;
char DTMF_SEPARATE_CODE; char DTMF_separate_code;
char DTMF_GROUP_CALL_CODE; char DTMF_group_call_code;
uint8_t DTMF_DECODE_RESPONSE; uint8_t DTMF_decode_response;
uint8_t DTMF_auto_reset_time; uint8_t DTMF_auto_reset_time;
uint16_t DTMF_PRELOAD_TIME; uint16_t DTMF_preload_time;
uint16_t DTMF_FIRST_CODE_PERSIST_TIME; uint16_t DTMF_first_code_persist_time;
uint16_t DTMF_HASH_CODE_PERSIST_TIME; uint16_t DTMF_hash_code_persist_time;
uint16_t DTMF_CODE_PERSIST_TIME; uint16_t DTMF_code_persist_time;
uint16_t DTMF_CODE_INTERVAL_TIME; uint16_t DTMF_code_interval_time;
bool DTMF_SIDE_TONE; bool DTMF_side_tone;
bool PERMIT_REMOTE_KILL; bool permit_remote_kill;
int16_t BK4819_XTAL_FREQ_LOW; int16_t BK4819_xtal_freq_low;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
bool NOAA_AUTO_SCAN; bool NOAA_auto_scan;
#endif #endif
uint8_t VOLUME_GAIN; uint8_t volume_gain;
uint8_t DAC_GAIN; uint8_t dac_gain;
VFO_Info_t VfoInfo[2]; VFO_Info_t VfoInfo[2];
uint32_t POWER_ON_PASSWORD; uint32_t power_on_password;
uint16_t VOX1_THRESHOLD; uint16_t vox1_threshold;
uint16_t VOX0_THRESHOLD; uint16_t vox0_threshold;
uint8_t field77_0x95; uint8_t field77_0x95;
uint8_t field78_0x96; uint8_t field78_0x96;
@ -220,7 +219,8 @@ 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 g_eeprom;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
void SETTINGS_SaveFM(void); void SETTINGS_SaveFM(void);

View File

@ -44,7 +44,7 @@ void UI_DisplayAircopy(void)
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
{ {
NUMBER_ToDigits(gRxVfo->freq_config_RX.Frequency, String); NUMBER_ToDigits(gRxVfo->freq_config_rx.frequency, String);
UI_DisplayFrequency(String, 16, 2, 0, 0); UI_DisplayFrequency(String, 16, 2, 0, 0);
UI_DisplaySmallDigits(2, String + 6, 97, 3, true); UI_DisplaySmallDigits(2, String + 6, 97, 3, true);
} }

View File

@ -53,11 +53,11 @@ void UI_DisplayFM(void)
{ {
if (gFM_ScanState == FM_SCAN_OFF) if (gFM_ScanState == FM_SCAN_OFF)
{ {
if (!gEeprom.FM_IsMrMode) if (!g_eeprom.fm_is_channel_mode)
{ {
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
{ {
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) if (g_eeprom.fm_frequency_playing == gFM_Channels[i])
{ {
sprintf(String, "VFO(CH%02u)", i + 1); sprintf(String, "VFO(CH%02u)", i + 1);
break; break;
@ -68,7 +68,7 @@ void UI_DisplayFM(void)
strcpy(String, "VFO"); strcpy(String, "VFO");
} }
else else
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1); sprintf(String, "MR(CH%02u)", g_eeprom.fm_selected_channel + 1);
} }
else else
{ {
@ -81,7 +81,7 @@ void UI_DisplayFM(void)
UI_PrintString(String, 0, 127, 2, 10); UI_PrintString(String, 0, 127, 2, 10);
memset(String, 0, sizeof(String)); memset(String, 0, sizeof(String));
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) if (gAskToSave || (g_eeprom.fm_is_channel_mode && gInputBoxIndex > 0))
{ {
UI_GenerateChannelString(String, gFM_ChannelPosition); UI_GenerateChannelString(String, gFM_ChannelPosition);
} }
@ -90,7 +90,7 @@ void UI_DisplayFM(void)
{ {
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
{ {
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String); NUMBER_ToDigits(g_eeprom.fm_frequency_playing * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true); UI_DisplayFrequency(String, 23, 4, false, true);
} }
else else
@ -101,7 +101,7 @@ void UI_DisplayFM(void)
} }
else else
{ {
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1); sprintf(String, "CH-%02u", g_eeprom.fm_selected_channel + 1);
} }
UI_PrintString(String, 0, 127, 4, 10); UI_PrintString(String, 0, 127, 4, 10);

View File

@ -21,7 +21,7 @@
char gInputBox[8]; char gInputBox[8];
uint8_t gInputBoxIndex; uint8_t gInputBoxIndex;
void INPUTBOX_Append(const KEY_Code_t Digit) void INPUTBOX_Append(const key_code_t Digit)
{ {
if (gInputBoxIndex >= sizeof(gInputBox)) if (gInputBoxIndex >= sizeof(gInputBox))
return; return;

View File

@ -24,7 +24,7 @@
extern char gInputBox[8]; extern char gInputBox[8];
extern uint8_t gInputBoxIndex; extern uint8_t gInputBoxIndex;
void INPUTBOX_Append(const KEY_Code_t Digit); void INPUTBOX_Append(const key_code_t Digit);
#endif #endif

View File

@ -50,7 +50,7 @@ static void Render(void)
void UI_DisplayLock(void) void UI_DisplayLock(void)
{ {
KEY_Code_t Key; key_code_t Key;
BEEP_Type_t Beep; BEEP_Type_t Beep;
gUpdateDisplay = true; gUpdateDisplay = true;
@ -67,17 +67,17 @@ void UI_DisplayLock(void)
Key = KEYBOARD_Poll(); Key = KEYBOARD_Poll();
if (gKeyReading0 == Key) if (g_key_reading_0 == Key)
{ {
if (++gDebounceCounter == key_debounce_10ms) if (++g_debounce_counter == key_debounce_10ms)
{ {
if (Key == KEY_INVALID) if (Key == KEY_INVALID)
{ {
gKeyReading1 = KEY_INVALID; g_key_reading_1 = KEY_INVALID;
} }
else else
{ {
gKeyReading1 = Key; g_key_reading_1 = Key;
switch (Key) switch (Key)
{ {
@ -105,7 +105,7 @@ void UI_DisplayLock(void)
NUMBER_Get(gInputBox, &Password); NUMBER_Get(gInputBox, &Password);
if ((gEeprom.POWER_ON_PASSWORD * 100) == Password) if ((g_eeprom.power_on_password * 100) == Password)
{ {
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
return; return;
@ -140,8 +140,8 @@ void UI_DisplayLock(void)
} }
else else
{ {
gDebounceCounter = 0; g_debounce_counter = 0;
gKeyReading0 = Key; g_key_reading_0 = Key;
} }
if (UART_IsCommandAvailable()) if (UART_IsCommandAvailable())

116
ui/main.c
View File

@ -56,11 +56,11 @@ center_line_t center_line = CENTER_LINE_NONE;
if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT) if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT)
return false; return false;
if (gEeprom.TX_TIMEOUT_TIMER == 0) if (g_eeprom.tx_timeout_timer == 0)
timeout_secs = 30; // 30 sec timeout_secs = 30; // 30 sec
else else
if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1))
timeout_secs = 60 * gEeprom.TX_TIMEOUT_TIMER; // minutes timeout_secs = 60 * g_eeprom.tx_timeout_timer; // minutes
else else
timeout_secs = 60 * 15; // 15 minutes timeout_secs = 60 * 15; // 15 minutes
@ -240,7 +240,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
char s[16]; char s[16];
unsigned int i; unsigned int i;
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (g_eeprom.key_lock && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || if (gCurrentFunction == FUNCTION_TRANSMIT ||
@ -313,10 +313,10 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
// 0000C0 6E 00 78 00 82 00 8C 00 B4 00 BE 00 C8 00 D2 00 // 0000C0 6E 00 78 00 82 00 8C 00 B4 00 BE 00 C8 00 D2 00
// //
const unsigned int band = 1; const unsigned int band = 1;
const int16_t level0 = gEEPROM_RSSI_CALIB[band][0]; const int16_t level0 = g_eeprom_RSSI_CALIB[band][0];
const int16_t level1 = gEEPROM_RSSI_CALIB[band][1]; const int16_t level1 = g_eeprom_RSSI_CALIB[band][1];
const int16_t level2 = gEEPROM_RSSI_CALIB[band][2]; const int16_t level2 = g_eeprom_RSSI_CALIB[band][2];
const int16_t level3 = gEEPROM_RSSI_CALIB[band][3]; const int16_t level3 = g_eeprom_RSSI_CALIB[band][3];
#else #else
const int16_t level0 = (-115 + 160) * 2; // dB const int16_t level0 = (-115 + 160) * 2; // dB
const int16_t level1 = ( -89 + 160) * 2; // dB const int16_t level1 = ( -89 + 160) * 2; // dB
@ -352,7 +352,7 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
// ********************************************************** // **********************************************************
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (g_eeprom.key_lock && gKeypadLocked > 0)
return; // display is in use return; // display is in use
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN)
@ -385,7 +385,7 @@ void UI_DisplayMain(void)
center_line = CENTER_LINE_NONE; center_line = CENTER_LINE_NONE;
// #ifdef SINGLE_VFO_CHAN // #ifdef SINGLE_VFO_CHAN
// const bool single_vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? true : false; // const bool single_vfo = (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? true : false;
// #else // #else
const bool single_vfo = false; const bool single_vfo = false;
// #endif // #endif
@ -393,7 +393,7 @@ void UI_DisplayMain(void)
// clear the screen // clear the screen
memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
if (gEeprom.KEY_LOCK && gKeypadLocked > 0) if (g_eeprom.key_lock && gKeypadLocked > 0)
{ // tell user how to unlock the keyboard { // tell user how to unlock the keyboard
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8); UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8); UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
@ -404,8 +404,8 @@ void UI_DisplayMain(void)
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; unsigned int channel = g_eeprom.tx_vfo;
// unsigned int tx_channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; // unsigned int tx_channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo;
const bool same_vfo = (channel == vfo_num) ? true : false; 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];
@ -421,8 +421,8 @@ void UI_DisplayMain(void)
} }
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) if (g_eeprom.dual_watch != DUAL_WATCH_OFF && gRxVfoIsActive)
channel = gEeprom.RX_VFO; // we're currently monitoring the other VFO channel = g_eeprom.rx_vfo; // we're currently monitoring the other VFO
if (channel != vfo_num) if (channel != vfo_num)
{ {
@ -472,7 +472,7 @@ void UI_DisplayMain(void)
if (!single_vfo && same_vfo) if (!single_vfo && same_vfo)
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) if (g_eeprom.cross_vfo_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));
} }
else else
@ -481,7 +481,7 @@ void UI_DisplayMain(void)
if (same_vfo) if (same_vfo)
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) //if (g_eeprom.cross_vfo_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));
} }
@ -494,7 +494,7 @@ void UI_DisplayMain(void)
else else
#endif #endif
{ {
channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo;
if (channel == vfo_num) if (channel == vfo_num)
{ // show the TX symbol { // show the TX symbol
mode = 1; mode = 1;
@ -512,7 +512,7 @@ void UI_DisplayMain(void)
if ((gCurrentFunction == FUNCTION_RECEIVE || if ((gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) && gCurrentFunction == FUNCTION_INCOMING) &&
gEeprom.RX_VFO == vfo_num) g_eeprom.rx_vfo == vfo_num)
{ {
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold("RX", 14, 0, line); UI_PrintStringSmallBold("RX", 14, 0, line);
@ -522,32 +522,32 @@ void UI_DisplayMain(void)
} }
} }
if (gEeprom.ScreenChannel[vfo_num] <= MR_CHANNEL_LAST) if (g_eeprom.screen_channel[vfo_num] <= USER_CHANNEL_LAST)
{ // channel mode { // channel mode
const unsigned int x = 2; const unsigned int x = 2;
const bool inputting = (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) ? false : true; const bool inputting = (gInputBoxIndex == 0 || g_eeprom.tx_vfo != vfo_num) ? false : true;
if (!inputting) if (!inputting)
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); // show the memory channel number NUMBER_ToDigits(g_eeprom.screen_channel[vfo_num] + 1, String); // show the memory channel number
else else
memmove(String + 5, gInputBox, 3); // show the input text memmove(String + 5, gInputBox, 3); // show the input text
UI_PrintStringSmall("M", x, 0, line + 1); UI_PrintStringSmall("M", x, 0, line + 1);
UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting); UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting);
} }
else else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
{ // frequency mode { // frequency mode
// show the frequency band number // show the frequency band number
const unsigned int x = 2; // was 14 const unsigned int x = 2; // was 14
// sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST); // sprintf(String, "FB%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST);
sprintf(String, "VFO%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST); sprintf(String, "VFO%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST);
UI_PrintStringSmall(String, x, 0, line + 1); UI_PrintStringSmall(String, x, 0, line + 1);
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
if (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) if (gInputBoxIndex == 0 || g_eeprom.tx_vfo != vfo_num)
{ // channel number { // channel number
sprintf(String, "N%u", 1 + gEeprom.ScreenChannel[vfo_num] - NOAA_CHANNEL_FIRST); sprintf(String, "N%u", 1 + g_eeprom.screen_channel[vfo_num] - NOAA_CHANNEL_FIRST);
} }
else else
{ // user entering channel number { // user entering channel number
@ -564,7 +564,7 @@ void UI_DisplayMain(void)
#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; channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo;
if (channel == vfo_num) if (channel == vfo_num)
state = VFO_STATE_ALARM; state = VFO_STATE_ALARM;
} }
@ -577,7 +577,7 @@ void UI_DisplayMain(void)
UI_PrintString(state_list[state], 31, 0, line, 8); UI_PrintString(state_list[state], 31, 0, line, 8);
} }
else else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num) if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]) && g_eeprom.tx_vfo == vfo_num)
{ // user entering a frequency { // user entering a frequency
UI_DisplayFrequency(gInputBox, 32, line, true, false); UI_DisplayFrequency(gInputBox, 32, line, true, false);
@ -585,25 +585,25 @@ void UI_DisplayMain(void)
} }
else else
{ {
uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; uint32_t frequency = g_eeprom.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; channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo;
if (channel == vfo_num) if (channel == vfo_num)
frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; frequency = g_eeprom.VfoInfo[vfo_num].pTX->frequency;
} }
if (gEeprom.ScreenChannel[vfo_num] <= MR_CHANNEL_LAST) if (g_eeprom.screen_channel[vfo_num] <= USER_CHANNEL_LAST)
{ // it's a channel { // it's a channel
// show the channel symbols // show the channel symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]];
if (attributes & MR_CH_SCANLIST1) if (attributes & USER_CH_SCANLIST1)
memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1));
if (attributes & MR_CH_SCANLIST2) if (attributes & USER_CH_SCANLIST2)
memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2));
#ifndef ENABLE_BIG_FREQ #ifndef ENABLE_BIG_FREQ
if ((attributes & MR_CH_COMPAND) > 0) if ((attributes & USER_CH_COMPAND) > 0)
memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
@ -614,7 +614,7 @@ void UI_DisplayMain(void)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (gEeprom.CHANNEL_DISPLAY_MODE) switch (g_eeprom.channel_display_mode)
{ {
case MDF_FREQUENCY: // show the channel frequency case MDF_FREQUENCY: // show the channel frequency
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
@ -631,20 +631,20 @@ void UI_DisplayMain(void)
break; break;
case MDF_CHANNEL: // show the channel number case MDF_CHANNEL: // show the channel number
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
UI_PrintString(String, 32, 0, line, 8); UI_PrintString(String, 32, 0, line, 8);
break; break;
case MDF_NAME: // show the channel name case MDF_NAME: // show the channel name
case MDF_NAME_FREQ: // show the channel name and frequency case MDF_NAME_FREQ: // show the channel name and frequency
BOARD_fetchChannelName(String, gEeprom.ScreenChannel[vfo_num]); BOARD_fetchChannelName(String, g_eeprom.screen_channel[vfo_num]);
if (String[0] == 0) if (String[0] == 0)
{ // no channel name, show the channel number instead { // no channel name, show the channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
} }
if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) if (g_eeprom.channel_display_mode == MDF_NAME)
{ {
UI_PrintString(String, 32, 0, line, 8); UI_PrintString(String, 32, 0, line, 8);
} }
@ -681,8 +681,8 @@ void UI_DisplayMain(void)
#endif #endif
// show the channel symbols // show the channel symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]];
if ((attributes & MR_CH_COMPAND) > 0) if ((attributes & USER_CH_COMPAND) > 0)
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
#else #else
@ -698,7 +698,7 @@ void UI_DisplayMain(void)
if (mode == 1) if (mode == 1)
{ // TX power level { // TX power level
switch (gRxVfo->OUTPUT_POWER) switch (gRxVfo->output_power)
{ {
case OUTPUT_POWER_LOW: Level = 2; break; case OUTPUT_POWER_LOW: Level = 2; break;
case OUTPUT_POWER_MID: Level = 4; break; case OUTPUT_POWER_MID: Level = 4; break;
@ -721,14 +721,14 @@ void UI_DisplayMain(void)
// ************ // ************
String[0] = '\0'; String[0] = '\0';
if (gEeprom.VfoInfo[vfo_num].AM_mode) if (g_eeprom.VfoInfo[vfo_num].am_mode)
{ // show the AM symbol { // show the AM symbol
strcpy(String, "AM"); strcpy(String, "AM");
} }
else else
{ // or show the CTCSS/DCS symbol { // or show the CTCSS/DCS symbol
const FREQ_Config_t *pConfig = (mode == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; const FREQ_Config_t *pConfig = (mode == 1) ? g_eeprom.VfoInfo[vfo_num].pTX : g_eeprom.VfoInfo[vfo_num].pRX;
const unsigned int code_type = pConfig->CodeType; const unsigned int code_type = pConfig->code_type;
const char *code_list[] = {"", "CT", "DCS", "DCR"}; const char *code_list[] = {"", "CT", "DCS", "DCR"};
if (code_type < ARRAY_SIZE(code_list)) if (code_type < ARRAY_SIZE(code_list))
strcpy(String, code_list[code_type]); strcpy(String, code_list[code_type]);
@ -738,28 +738,28 @@ void UI_DisplayMain(void)
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
{ // show the TX power { // show the TX power
const char pwr_list[] = "LMH"; const char pwr_list[] = "LMH";
const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER; const unsigned int i = g_eeprom.VfoInfo[vfo_num].output_power;
String[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0'; String[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
String[1] = '\0'; String[1] = '\0';
UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, line + 1); UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, line + 1);
} }
if (gEeprom.VfoInfo[vfo_num].freq_config_RX.Frequency != gEeprom.VfoInfo[vfo_num].freq_config_TX.Frequency) if (g_eeprom.VfoInfo[vfo_num].freq_config_rx.frequency != g_eeprom.VfoInfo[vfo_num].freq_config_tx.frequency)
{ // show the TX offset symbol { // show the TX offset symbol
const char dir_list[] = "\0+-"; const char dir_list[] = "\0+-";
const unsigned int i = gEeprom.VfoInfo[vfo_num].TX_OFFSET_FREQUENCY_DIRECTION; const unsigned int i = g_eeprom.VfoInfo[vfo_num].tx_offset_freq_dir;
String[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?'; String[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?';
String[1] = '\0'; String[1] = '\0';
UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1); UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1);
} }
// show the TX/RX reverse symbol // show the TX/RX reverse symbol
if (gEeprom.VfoInfo[vfo_num].FrequencyReverse) if (g_eeprom.VfoInfo[vfo_num].frequency_reverse)
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1); UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1);
{ // show the narrow band symbol { // show the narrow band symbol
String[0] = '\0'; String[0] = '\0';
if (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) if (g_eeprom.VfoInfo[vfo_num].channel_bandwidth == BANDWIDTH_NARROW)
{ {
String[0] = 'N'; String[0] = 'N';
String[1] = '\0'; String[1] = '\0';
@ -768,11 +768,11 @@ void UI_DisplayMain(void)
} }
// show the DTMF decoding symbol // show the DTMF decoding symbol
if (gEeprom.VfoInfo[vfo_num].DTMF_DECODING_ENABLE || gSetting_KILLED) if (g_eeprom.VfoInfo[vfo_num].DTMF_decoding_enable || gSetting_KILLED)
UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1);
// show the audio scramble symbol // show the audio scramble symbol
if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) if (g_eeprom.VfoInfo[vfo_num].scrambling_type > 0 && gSetting_ScrambleEnable)
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1); UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1);
} }
@ -804,13 +804,13 @@ void UI_DisplayMain(void)
#if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA)
// show the AM-FIX debug data // show the AM-FIX debug data
if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix) if (rx && g_eeprom.VfoInfo[g_eeprom.rx_vfo].am_mode && gSetting_AM_fix)
{ {
if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE)
return; return;
center_line = CENTER_LINE_AM_FIX_DATA; center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(gEeprom.RX_VFO, String); AM_fix_print_data(g_eeprom.rx_vfo, String);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(String, 2, 0, 3);
} }
else else
@ -821,7 +821,7 @@ void UI_DisplayMain(void)
if (rx) if (rx)
{ {
center_line = CENTER_LINE_RSSI; center_line = CENTER_LINE_RSSI;
UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false); UI_DisplayRSSIBar(gCurrentRSSI[g_eeprom.rx_vfo], false);
} }
else else
#endif #endif

View File

@ -53,9 +53,9 @@ const t_menu_item MenuList[] =
{"RxCTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS" {"RxCTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS"
{"Tx DCS", VOICE_ID_DCS, MENU_T_DCS }, // was "T_DCS" {"Tx DCS", VOICE_ID_DCS, MENU_T_DCS }, // was "T_DCS"
{"TxCTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS" {"TxCTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS"
{"Tx DIR", VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, MENU_SFT_D }, // was "SFT_D" {"Tx DIR", voice_id_tX_OFFSET_FREQ_DIR, MENU_SFT_D }, // was "SFT_D"
{"TxOFFS", VOICE_ID_TX_OFFSET_FREQUENCY, MENU_OFFSET }, // was "OFFSET" {"TxOFFS", voice_id_tX_OFFSET_FREQ, MENU_OFFSET }, // was "OFFSET"
{"Tx TO", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT" {"Tx TO", voice_id_tRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
{"Tx VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX" {"Tx VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX"
{"2nd RX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR" {"2nd RX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR"
{"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR" {"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR"
@ -288,7 +288,7 @@ const char gSubMenu_F_LOCK[6][4] =
"438" "438"
}; };
const char gSubMenu_BACKLIGHT[8][7] = const char gSubMenu_backlight[8][7] =
{ {
"OFF", "OFF",
"5 sec", "5 sec",
@ -556,16 +556,16 @@ 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 = (gMenuCursor == MENU_R_CTCS) ? &gTxVfo->freq_config_rx : &gTxVfo->freq_config_tx;
if (gSubMenuSelection == 0) if (gSubMenuSelection == 0)
{ {
strcpy(String, "OFF"); strcpy(String, "OFF");
if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE)
break; break;
Code = 0; Code = 0;
pConfig->CodeType = CODE_TYPE_OFF; pConfig->code_type = CODE_TYPE_OFF;
pConfig->Code = Code; pConfig->code = Code;
BK4819_ExitSubAu(); BK4819_ExitSubAu();
} }
@ -573,9 +573,9 @@ void UI_DisplayMenu(void)
{ {
sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10);
pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE;
Code = gSubMenuSelection - 1; Code = gSubMenuSelection - 1;
pConfig->Code = Code; pConfig->code = Code;
BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); BK4819_SetCTCSSFrequency(CTCSS_Options[Code]);
} }
@ -643,7 +643,7 @@ void UI_DisplayMenu(void)
#endif #endif
case MENU_ABR: case MENU_ABR:
strcpy(String, gSubMenu_BACKLIGHT[gSubMenuSelection]); strcpy(String, gSubMenu_backlight[gSubMenuSelection]);
break; break;
case MENU_AM: case MENU_AM:
@ -800,15 +800,15 @@ void UI_DisplayMenu(void)
#endif #endif
case MENU_ANI_ID: case MENU_ANI_ID:
strcpy(String, gEeprom.ANI_DTMF_ID); strcpy(String, g_eeprom.ani_DTMF_id);
break; break;
case MENU_UPCODE: case MENU_UPCODE:
strcpy(String, gEeprom.DTMF_UP_CODE); strcpy(String, g_eeprom.DTMF_up_code);
break; break;
case MENU_DWCODE: case MENU_DWCODE:
strcpy(String, gEeprom.DTMF_DOWN_CODE); strcpy(String, g_eeprom.DTMF_down_code);
break; break;
case MENU_D_RSP: case MENU_D_RSP:
@ -980,8 +980,8 @@ void UI_DisplayMenu(void)
else else
UI_GenerateChannelStringEx(String, true, gSubMenuSelection); UI_GenerateChannelStringEx(String, true, gSubMenuSelection);
// if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i]) // if (gSubMenuSelection == 0xFF || !g_eeprom.scan_list_enabled[i])
if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i]) if (gSubMenuSelection < 0 || !g_eeprom.scan_list_enabled[i])
{ {
// channel number // channel number
UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8);
@ -1003,15 +1003,15 @@ void UI_DisplayMenu(void)
strcpy(String, "--"); strcpy(String, "--");
UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 2); UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 2);
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i])) if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch1[i]))
{ {
sprintf(String, "PRI1:%u", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1); sprintf(String, "PRI1:%u", g_eeprom.scan_list_priority_ch1[i] + 1);
UI_PrintString(String, menu_item_x1, menu_item_x2, 3, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 3, 8);
} }
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i])) if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch2[i]))
{ {
sprintf(String, "PRI2:%u", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1); sprintf(String, "PRI2:%u", g_eeprom.scan_list_priority_ch2[i] + 1);
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
} }
} }
@ -1032,12 +1032,12 @@ void UI_DisplayMenu(void)
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 (gMenuCursor == MENU_UPCODE)
if (strlen(gEeprom.DTMF_UP_CODE) > 8) if (strlen(g_eeprom.DTMF_up_code) > 8)
UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(g_eeprom.DTMF_up_code + 8, menu_item_x1, menu_item_x2, 4, 8);
if (gMenuCursor == MENU_DWCODE) if (gMenuCursor == MENU_DWCODE)
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) if (strlen(g_eeprom.DTMF_down_code) > 8)
UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(g_eeprom.DTMF_down_code + 8, menu_item_x1, menu_item_x2, 4, 8);
if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid) if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid)
{ {

View File

@ -20,11 +20,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "audio.h" // VOICE_ID_t #include "audio.h" // voice_id_t
typedef struct { typedef struct {
const char name[7]; // menu display area only has room for 6 characters const char name[7]; // menu display area only has room for 6 characters
VOICE_ID_t voice_id; voice_id_t voice_id;
uint8_t menu_id; uint8_t menu_id;
} t_menu_item; } t_menu_item;
@ -164,7 +164,7 @@ extern const char gSubMenu_PONMSG[4][8];
extern const char gSubMenu_ROGER[3][9]; extern const char gSubMenu_ROGER[3][9];
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];
extern const char gSubMenu_RX_TX[4][6]; extern const char gSubMenu_RX_TX[4][6];
#ifdef ENABLE_AM_FIX_TEST1 #ifdef ENABLE_AM_FIX_TEST1
extern const char gSubMenu_AM_fix_test1[4][8]; extern const char gSubMenu_AM_fix_test1[4][8];

View File

@ -96,15 +96,15 @@ void UI_DisplayStatus(const bool test_display)
// 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 (gNextChannel <= USER_CHANNEL_LAST)
{ // channel mode { // channel mode
if (gEeprom.SCAN_LIST_DEFAULT == 0) if (g_eeprom.scan_list_default == 0)
UI_PrintStringSmallBuffer("1", line + x); UI_PrintStringSmallBuffer("1", line + x);
else else
if (gEeprom.SCAN_LIST_DEFAULT == 1) if (g_eeprom.scan_list_default == 1)
UI_PrintStringSmallBuffer("2", line + x); UI_PrintStringSmallBuffer("2", line + x);
else else
if (gEeprom.SCAN_LIST_DEFAULT == 2) if (g_eeprom.scan_list_default == 2)
UI_PrintStringSmallBuffer("*", line + x); UI_PrintStringSmallBuffer("*", line + x);
} }
else else
@ -117,7 +117,7 @@ void UI_DisplayStatus(const bool test_display)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
// VOICE indicator // VOICE indicator
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display) if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF || 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);
@ -128,7 +128,7 @@ void UI_DisplayStatus(const bool test_display)
#endif #endif
// DUAL-WATCH indicator // DUAL-WATCH indicator
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display) if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display)
{ {
if (gDualWatchActive || test_display) if (gDualWatchActive || test_display)
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1)); memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1));
@ -138,7 +138,7 @@ void UI_DisplayStatus(const bool test_display)
x += sizeof(BITMAP_TDR1); x += sizeof(BITMAP_TDR1);
// CROSS-VFO indicator // CROSS-VFO indicator
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display) if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF || test_display)
{ {
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB)); memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
x1 = x + sizeof(BITMAP_XB); x1 = x + sizeof(BITMAP_XB);
@ -147,7 +147,7 @@ void UI_DisplayStatus(const bool test_display)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
// VOX indicator // VOX indicator
if (gEeprom.VOX_SWITCH || test_display) if (g_eeprom.vox_switch || 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);
@ -156,14 +156,14 @@ void UI_DisplayStatus(const bool test_display)
#endif #endif
// KEY-LOCK indicator // KEY-LOCK indicator
if (gEeprom.KEY_LOCK || test_display) if (g_eeprom.key_lock || test_display)
{ {
memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
x += sizeof(BITMAP_KeyLock); x += sizeof(BITMAP_KeyLock);
x1 = x; x1 = x;
} }
else else
if (gWasFKeyPressed) if (g_was_f_key_pressed)
{ {
memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key)); memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
x += sizeof(BITMAP_F_Key); x += sizeof(BITMAP_F_Key);

View File

@ -94,7 +94,7 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
gAskForConfirmation = 0; gAskForConfirmation = 0;
gAskToSave = false; gAskToSave = false;
gAskToDelete = false; gAskToDelete = false;
gWasFKeyPressed = false; g_was_f_key_pressed = false;
gUpdateStatus = true; gUpdateStatus = true;
} }

View File

@ -48,12 +48,12 @@ void UI_DisplayWelcome(void)
memset(gStatusLine, 0, sizeof(gStatusLine)); memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE) if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_NONE)
{ {
ST7565_FillScreen(0xFF); ST7565_FillScreen(0xFF);
} }
else else
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_FULL_SCREEN) if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_FULL_SCREEN)
{ {
ST7565_FillScreen(0xFF); ST7565_FillScreen(0xFF);
} }
@ -63,7 +63,7 @@ void UI_DisplayWelcome(void)
memset(WelcomeString1, 0, sizeof(WelcomeString1)); memset(WelcomeString1, 0, sizeof(WelcomeString1));
memset(WelcomeString2, 0, sizeof(WelcomeString2)); memset(WelcomeString2, 0, sizeof(WelcomeString2));
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE) if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_VOLTAGE)
{ {
strcpy(WelcomeString0, "VOLTAGE"); strcpy(WelcomeString0, "VOLTAGE");
sprintf(WelcomeString1, "%u.%02uV %u%%", sprintf(WelcomeString1, "%u.%02uV %u%%",

View File

@ -4,7 +4,7 @@
#ifdef GIT_HASH #ifdef GIT_HASH
#define VER GIT_HASH #define VER GIT_HASH
#else #else
#define VER "231007" #define VER "231009"
#endif #endif
#ifndef ONE_OF_ELEVEN_VER #ifndef ONE_OF_ELEVEN_VER