diff --git a/Makefile b/Makefile index d11594b..f9cb794 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ ENABLE_LTO := 1 ENABLE_UART := 1 ENABLE_AIRCOPY := 0 ENABLE_FMRADIO := 1 -ENABLE_NOAA := 0 +ENABLE_NOAA := 1 ENABLE_VOICE := 1 ENABLE_VOX := 1 -ENABLE_ALARM := 0 +ENABLE_ALARM := 1 ENABLE_TX1750 := 1 -ENABLE_PWRON_PASSWORD := 0 +ENABLE_PWRON_PASSWORD := 1 ENABLE_BIG_FREQ := 0 ENABLE_SMALL_BOLD := 1 ENABLE_KEEP_MEM_NAME := 1 @@ -33,8 +33,8 @@ ENABLE_AM_FIX_SHOW_DATA := 1 ENABLE_SQUELCH_MORE_SENSITIVE := 1 ENABLE_FASTER_CHANNEL_SCAN := 1 ENABLE_RSSI_BAR := 1 -ENABLE_AUDIO_BAR := 0 ENABLE_SHOW_TX_TIMEOUT := 1 +ENABLE_AUDIO_BAR := 0 ENABLE_COPY_CHAN_TO_VFO := 1 #ENABLE_PANADAPTER := 1 #ENABLE_SINGLE_VFO_CHAN := 1 @@ -53,6 +53,11 @@ ifeq ($(ENABLE_LTO),1) ENABLE_OVERLAY := 0 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_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS)) BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS)) @@ -108,6 +113,9 @@ OBJS += app/generic.o OBJS += app/main.o OBJS += app/menu.o OBJS += app/scanner.o +ifeq ($(ENABLE_PANADAPTER),1) + OBJS += app/spectrum.o +endif ifeq ($(ENABLE_UART),1) OBJS += app/uart.o endif @@ -295,8 +303,8 @@ endif ifeq ($(ENABLE_FASTER_CHANNEL_SCAN),1) CFLAGS += -DENABLE_FASTER_CHANNEL_SCAN endif -ifeq ($(ENABLE_BACKLIGHT_ON_RX),1) - CFLAGS += -DENABLE_BACKLIGHT_ON_RX +ifeq ($(ENABLE_backlight_ON_RX),1) + CFLAGS += -DENABLE_backlight_ON_RX endif ifeq ($(ENABLE_RSSI_BAR),1) CFLAGS += -DENABLE_RSSI_BAR diff --git a/app/action.c b/app/action.c index 36b61f6..8156119 100644 --- a/app/action.c +++ b/app/action.c @@ -55,14 +55,14 @@ static void ACTION_FlashLight(void) void ACTION_Power(void) { - if (++gTxVfo->OUTPUT_POWER > OUTPUT_POWER_HIGH) - gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW; + if (++gTxVfo->output_power > OUTPUT_POWER_HIGH) + gTxVfo->output_power = OUTPUT_POWER_LOW; gRequestSaveChannel = 1; //gRequestSaveChannel = 2; // auto save the channel #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_POWER; + g_another_voice_id = VOICE_ID_POWER; #endif gRequestDisplayScreen = gScreenToDisplay; @@ -74,8 +74,8 @@ void ACTION_Monitor(void) { // enable the monitor RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST && gIsNoaaMode) - gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; + if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST && gIsNoaaMode) + gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST; #endif RADIO_SetupRegisters(true); APP_StartListening(FUNCTION_MONITOR, false); @@ -92,7 +92,7 @@ void ACTION_Monitor(void) } #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; gScheduleNOAA = false; @@ -130,7 +130,7 @@ void ACTION_Scan(bool bRestart) FM_PlayAndUpdate(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } else @@ -142,20 +142,20 @@ void ACTION_Scan(bool bRestart) gFM_AutoScan = true; gFM_ChannelPosition = 0; FM_EraseChannels(); - Frequency = gEeprom.FM_LowerLimit; + Frequency = g_eeprom.fm_lower_limit; } else { gFM_AutoScan = false; gFM_ChannelPosition = 0; - Frequency = gEeprom.FM_FrequencyPlaying; + Frequency = g_eeprom.fm_frequency_playing; } BK1080_GetFrequencyDeviation(Frequency); FM_Tune(Frequency, 1, bRestart); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN; + g_another_voice_id = VOICE_ID_SCANNING_BEGIN; #endif } } @@ -177,7 +177,7 @@ void ACTION_Scan(bool bRestart) RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) #endif { GUI_SelectNextDisplay(DISPLAY_MAIN); @@ -185,11 +185,11 @@ void ACTION_Scan(bool bRestart) if (gScanStateDir != SCAN_OFF) { // already scanning - if (gNextMrChannel <= MR_CHANNEL_LAST) + if (gNextChannel <= USER_CHANNEL_LAST) { // 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 CHANNEL_Next(true, gScanStateDir); @@ -204,7 +204,7 @@ void ACTION_Scan(bool bRestart) SCANNER_Stop(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } } @@ -219,7 +219,7 @@ void ACTION_Scan(bool bRestart) #endif // 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 gDualWatchActive = false; @@ -229,9 +229,9 @@ void ACTION_Scan(bool bRestart) } else // if (!bRestart) - if (!bRestart && gNextMrChannel <= MR_CHANNEL_LAST) + if (!bRestart && gNextChannel <= USER_CHANNEL_LAST) { // 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 CHANNEL_Next(true, gScanStateDir); @@ -247,7 +247,7 @@ void ACTION_Scan(bool bRestart) SCANNER_Stop(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif gRequestDisplayScreen = DISPLAY_MAIN; @@ -257,11 +257,11 @@ void ACTION_Scan(bool bRestart) #ifdef ENABLE_VOX void ACTION_Vox(void) { - gEeprom.VOX_SWITCH = !gEeprom.VOX_SWITCH; + g_eeprom.vox_switch = !g_eeprom.vox_switch; gRequestSaveSettings = true; gFlagReconfigureVfos = true; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_VOX; + g_another_voice_id = VOICE_ID_VOX; #endif gUpdateStatus = true; } @@ -323,7 +323,7 @@ void ACTION_Scan(bool bRestart) } #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 Long = ACTION_OPT_NONE; @@ -346,7 +346,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif gRequestDisplayScreen = DISPLAY_MAIN; @@ -359,14 +359,14 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Key == KEY_SIDE1) { - Short = gEeprom.KEY_1_SHORT_PRESS_ACTION; - Long = gEeprom.KEY_1_LONG_PRESS_ACTION; + Short = g_eeprom.key1_short_press_action; + Long = g_eeprom.key1_long_press_action; } else if (Key == KEY_SIDE2) { - Short = gEeprom.KEY_2_SHORT_PRESS_ACTION; - Long = gEeprom.KEY_2_LONG_PRESS_ACTION; + Short = g_eeprom.key2_short_press_action; + Long = g_eeprom.key2_long_press_action; } if (!bKeyHeld && bKeyPressed) diff --git a/app/action.h b/app/action.h index 3008d4e..b568599 100644 --- a/app/action.h +++ b/app/action.h @@ -33,7 +33,7 @@ void ACTION_Scan(bool bFlag); void ACTION_FM(void); #endif -void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); +void ACTION_Handle(key_code_t Key, bool bKeyPressed, bool bKeyHeld); #endif diff --git a/app/aircopy.c b/app/aircopy.c index c257e28..8e9cd85 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -113,7 +113,7 @@ void AIRCOPY_StorePacket(void) 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) { @@ -125,7 +125,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex < 6) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif 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) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gRxVfo->Band = i; + gRxVfo->band = i; Frequency += 75; - Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->StepFrequency, 0); - gRxVfo->freq_config_RX.Frequency = Frequency; - gRxVfo->freq_config_TX.Frequency = Frequency; + Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->step_freq, 0); + gRxVfo->freq_config_rx.frequency = Frequency; + gRxVfo->freq_config_tx.frequency = Frequency; RADIO_ConfigureSquelchAndOutputPower(gRxVfo); gCurrentVfo = gRxVfo; 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) { diff --git a/app/aircopy.h b/app/aircopy.h index d951290..c52fa14 100644 --- a/app/aircopy.h +++ b/app/aircopy.h @@ -21,25 +21,24 @@ #include "driver/keyboard.h" -enum AIRCOPY_State_t +enum aircopy_state_e { AIRCOPY_READY = 0, AIRCOPY_TRANSFER, 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 gAirCopyBlockNumber; -extern uint16_t gErrorsDuringAirCopy; -extern uint8_t gAirCopyIsSendMode; - -extern uint16_t g_FSK_Buffer[36]; +extern uint16_t g_fsk_buffer[36]; void AIRCOPY_SendMessage(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 diff --git a/app/app.c b/app/app.c index e0caf33..e5b52a9 100644 --- a/app/app.c +++ b/app/app.c @@ -69,7 +69,7 @@ const uint8_t orig_lna = 2; // -14dB const uint8_t orig_mixer = 3; // 0dB const uint8_t orig_pga = 6; // -3dB -static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); +static void APP_ProcessKey(key_code_t Key, bool bKeyPressed, bool bKeyHeld); static void updateRSSI(const int vfo) { @@ -77,7 +77,7 @@ static void updateRSSI(const int vfo) #ifdef ENABLE_AM_FIX // add RF gain adjust compensation - if (gEeprom.VfoInfo[vfo].AM_mode && gSetting_AM_fix) + if (g_eeprom.VfoInfo[vfo].am_mode && gSetting_AM_fix) rssi -= rssi_gain_diff[vfo]; #endif @@ -107,7 +107,7 @@ static void APP_CheckForIncoming(void) gRxReceptionMode = RX_MODE_DETECTED; } - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF) { // dual watch is disabled #ifdef ENABLE_NOAA @@ -123,7 +123,7 @@ static void APP_CheckForIncoming(void) FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); gUpdateRSSI = true; } @@ -139,7 +139,7 @@ static void APP_CheckForIncoming(void) FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); gUpdateRSSI = true; } return; @@ -161,7 +161,7 @@ static void APP_CheckForIncoming(void) FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); gUpdateRSSI = true; } return; @@ -178,7 +178,7 @@ static void APP_CheckForIncoming(void) FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); gUpdateRSSI = true; } } @@ -201,23 +201,23 @@ static void APP_HandleIncoming(void) return; } - bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF); + bFlag = (gScanStateDir == SCAN_OFF && gCurrentcode_type == CODE_TYPE_OFF); #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) + if (IS_NOAA_CHANNEL(gRxVfo->channel_save) && gNOAACountdown_10ms > 0) { gNOAACountdown_10ms = 0; bFlag = true; } #endif - if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) + if (g_CTCSS_lost && gCurrentcode_type == CODE_TYPE_CONTINUOUS_TONE) { bFlag = true; gFoundCTCSS = false; } - if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) + if (g_CDCSS_lost && g_CDCSS_code_type == CDCSS_POSITIVE_CODE && (gCurrentcode_type == CODE_TYPE_DIGITAL || gCurrentcode_type == CODE_TYPE_REVERSE_DIGITAL)) { gFoundCDCSS = false; } @@ -227,7 +227,7 @@ static void APP_HandleIncoming(void) if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) { // not scanning - if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) + if (gRxVfo->DTMF_decoding_enable || gSetting_KILLED) { // DTMF DCD is enabled DTMF_HandleRequest(); @@ -269,7 +269,7 @@ static void APP_HandleReceive(void) goto Skip; } - if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel)) + if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextChannel)) { if (g_SquelchLost) return; @@ -278,7 +278,7 @@ static void APP_HandleReceive(void) goto Skip; } - switch (gCurrentCodeType) + switch (gCurrentcode_type) { default: case CODE_TYPE_OFF: @@ -309,26 +309,26 @@ static void APP_HandleReceive(void) if (g_SquelchLost) { #ifdef ENABLE_NOAA - if (!gEndOfRxDetectedMaybe && IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + if (!gEndOfRxDetectedMaybe && IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) #else if (!gEndOfRxDetectedMaybe) #endif { - switch (gCurrentCodeType) + switch (gCurrentcode_type) { case CODE_TYPE_OFF: - if (gEeprom.SQUELCH_LEVEL) + if (g_eeprom.squelch_level) { - if (g_CxCSS_TAIL_Found) + if (g_CxCSS_tailL_found) { Mode = END_OF_RX_MODE_TTE; - g_CxCSS_TAIL_Found = false; + g_CxCSS_tailL_found = false; } } break; case CODE_TYPE_CONTINUOUS_TONE: - if (g_CTCSS_Lost) + if (g_CTCSS_lost) { gFoundCTCSS = false; } @@ -339,16 +339,16 @@ static void APP_HandleReceive(void) gFoundCTCSSCountdown_10ms = 100; // 1 sec } - if (g_CxCSS_TAIL_Found) + if (g_CxCSS_tailL_found) { Mode = END_OF_RX_MODE_TTE; - g_CxCSS_TAIL_Found = false; + g_CxCSS_tailL_found = false; } break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE) + if (g_CDCSS_lost && g_CDCSS_code_type == CDCSS_POSITIVE_CODE) { gFoundCDCSS = false; } @@ -359,12 +359,12 @@ static void APP_HandleReceive(void) gFoundCDCSSCountdown_10ms = 100; // 1 sec } - if (g_CxCSS_TAIL_Found) + if (g_CxCSS_tailL_found) { if (BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; - g_CxCSS_TAIL_Found = false; + g_CxCSS_tailL_found = false; } break; @@ -377,8 +377,8 @@ static void APP_HandleReceive(void) if (!gEndOfRxDetectedMaybe && Mode == END_OF_RX_MODE_SKIP && gNextTimeslice40ms && - gEeprom.TAIL_NOTE_ELIMINATION && - (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) && + g_eeprom.tail_note_elimination && + (gCurrentcode_type == CODE_TYPE_DIGITAL || gCurrentcode_type == CODE_TYPE_REVERSE_DIGITAL) && BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; else @@ -394,7 +394,7 @@ Skip: RADIO_SetupRegisters(true); #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + if (IS_NOAA_CHANNEL(gRxVfo->channel_save)) gNOAACountdown_10ms = 300; // 3 sec #endif @@ -402,7 +402,7 @@ Skip: if (gScanStateDir != SCAN_OFF) { - switch (gEeprom.SCAN_RESUME_MODE) + switch (g_eeprom.scan_resume_mode) { case SCAN_RESUME_TO: break; @@ -421,7 +421,7 @@ Skip: break; case END_OF_RX_MODE_TTE: - if (gEeprom.TAIL_NOTE_ELIMINATION) + if (g_eeprom.tail_note_elimination) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); @@ -457,7 +457,7 @@ static void APP_HandleFunction(void) break; case FUNCTION_POWER_SAVE: - if (!gRxIdleMode) + if (!g_rx_idle_mode) APP_CheckForIncoming(); break; @@ -468,8 +468,8 @@ static void APP_HandleFunction(void) void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) { - const unsigned int chan = gEeprom.RX_VFO; -// const unsigned int chan = gRxVfo->CHANNEL_SAVE; + const unsigned int chan = g_eeprom.rx_vfo; +// const unsigned int chan = gRxVfo->channel_save; if (gSetting_KILLED) return; @@ -487,11 +487,11 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) gEnableSpeaker = true; if (gSetting_backlight_on_tx_rx >= 2) - BACKLIGHT_TurnOn(); + backlight_turn_on(); if (gScanStateDir != SCAN_OFF) { - switch (gEeprom.SCAN_RESUME_MODE) + switch (g_eeprom.scan_resume_mode) { case SCAN_RESUME_TO: if (!gScanPauseMode) @@ -513,12 +513,12 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) } #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gIsNoaaMode) + if (IS_NOAA_CHANNEL(gRxVfo->channel_save) && gIsNoaaMode) { - gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST; - gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel]; - gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel]; - gEeprom.ScreenChannel[chan] = gRxVfo->CHANNEL_SAVE; + gRxVfo->channel_save = gNoaaChannel + NOAA_CHANNEL_FIRST; + gRxVfo->pRX->frequency = NoaaFrequencyTable[gNoaaChannel]; + gRxVfo->pTX->frequency = NoaaFrequencyTable[gNoaaChannel]; + g_eeprom.screen_channel[chan] = gRxVfo->channel_save; gNOAA_Countdown_10ms = 500; // 5 sec gScheduleNOAA = false; @@ -530,7 +530,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && - gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + g_eeprom.dual_watch != DUAL_WATCH_OFF) { // not scanning, dual watch is enabled gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms; @@ -552,7 +552,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) uint16_t pga = orig_pga; #ifdef ENABLE_AM_FIX - if (gRxVfo->AM_mode && gSetting_AM_fix) + if (gRxVfo->am_mode && gSetting_AM_fix) { // AM RX mode if (reset_am_fix) AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency @@ -571,13 +571,13 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) BK4819_WriteRegister(BK4819_REG_48, (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference ( 0u << 10) | // AF Rx Gain-1 - (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 - (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) + (g_eeprom.volume_gain << 4) | // AF Rx Gain-2 + (g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2) #ifdef ENABLE_VOICE - if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished + if (g_voice_write_index == 0) // AM/FM RX mode will be set when the voice has finished #endif - BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now + BK4819_SetAF(gRxVfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now FUNCTION_Select(Function); @@ -598,11 +598,11 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) { - uint32_t Frequency = pInfo->freq_config_RX.Frequency + (Step * pInfo->StepFrequency); + uint32_t Frequency = pInfo->freq_config_rx.frequency + (Step * pInfo->step_freq); - if (pInfo->StepFrequency == 833) + if (pInfo->step_freq == 833) { - const uint32_t Lower = frequencyBandTable[pInfo->Band].lower; + const uint32_t Lower = frequencyBandTable[pInfo->band].lower; const uint32_t Delta = Frequency - Lower; uint32_t Base = (Delta / 2500) * 2500; const uint32_t Index = ((Delta - Base) % 2500) / 833; @@ -613,18 +613,18 @@ uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) Frequency = Lower + Base + (Index * 833); } - if (Frequency >= frequencyBandTable[pInfo->Band].upper) - Frequency = frequencyBandTable[pInfo->Band].lower; + if (Frequency >= frequencyBandTable[pInfo->band].upper) + Frequency = frequencyBandTable[pInfo->band].lower; else - if (Frequency < frequencyBandTable[pInfo->Band].lower) - Frequency = FREQUENCY_FloorToStep(frequencyBandTable[pInfo->Band].upper, pInfo->StepFrequency, frequencyBandTable[pInfo->Band].lower); + if (Frequency < frequencyBandTable[pInfo->band].lower) + Frequency = FREQUENCY_FloorToStep(frequencyBandTable[pInfo->band].upper, pInfo->step_freq, frequencyBandTable[pInfo->band].lower); return Frequency; } static void FREQ_NextChannel(void) { - gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir); + gRxVfo->freq_config_rx.frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir); RADIO_ApplyOffset(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo); @@ -640,14 +640,14 @@ static void FREQ_NextChannel(void) gUpdateDisplay = true; } -static void MR_NextChannel(void) +static void USER_NextChannel(void) { - static unsigned int prev_mr_chan = 0; - const bool enabled = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCAN_LIST_ENABLED[gEeprom.SCAN_LIST_DEFAULT] : true; - const int chan1 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH1[gEeprom.SCAN_LIST_DEFAULT] : -1; - const int chan2 = (gEeprom.SCAN_LIST_DEFAULT < 2) ? gEeprom.SCANLIST_PRIORITY_CH2[gEeprom.SCAN_LIST_DEFAULT] : -1; - const unsigned int prev_chan = gNextMrChannel; - unsigned int chan = 0; + static unsigned int prevChannel = 0; + const bool enabled = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_enabled[g_eeprom.scan_list_default] : true; + const int chan1 = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_priority_ch1[g_eeprom.scan_list_default] : -1; + const int chan2 = (g_eeprom.scan_list_default < 2) ? g_eeprom.scan_list_priority_ch2[g_eeprom.scan_list_default] : -1; + const unsigned int prev_chan = gNextChannel; + unsigned int chan = 0; if (enabled) { @@ -657,14 +657,14 @@ static void MR_NextChannel(void) switch (gCurrentScanList) { case SCAN_NEXT_CHAN_SCANLIST1: - prev_mr_chan = gNextMrChannel; + prevChannel = gNextChannel; if (chan1 >= 0) { if (RADIO_CheckValidChannel(chan1, false, 0)) { gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; - gNextMrChannel = chan1; + gNextChannel = chan1; break; } } @@ -675,30 +675,30 @@ static void MR_NextChannel(void) if (RADIO_CheckValidChannel(chan2, false, 0)) { gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2; - gNextMrChannel = chan2; + gNextChannel = chan2; break; } } // this bit doesn't yet work if the other VFO is a frequency - case SCAN_NEXT_CHAN_DUAL_WATCH: + case SCAN_NEXT_CHAN_dual_watch: // dual watch is enabled - include the other VFO in the scan -// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) +// if (g_eeprom.dual_watch != DUAL_WATCH_OFF) // { -// chan = (gEeprom.RX_VFO + 1) & 1u; -// chan = gEeprom.ScreenChannel[chan]; -// if (chan <= MR_CHANNEL_LAST) +// chan = (g_eeprom.rx_vfo + 1) & 1u; +// chan = g_eeprom.screen_channel[chan]; +// if (chan <= USER_CHANNEL_LAST) // { -// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH; -// gNextMrChannel = chan; +// gCurrentScanList = SCAN_NEXT_CHAN_dual_watch; +// gNextChannel = chan; // break; // } // } default: - case SCAN_NEXT_CHAN_MR: - gCurrentScanList = SCAN_NEXT_CHAN_MR; - gNextMrChannel = prev_mr_chan; + case SCAN_NEXT_CHAN_USER: + gCurrentScanList = SCAN_NEXT_CHAN_USER; + gNextChannel = prevChannel; chan = 0xff; break; } @@ -708,23 +708,23 @@ static void MR_NextChannel(void) if (!enabled || chan == 0xff) { - chan = RADIO_FindNextChannel(gNextMrChannel + gScanStateDir, gScanStateDir, (gEeprom.SCAN_LIST_DEFAULT < 2) ? true : false, gEeprom.SCAN_LIST_DEFAULT); + chan = RADIO_FindNextChannel(gNextChannel + gScanStateDir, gScanStateDir, (g_eeprom.scan_list_default < 2) ? true : false, g_eeprom.scan_list_default); if (chan == 0xFF) { // no valid channel found - chan = MR_CHANNEL_FIRST; + chan = USER_CHANNEL_FIRST; // return; } - gNextMrChannel = chan; + gNextChannel = chan; } - if (gNextMrChannel != prev_chan) + if (gNextChannel != prev_chan) { - gEeprom.MrChannel[ gEeprom.RX_VFO] = gNextMrChannel; - gEeprom.ScreenChannel[gEeprom.RX_VFO] = gNextMrChannel; + g_eeprom.user_channel[g_eeprom.rx_vfo] = gNextChannel; + g_eeprom.screen_channel[g_eeprom.rx_vfo] = gNextChannel; - RADIO_ConfigureChannel(gEeprom.RX_VFO, VFO_CONFIGURE_RELOAD); + RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD); RADIO_SetupRegisters(true); gUpdateDisplay = true; @@ -756,21 +756,21 @@ static void DUALWATCH_Alternate(void) #ifdef ENABLE_NOAA if (gIsNoaaMode) { - if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) - gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1; + if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) || IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) + g_eeprom.rx_vfo = (g_eeprom.rx_vfo + 1) & 1; else - gEeprom.RX_VFO = 0; + g_eeprom.rx_vfo = 0; - gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; + gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; - if (gEeprom.VfoInfo[0].CHANNEL_SAVE >= NOAA_CHANNEL_FIRST) + if (g_eeprom.VfoInfo[0].channel_save >= NOAA_CHANNEL_FIRST) NOAA_IncreaseChannel(); } else #endif { // toggle between VFO's - gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1; - gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; + g_eeprom.rx_vfo = (g_eeprom.rx_vfo + 1) & 1; + gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; if (!gDualWatchActive) { // let the user see DW is active @@ -810,7 +810,7 @@ void APP_CheckRadioInterrupts(void) // 3 = 240deg phase shift // const uint8_t ctcss_shift = BK4819_GetCTCShift(); // if (ctcss_shift > 0) -// g_CTCSS_Lost = true; +// g_CTCSS_lost = true; if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND) { // save the RX'ed DTMF character @@ -833,7 +833,7 @@ void APP_CheckRadioInterrupts(void) gUpdateDisplay = true; } - if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) + if (gRxVfo->DTMF_decoding_enable || gSetting_KILLED) { if (gDTMF_RX_index >= (sizeof(gDTMF_RX) - 1)) { // make room @@ -852,38 +852,38 @@ void APP_CheckRadioInterrupts(void) } if (interrupt_status_bits & BK4819_REG_02_CxCSS_TAIL) - g_CxCSS_TAIL_Found = true; + g_CxCSS_tailL_found = true; if (interrupt_status_bits & BK4819_REG_02_CDCSS_LOST) { - g_CDCSS_Lost = true; - gCDCSSCodeType = BK4819_GetCDCSSCodeType(); + g_CDCSS_lost = true; + g_CDCSS_code_type = BK4819_get_CDCSS_code_type(); } if (interrupt_status_bits & BK4819_REG_02_CDCSS_FOUND) - g_CDCSS_Lost = false; + g_CDCSS_lost = false; if (interrupt_status_bits & BK4819_REG_02_CTCSS_LOST) - g_CTCSS_Lost = true; + g_CTCSS_lost = true; if (interrupt_status_bits & BK4819_REG_02_CTCSS_FOUND) - g_CTCSS_Lost = false; + g_CTCSS_lost = false; #ifdef ENABLE_VOX if (interrupt_status_bits & BK4819_REG_02_VOX_LOST) { - g_VOX_Lost = true; - gVoxPauseCountdown = 10; + g_vox_lost = true; + g_vox_pause_count_down = 10; - if (gEeprom.VOX_SWITCH) + if (g_eeprom.vox_switch) { - if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) + if (gCurrentFunction == FUNCTION_POWER_SAVE && !g_rx_idle_mode) { gPowerSave_10ms = power_save2_10ms; gPowerSaveCountdownExpired = 0; } - if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) + if (g_eeprom.dual_watch != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) { gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms; gScheduleDualWatch = false; @@ -897,8 +897,8 @@ void APP_CheckRadioInterrupts(void) if (interrupt_status_bits & BK4819_REG_02_VOX_FOUND) { - g_VOX_Lost = false; - gVoxPauseCountdown = 0; + g_vox_lost = false; + g_vox_pause_count_down = 0; } #endif @@ -934,11 +934,11 @@ void APP_EndTransmission(void) RADIO_SendEndOfTransmission(); - if (gCurrentVfo->pTX->CodeType != CODE_TYPE_OFF) + if (gCurrentVfo->pTX->code_type != CODE_TYPE_OFF) { // CTCSS/DCS is enabled - //if (gEeprom.TAIL_NOTE_ELIMINATION && gEeprom.REPEATER_TAIL_TONE_ELIMINATION > 0) - if (gEeprom.TAIL_NOTE_ELIMINATION) + //if (g_eeprom.tail_note_elimination && g_eeprom.repeater_tail_tone_elimination > 0) + if (g_eeprom.tail_note_elimination) { // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash RADIO_EnableCxCSS(); } @@ -963,13 +963,13 @@ void APP_EndTransmission(void) if (gVoxResumeCountdown == 0) { - if (gVoxPauseCountdown) + if (g_vox_pause_count_down) return; } else { - g_VOX_Lost = false; - gVoxPauseCountdown = 0; + g_vox_lost = false; + g_vox_pause_count_down = 0; } #ifdef ENABLE_FMRADIO @@ -985,7 +985,7 @@ void APP_EndTransmission(void) if (gVOX_NoiseDetected) { - if (g_VOX_Lost) + if (g_vox_lost) gVoxStopCountdown_10ms = vox_stop_count_down_10ms; else if (gVoxStopCountdown_10ms == 0) @@ -1002,13 +1002,13 @@ void APP_EndTransmission(void) { APP_EndTransmission(); - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) + if (g_eeprom.repeater_tail_tone_elimination == 0) { //if (gCurrentFunction != FUNCTION_FOREGROUND) FUNCTION_Select(FUNCTION_FOREGROUND); } else - gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; + gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; } gUpdateStatus = true; @@ -1018,7 +1018,7 @@ void APP_EndTransmission(void) return; } - if (g_VOX_Lost) + if (g_vox_lost) { gVOX_NoiseDetected = true; @@ -1038,10 +1038,10 @@ void APP_EndTransmission(void) void APP_Update(void) { #ifdef ENABLE_VOICE - if (gFlagPlayQueuedVoice) + if (g_flag_play_queued_voice) { AUDIO_PlayQueuedVoice(); - gFlagPlayQueuedVoice = false; + g_flag_play_queued_voice = false; } #endif @@ -1072,13 +1072,13 @@ void APP_Update(void) #endif #ifdef ENABLE_VOICE - if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0) + if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && g_voice_write_index == 0) #else if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) #endif { // scanning - if (IS_FREQ_CHANNEL(gNextMrChannel)) + if (IS_FREQ_CHANNEL(gNextChannel)) { if (gCurrentFunction == FUNCTION_INCOMING) APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); @@ -1087,10 +1087,10 @@ void APP_Update(void) } else { - if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING) + if (gCurrentcode_type == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING) APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); else - MR_NextChannel(); // switch to next channel + USER_NextChannel(); // switch to next channel } gScanPauseMode = false; @@ -1099,7 +1099,7 @@ void APP_Update(void) } #ifdef ENABLE_VOICE - if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && gVoiceWriteIndex == 0) + if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && g_voice_write_index == 0) #else if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen) #endif @@ -1111,9 +1111,9 @@ void APP_Update(void) #ifdef ENABLE_NOAA #ifdef ENABLE_VOICE - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && g_voice_write_index == 0) #else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) #endif { NOAA_IncreaseChannel(); @@ -1125,10 +1125,10 @@ void APP_Update(void) #endif // toggle between the VFO's if dual watch is enabled - if (gScreenToDisplay != DISPLAY_SCANNER && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + if (gScreenToDisplay != DISPLAY_SCANNER && g_eeprom.dual_watch != DUAL_WATCH_OFF) { #ifdef ENABLE_VOICE - if (gScheduleDualWatch && gVoiceWriteIndex == 0) + if (gScheduleDualWatch && g_voice_write_index == 0) #else if (gScheduleDualWatch) #endif @@ -1169,7 +1169,7 @@ void APP_Update(void) #endif #ifdef ENABLE_VOX - if (gEeprom.VOX_SWITCH) + if (g_eeprom.vox_switch) APP_HandleVox(); #endif @@ -1182,7 +1182,7 @@ void APP_Update(void) #endif gPttIsPressed || gKeyBeingHeld || - gEeprom.BATTERY_SAVE == 0 || + g_eeprom.battery_save == 0 || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gScreenToDisplay != DISPLAY_MAIN || @@ -1191,7 +1191,7 @@ void APP_Update(void) gBatterySaveCountdown_10ms = battery_save_count_10ms; } else - if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) + if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) && IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) || !gIsNoaaMode) { //if (gCurrentFunction != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE); @@ -1207,7 +1207,7 @@ void APP_Update(void) #endif gPttIsPressed || gKeyBeingHeld || - gEeprom.BATTERY_SAVE == 0 || + g_eeprom.battery_save == 0 || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gScreenToDisplay != DISPLAY_MAIN || @@ -1226,22 +1226,22 @@ void APP_Update(void) } #ifdef ENABLE_VOICE - if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && gVoiceWriteIndex == 0) + if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && g_voice_write_index == 0) #else if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE) #endif { // wake up, enable RX then go back to sleep - if (gRxIdleMode) + if (g_rx_idle_mode) { BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); #ifdef ENABLE_VOX - if (gEeprom.VOX_SWITCH) - BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD); + if (g_eeprom.vox_switch) + BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold); #endif - if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && + if (g_eeprom.dual_watch != DUAL_WATCH_OFF && gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) { // dual watch mode, toggle between the two VFO's @@ -1253,18 +1253,18 @@ void APP_Update(void) FUNCTION_Init(); gPowerSave_10ms = power_save1_10ms; // come back here in a bit - gRxIdleMode = false; // RX is awake + g_rx_idle_mode = false; // RX is awake } else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI) { // dual watch mode, go back to sleep - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); // go back to sleep - gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; - gRxIdleMode = true; + gPowerSave_10ms = g_eeprom.battery_save * 10; + g_rx_idle_mode = true; BK4819_DisableVox(); BK4819_Sleep(); @@ -1289,7 +1289,7 @@ void APP_Update(void) // called every 10ms void APP_CheckKeys(void) { - KEY_Code_t Key; + key_code_t Key; #ifdef ENABLE_AIRCOPY if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) @@ -1307,7 +1307,7 @@ void APP_CheckKeys(void) { // stop transmitting APP_ProcessKey(KEY_PTT, false, false); gPttIsPressed = false; - if (gKeyReading1 != KEY_INVALID) + if (g_key_reading_1 != KEY_INVALID) gPttWasReleased = true; } } @@ -1335,40 +1335,40 @@ void APP_CheckKeys(void) if (Key == KEY_INVALID) { -// gKeyReading0 = KEY_INVALID; -// gKeyReading1 = KEY_INVALID; -// gDebounceCounter = 0; +// g_key_reading_0 = KEY_INVALID; +// g_key_reading_1 = KEY_INVALID; +// g_debounce_counter = 0; // gKeyBeingHeld = false; // return; } boot_counter_10ms = 0; // cancel boot screen/beeps - if (gKeyReading0 != Key) + if (g_key_reading_0 != Key) { // new key pressed - if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID) - APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key + if (g_key_reading_0 != KEY_INVALID && Key != KEY_INVALID) + APP_ProcessKey(g_key_reading_1, false, gKeyBeingHeld); // key pressed without releasing previous key - gKeyReading0 = Key; - gDebounceCounter = 0; + g_key_reading_0 = Key; + g_debounce_counter = 0; return; } - if (++gDebounceCounter == key_debounce_10ms) + if (++g_debounce_counter == key_debounce_10ms) { // debounced new key pressed if (Key == KEY_INVALID) { - if (gKeyReading1 != KEY_INVALID) + if (g_key_reading_1 != KEY_INVALID) { - APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); - gKeyReading1 = KEY_INVALID; + APP_ProcessKey(g_key_reading_1, false, gKeyBeingHeld); + g_key_reading_1 = KEY_INVALID; } } else { - gKeyReading1 = Key; + g_key_reading_1 = Key; APP_ProcessKey(Key, true, false); } @@ -1376,12 +1376,12 @@ void APP_CheckKeys(void) return; } - if (gDebounceCounter < key_repeat_delay_10ms) + if (g_debounce_counter < key_repeat_delay_10ms) return; // key is being held pressed - if (gDebounceCounter == key_repeat_delay_10ms) + if (g_debounce_counter == key_repeat_delay_10ms) { // initial key repeat delay after pressed if (Key != KEY_PTT) { @@ -1394,14 +1394,14 @@ void APP_CheckKeys(void) if (Key == KEY_UP || Key == KEY_DOWN) { gKeyBeingHeld = true; - if ((gDebounceCounter % key_repeat_10ms) == 0) + if ((g_debounce_counter % key_repeat_10ms) == 0) APP_ProcessKey(Key, true, true); } - if (gDebounceCounter < 0xFFFF) + if (g_debounce_counter < 0xFFFF) return; - gDebounceCounter = key_repeat_delay_10ms; + g_debounce_counter = key_repeat_delay_10ms; } } @@ -1416,9 +1416,9 @@ void APP_TimeSlice10ms(void) #endif #ifdef ENABLE_AM_FIX -// if (gEeprom.VfoInfo[gEeprom.RX_VFO].AM_mode && gSetting_AM_fix) - if (gRxVfo->AM_mode && gSetting_AM_fix) - AM_fix_10ms(gEeprom.RX_VFO); +// if (g_eeprom.VfoInfo[g_eeprom.rx_vfo].am_mode && gSetting_AM_fix) + if (gRxVfo->am_mode && gSetting_AM_fix) + AM_fix_10ms(g_eeprom.rx_vfo); #endif if (UART_IsCommandAvailable()) @@ -1431,7 +1431,7 @@ void APP_TimeSlice10ms(void) if (gReducedService) return; - if (gCurrentFunction != FUNCTION_POWER_SAVE || !gRxIdleMode) + if (gCurrentFunction != FUNCTION_POWER_SAVE || !g_rx_idle_mode) APP_CheckRadioInterrupts(); if (gCurrentFunction == FUNCTION_TRANSMIT) @@ -1465,8 +1465,8 @@ void APP_TimeSlice10ms(void) if (gVoxResumeCountdown > 0) gVoxResumeCountdown--; - if (gVoxPauseCountdown > 0) - gVoxPauseCountdown--; + if (g_vox_pause_count_down > 0) + g_vox_pause_count_down--; #endif if (gCurrentFunction == FUNCTION_TRANSMIT) @@ -1488,7 +1488,7 @@ void APP_TimeSlice10ms(void) BK4819_SetScrambleFrequencyControlWord(Tone); - if (gEeprom.ALARM_MODE == ALARM_MODE_TONE && gAlarmRunningCounter == 512) + if (g_eeprom.alarm_mode == ALARM_MODE_TONE && gAlarmRunningCounter == 512) { gAlarmRunningCounter = 0; @@ -1699,9 +1699,9 @@ void cancelUserInputModes(void) gUpdateDisplay = true; } - if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) + if (g_was_f_key_pressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) { - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gInputBoxIndex = 0; gKeyInputCountdown = 0; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; @@ -1775,7 +1775,7 @@ void APP_TimeSlice500ms(void) if (gBacklightCountdown > 0 && !gAskToSave && gCssScanMode == CSS_SCAN_MODE_OFF) if (gScreenToDisplay != DISPLAY_MENU || gMenuCursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option if (--gBacklightCountdown == 0) - 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 backlight off if (gSerialConfigCountDown_500ms > 0) @@ -1833,10 +1833,10 @@ void APP_TimeSlice500ms(void) if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) #endif { - if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) + if (g_eeprom.auto_keypad_lock && gKeyLockCountdown > 0 && !gDTMF_InputMode) { if (--gKeyLockCountdown == 0) - gEeprom.KEY_LOCK = true; // lock the keyboard + g_eeprom.key_lock = true; // lock the keyboard gUpdateStatus = true; // lock symbol needs showing } @@ -1844,7 +1844,7 @@ void APP_TimeSlice500ms(void) { gMenuCountdown = 0; - if (gEeprom.BACKLIGHT == 0) + if (g_eeprom.backlight == 0) { gBacklightCountdown = 0; GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF @@ -1865,7 +1865,7 @@ void APP_TimeSlice500ms(void) */ DTMF_clear_input_box(); - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gInputBoxIndex = 0; gAskToSave = false; @@ -1903,7 +1903,7 @@ void APP_TimeSlice500ms(void) } if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT) - updateRSSI(gEeprom.RX_VFO); + updateRSSI(g_eeprom.rx_vfo); #ifdef ENABLE_FMRADIO if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) @@ -1964,7 +1964,7 @@ void APP_TimeSlice500ms(void) ST7565_HardwareReset(); - 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 } #ifdef ENABLE_VOICE @@ -2016,7 +2016,7 @@ void APP_TimeSlice500ms(void) { if (--gDTMF_auto_reset_time_500ms == 0) { - if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && gEeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX) + if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && g_eeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX) gDTMF_CallState = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed else gDTMF_CallState = DTMF_CALL_STATE_NONE; @@ -2054,7 +2054,7 @@ void APP_TimeSlice500ms(void) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = false; - if (gEeprom.ALARM_MODE == ALARM_MODE_TONE) + if (g_eeprom.alarm_mode == ALARM_MODE_TONE) { RADIO_SendEndOfTransmission(); RADIO_EnableCxCSS(); @@ -2077,20 +2077,20 @@ void CHANNEL_Next(const bool bFlag, const int8_t scan_direction) { RADIO_SelectVfos(); - gNextMrChannel = gRxVfo->CHANNEL_SAVE; + gNextChannel = gRxVfo->channel_save; gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; gScanStateDir = scan_direction; - if (gNextMrChannel <= MR_CHANNEL_LAST) + if (gNextChannel <= USER_CHANNEL_LAST) { // channel mode if (bFlag) - gRestoreMrChannel = gNextMrChannel; - MR_NextChannel(); + gRestoreUSER_CHANNEL = gNextChannel; + USER_NextChannel(); } else { // frequency mode if (bFlag) - gRestoreFrequency = gRxVfo->freq_config_RX.Frequency; + gRestoreFrequency = gRxVfo->freq_config_rx.frequency; FREQ_NextChannel(); } @@ -2101,7 +2101,7 @@ void CHANNEL_Next(const bool bFlag, const int8_t scan_direction) bScanKeepFrequency = false; } -static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const bool bKeyHeld) +static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const bool bKeyHeld) { bool bFlag = false; @@ -2110,9 +2110,9 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); - if (Key == KEY_EXIT && !backlight_was_on && gEeprom.BACKLIGHT > 0) + if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.backlight > 0) { // just turn the light on for now so the user can see what's what - BACKLIGHT_TurnOn(); + backlight_turn_on(); gBeepToPlay = BEEP_NONE; return; } @@ -2122,7 +2122,7 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b gBatterySaveCountdown_10ms = battery_save_count_10ms; - if (gEeprom.AUTO_KEYPAD_LOCK) + if (g_eeprom.auto_keypad_lock) gKeyLockCountdown = 30; // 15 seconds if (!bKeyPressed) @@ -2149,10 +2149,10 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b if (gFlagSaveChannel) { - SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gFlagSaveChannel); + SETTINGS_SaveChannel(gTxVfo->channel_save, g_eeprom.tx_vfo, gTxVfo, gFlagSaveChannel); gFlagSaveChannel = false; - RADIO_ConfigureChannel(gEeprom.TX_VFO, VFO_CONFIGURE); + RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE); RADIO_SetupRegisters(true); GUI_SelectNextDisplay(DISPLAY_MAIN); @@ -2161,7 +2161,7 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b else { if (Key != KEY_PTT || gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3) - BACKLIGHT_TurnOn(); + backlight_turn_on(); if (Key == KEY_EXIT && bKeyHeld) { // exit key held pressed @@ -2195,7 +2195,7 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b } } - if (gEeprom.KEY_LOCK && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) + if (g_eeprom.key_lock && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) { // keyboard is locked if (Key == KEY_F) @@ -2260,9 +2260,9 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b } } - if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) + if (g_was_f_key_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) { // cancel the F-key - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; } @@ -2306,15 +2306,15 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b BK4819_ExitDTMF_TX(false); - if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable) + if (gCurrentVfo->scrambling_type == 0 || !gSetting_ScrambleEnable) BK4819_DisableScramble(); else - BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); + BK4819_EnableScramble(gCurrentVfo->scrambling_type - 1); } } else { - if (gEeprom.DTMF_SIDE_TONE) + if (g_eeprom.DTMF_side_tone) { // user will here the DTMF tones in speaker GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; @@ -2323,9 +2323,9 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b BK4819_DisableScramble(); if (Code == 0xFE) - BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750); + BK4819_TransmitTone(g_eeprom.DTMF_side_tone, 1750); else - BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code); + BK4819_PlayDTMFEx(g_eeprom.DTMF_side_tone, Code); } } #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) @@ -2334,10 +2334,10 @@ static void APP_ProcessKey(const KEY_Code_t Key, const bool bKeyPressed, const b { ALARM_Off(); - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) + if (g_eeprom.repeater_tail_tone_elimination == 0) FUNCTION_Select(FUNCTION_FOREGROUND); else - gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; + gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; if (Key == KEY_PTT) gPttWasPressed = true; @@ -2453,7 +2453,7 @@ Skip: { if (!bKeyHeld) { - SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel); + SETTINGS_SaveChannel(gTxVfo->channel_save, g_eeprom.tx_vfo, gTxVfo, gRequestSaveChannel); if (gScreenToDisplay != DISPLAY_SCANNER) if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere @@ -2478,7 +2478,7 @@ Skip: RADIO_ConfigureChannel(1, gVfoConfigureMode); } else - RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode); + RADIO_ConfigureChannel(g_eeprom.tx_vfo, gVfoConfigureMode); if (gRequestDisplayScreen == DISPLAY_INVALID) gRequestDisplayScreen = DISPLAY_MAIN; @@ -2543,12 +2543,12 @@ Skip: } #ifdef ENABLE_VOICE - if (gAnotherVoiceID != VOICE_ID_INVALID) + if (g_another_voice_id != VOICE_ID_INVALID) { - if (gAnotherVoiceID < 76) - AUDIO_SetVoiceID(0, gAnotherVoiceID); + if (g_another_voice_id < 76) + AUDIO_SetVoiceID(0, g_another_voice_id); AUDIO_PlaySingleVoice(false); - gAnotherVoiceID = VOICE_ID_INVALID; + g_another_voice_id = VOICE_ID_INVALID; } #endif diff --git a/app/dtmf.c b/app/dtmf.c index 68b23eb..872f6be 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -162,7 +162,7 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned { 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; gDTMF_IsGroupCall = true; } @@ -175,7 +175,7 @@ DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size) { unsigned int 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; return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP; @@ -215,7 +215,7 @@ void DTMF_HandleRequest(void) return; } - if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) + if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED) { // D-DCD is disabled or we're alive DTMF_clear_RX(); return; @@ -226,14 +226,14 @@ void DTMF_HandleRequest(void) if (gDTMF_RX_index >= 9) { // 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); if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) { // bugger - if (gEeprom.PERMIT_REMOTE_KILL) + if (g_eeprom.permit_remote_kill) { gSetting_KILLED = true; // oooerr ! @@ -267,7 +267,7 @@ void DTMF_HandleRequest(void) if (gDTMF_RX_index >= 9) { // 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); @@ -316,7 +316,7 @@ void DTMF_HandleRequest(void) gDTMF_RX_index >= 9) { // 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); @@ -338,7 +338,7 @@ void DTMF_HandleRequest(void) 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; @@ -359,7 +359,7 @@ void DTMF_HandleRequest(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gEeprom.DTMF_DECODE_RESPONSE) + switch (g_eeprom.DTMF_decode_response) { case DTMF_DEC_RESPONSE_BOTH: gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; @@ -399,7 +399,7 @@ void DTMF_Reply(void) } else { // 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; } break; @@ -409,23 +409,23 @@ void DTMF_Reply(void) break; 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; break; default: case DTMF_REPLY_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_OFF || - gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN) + gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO || + gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_OFF || + gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_TX_DOWN) { gDTMF_ReplyState = DTMF_REPLY_NONE; return; } // send TX-UP DTMF - pString = gEeprom.DTMF_UP_CODE; + pString = g_eeprom.DTMF_up_code; break; } @@ -434,9 +434,9 @@ void DTMF_Reply(void) if (pString == NULL) 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 GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; @@ -444,15 +444,15 @@ void DTMF_Reply(void) SYSTEM_DelayMs(Delay); - BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE); + BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone); BK4819_PlayDTMFString( pString, 1, - gEeprom.DTMF_FIRST_CODE_PERSIST_TIME, - gEeprom.DTMF_HASH_CODE_PERSIST_TIME, - gEeprom.DTMF_CODE_PERSIST_TIME, - gEeprom.DTMF_CODE_INTERVAL_TIME); + g_eeprom.DTMF_first_code_persist_time, + g_eeprom.DTMF_hash_code_persist_time, + g_eeprom.DTMF_code_persist_time, + g_eeprom.DTMF_code_interval_time); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); diff --git a/app/fm.c b/app/fm.c index d91259c..5beae5b 100644 --- a/app/fm.c +++ b/app/fm.c @@ -74,18 +74,18 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) 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) { - gEeprom.FM_IsMrMode = false; + g_eeprom.fm_is_channel_mode = false; return -1; } - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; + g_eeprom.fm_selected_channel = Channel; + g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; } return 0; @@ -130,23 +130,23 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag) gFM_FoundFrequency = false; gAskToSave = false; gAskToDelete = false; - gEeprom.FM_FrequencyPlaying = Frequency; + g_eeprom.fm_frequency_playing = Frequency; if (!bFlag) { Frequency += Step; - if (Frequency < gEeprom.FM_LowerLimit) - Frequency = gEeprom.FM_UpperLimit; + if (Frequency < g_eeprom.fm_lower_limit) + Frequency = g_eeprom.fm_upper_limit; else - if (Frequency > gEeprom.FM_UpperLimit) - Frequency = gEeprom.FM_LowerLimit; + if (Frequency > g_eeprom.fm_upper_limit) + Frequency = g_eeprom.fm_lower_limit; - gEeprom.FM_FrequencyPlaying = Frequency; + g_eeprom.fm_frequency_playing = Frequency; } gFM_ScanState = Step; - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); } void FM_PlayAndUpdate(void) @@ -155,12 +155,12 @@ void FM_PlayAndUpdate(void) if (gFM_AutoScan) { - gEeprom.FM_IsMrMode = true; - gEeprom.FM_SelectedChannel = 0; + g_eeprom.fm_is_channel_mode = true; + g_eeprom.fm_selected_channel = 0; } FM_ConfigureChannelState(); - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); SETTINGS_SaveFM(); gFmPlayCountdown_10ms = 0; @@ -224,15 +224,15 @@ Bail: 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_MR_MODE 1 + #define STATE_USER_MODE 1 #define STATE_SAVE 2 if (!bKeyHeld && bKeyPressed) { - if (!gWasFKeyPressed) + if (!g_was_f_key_pressed) { uint8_t State; @@ -254,7 +254,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) 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); @@ -281,21 +281,21 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) NUMBER_Get(gInputBox, &Frequency); 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; gRequestDisplayScreen = DISPLAY_FM; return; } - gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; + g_eeprom.fm_selected_frequency = (uint16_t)Frequency; #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency; + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); gRequestSaveFM = true; return; } @@ -308,16 +308,16 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; - if (State == STATE_MR_MODE) + if (State == STATE_USER_MODE) { if (FM_CheckValidChannel(Channel)) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + g_eeprom.fm_selected_channel = Channel; + g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); gRequestSaveFM = true; return; } @@ -326,7 +326,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Channel < 20) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gRequestDisplayScreen = DISPLAY_FM; gInputBoxIndex = 0; @@ -339,14 +339,14 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif return; } gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; gRequestDisplayScreen = DISPLAY_FM; @@ -357,11 +357,11 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) break; case KEY_1: - gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; + g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode; if (!FM_ConfigureChannelState()) { - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); gRequestSaveFM = true; } else @@ -429,14 +429,14 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif } else { FM_PlayAndUpdate(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } @@ -456,11 +456,11 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (gFM_ScanState == FM_SCAN_OFF) { - if (!gEeprom.FM_IsMrMode) + if (!g_eeprom.fm_is_channel_mode) { if (gAskToSave) { - gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; + gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing; gAskToSave = false; gRequestSaveFM = true; } @@ -471,10 +471,10 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) { if (gAskToDelete) { - gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF; + gFM_Channels[g_eeprom.fm_selected_channel] = 0xFFFF; FM_ConfigureChannelState(); - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); gRequestSaveFM = true; gAskToDelete = false; @@ -494,7 +494,7 @@ static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (gAskToSave) { - gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; + gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing; gAskToSave = false; gRequestSaveFM = true; } @@ -539,42 +539,42 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) return; } - FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false); + FM_Tune(g_eeprom.fm_frequency_playing, Step, false); gRequestDisplayScreen = DISPLAY_FM; return; } - if (gEeprom.FM_IsMrMode) + if (g_eeprom.fm_is_channel_mode) { - const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); - if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) + const uint8_t Channel = FM_FindNextChannel(g_eeprom.fm_selected_channel + Step, Step); + if (Channel == 0xFF || g_eeprom.fm_selected_channel == Channel) goto Bail; - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; + g_eeprom.fm_selected_channel = Channel; + g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; } else { - uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step; - if (Frequency < gEeprom.FM_LowerLimit) - Frequency = gEeprom.FM_UpperLimit; + uint16_t Frequency = g_eeprom.fm_selected_frequency + Step; + if (Frequency < g_eeprom.fm_lower_limit) + Frequency = g_eeprom.fm_upper_limit; else - if (Frequency > gEeprom.FM_UpperLimit) - Frequency = gEeprom.FM_LowerLimit; + if (Frequency > g_eeprom.fm_upper_limit) + Frequency = g_eeprom.fm_lower_limit; - gEeprom.FM_FrequencyPlaying = Frequency; - gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; + g_eeprom.fm_frequency_playing = Frequency; + g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; } gRequestSaveFM = true; Bail: - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); 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) { @@ -617,15 +617,15 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) 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) { gFmPlayCountdown_10ms = 0; gFM_FoundFrequency = true; - if (!gEeprom.FM_IsMrMode) - gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; + if (!g_eeprom.fm_is_channel_mode) + g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; @@ -635,7 +635,7 @@ void FM_Play(void) } if (gFM_ChannelPosition < 20) - gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying; + gFM_Channels[gFM_ChannelPosition++] = g_eeprom.fm_frequency_playing; 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(); else - FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false); + FM_Tune(g_eeprom.fm_frequency_playing, gFM_ScanState, false); GUI_SelectNextDisplay(DISPLAY_FM); } @@ -659,7 +659,7 @@ void FM_Start(void) gFM_ScanState = FM_SCAN_OFF; 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); diff --git a/app/fm.h b/app/fm.h index 012119a..41947dc 100644 --- a/app/fm.h +++ b/app/fm.h @@ -52,7 +52,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag); void FM_PlayAndUpdate(void); 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_Start(void); diff --git a/app/generic.c b/app/generic.c index 54a43e4..25c223c 100644 --- a/app/generic.c +++ b/app/generic.c @@ -61,10 +61,10 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) { // toggle the keyboad lock #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 - gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK; + g_eeprom.key_lock = !g_eeprom.key_lock; gRequestSaveSettings = true; } @@ -79,14 +79,14 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) return; #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; #ifdef ENABLE_VOICE - if (!gWasFKeyPressed) - gAnotherVoiceID = VOICE_ID_CANCEL; + if (!g_was_f_key_pressed) + g_another_voice_id = VOICE_ID_CANCEL; #endif gUpdateStatus = true; @@ -132,10 +132,10 @@ void GENERIC_Key_PTT(bool bKeyPressed) { APP_EndTransmission(); - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) + if (g_eeprom.repeater_tail_tone_elimination == 0) FUNCTION_Select(FUNCTION_FOREGROUND); else - gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; + gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; } gFlagEndTransmission = false; @@ -162,7 +162,7 @@ void GENERIC_Key_PTT(bool bKeyPressed) if (gScreenToDisplay == DISPLAY_SCANNER) { // 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; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gFlagResetVfos = true; @@ -178,7 +178,7 @@ void GENERIC_Key_PTT(bool bKeyPressed) MENU_StopCssScan(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } @@ -190,7 +190,7 @@ void GENERIC_Key_PTT(bool bKeyPressed) { // FM radio is scanning .. stop FM_PlayAndUpdate(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif gRequestDisplayScreen = DISPLAY_FM; goto cancel_tx; @@ -235,7 +235,7 @@ void GENERIC_Key_PTT(bool bKeyPressed) #else // 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 (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); else gDTMF_CallMode = DTMF_CALL_MODE_DTMF; diff --git a/app/main.c b/app/main.c index 6040439..75b380e 100644 --- a/app/main.c +++ b/app/main.c @@ -41,34 +41,34 @@ void toggle_chan_scanlist(void) { // 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; - if (gTxVfo->SCANLIST1_PARTICIPATION) + if (gTxVfo->scanlist_1_participation) { - if (gTxVfo->SCANLIST2_PARTICIPATION) - gTxVfo->SCANLIST1_PARTICIPATION = 0; + if (gTxVfo->scanlist_2_participation) + gTxVfo->scanlist_1_participation = 0; else - gTxVfo->SCANLIST2_PARTICIPATION = 1; + gTxVfo->scanlist_2_participation = 1; } else { - if (gTxVfo->SCANLIST2_PARTICIPATION) - gTxVfo->SCANLIST2_PARTICIPATION = 0; + if (gTxVfo->scanlist_2_participation) + gTxVfo->scanlist_2_participation = 0; 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; 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 Vfo = gEeprom.TX_VFO; + uint8_t Vfo = g_eeprom.tx_vfo; if (gScreenToDisplay == DISPLAY_MENU) { @@ -95,15 +95,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; 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; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; } - Band = gTxVfo->Band + 1; + Band = gTxVfo->band + 1; if (gSetting_350EN || Band != BAND5_350MHz) { if (Band > BAND7_470MHz) @@ -111,10 +111,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } else Band = BAND6_400MHz; - gTxVfo->Band = Band; + gTxVfo->band = Band; - gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; - gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band; + g_eeprom.screen_channel[Vfo] = FREQ_CHANNEL_FIRST + Band; + g_eeprom.freq_channel[Vfo] = FREQ_CHANNEL_FIRST + Band; gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; @@ -127,19 +127,19 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_2: - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A) - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_B; + if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A) + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_B; else - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_CHAN_A; + if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B) + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_A; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) - gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_B; + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A) + g_eeprom.dual_watch = DUAL_WATCH_CHAN_B; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) - gEeprom.DUAL_WATCH = DUAL_WATCH_CHAN_A; + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B) + g_eeprom.dual_watch = DUAL_WATCH_CHAN_A; else - gEeprom.TX_VFO = (Vfo + 1) & 1u; + g_eeprom.tx_vfo = (Vfo + 1) & 1u; gRequestSaveSettings = 1; gFlagReconfigureVfos = true; @@ -153,32 +153,32 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) case KEY_3: #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 - if (gEeprom.VFO_OPEN) + if (g_eeprom.vfo_open) #endif { uint8_t Channel; - if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) + if (IS_USER_CHANNEL(gTxVfo->channel_save)) { // 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 - gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; + g_another_voice_id = VOICE_ID_FREQUENCY_MODE; #endif gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; 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) { // swap to channel mode - gEeprom.ScreenChannel[Vfo] = Channel; + g_eeprom.screen_channel[Vfo] = Channel; #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); AUDIO_SetDigitVoice(1, Channel + 1); - gAnotherVoiceID = (VOICE_ID_t)0xFE; + g_another_voice_id = (voice_id_t)0xFE; #endif gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; @@ -192,11 +192,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_4: - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gFlagStartScan = true; gScanSingleFrequency = false; - gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; + gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; gUpdateStatus = true; // if (beep) @@ -207,15 +207,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) case KEY_5: #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 { - gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO]; + g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo]; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_FREQUENCY_MODE; + g_another_voice_id = VOICE_ID_FREQUENCY_MODE; #endif } gRequestSaveVFO = true; @@ -242,19 +242,19 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_8: - gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false; + gTxVfo->frequency_reverse = gTxVfo->frequency_reverse == false; gRequestSaveChannel = 1; break; 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; - gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL; + g_eeprom.user_channel[Vfo] = g_eeprom.chan_1_call; + g_eeprom.screen_channel[Vfo] = g_eeprom.chan_1_call; #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); - AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1); - gAnotherVoiceID = (VOICE_ID_t)0xFE; + AUDIO_SetDigitVoice(1, g_eeprom.chan_1_call + 1); + g_another_voice_id = (voice_id_t)0xFE; #endif gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; @@ -267,7 +267,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) default: gUpdateStatus = true; - gWasFKeyPressed = false; + g_was_f_key_pressed = false; if (beep) 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) { // key held down @@ -290,7 +290,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_MAIN; } - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; 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 } - if (!gWasFKeyPressed) + if (!g_was_f_key_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; @@ -317,7 +317,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_MAIN; - if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) + if (IS_USER_CHANNEL(gTxVfo->channel_save)) { // user is entering channel number uint16_t Channel; @@ -325,7 +325,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex != 3) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gRequestDisplayScreen = DISPLAY_MAIN; return; @@ -342,11 +342,11 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gEeprom.MrChannel[Vfo] = (uint8_t)Channel; - gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; + g_eeprom.user_channel[Vfo] = (uint8_t)Channel; + g_eeprom.screen_channel[Vfo] = (uint8_t)Channel; gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; @@ -354,9 +354,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } // #ifdef ENABLE_NOAA -// if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) +// if (IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save)) // #endif - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) + if (IS_FREQ_CHANNEL(gTxVfo->channel_save)) { // user is entering a frequency uint32_t Frequency; @@ -364,7 +364,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex < 6) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif 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); #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - if (gTxVfo->Band != band) + if (gTxVfo->band != band) { - gTxVfo->Band = band; - gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST; - gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST; + gTxVfo->band = band; + g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST; + g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST; 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 += 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) { // clamp the frequency to the limit 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; return; @@ -429,7 +429,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_NOAA else - if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) + if (IS_NOAA_CHANNEL(gTxVfo->channel_save)) { // user is entering NOAA channel uint8_t Channel; @@ -437,7 +437,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex != 2) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gRequestDisplayScreen = DISPLAY_MAIN; return; @@ -450,10 +450,10 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { Channel += NOAA_CHANNEL_FIRST; #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gEeprom.NoaaChannel[Vfo] = Channel; - gEeprom.ScreenChannel[Vfo] = Channel; + g_eeprom.noaa_channel[Vfo] = Channel; + g_eeprom.screen_channel[Vfo] = Channel; gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; return; @@ -466,7 +466,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; processFKeyFunction(Key, true); @@ -500,7 +500,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_VOICE if (gInputBoxIndex == 0) - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif } else @@ -508,7 +508,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) SCANNER_Stop(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } @@ -550,7 +550,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) if (bKeyPressed) { // long press MENU key - gWasFKeyPressed = false; + g_was_f_key_pressed = false; if (gScreenToDisplay == DISPLAY_MAIN) { @@ -560,12 +560,12 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) gRequestDisplayScreen = DISPLAY_MAIN; } - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; #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) @@ -580,21 +580,21 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) 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 - 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; - gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel; - gEeprom.TX_VFO = vfo; + g_eeprom.screen_channel[vfo] = channel; + g_eeprom.VfoInfo[vfo].channel_save = channel; + g_eeprom.tx_vfo = vfo; RADIO_SelectVfos(); RADIO_ApplyOffset(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo); 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; @@ -624,7 +624,7 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) gFlagRefreshSetting = true; gRequestDisplayScreen = DISPLAY_MENU; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_MENU; + g_another_voice_id = VOICE_ID_MENU; #endif } else @@ -646,7 +646,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) return; } - if (bKeyHeld && !gWasFKeyPressed) + if (bKeyHeld && !g_was_f_key_pressed) { // long press .. toggle scanning if (!bKeyPressed) return; // released @@ -666,11 +666,11 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) // just released - if (!gWasFKeyPressed) + if (!g_was_f_key_pressed) { // pressed without the F-key #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 if (gScanStateDir == SCAN_OFF) #endif @@ -687,10 +687,10 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) } else { // with the F-key - gWasFKeyPressed = false; + g_was_f_key_pressed = false; #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) + if (IS_NOAA_CHANNEL(gTxVfo->channel_save)) { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; @@ -700,8 +700,8 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) // scan the CTCSS/DCS code gFlagStartScan = true; gScanSingleFrequency = true; - gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; + gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; } 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) { - uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO]; + uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo]; if (bKeyHeld || !bKeyPressed) { // long press @@ -728,8 +728,8 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) return; #ifdef ENABLE_VOICE - AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1); - gAnotherVoiceID = (VOICE_ID_t)0xFE; + AUDIO_SetDigitVoice(0, gTxVfo->channel_save + 1); + g_another_voice_id = (voice_id_t)0xFE; #endif return; @@ -764,7 +764,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) return; } - gTxVfo->freq_config_RX.Frequency = frequency; + gTxVfo->freq_config_rx.frequency = frequency; gRequestSaveChannel = 1; return; @@ -777,23 +777,23 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) if (Channel == Next) return; - gEeprom.MrChannel[gEeprom.TX_VFO] = Next; - gEeprom.ScreenChannel[gEeprom.TX_VFO] = Next; + g_eeprom.user_channel[g_eeprom.tx_vfo] = Next; + g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next; if (!bKeyHeld) { #ifdef ENABLE_VOICE AUDIO_SetDigitVoice(0, Next + 1); - gAnotherVoiceID = (VOICE_ID_t)0xFE; + g_another_voice_id = (voice_id_t)0xFE; #endif } } #ifdef ENABLE_NOAA else { - Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_VFO] - NOAA_CHANNEL_FIRST, Direction, 0, 9); - gEeprom.NoaaChannel[gEeprom.TX_VFO] = Channel; - gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel; + Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(g_eeprom.screen_channel[g_eeprom.tx_vfo] - NOAA_CHANNEL_FIRST, Direction, 0, 9); + g_eeprom.noaa_channel[g_eeprom.tx_vfo] = Channel; + g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel; } #endif @@ -810,7 +810,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) 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 if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) diff --git a/app/main.h b/app/main.h index f679aac..b2efa69 100644 --- a/app/main.h +++ b/app/main.h @@ -19,7 +19,7 @@ #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 diff --git a/app/menu.c b/app/menu.c index 545c696..a358973 100644 --- a/app/menu.c +++ b/app/menu.c @@ -59,11 +59,11 @@ int16_t BK4819_XtalFreqLow; uint16_t EEPROM_1F8A; uint16_t EEPROM_1F8C; - uint8_t VOLUME_GAIN; - uint8_t DAC_GAIN; + uint8_t volume_gain; + uint8_t dac_gain; } __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 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: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1; + *pMax = ARRAY_SIZE(gSubMenu_backlight) - 1; break; 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_MEM_NAME: *pMin = 0; - *pMax = MR_CHANNEL_LAST; + *pMax = USER_CHANNEL_LAST; break; case MENU_SLIST1: case MENU_SLIST2: *pMin = -1; - *pMax = MR_CHANNEL_LAST; + *pMax = USER_CHANNEL_LAST; break; case MENU_SAVE: @@ -352,7 +352,7 @@ void MENU_AcceptSetting(void) int32_t Min; int32_t Max; 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)) { @@ -367,13 +367,13 @@ void MENU_AcceptSetting(void) return; case MENU_SQL: - gEeprom.SQUELCH_LEVEL = gSubMenuSelection; + g_eeprom.squelch_level = gSubMenuSelection; gVfoConfigureMode = VFO_CONFIGURE; break; case MENU_STEP: - gTxVfo->STEP_SETTING = gSubMenuSelection; - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) + gTxVfo->step_setting = gSubMenuSelection; + if (IS_FREQ_CHANNEL(gTxVfo->channel_save)) { gRequestSaveChannel = 1; return; @@ -381,39 +381,39 @@ void MENU_AcceptSetting(void) return; case MENU_TXP: - gTxVfo->OUTPUT_POWER = gSubMenuSelection; + gTxVfo->output_power = gSubMenuSelection; gRequestSaveChannel = 1; return; case MENU_T_DCS: - pConfig = &gTxVfo->freq_config_TX; + pConfig = &gTxVfo->freq_config_tx; // Fallthrough case MENU_R_DCS: 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; return; } - Code = 0; - pConfig->CodeType = CODE_TYPE_OFF; + Code = 0; + pConfig->code_type = CODE_TYPE_OFF; } else if (gSubMenuSelection < 105) { - pConfig->CodeType = CODE_TYPE_DIGITAL; - Code = gSubMenuSelection - 1; + pConfig->code_type = CODE_TYPE_DIGITAL; + Code = gSubMenuSelection - 1; } else { - pConfig->CodeType = CODE_TYPE_REVERSE_DIGITAL; - Code = gSubMenuSelection - 105; + pConfig->code_type = CODE_TYPE_REVERSE_DIGITAL; + Code = gSubMenuSelection - 105; } - pConfig->Code = Code; + pConfig->code = Code; gRequestSaveChannel = 1; return; @@ -421,26 +421,26 @@ void MENU_AcceptSetting(void) #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" case MENU_T_CTCS: - pConfig = &gTxVfo->freq_config_TX; + pConfig = &gTxVfo->freq_config_tx; case MENU_R_CTCS: if (gSubMenuSelection == 0) { - if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) + if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE) { gRequestSaveChannel = 1; return; } Code = 0; - pConfig->Code = Code; - pConfig->CodeType = CODE_TYPE_OFF; + pConfig->code = Code; + pConfig->code_type = CODE_TYPE_OFF; BK4819_ExitSubAu(); } else { - pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; + pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE; Code = gSubMenuSelection - 1; - pConfig->Code = Code; + pConfig->code = Code; BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); } @@ -451,22 +451,22 @@ void MENU_AcceptSetting(void) #pragma GCC diagnostic pop case MENU_SFT_D: - gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection; + gTxVfo->tx_offset_freq_dir = gSubMenuSelection; gRequestSaveChannel = 1; return; case MENU_OFFSET: - gTxVfo->TX_OFFSET_FREQUENCY = gSubMenuSelection; + gTxVfo->tx_offset_freq = gSubMenuSelection; gRequestSaveChannel = 1; return; case MENU_W_N: - gTxVfo->CHANNEL_BANDWIDTH = gSubMenuSelection; + gTxVfo->channel_bandwidth = gSubMenuSelection; gRequestSaveChannel = 1; return; case MENU_SCR: - gTxVfo->SCRAMBLING_TYPE = gSubMenuSelection; + gTxVfo->scrambling_type = gSubMenuSelection; #if 0 if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) BK4819_EnableScramble(gSubMenuSelection - 1); @@ -477,16 +477,16 @@ void MENU_AcceptSetting(void) return; case MENU_BCL: - gTxVfo->BUSY_CHANNEL_LOCK = gSubMenuSelection; + gTxVfo->busy_channel_lock = gSubMenuSelection; gRequestSaveChannel = 1; return; case MENU_MEM_CH: - gTxVfo->CHANNEL_SAVE = gSubMenuSelection; + gTxVfo->channel_save = gSubMenuSelection; #if 0 - gEeprom.MrChannel[0] = gSubMenuSelection; + g_eeprom.user_channel[0] = gSubMenuSelection; #else - gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection; + g_eeprom.user_channel[g_eeprom.tx_vfo] = gSubMenuSelection; #endif gRequestSaveChannel = 2; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; @@ -504,21 +504,21 @@ void MENU_AcceptSetting(void) } // save the channel name - memset(gTxVfo->Name, 0, sizeof(gTxVfo->Name)); - memmove(gTxVfo->Name, edit, 10); - SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_VFO, gTxVfo, 3); + memset(gTxVfo->name, 0, sizeof(gTxVfo->name)); + memmove(gTxVfo->name, edit, 10); + SETTINGS_SaveChannel(gSubMenuSelection, g_eeprom.tx_vfo, gTxVfo, 3); gFlagReconfigureVfos = true; return; case MENU_SAVE: - gEeprom.BATTERY_SAVE = gSubMenuSelection; + g_eeprom.battery_save = gSubMenuSelection; break; #ifdef ENABLE_VOX case MENU_VOX: - gEeprom.VOX_SWITCH = gSubMenuSelection != 0; - if (gEeprom.VOX_SWITCH) - gEeprom.VOX_LEVEL = gSubMenuSelection - 1; + g_eeprom.vox_switch = gSubMenuSelection != 0; + if (g_eeprom.vox_switch) + g_eeprom.vox_level = gSubMenuSelection - 1; BOARD_EEPROM_LoadMoreSettings(); gFlagReconfigureVfos = true; gUpdateStatus = true; @@ -526,7 +526,7 @@ void MENU_AcceptSetting(void) #endif case MENU_ABR: - gEeprom.BACKLIGHT = gSubMenuSelection; + g_eeprom.backlight = gSubMenuSelection; break; case MENU_ABR_ON_TX_RX: @@ -534,8 +534,8 @@ void MENU_AcceptSetting(void) break; case MENU_TDR: -// gEeprom.DUAL_WATCH = gSubMenuSelection; - gEeprom.DUAL_WATCH = (gSubMenuSelection > 0) ? 1 + gEeprom.TX_VFO : DUAL_WATCH_OFF; +// g_eeprom.dual_watch = gSubMenuSelection; + g_eeprom.dual_watch = (gSubMenuSelection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF; gFlagReconfigureVfos = true; gUpdateStatus = true; @@ -543,69 +543,69 @@ void MENU_AcceptSetting(void) case MENU_XB: #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0])) + if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0])) return; - if (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) + if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[1])) return; #endif - gEeprom.CROSS_BAND_RX_TX = gSubMenuSelection; + g_eeprom.cross_vfo_rx_tx = gSubMenuSelection; gFlagReconfigureVfos = true; gUpdateStatus = true; break; case MENU_BEEP: - gEeprom.BEEP_CONTROL = gSubMenuSelection; + g_eeprom.beep_control = gSubMenuSelection; break; case MENU_TOT: - gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection; + g_eeprom.tx_timeout_timer = gSubMenuSelection; break; #ifdef ENABLE_VOICE case MENU_VOICE: - gEeprom.VOICE_PROMPT = gSubMenuSelection; + g_eeprom.voice_prompt = gSubMenuSelection; gUpdateStatus = true; break; #endif case MENU_SC_REV: - gEeprom.SCAN_RESUME_MODE = gSubMenuSelection; + g_eeprom.scan_resume_mode = gSubMenuSelection; break; case MENU_MDF: - gEeprom.CHANNEL_DISPLAY_MODE = gSubMenuSelection; + g_eeprom.channel_display_mode = gSubMenuSelection; break; case MENU_AUTOLK: - gEeprom.AUTO_KEYPAD_LOCK = gSubMenuSelection; + g_eeprom.auto_keypad_lock = gSubMenuSelection; gKeyLockCountdown = 30; break; case MENU_S_ADD1: - gTxVfo->SCANLIST1_PARTICIPATION = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gTxVfo->scanlist_1_participation = gSubMenuSelection; + SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; return; case MENU_S_ADD2: - gTxVfo->SCANLIST2_PARTICIPATION = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gTxVfo->scanlist_2_participation = gSubMenuSelection; + SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; return; case MENU_STE: - gEeprom.TAIL_NOTE_ELIMINATION = gSubMenuSelection; + g_eeprom.tail_note_elimination = gSubMenuSelection; break; case MENU_RP_STE: - gEeprom.REPEATER_TAIL_TONE_ELIMINATION = gSubMenuSelection; + g_eeprom.repeater_tail_tone_elimination = gSubMenuSelection; break; case MENU_MIC: - gEeprom.MIC_SENSITIVITY = gSubMenuSelection; + g_eeprom.mic_sensitivity = gSubMenuSelection; BOARD_EEPROM_LoadMoreSettings(); gFlagReconfigureVfos = true; break; @@ -617,45 +617,45 @@ void MENU_AcceptSetting(void) #endif case MENU_COMPAND: - gTxVfo->Compander = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gTxVfo->compander = gSubMenuSelection; + SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; // gRequestSaveChannel = 1; return; case MENU_1_CALL: - gEeprom.CHAN_1_CALL = gSubMenuSelection; + g_eeprom.chan_1_call = gSubMenuSelection; break; case MENU_S_LIST: - gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection; + g_eeprom.scan_list_default = gSubMenuSelection; break; #ifdef ENABLE_ALARM case MENU_AL_MOD: - gEeprom.ALARM_MODE = gSubMenuSelection; + g_eeprom.alarm_mode = gSubMenuSelection; break; #endif case MENU_D_ST: - gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; + g_eeprom.DTMF_side_tone = gSubMenuSelection; break; case MENU_D_RSP: - gEeprom.DTMF_DECODE_RESPONSE = gSubMenuSelection; + g_eeprom.DTMF_decode_response = gSubMenuSelection; break; case MENU_D_HOLD: - gEeprom.DTMF_auto_reset_time = gSubMenuSelection; + g_eeprom.DTMF_auto_reset_time = gSubMenuSelection; break; case MENU_D_PRE: - gEeprom.DTMF_PRELOAD_TIME = gSubMenuSelection * 10; + g_eeprom.DTMF_preload_time = gSubMenuSelection * 10; break; case MENU_PTT_ID: - gTxVfo->DTMF_PTT_ID_TX_MODE = gSubMenuSelection; + gTxVfo->DTMF_ptt_id_tx_mode = gSubMenuSelection; gRequestSaveChannel = 1; return; @@ -664,7 +664,7 @@ void MENU_AcceptSetting(void) break; case MENU_D_DCD: - gTxVfo->DTMF_DECODING_ENABLE = gSubMenuSelection; + gTxVfo->DTMF_decoding_enable = gSubMenuSelection; DTMF_clear_RX(); gRequestSaveChannel = 1; return; @@ -692,15 +692,15 @@ void MENU_AcceptSetting(void) return; case MENU_PONMSG: - gEeprom.POWER_ON_DISPLAY_MODE = gSubMenuSelection; + g_eeprom.pwr_on_display_mode = gSubMenuSelection; break; case MENU_ROGER: - gEeprom.ROGER = gSubMenuSelection; + g_eeprom.roger_mode = gSubMenuSelection; break; case MENU_AM: - gTxVfo->AM_mode = gSubMenuSelection; + gTxVfo->am_mode = gSubMenuSelection; gRequestSaveChannel = 1; return; @@ -722,7 +722,7 @@ void MENU_AcceptSetting(void) #ifdef ENABLE_NOAA case MENU_NOAA_S: - gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection; + g_eeprom.NOAA_auto_scan = gSubMenuSelection; gFlagReconfigureVfos = true; break; #endif @@ -734,19 +734,19 @@ void MENU_AcceptSetting(void) return; case MENU_SIDE1_SHORT: - gEeprom.KEY_1_SHORT_PRESS_ACTION = gSubMenuSelection; + g_eeprom.key1_short_press_action = gSubMenuSelection; break; case MENU_SIDE1_LONG: - gEeprom.KEY_1_LONG_PRESS_ACTION = gSubMenuSelection; + g_eeprom.key1_long_press_action = gSubMenuSelection; break; case MENU_SIDE2_SHORT: - gEeprom.KEY_2_SHORT_PRESS_ACTION = gSubMenuSelection; + g_eeprom.key2_short_press_action = gSubMenuSelection; break; case MENU_SIDE2_LONG: - gEeprom.KEY_2_LONG_PRESS_ACTION = gSubMenuSelection; + g_eeprom.key2_long_press_action = gSubMenuSelection; break; case MENU_RESET: @@ -833,25 +833,25 @@ void MENU_SelectNextCode(void) { if (gSubMenuSelection > 104) { - gSelectedCodeType = CODE_TYPE_REVERSE_DIGITAL; + gSelectedcode_type = CODE_TYPE_REVERSE_DIGITAL; gSelectedCode = gSubMenuSelection - 105; } else { - gSelectedCodeType = CODE_TYPE_DIGITAL; + gSelectedcode_type = CODE_TYPE_DIGITAL; gSelectedCode = gSubMenuSelection - 1; } } else { - gSelectedCodeType = CODE_TYPE_CONTINUOUS_TONE; + gSelectedcode_type = CODE_TYPE_CONTINUOUS_TONE; gSelectedCode = gSubMenuSelection - 1; } 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; } @@ -876,25 +876,25 @@ void MENU_ShowCurrentSetting(void) switch (gMenuCursor) { case MENU_SQL: - gSubMenuSelection = gEeprom.SQUELCH_LEVEL; + gSubMenuSelection = g_eeprom.squelch_level; break; case MENU_STEP: - gSubMenuSelection = gTxVfo->STEP_SETTING; + gSubMenuSelection = gTxVfo->step_setting; break; case MENU_TXP: - gSubMenuSelection = gTxVfo->OUTPUT_POWER; + gSubMenuSelection = gTxVfo->output_power; break; case MENU_R_DCS: - switch (gTxVfo->freq_config_RX.CodeType) + switch (gTxVfo->freq_config_rx.code_type) { case CODE_TYPE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_RX.Code + 1; + gSubMenuSelection = gTxVfo->freq_config_rx.code + 1; break; case CODE_TYPE_REVERSE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_RX.Code + 105; + gSubMenuSelection = gTxVfo->freq_config_rx.code + 105; break; default: gSubMenuSelection = 0; @@ -907,17 +907,17 @@ void MENU_ShowCurrentSetting(void) break; 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; case MENU_T_DCS: - switch (gTxVfo->freq_config_TX.CodeType) + switch (gTxVfo->freq_config_tx.code_type) { case CODE_TYPE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_TX.Code + 1; + gSubMenuSelection = gTxVfo->freq_config_tx.code + 1; break; case CODE_TYPE_REVERSE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_TX.Code + 105; + gSubMenuSelection = gTxVfo->freq_config_tx.code + 105; break; default: gSubMenuSelection = 0; @@ -926,53 +926,53 @@ void MENU_ShowCurrentSetting(void) break; 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; case MENU_SFT_D: - gSubMenuSelection = gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION; + gSubMenuSelection = gTxVfo->tx_offset_freq_dir; break; case MENU_OFFSET: - gSubMenuSelection = gTxVfo->TX_OFFSET_FREQUENCY; + gSubMenuSelection = gTxVfo->tx_offset_freq; break; case MENU_W_N: - gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH; + gSubMenuSelection = gTxVfo->channel_bandwidth; break; case MENU_SCR: - gSubMenuSelection = gTxVfo->SCRAMBLING_TYPE; + gSubMenuSelection = gTxVfo->scrambling_type; break; case MENU_BCL: - gSubMenuSelection = gTxVfo->BUSY_CHANNEL_LOCK; + gSubMenuSelection = gTxVfo->busy_channel_lock; break; case MENU_MEM_CH: #if 0 - gSubMenuSelection = gEeprom.MrChannel[0]; + gSubMenuSelection = g_eeprom.user_channel[0]; #else - gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; + gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo]; #endif break; case MENU_MEM_NAME: - gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; + gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo]; break; case MENU_SAVE: - gSubMenuSelection = gEeprom.BATTERY_SAVE; + gSubMenuSelection = g_eeprom.battery_save; break; #ifdef ENABLE_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; #endif case MENU_ABR: - gSubMenuSelection = gEeprom.BACKLIGHT; + gSubMenuSelection = g_eeprom.backlight; gBacklightCountdown = 0; GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu @@ -983,58 +983,58 @@ void MENU_ShowCurrentSetting(void) break; case MENU_TDR: -// gSubMenuSelection = gEeprom.DUAL_WATCH; - gSubMenuSelection = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? 0 : 1; +// gSubMenuSelection = g_eeprom.dual_watch; + gSubMenuSelection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1; break; case MENU_XB: - gSubMenuSelection = gEeprom.CROSS_BAND_RX_TX; + gSubMenuSelection = g_eeprom.cross_vfo_rx_tx; break; case MENU_BEEP: - gSubMenuSelection = gEeprom.BEEP_CONTROL; + gSubMenuSelection = g_eeprom.beep_control; break; case MENU_TOT: - gSubMenuSelection = gEeprom.TX_TIMEOUT_TIMER; + gSubMenuSelection = g_eeprom.tx_timeout_timer; break; #ifdef ENABLE_VOICE case MENU_VOICE: - gSubMenuSelection = gEeprom.VOICE_PROMPT; + gSubMenuSelection = g_eeprom.voice_prompt; break; #endif case MENU_SC_REV: - gSubMenuSelection = gEeprom.SCAN_RESUME_MODE; + gSubMenuSelection = g_eeprom.scan_resume_mode; break; case MENU_MDF: - gSubMenuSelection = gEeprom.CHANNEL_DISPLAY_MODE; + gSubMenuSelection = g_eeprom.channel_display_mode; break; case MENU_AUTOLK: - gSubMenuSelection = gEeprom.AUTO_KEYPAD_LOCK; + gSubMenuSelection = g_eeprom.auto_keypad_lock; break; case MENU_S_ADD1: - gSubMenuSelection = gTxVfo->SCANLIST1_PARTICIPATION; + gSubMenuSelection = gTxVfo->scanlist_1_participation; break; case MENU_S_ADD2: - gSubMenuSelection = gTxVfo->SCANLIST2_PARTICIPATION; + gSubMenuSelection = gTxVfo->scanlist_2_participation; break; case MENU_STE: - gSubMenuSelection = gEeprom.TAIL_NOTE_ELIMINATION; + gSubMenuSelection = g_eeprom.tail_note_elimination; break; case MENU_RP_STE: - gSubMenuSelection = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; + gSubMenuSelection = g_eeprom.repeater_tail_tone_elimination; break; case MENU_MIC: - gSubMenuSelection = gEeprom.MIC_SENSITIVITY; + gSubMenuSelection = g_eeprom.mic_sensitivity; break; #ifdef ENABLE_AUDIO_BAR @@ -1044,15 +1044,15 @@ void MENU_ShowCurrentSetting(void) #endif case MENU_COMPAND: - gSubMenuSelection = gTxVfo->Compander; + gSubMenuSelection = gTxVfo->compander; return; case MENU_1_CALL: - gSubMenuSelection = gEeprom.CHAN_1_CALL; + gSubMenuSelection = g_eeprom.chan_1_call; break; case MENU_S_LIST: - gSubMenuSelection = gEeprom.SCAN_LIST_DEFAULT; + gSubMenuSelection = g_eeprom.scan_list_default; break; case MENU_SLIST1: @@ -1065,20 +1065,20 @@ void MENU_ShowCurrentSetting(void) #ifdef ENABLE_ALARM case MENU_AL_MOD: - gSubMenuSelection = gEeprom.ALARM_MODE; + gSubMenuSelection = g_eeprom.alarm_mode; break; #endif case MENU_D_ST: - gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; + gSubMenuSelection = g_eeprom.DTMF_side_tone; break; case MENU_D_RSP: - gSubMenuSelection = gEeprom.DTMF_DECODE_RESPONSE; + gSubMenuSelection = g_eeprom.DTMF_decode_response; break; case MENU_D_HOLD: - gSubMenuSelection = gEeprom.DTMF_auto_reset_time; + gSubMenuSelection = g_eeprom.DTMF_auto_reset_time; if (gSubMenuSelection <= DTMF_HOLD_MIN) gSubMenuSelection = DTMF_HOLD_MIN; @@ -1106,11 +1106,11 @@ void MENU_ShowCurrentSetting(void) break; case MENU_D_PRE: - gSubMenuSelection = gEeprom.DTMF_PRELOAD_TIME / 10; + gSubMenuSelection = g_eeprom.DTMF_preload_time / 10; break; case MENU_PTT_ID: - gSubMenuSelection = gTxVfo->DTMF_PTT_ID_TX_MODE; + gSubMenuSelection = gTxVfo->DTMF_ptt_id_tx_mode; break; case MENU_BAT_TXT: @@ -1118,7 +1118,7 @@ void MENU_ShowCurrentSetting(void) return; case MENU_D_DCD: - gSubMenuSelection = gTxVfo->DTMF_DECODING_ENABLE; + gSubMenuSelection = gTxVfo->DTMF_decoding_enable; break; case MENU_D_LIST: @@ -1130,15 +1130,15 @@ void MENU_ShowCurrentSetting(void) break; case MENU_PONMSG: - gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE; + gSubMenuSelection = g_eeprom.pwr_on_display_mode; break; case MENU_ROGER: - gSubMenuSelection = gEeprom.ROGER; + gSubMenuSelection = g_eeprom.roger_mode; break; case MENU_AM: - gSubMenuSelection = gTxVfo->AM_mode; + gSubMenuSelection = gTxVfo->am_mode; break; #ifdef ENABLE_AM_FIX @@ -1155,32 +1155,32 @@ void MENU_ShowCurrentSetting(void) #ifdef ENABLE_NOAA case MENU_NOAA_S: - gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN; + gSubMenuSelection = g_eeprom.NOAA_auto_scan; break; #endif case MENU_DEL_CH: #if 0 - gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1); + gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1); #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 break; case MENU_SIDE1_SHORT: - gSubMenuSelection = gEeprom.KEY_1_SHORT_PRESS_ACTION; + gSubMenuSelection = g_eeprom.key1_short_press_action; break; case MENU_SIDE1_LONG: - gSubMenuSelection = gEeprom.KEY_1_LONG_PRESS_ACTION; + gSubMenuSelection = g_eeprom.key1_long_press_action; break; case MENU_SIDE2_SHORT: - gSubMenuSelection = gEeprom.KEY_2_SHORT_PRESS_ACTION; + gSubMenuSelection = g_eeprom.key2_short_press_action; break; case MENU_SIDE2_LONG: - gSubMenuSelection = gEeprom.KEY_2_LONG_PRESS_ACTION; + gSubMenuSelection = g_eeprom.key2_long_press_action; break; case MENU_350TX: @@ -1213,7 +1213,7 @@ void MENU_ShowCurrentSetting(void) #ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: - gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW; + gSubMenuSelection = g_eeprom.BK4819_xtal_freq_low; break; #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; 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) { // invalid frequency #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif return; } #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif NUMBER_Get(gInputBox, &Frequency); - gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->StepFrequency, 0); + gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->step_freq, 0); gInputBoxIndex = 0; return; @@ -1337,7 +1337,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex < 3) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gRequestDisplayScreen = DISPLAY_MENU; 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; - if (Value <= MR_CHANNEL_LAST) + if (Value <= USER_CHANNEL_LAST) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gSubMenuSelection = Value; return; @@ -1413,7 +1413,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gFlagRefreshSetting = true; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif } else @@ -1426,12 +1426,12 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) } #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif gRequestDisplayScreen = DISPLAY_MAIN; - if (gEeprom.BACKLIGHT == 0) + if (g_eeprom.backlight == 0) { gBacklightCountdown = 0; 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(); #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif gRequestDisplayScreen = DISPLAY_MENU; @@ -1463,7 +1463,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { #ifdef ENABLE_VOICE if (gMenuCursor != MENU_SCR) - gAnotherVoiceID = MenuList[MenuList_sorted[gMenuCursor]].voice_id; + g_another_voice_id = MenuList[MenuList_sorted[gMenuCursor]].voice_id; #endif #if 1 @@ -1583,9 +1583,9 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) #ifdef ENABLE_VOICE 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 - gAnotherVoiceID = VOICE_ID_CONFIRM; + g_another_voice_id = VOICE_ID_CONFIRM; #endif gInputBoxIndex = 0; @@ -1620,9 +1620,9 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->AM_mode == 0) + if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save) && gRxVfo->am_mode == 0) #else - if (gRxVfo->AM_mode == 0) + if (gRxVfo->am_mode == 0) #endif { 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(); gRequestDisplayScreen = DISPLAY_MENU; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; + g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } } @@ -1712,7 +1712,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gRequestDisplayScreen = DISPLAY_MENU; - if (gMenuCursor != MENU_ABR && gEeprom.BACKLIGHT == 0) + if (gMenuCursor != MENU_ABR && g_eeprom.backlight == 0) { gBacklightCountdown = 0; 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) { - int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection; + int32_t Offset = (Direction * gTxVfo->step_freq) + gSubMenuSelection; if (Offset < 99999990) { if (Offset < 0) @@ -1732,7 +1732,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) else Offset = 0; - gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->StepFrequency, 0); + gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->step_freq, 0); gRequestDisplayScreen = DISPLAY_MENU; return; } @@ -1771,7 +1771,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) 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) { diff --git a/app/menu.h b/app/menu.h index ec8e144..1367fb7 100644 --- a/app/menu.h +++ b/app/menu.h @@ -30,7 +30,7 @@ void MENU_ShowCurrentSetting(void); void MENU_StartCssScan(int8_t Direction); 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 diff --git a/app/scanner.c b/app/scanner.c index b0e1046..d8ff209 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -26,7 +26,7 @@ #include "ui/inputbox.h" #include "ui/ui.h" -DCS_CodeType_t gScanCssResultType; +dcs_code_type_t gScanCssResultType; uint8_t gScanCssResultCode; bool gFlagStartScan; bool gFlagStopScan; @@ -44,7 +44,7 @@ bool gScanUseCssResult; int8_t gScanStateDir; 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) { @@ -61,7 +61,7 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex < 3) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif return; } @@ -69,10 +69,10 @@ static void SCANNER_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0); gScanChannel = (uint8_t)Channel; @@ -95,13 +95,13 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) case SCAN_EDIT_STATE_NONE: 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; gFlagStopScan = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gFlagResetVfos = true; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif break; @@ -118,7 +118,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) case SCAN_EDIT_STATE_DONE: gScannerEditState = SCAN_EDIT_STATE_NONE; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; + g_another_voice_id = VOICE_ID_CANCEL; #endif gRequestDisplayScreen = DISPLAY_SCANNER; break; @@ -199,11 +199,11 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) #else #ifdef ENABLE_1250HZ_STEP - const STEP_Setting_t small_step = STEP_1_25kHz; - const STEP_Setting_t big_step = STEP_6_25kHz; + const step_setting_t small_step = STEP_1_25kHz; + const step_setting_t big_step = STEP_6_25kHz; #else - const STEP_Setting_t small_step = STEP_2_5kHz; - const STEP_Setting_t big_step = STEP_6_25kHz; + const step_setting_t small_step = STEP_2_5kHz; + const step_setting_t big_step = STEP_6_25kHz; #endif const uint32_t small_step_freq = StepFrequencyTable[small_step]; @@ -242,11 +242,11 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) #endif } - if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST) + if (gTxVfo->channel_save <= USER_CHANNEL_LAST) { gScannerEditState = SCAN_EDIT_STATE_BUSY; - gScanChannel = gTxVfo->CHANNEL_SAVE; - gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->CHANNEL_SAVE, false, 0); + gScanChannel = gTxVfo->channel_save; + gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->channel_save, false, 0); } else { @@ -256,7 +256,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) gScanCssState = SCAN_CSS_STATE_FOUND; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_MEMORY_CHANNEL; + g_another_voice_id = VOICE_ID_MEMORY_CHANNEL; #endif gRequestDisplayScreen = DISPLAY_SCANNER; @@ -275,45 +275,45 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) case SCAN_EDIT_STATE_DONE: if (!gScanSingleFrequency) { - RADIO_InitInfo(gTxVfo, gTxVfo->CHANNEL_SAVE, gScanFrequency); + RADIO_InitInfo(gTxVfo, gTxVfo->channel_save, gScanFrequency); if (gScanUseCssResult) { - gTxVfo->freq_config_RX.CodeType = gScanCssResultType; - gTxVfo->freq_config_RX.Code = gScanCssResultCode; + gTxVfo->freq_config_rx.code_type = gScanCssResultType; + gTxVfo->freq_config_rx.code = gScanCssResultCode; } - gTxVfo->freq_config_TX = gTxVfo->freq_config_RX; - gTxVfo->STEP_SETTING = gStepSetting; + gTxVfo->freq_config_tx = gTxVfo->freq_config_rx; + gTxVfo->step_setting = gStepSetting; } else { RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); - gTxVfo->freq_config_RX.CodeType = gScanCssResultType; - gTxVfo->freq_config_RX.Code = gScanCssResultCode; - gTxVfo->freq_config_TX.CodeType = gScanCssResultType; - gTxVfo->freq_config_TX.Code = gScanCssResultCode; + gTxVfo->freq_config_rx.code_type = gScanCssResultType; + gTxVfo->freq_config_rx.code = gScanCssResultCode; + gTxVfo->freq_config_tx.code_type = gScanCssResultType; + gTxVfo->freq_config_tx.code = gScanCssResultCode; } - if (gTxVfo->CHANNEL_SAVE <= MR_CHANNEL_LAST) + if (gTxVfo->channel_save <= USER_CHANNEL_LAST) { Channel = gScanChannel; - gEeprom.MrChannel[gEeprom.TX_VFO] = Channel; + g_eeprom.user_channel[g_eeprom.tx_vfo] = Channel; } else { - Channel = gTxVfo->Band + FREQ_CHANNEL_FIRST; - gEeprom.FreqChannel[gEeprom.TX_VFO] = Channel; + Channel = gTxVfo->band + FREQ_CHANNEL_FIRST; + g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel; } - gTxVfo->CHANNEL_SAVE = Channel; - gEeprom.ScreenChannel[gEeprom.TX_VFO] = Channel; + gTxVfo->channel_save = Channel; + g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel; gRequestSaveChannel = 2; #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CONFIRM; + g_another_voice_id = VOICE_ID_CONFIRM; #endif 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) { - gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST); + gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, USER_CHANNEL_LAST); gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0); 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; } -void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) +void SCANNER_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) { switch (Key) { @@ -414,17 +414,17 @@ void SCANNER_Start(void) RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) - gRxVfo->CHANNEL_SAVE = FREQ_CHANNEL_FIRST + BAND6_400MHz; + if (IS_NOAA_CHANNEL(gRxVfo->channel_save)) + gRxVfo->channel_save = FREQ_CHANNEL_FIRST + BAND6_400MHz; #endif - BackupStep = gRxVfo->STEP_SETTING; - BackupStepFreq = gRxVfo->StepFrequency; + BackupStep = gRxVfo->step_setting; + 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->StepFrequency = BackupStepFreq; + gRxVfo->step_setting = BackupStep; + gRxVfo->step_freq = BackupStepFreq; RADIO_SetupRegisters(true); @@ -435,8 +435,8 @@ void SCANNER_Start(void) if (gScanSingleFrequency) { gScanCssState = SCAN_CSS_STATE_SCANNING; - gScanFrequency = gRxVfo->pRX->Frequency; - gStepSetting = gRxVfo->STEP_SETTING; + gScanFrequency = gRxVfo->pRX->frequency; + gStepSetting = gRxVfo->step_setting; BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency); BK4819_SetScanFrequency(gScanFrequency); @@ -457,12 +457,12 @@ void SCANNER_Start(void) gScanCssResultType = 0xFF; gScanHitCount = 0; gScanUseCssResult = false; - g_CxCSS_TAIL_Found = false; - g_CDCSS_Lost = false; - gCDCSSCodeType = 0; - g_CTCSS_Lost = false; + g_CxCSS_tailL_found = false; + g_CDCSS_lost = false; + g_CDCSS_code_type = 0; + g_CTCSS_lost = false; #ifdef ENABLE_VOX - g_VOX_Lost = false; + g_vox_lost = false; #endif g_SquelchLost = false; gScannerEditState = SCAN_EDIT_STATE_NONE; @@ -474,7 +474,7 @@ void SCANNER_Start(void) void SCANNER_Stop(void) { - const uint8_t Previous = gRestoreMrChannel; + const uint8_t Previous = gRestoreUSER_CHANNEL; if (gScanStateDir == SCAN_OFF) return; // but, but, we weren't ! @@ -483,16 +483,16 @@ void SCANNER_Stop(void) if (!bScanKeepFrequency) { - if (gNextMrChannel <= MR_CHANNEL_LAST) + if (gNextChannel <= USER_CHANNEL_LAST) { - gEeprom.MrChannel[gEeprom.RX_VFO] = gRestoreMrChannel; - gEeprom.ScreenChannel[gEeprom.RX_VFO] = Previous; + g_eeprom.user_channel[g_eeprom.rx_vfo] = gRestoreUSER_CHANNEL; + 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 { - gRxVfo->freq_config_RX.Frequency = gRestoreFrequency; + gRxVfo->freq_config_rx.frequency = gRestoreFrequency; RADIO_ApplyOffset(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo); } @@ -501,11 +501,11 @@ void SCANNER_Stop(void) return; } - if (gRxVfo->CHANNEL_SAVE > MR_CHANNEL_LAST) + if (gRxVfo->channel_save > USER_CHANNEL_LAST) { RADIO_ApplyOffset(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; } diff --git a/app/scanner.h b/app/scanner.h index d0d4630..3df9923 100644 --- a/app/scanner.h +++ b/app/scanner.h @@ -42,7 +42,7 @@ enum SCAN_edit_state_e { }; 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 bool gFlagStartScan; extern bool gFlagStopScan; @@ -60,7 +60,7 @@ extern bool gScanUseCssResult; extern int8_t gScanStateDir; 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_Stop(void); diff --git a/app/spectrum.c b/app/spectrum.c index 1169f96..85c9bc1 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -22,169 +22,181 @@ const uint16_t RSSI_MAX_VALUE = 65535; static uint32_t initialFreq; -static char String[32]; +static char String[32]; -bool isInitialized = false; -bool monitorMode = false; -bool redrawStatus = true; -bool redrawScreen = false; -bool newScanStart = true; +bool isInitialized = false; +bool monitorMode = false; +bool redrawStatus = true; +bool redrawScreen = false; +bool newScanStart = true; bool preventKeypress = true; -bool isListening = false; -bool isTransmitting = false; +bool isListening = false; +bool isTransmitting = false; -State currentState = SPECTRUM, previousState = SPECTRUM; +State currentState = SPECTRUM, previousState = SPECTRUM; -PeakInfo peak; -ScanInfo scanInfo; -KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0}; +PeakInfo peak; +ScanInfo scanInfo; +KeyboardState kbd = {KEY_INVALID, KEY_INVALID, 0}; -const char *bwOptions[] = {" 25k", "12.5k", "6.25k"}; -const char *modulationTypeOptions[] = {" FM", " AM", "USB"}; +const char *bwOptions[] = {" 25k", "12.5k", "6.25k"}; +const char *modulationTypeOptions[] = {" FM", " AM", "USB"}; const uint8_t modulationTypeTuneSteps[] = {100, 50, 10}; -const uint8_t modTypeReg47Values[] = {1, 7, 5}; +const uint8_t modTypeReg47Values[] = {1, 7, 5}; SpectrumSettings settings = { - .stepsCount = STEPS_64, - .scanStepIndex = S_STEP_25_0kHz, - .frequencyChangeStep = 80000, - .scanDelay = 3200, - .rssiTriggerLevel = 150, - .backlightState = true, - .bw = BK4819_FILTER_BW_WIDE, - .listenBw = BK4819_FILTER_BW_WIDE, - .modulationType = false, + .stepsCount = STEPS_64, + .scanStepIndex = S_STEP_25_0kHz, + .frequencyChangeStep = 80000, + .scanDelay = 3200, + .rssiTriggerLevel = 150, + .backlightState = true, + .bw = BK4819_FILTER_BW_WIDE, + .listenBw = BK4819_FILTER_BW_WIDE, + .modulationType = false, }; -uint32_t fMeasure = 0; -uint32_t fTx = 0; -uint32_t currentFreq, tempFreq; +uint32_t fMeasure = 0; +uint32_t fTx = 0; +uint32_t currentFreq; +uint32_t tempFreq; 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 registerSpecs[] = { - {}, - {"LNAs", 0x13, 8, 0b11, 1}, - {"LNA", 0x13, 5, 0b111, 1}, - {"PGA", 0x13, 0, 0b111, 1}, - {"MIX", 0x13, 3, 0b11, 1}, - - {"DEV", 0x40, 0, 4095, 1}, - {"CMP", 0x31, 3, 1, 1}, - {"MIC", 0x7D, 0, 0x1F, 1}, +static const RegisterSpec registerSpecs[] = { + {}, + {"LNAs", 0x13, 8, 0b11, 1}, + {"LNA", 0x13, 5, 0b111, 1}, + {"PGA", 0x13, 0, 0b111, 1}, + {"MIX", 0x13, 3, 0b11, 1}, + {"DEV", 0x40, 0, 4095, 1}, + {"CMP", 0x31, 3, 1, 1}, + {"MIC", 0x7D, 0, 0x1F, 1}, }; static uint16_t registersBackup[128]; 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); const uint8_t FREQ_INPUT_LENGTH = 10; -uint8_t freqInputIndex = 0; -uint8_t freqInputDotIndex = 0; -KEY_Code_t freqInputArr[10]; -char freqInputString[] = "----------"; // XXXX.XXXXX +uint8_t freqInputIndex = 0; +uint8_t freqInputDotIndex = 0; +key_code_t freqInputArr[10]; +char freqInputString[] = "----------"; // XXXX.XXXXX -uint8_t menuState = 0; +uint8_t menuState = 0; -uint16_t listenT = 0; +uint16_t listenT = 0; -uint16_t batteryUpdateTimer = 0; -bool isMovingInitialized = false; -uint8_t lastStepsCount = 0; +uint16_t batteryUpdateTimer = 0; +bool isMovingInitialized = false; +uint8_t lastStepsCount = 0; -uint8_t CountBits(uint16_t n) { - uint8_t count = 0; - while (n) { - count++; - n >>= 1; - } - return count; +uint8_t CountBits(uint16_t n) +{ + uint8_t count = 0; + while (n) + { + count++; + n >>= 1; + } + return count; } -static uint16_t GetRegMask(RegisterSpec s) { - return (1 << CountBits(s.maxValue)) - 1; +static uint16_t GetRegMask(RegisterSpec s) +{ + return (1 << CountBits(s.maxValue)) - 1; } -static uint16_t GetRegValue(RegisterSpec s) { - return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue; +static uint16_t GetRegValue(RegisterSpec s) +{ + return (BK4819_ReadRegister(s.num) >> s.offset) & s.maxValue; } -static void SetRegValue(RegisterSpec s, uint16_t v) { - uint16_t reg = BK4819_ReadRegister(s.num); - reg &= ~(GetRegMask(s) << s.offset); - BK4819_WriteRegister(s.num, reg | (v << s.offset)); +static void SetRegValue(RegisterSpec s, uint16_t v) +{ + uint16_t reg = BK4819_ReadRegister(s.num); + reg &= ~(GetRegMask(s) << s.offset); + BK4819_WriteRegister(s.num, reg | (v << s.offset)); } -static void UpdateRegMenuValue(RegisterSpec s, bool add) { - uint16_t v = GetRegValue(s); - - if (add && v <= s.maxValue - s.inc) { - v += s.inc; - } else if (!add && v >= 0 + s.inc) { - v -= s.inc; - } - - SetRegValue(s, v); - redrawScreen = true; +static void UpdateRegMenuValue(RegisterSpec s, bool add) +{ + uint16_t v = GetRegValue(s); + + if (add && v <= s.maxValue - s.inc) + v += s.inc; + else + if (!add && v >= 0 + s.inc) + v -= s.inc; + + SetRegValue(s, v); + redrawScreen = true; } // Utility functions -KEY_Code_t GetKey() { - KEY_Code_t btn = KEYBOARD_Poll(); - if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) { - btn = KEY_PTT; - } - return btn; +key_code_t GetKey() +{ + key_code_t btn = KEYBOARD_Poll(); + if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) + btn = KEY_PTT; + return btn; } -void SetState(State state) { - previousState = currentState; - currentState = state; - redrawScreen = true; - redrawStatus = true; +void SetState(State state) +{ + previousState = currentState; + currentState = state; + redrawScreen = true; + redrawStatus = true; } // Radio functions -static void BackupRegisters() { - for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) { - uint8_t regNum = registersToBackup[i]; - registersBackup[regNum] = BK4819_ReadRegister(regNum); - } +static void BackupRegisters() +{ + for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) + { + uint8_t regNum = registersToBackup[i]; + registersBackup[regNum] = BK4819_ReadRegister(regNum); + } } -static void RestoreRegisters() { - for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) { - uint8_t regNum = registersToBackup[i]; - BK4819_WriteRegister(regNum, registersBackup[regNum]); - } +static void RestoreRegisters() +{ + for (int i = 0; i < ARRAY_SIZE(registersToBackup); ++i) + { + uint8_t regNum = registersToBackup[i]; + BK4819_WriteRegister(regNum, registersBackup[regNum]); + } } -static void SetModulation(ModulationType type) { - // restore only registers, which we affect here fully - BK4819_WriteRegister(0x37, registersBackup[0x37]); - BK4819_WriteRegister(0x3D, registersBackup[0x3D]); - BK4819_WriteRegister(0x48, registersBackup[0x48]); - - SetRegValue(afOutRegSpec, modTypeReg47Values[type]); - - if (type == MOD_USB) { - BK4819_WriteRegister(0x37, 0b0001011000001111); - BK4819_WriteRegister(0x3D, 0b0010101101000101); - BK4819_WriteRegister(0x48, 0b0000001110101000); - } - - if (type == MOD_AM) { - SetRegValue(afDacGainRegSpec, 0xE); - } +static void SetModulation(ModulationType type) +{ + // restore only registers, which we affect here fully + BK4819_WriteRegister(0x37, registersBackup[0x37]); + BK4819_WriteRegister(0x3D, registersBackup[0x3D]); + BK4819_WriteRegister(0x48, registersBackup[0x48]); + + SetRegValue(afOutRegSpec, modTypeReg47Values[type]); + + if (type == MOD_USB) + { + BK4819_WriteRegister(0x37, 0b0001011000001111); + BK4819_WriteRegister(0x3D, 0b0010101101000101); + BK4819_WriteRegister(0x48, 0b0000001110101000); + } + + if (type == MOD_AM) + SetRegValue(afDacGainRegSpec, 0xE); } static void SetF(uint32_t f) { @@ -646,7 +658,7 @@ static void FreqInput() { SetState(FREQ_INPUT); } -static void UpdateFreqInput(KEY_Code_t key) { +static void UpdateFreqInput(key_code_t key) { if (key != KEY_EXIT && freqInputIndex >= 10) { return; } @@ -667,7 +679,7 @@ static void UpdateFreqInput(KEY_Code_t key) { uint8_t dotIndex = freqInputDotIndex == 0 ? freqInputIndex : freqInputDotIndex; - KEY_Code_t digitKey; + key_code_t digitKey; for (int i = 0; i < 10; ++i) { if (i < freqInputIndex) { 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) { case KEY_3: break; @@ -1315,7 +1327,7 @@ static void AutomaticPresetChoose(uint32_t f) { void APP_RunSpectrum() { BackupRegisters(); // 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; currentFreq = initialFreq; settings.scanStepIndex = gStepSettingToIndex[vfo.STEP_SETTING]; diff --git a/app/spectrum.h b/app/spectrum.h index 739f4d0..9aeeaf8 100644 --- a/app/spectrum.h +++ b/app/spectrum.h @@ -17,6 +17,10 @@ #ifndef SPECTRUM_H #define SPECTRUM_H +#include +#include +#include + #include "../bitmaps.h" #include "../board.h" #include "../bsp/dp32g030/gpio.h" @@ -36,184 +40,164 @@ #include "../radio.h" #include "../settings.h" #include "../ui/helper.h" -#include -#include -#include static const uint8_t DrawingEndY = 40; static const uint16_t scanStepValues[] = { - 1, 10, 50, 100, - - 250, 500, 625, 833, 1000, 1250, 2500, 10000, + 1, 10, 50, 100, 250, 500, 625, 833, 1000, 1250, 2500, 10000, }; static const uint8_t gStepSettingToIndex[] = { - [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_8_33kHz] = 7, + [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_8_33kHz] = 7, }; static const uint16_t scanStepBWRegValues[12] = { - // RX RXw TX BW - // 0b0 000 000 001 01 1000 - // 1 - 0b0000000001011000, // 6.25 - // 10 - 0b0000000001011000, // 6.25 - // 50 - 0b0000000001011000, // 6.25 - // 100 - 0b0000000001011000, // 6.25 - // 250 - 0b0000000001011000, // 6.25 - // 500 - 0b0010010001011000, // 6.25 - // 625 - 0b0100100001011000, // 6.25 - // 833 - 0b0110110001001000, // 6.25 - // 1000 - 0b0110110001001000, // 6.25 - // 1250 - 0b0111111100001000, // 6.25 - // 2500 - 0b0011011000101000, // 25 - // 10000 - 0b0011011000101000, // 25 + // RX RXw TX BW + // 0b0 000 000 001 01 1000 + // 1 + 0b0000000001011000, // 6.25 + // 10 + 0b0000000001011000, // 6.25 + // 50 + 0b0000000001011000, // 6.25 + // 100 + 0b0000000001011000, // 6.25 + // 250 + 0b0000000001011000, // 6.25 + // 500 + 0b0010010001011000, // 6.25 + // 625 + 0b0100100001011000, // 6.25 + // 833 + 0b0110110001001000, // 6.25 + // 1000 + 0b0110110001001000, // 6.25 + // 1250 + 0b0111111100001000, // 6.25 + // 2500 + 0b0011011000101000, // 25 + // 10000 + 0b0011011000101000, // 25 }; static const uint16_t listenBWRegValues[] = { - 0b0011011000101000, // 25 - 0b0111111100001000, // 12.5 - 0b0100100001011000, // 6.25 + 0b0011011000101000, // 25 + 0b0111111100001000, // 12.5 + 0b0100100001011000, // 6.25 }; typedef enum State { - SPECTRUM, - FREQ_INPUT, - STILL, + SPECTRUM, + FREQ_INPUT, + STILL, } State; typedef enum StepsCount { - STEPS_128, - STEPS_64, - STEPS_32, - STEPS_16, + STEPS_128, + STEPS_64, + STEPS_32, + STEPS_16, } StepsCount; typedef enum ModulationType { - MOD_FM, - MOD_AM, - MOD_USB, + MOD_FM, + MOD_AM, + MOD_USB, } ModulationType; typedef enum ScanStep { - S_STEP_0_01kHz, - S_STEP_0_1kHz, - S_STEP_0_5kHz, - S_STEP_1_0kHz, + S_STEP_0_01kHz, + S_STEP_0_1kHz, + S_STEP_0_5kHz, + S_STEP_1_0kHz, - S_STEP_2_5kHz, - S_STEP_5_0kHz, - S_STEP_6_25kHz, - S_STEP_8_33kHz, - S_STEP_10_0kHz, - S_STEP_12_5kHz, - S_STEP_25_0kHz, - S_STEP_100_0kHz, + S_STEP_2_5kHz, + S_STEP_5_0kHz, + S_STEP_6_25kHz, + S_STEP_8_33kHz, + S_STEP_10_0kHz, + S_STEP_12_5kHz, + S_STEP_25_0kHz, + S_STEP_100_0kHz, } ScanStep; typedef struct SpectrumSettings { - StepsCount stepsCount; - ScanStep scanStepIndex; - uint32_t frequencyChangeStep; - uint16_t scanDelay; - uint16_t rssiTriggerLevel; + StepsCount stepsCount; + ScanStep scanStepIndex; + uint32_t frequencyChangeStep; + uint16_t scanDelay; + uint16_t rssiTriggerLevel; - bool backlightState; - BK4819_FilterBandwidth_t bw; - BK4819_FilterBandwidth_t listenBw; - ModulationType modulationType; + bool backlightState; + BK4819_FilterBandwidth_t bw; + BK4819_FilterBandwidth_t listenBw; + ModulationType modulationType; } SpectrumSettings; typedef struct KeyboardState { - KEY_Code_t current; - KEY_Code_t prev; - uint8_t counter; + KEY_Code_t current; + KEY_Code_t prev; + uint8_t counter; } KeyboardState; typedef struct ScanInfo { - uint16_t rssi, rssiMin, rssiMax; - uint8_t i, iPeak; - uint32_t f, fPeak; - uint16_t scanStep; - uint8_t measurementsCount; + uint16_t rssi, rssiMin, rssiMax; + uint8_t i, iPeak; + uint32_t f, fPeak; + uint16_t scanStep; + uint8_t measurementsCount; } ScanInfo; typedef struct RegisterSpec { - const char *name; - uint8_t num; - uint8_t offset; - uint16_t maxValue; - uint16_t inc; + const char *name; + uint8_t num; + uint8_t offset; + uint16_t maxValue; + uint16_t inc; } RegisterSpec; typedef struct PeakInfo { - uint16_t t; - uint16_t rssi; - uint8_t i; - uint32_t f; + uint16_t t; + uint16_t rssi; + uint8_t i; + uint32_t f; } PeakInfo; typedef struct MovingAverage { - uint16_t mean[128]; - uint16_t buf[4][128]; - uint16_t min, mid, max; - uint16_t t; + uint16_t mean[128]; + uint16_t buf[4][128]; + uint16_t min, mid, max; + uint16_t t; } MovingAverage; typedef struct FreqPreset { - char name[16]; - uint32_t fStart; - uint32_t fEnd; - StepsCount stepsCountIndex; - uint8_t stepSizeIndex; - ModulationType modulationType; - BK4819_FilterBandwidth_t listenBW; + char name[16]; + uint32_t fStart; + uint32_t fEnd; + StepsCount stepsCountIndex; + uint8_t stepSizeIndex; + ModulationType modulationType; + BK4819_FilterBandwidth_t listenBW; } FreqPreset; static const FreqPreset freqPresets[] = { - {"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB, - BK4819_FILTER_BW_NARROWER}, - {"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB, - BK4819_FILTER_BW_NARROWER}, - {"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB, - BK4819_FILTER_BW_NARROWER}, - {"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM, - BK4819_FILTER_BW_NARROW}, - {"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB, - BK4819_FILTER_BW_NARROWER}, - {"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM, - BK4819_FILTER_BW_NARROW}, - {"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM, - 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}, + {"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER}, + {"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER}, + {"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER}, + {"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW }, + {"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER}, + {"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM, BK4819_FILTER_BW_NARROW }, + {"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM, 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); -#endif /* ifndef SPECTRUM_H */ - -// vim: ft=c +#endif diff --git a/app/uart.c b/app/uart.c index 61d1ac5..561998b 100644 --- a/app/uart.c +++ b/app/uart.c @@ -390,16 +390,16 @@ static void CMD_052F(const uint8_t *pBuffer) { const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer; - gEeprom.DUAL_WATCH = DUAL_WATCH_OFF; - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; - gEeprom.RX_VFO = 0; - gEeprom.DTMF_SIDE_TONE = false; - gEeprom.VfoInfo[0].FrequencyReverse = false; - gEeprom.VfoInfo[0].pRX = &gEeprom.VfoInfo[0].freq_config_RX; - gEeprom.VfoInfo[0].pTX = &gEeprom.VfoInfo[0].freq_config_TX; - gEeprom.VfoInfo[0].TX_OFFSET_FREQUENCY_DIRECTION = TX_OFFSET_FREQUENCY_DIRECTION_OFF; - gEeprom.VfoInfo[0].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; - gEeprom.VfoInfo[0].DTMF_DECODING_ENABLE = false; + g_eeprom.dual_watch = DUAL_WATCH_OFF; + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; + g_eeprom.rx_vfo = 0; + g_eeprom.DTMF_side_tone = false; + g_eeprom.VfoInfo[0].frequency_reverse = false; + g_eeprom.VfoInfo[0].pRX = &g_eeprom.VfoInfo[0].freq_config_rx; + g_eeprom.VfoInfo[0].pTX = &g_eeprom.VfoInfo[0].freq_config_tx; + g_eeprom.VfoInfo[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; + g_eeprom.VfoInfo[0].DTMF_ptt_id_tx_mode = PTT_ID_OFF; + g_eeprom.VfoInfo[0].DTMF_decoding_enable = false; #ifdef ENABLE_NOAA gIsNoaaMode = false; diff --git a/audio.c b/audio.c index b46fd44..2fbbde5 100644 --- a/audio.c +++ b/audio.c @@ -59,12 +59,12 @@ 0x41, 0x32, 0x3C, 0x37, }; - VOICE_ID_t gVoiceID[8]; - uint8_t gVoiceReadIndex; - uint8_t gVoiceWriteIndex; - volatile uint16_t gCountdownToPlayNextVoice_10ms; - volatile bool gFlagPlayQueuedVoice; - VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID; + voice_id_t g_voice_id[8]; + uint8_t g_voice_read_index; + uint8_t g_voice_write_index; + volatile uint16_t g_count_down_to_play_next_voice_10ms; + volatile bool g_flag_play_queued_voice; + voice_id_t g_another_voice_id = VOICE_ID_INVALID; #endif @@ -81,7 +81,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) Beep != BEEP_440HZ_500MS && Beep != BEEP_880HZ_200MS && Beep != BEEP_880HZ_500MS && - !gEeprom.BEEP_CONTROL) + !g_eeprom.beep_control) return; #ifdef ENABLE_AIRCOPY @@ -99,7 +99,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) 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(); #ifdef ENABLE_FMRADIO @@ -209,7 +209,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) BK1080_Mute(false); #endif - if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode) + if (gCurrentFunction == FUNCTION_POWER_SAVE && g_rx_idle_mode) BK4819_Sleep(); } @@ -244,11 +244,11 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) uint8_t VoiceID; 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 if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese)) goto Bailout; @@ -284,7 +284,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(5); AUDIO_PlayVoice(VoiceID); - if (gVoiceWriteIndex == 1) + if (g_voice_write_index == 1) Delay += 3; if (bFlag) @@ -294,7 +294,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR || 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 if (gFmRadioMode) @@ -304,8 +304,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (!gEnableSpeaker) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gVoiceWriteIndex = 0; - gVoiceReadIndex = 0; + g_voice_write_index = 0; + g_voice_read_index = 0; #ifdef ENABLE_VOX gVoxResumeCountdown = 80; @@ -314,32 +314,32 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) return; } - gVoiceReadIndex = 1; - gCountdownToPlayNextVoice_10ms = Delay; - gFlagPlayQueuedVoice = false; + g_voice_read_index = 1; + g_count_down_to_play_next_voice_10ms = Delay; + g_flag_play_queued_voice = false; return; } Bailout: - gVoiceReadIndex = 0; - gVoiceWriteIndex = 0; + g_voice_read_index = 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; if (Index == 0) { - gVoiceWriteIndex = 0; - gVoiceReadIndex = 0; + g_voice_write_index = 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) @@ -350,8 +350,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (Index == 0) { - gVoiceWriteIndex = 0; - gVoiceReadIndex = 0; + g_voice_write_index = 0; + g_voice_read_index = 0; } Count = 0; @@ -365,17 +365,17 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) else { Result = Remainder / 100U; - gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result; + g_voice_id[g_voice_write_index++] = (voice_id_t)Result; Count++; Remainder -= Result * 100U; } Result = Remainder / 10U; - gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result; + g_voice_id[g_voice_write_index++] = (voice_id_t)Result; Count++; Remainder -= Result * 10U; Skip: - gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder; + g_voice_id[g_voice_write_index++] = (voice_id_t)Remainder; return Count + 1U; } @@ -388,10 +388,10 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) 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]; - if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) + VoiceID = g_voice_id[g_voice_read_index]; + if (g_eeprom.voice_prompt == VOICE_PROMPT_CHINESE) { if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese)) { @@ -412,17 +412,17 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) Skip = true; } - gVoiceReadIndex++; + g_voice_read_index++; if (!Skip) { - if (gVoiceReadIndex == gVoiceWriteIndex) + if (g_voice_read_index == g_voice_write_index) Delay += 3; AUDIO_PlayVoice(VoiceID); - gCountdownToPlayNextVoice_10ms = Delay; - gFlagPlayQueuedVoice = false; + g_count_down_to_play_next_voice_10ms = Delay; + g_flag_play_queued_voice = false; #ifdef ENABLE_VOX gVoxResumeCountdown = 2000; @@ -435,7 +435,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR || 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 if (gFmRadioMode) @@ -449,8 +449,8 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) gVoxResumeCountdown = 80; #endif - gVoiceWriteIndex = 0; - gVoiceReadIndex = 0; + g_voice_write_index = 0; + g_voice_read_index = 0; } #endif diff --git a/audio.h b/audio.h index 86b5928..7e7dd14 100644 --- a/audio.h +++ b/audio.h @@ -46,101 +46,100 @@ enum VOICE_ID_ENG_BASE = 0x60U, }; -enum VOICE_ID_t +enum voice_id_e { - VOICE_ID_0 = 0x00U, - VOICE_ID_1 = 0x01U, - VOICE_ID_2 = 0x02U, - VOICE_ID_3 = 0x03U, - VOICE_ID_4 = 0x04U, - VOICE_ID_5 = 0x05U, - VOICE_ID_6 = 0x06U, - VOICE_ID_7 = 0x07U, - VOICE_ID_8 = 0x08U, - VOICE_ID_9 = 0x09U, - VOICE_ID_10 = 0x0AU, - VOICE_ID_100 = 0x0BU, - VOICE_ID_WELCOME = 0x0CU, - VOICE_ID_LOCK = 0x0DU, - VOICE_ID_UNLOCK = 0x0EU, - VOICE_ID_SCANNING_BEGIN = 0x0FU, - VOICE_ID_SCANNING_STOP = 0x10U, - VOICE_ID_SCRAMBLER_ON = 0x11U, - VOICE_ID_SCRAMBLER_OFF = 0x12U, - VOICE_ID_FUNCTION = 0x13U, - VOICE_ID_CTCSS = 0x14U, - VOICE_ID_DCS = 0x15U, - VOICE_ID_POWER = 0x16U, - VOICE_ID_SAVE_MODE = 0x17U, - VOICE_ID_MEMORY_CHANNEL = 0x18U, - VOICE_ID_DELETE_CHANNEL = 0x19U, - VOICE_ID_FREQUENCY_STEP = 0x1AU, - VOICE_ID_SQUELCH = 0x1BU, - VOICE_ID_TRANSMIT_OVER_TIME = 0x1CU, - VOICE_ID_BACKLIGHT_SELECTION = 0x1DU, - VOICE_ID_VOX = 0x1EU, - VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION = 0x1FU, - VOICE_ID_TX_OFFSET_FREQUENCY = 0x20U, - VOICE_ID_TRANSMITING_MEMORY = 0x21U, - VOICE_ID_RECEIVING_MEMORY = 0x22U, - VOICE_ID_EMERGENCY_CALL = 0x23U, - VOICE_ID_LOW_VOLTAGE = 0x24U, - VOICE_ID_CHANNEL_MODE = 0x25U, - VOICE_ID_FREQUENCY_MODE = 0x26U, - VOICE_ID_VOICE_PROMPT = 0x27U, - VOICE_ID_BAND_SELECTION = 0x28U, - VOICE_ID_DUAL_STANDBY = 0x29U, - VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU, - VOICE_ID_OPTIONAL_SIGNAL = 0x2BU, - VOICE_ID_MUTE_MODE = 0x2CU, - VOICE_ID_BUSY_LOCKOUT = 0x2DU, - VOICE_ID_BEEP_PROMPT = 0x2EU, - VOICE_ID_ANI_CODE = 0x2FU, - VOICE_ID_INITIALISATION = 0x30U, - VOICE_ID_CONFIRM = 0x31U, - VOICE_ID_CANCEL = 0x32U, - VOICE_ID_ON = 0x33U, - VOICE_ID_OFF = 0x34U, - VOICE_ID_2_TONE = 0x35U, - VOICE_ID_5_TONE = 0x36U, - VOICE_ID_DIGITAL_SIGNAL = 0x37U, - VOICE_ID_REPEATER = 0x38U, - VOICE_ID_MENU = 0x39U, - VOICE_ID_11 = 0x3AU, - VOICE_ID_12 = 0x3BU, - VOICE_ID_13 = 0x3CU, - VOICE_ID_14 = 0x3DU, - VOICE_ID_15 = 0x3EU, - VOICE_ID_16 = 0x3FU, - VOICE_ID_17 = 0x40U, - VOICE_ID_18 = 0x41U, - VOICE_ID_19 = 0x42U, - VOICE_ID_20 = 0x43U, - VOICE_ID_30 = 0x44U, - VOICE_ID_40 = 0x45U, - VOICE_ID_50 = 0x46U, - VOICE_ID_60 = 0x47U, - VOICE_ID_70 = 0x48U, - VOICE_ID_80 = 0x49U, - VOICE_ID_90 = 0x4AU, - VOICE_ID_END = 0x4BU, - - VOICE_ID_INVALID = 0xFFU, + VOICE_ID_0 = 0x00U, + VOICE_ID_1 = 0x01U, + VOICE_ID_2 = 0x02U, + VOICE_ID_3 = 0x03U, + VOICE_ID_4 = 0x04U, + VOICE_ID_5 = 0x05U, + VOICE_ID_6 = 0x06U, + VOICE_ID_7 = 0x07U, + VOICE_ID_8 = 0x08U, + VOICE_ID_9 = 0x09U, + VOICE_ID_10 = 0x0AU, + VOICE_ID_100 = 0x0BU, + VOICE_ID_WELCOME = 0x0CU, + VOICE_ID_LOCK = 0x0DU, + VOICE_ID_UNLOCK = 0x0EU, + VOICE_ID_SCANNING_BEGIN = 0x0FU, + VOICE_ID_SCANNING_STOP = 0x10U, + VOICE_ID_SCRAMBLER_ON = 0x11U, + VOICE_ID_SCRAMBLER_OFF = 0x12U, + VOICE_ID_FUNCTION = 0x13U, + VOICE_ID_CTCSS = 0x14U, + VOICE_ID_DCS = 0x15U, + VOICE_ID_POWER = 0x16U, + VOICE_ID_SAVE_MODE = 0x17U, + VOICE_ID_MEMORY_CHANNEL = 0x18U, + VOICE_ID_DELETE_CHANNEL = 0x19U, + VOICE_ID_FREQUENCY_STEP = 0x1AU, + VOICE_ID_SQUELCH = 0x1BU, + voice_id_tRANSMIT_OVER_TIME = 0x1CU, + VOICE_ID_BACKLIGHT_SELECTION = 0x1DU, + VOICE_ID_VOX = 0x1EU, + voice_id_tX_OFFSET_FREQ_DIR = 0x1FU, + voice_id_tX_OFFSET_FREQ = 0x20U, + voice_id_tRANSMITING_MEMORY = 0x21U, + VOICE_ID_RECEIVING_MEMORY = 0x22U, + VOICE_ID_EMERGENCY_CALL = 0x23U, + VOICE_ID_LOW_VOLTAGE = 0x24U, + VOICE_ID_CHANNEL_MODE = 0x25U, + VOICE_ID_FREQUENCY_MODE = 0x26U, + VOICE_ID_VOICE_PROMPT = 0x27U, + VOICE_ID_BAND_SELECTION = 0x28U, + VOICE_ID_DUAL_STANDBY = 0x29U, + VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU, + VOICE_ID_OPTIONAL_SIGNAL = 0x2BU, + VOICE_ID_MUTE_MODE = 0x2CU, + VOICE_ID_BUSY_LOCKOUT = 0x2DU, + VOICE_ID_BEEP_PROMPT = 0x2EU, + VOICE_ID_ANI_CODE = 0x2FU, + VOICE_ID_INITIALISATION = 0x30U, + VOICE_ID_CONFIRM = 0x31U, + VOICE_ID_CANCEL = 0x32U, + VOICE_ID_ON = 0x33U, + VOICE_ID_OFF = 0x34U, + VOICE_ID_2_TONE = 0x35U, + VOICE_ID_5_TONE = 0x36U, + VOICE_ID_DIGITAL_SIGNAL = 0x37U, + VOICE_ID_REPEATER = 0x38U, + VOICE_ID_MENU = 0x39U, + VOICE_ID_11 = 0x3AU, + VOICE_ID_12 = 0x3BU, + VOICE_ID_13 = 0x3CU, + VOICE_ID_14 = 0x3DU, + VOICE_ID_15 = 0x3EU, + VOICE_ID_16 = 0x3FU, + VOICE_ID_17 = 0x40U, + VOICE_ID_18 = 0x41U, + VOICE_ID_19 = 0x42U, + VOICE_ID_20 = 0x43U, + VOICE_ID_30 = 0x44U, + VOICE_ID_40 = 0x45U, + VOICE_ID_50 = 0x46U, + VOICE_ID_60 = 0x47U, + VOICE_ID_70 = 0x48U, + VOICE_ID_80 = 0x49U, + VOICE_ID_90 = 0x4AU, + VOICE_ID_END = 0x4BU, + + VOICE_ID_INVALID = 0xFFU, }; - -typedef enum VOICE_ID_t VOICE_ID_t; +typedef enum voice_id_e voice_id_t; #ifdef ENABLE_VOICE - extern VOICE_ID_t gVoiceID[8]; - extern uint8_t gVoiceReadIndex; - extern uint8_t gVoiceWriteIndex; - extern volatile uint16_t gCountdownToPlayNextVoice_10ms; - extern volatile bool gFlagPlayQueuedVoice; - extern VOICE_ID_t gAnotherVoiceID; + extern voice_id_t g_voice_id[8]; + extern uint8_t g_voice_read_index; + extern uint8_t g_voice_write_index; + extern volatile uint16_t g_count_down_to_play_next_voice_10ms; + extern volatile bool g_flag_play_queued_voice; + extern voice_id_t g_another_voice_id; void AUDIO_PlayVoice(uint8_t VoiceID); 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); void AUDIO_PlayQueuedVoice(void); #endif diff --git a/board.c b/board.c index 1aea112..44764d6 100644 --- a/board.c +++ b/board.c @@ -525,40 +525,40 @@ void BOARD_EEPROM_Init(void) // 0E70..0E77 EEPROM_ReadBuffer(0x0E70, Data, 8); - gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST; - gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1; - gEeprom.TX_TIMEOUT_TIMER = (Data[2] < 11) ? Data[2] : 1; + g_eeprom.chan_1_call = IS_USER_CHANNEL(Data[0]) ? Data[0] : USER_CHANNEL_FIRST; + g_eeprom.squelch_level = (Data[1] < 10) ? Data[1] : 1; + g_eeprom.tx_timeout_timer = (Data[2] < 11) ? Data[2] : 1; #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 - gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; + g_eeprom.key_lock = (Data[4] < 2) ? Data[4] : false; #ifdef ENABLE_VOX - gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false; - gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1; + g_eeprom.vox_switch = (Data[5] < 2) ? Data[5] : false; + g_eeprom.vox_level = (Data[6] < 10) ? Data[6] : 1; #endif - gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4; + g_eeprom.mic_sensitivity = (Data[7] < 5) ? Data[7] : 4; // 0E78..0E7F EEPROM_ReadBuffer(0x0E78, Data, 8); - gEeprom.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; - gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; - gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; - gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3; - gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; - gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; + g_eeprom.channel_display_mode = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode + g_eeprom.cross_vfo_rx_tx = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; + g_eeprom.battery_save = (Data[3] < 5) ? Data[3] : 4; + g_eeprom.dual_watch = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; + g_eeprom.backlight = (Data[5] < ARRAY_SIZE(gSubMenu_backlight)) ? Data[5] : 3; + g_eeprom.tail_note_elimination = (Data[6] < 2) ? Data[6] : false; + g_eeprom.vfo_open = (Data[7] < 2) ? Data[7] : true; // 0E80..0E87 EEPROM_ReadBuffer(0x0E80, Data, 8); - gEeprom.ScreenChannel[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); - gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST; - gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST; - gEeprom.FreqChannel[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.screen_channel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + g_eeprom.screen_channel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + g_eeprom.user_channel[0] = IS_USER_CHANNEL(Data[1]) ? Data[1] : USER_CHANNEL_FIRST; + g_eeprom.user_channel[1] = IS_USER_CHANNEL(Data[4]) ? Data[4] : USER_CHANNEL_FIRST; + g_eeprom.freq_channel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (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 - gEeprom.NoaaChannel[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[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST; + g_eeprom.noaa_channel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST; #endif #ifdef ENABLE_FMRADIO @@ -572,15 +572,15 @@ void BOARD_EEPROM_Init(void) } __attribute__((packed)) FM; EEPROM_ReadBuffer(0x0E88, &FM, 8); - gEeprom.FM_LowerLimit = 760; - gEeprom.FM_UpperLimit = 1080; - if (FM.SelectedFrequency < gEeprom.FM_LowerLimit || FM.SelectedFrequency > gEeprom.FM_UpperLimit) - gEeprom.FM_SelectedFrequency = 960; + g_eeprom.fm_lower_limit = 760; + g_eeprom.fm_upper_limit = 1080; + if (FM.SelectedFrequency < g_eeprom.fm_lower_limit || FM.SelectedFrequency > g_eeprom.fm_upper_limit) + g_eeprom.fm_selected_frequency = 960; else - gEeprom.FM_SelectedFrequency = FM.SelectedFrequency; + g_eeprom.fm_selected_frequency = FM.SelectedFrequency; - gEeprom.FM_SelectedChannel = FM.SelectedChannel; - gEeprom.FM_IsMrMode = (FM.IsMrMode < 2) ? FM.IsMrMode : false; + g_eeprom.fm_selected_channel = FM.SelectedChannel; + g_eeprom.fm_is_channel_mode = (FM.IsMrMode < 2) ? FM.IsMrMode : false; } // 0E40..0E67 @@ -590,111 +590,111 @@ void BOARD_EEPROM_Init(void) // 0E90..0E97 EEPROM_ReadBuffer(0x0E90, Data, 8); - gEeprom.BEEP_CONTROL = (Data[0] < 2) ? Data[0] : true; - gEeprom.KEY_1_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; - gEeprom.KEY_2_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; - gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; - gEeprom.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.beep_control = (Data[0] < 2) ? Data[0] : true; + g_eeprom.key1_short_press_action = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; + g_eeprom.key1_long_press_action = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT; + g_eeprom.key2_short_press_action = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; + g_eeprom.key2_long_press_action = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; + g_eeprom.scan_resume_mode = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; + g_eeprom.auto_keypad_lock = (Data[6] < 2) ? Data[6] : false; + g_eeprom.pwr_on_display_mode = (Data[7] < 4) ? Data[7] : PWR_ON_DISPLAY_MODE_VOLTAGE; // 0E98..0E9F EEPROM_ReadBuffer(0x0E98, Data, 8); - memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4); + memmove(&g_eeprom.power_on_password, Data, 4); // 0EA0..0EA7 #ifdef ENABLE_VOICE 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 // 0EA8..0EAF EEPROM_ReadBuffer(0x0EA8, Data, 8); #ifdef ENABLE_ALARM - gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true; + g_eeprom.alarm_mode = (Data[0] < 2) ? Data[0] : true; #endif - gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; - gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0; - gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0; + g_eeprom.roger_mode = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; + g_eeprom.repeater_tail_tone_elimination = (Data[2] < 11) ? Data[2] : 0; + g_eeprom.tx_vfo = (Data[3] < 2) ? Data[3] : 0; // 0ED0..0ED7 EEPROM_ReadBuffer(0x0ED0, Data, 8); - gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; - gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; - gEeprom.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; - gEeprom.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; - gEeprom.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_side_tone = (Data[0] < 2) ? Data[0] : true; + g_eeprom.DTMF_separate_code = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; + g_eeprom.DTMF_group_call_code = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#'; + g_eeprom.DTMF_decode_response = (Data[3] < 4) ? Data[3] : DTMF_DEC_RESPONSE_RING; + g_eeprom.DTMF_auto_reset_time = (Data[4] <= DTMF_HOLD_MAX) ? Data[4] : (Data[4] >= DTMF_HOLD_MIN) ? Data[4] : DTMF_HOLD_MAX; + g_eeprom.DTMF_preload_time = (Data[5] < 101) ? Data[5] * 10 : 200; + g_eeprom.DTMF_first_code_persist_time = (Data[6] < 101) ? Data[6] * 10 : 70; + g_eeprom.DTMF_hash_code_persist_time = (Data[7] < 101) ? Data[7] * 10 : 70; // 0ED8..0EDF EEPROM_ReadBuffer(0x0ED8, Data, 8); - gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 70; - gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 70; - gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : false; + g_eeprom.DTMF_code_persist_time = (Data[0] < 101) ? Data[0] * 10 : 70; + g_eeprom.DTMF_code_interval_time = (Data[1] < 101) ? Data[1] * 10 : 70; + g_eeprom.permit_remote_kill = (Data[2] < 2) ? Data[2] : false; // 0EE0..0EE7 EEPROM_ReadBuffer(0x0EE0, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memmove(gEeprom.ANI_DTMF_ID, Data, 8); + memmove(g_eeprom.ani_DTMF_id, Data, 8); else { - memset(gEeprom.ANI_DTMF_ID, 0, sizeof(gEeprom.ANI_DTMF_ID)); - strcpy(gEeprom.ANI_DTMF_ID, "123"); + memset(g_eeprom.ani_DTMF_id, 0, sizeof(g_eeprom.ani_DTMF_id)); + strcpy(g_eeprom.ani_DTMF_id, "123"); } // 0EE8..0EEF EEPROM_ReadBuffer(0x0EE8, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memmove(gEeprom.KILL_CODE, Data, 8); + memmove(g_eeprom.kill_code, Data, 8); else { - memset(gEeprom.KILL_CODE, 0, sizeof(gEeprom.KILL_CODE)); - strcpy(gEeprom.KILL_CODE, "ABCD9"); + memset(g_eeprom.kill_code, 0, sizeof(g_eeprom.kill_code)); + strcpy(g_eeprom.kill_code, "ABCD9"); } // 0EF0..0EF7 EEPROM_ReadBuffer(0x0EF0, Data, 8); if (DTMF_ValidateCodes((char *)Data, 8)) - memmove(gEeprom.REVIVE_CODE, Data, 8); + memmove(g_eeprom.revive_code, Data, 8); else { - memset(gEeprom.REVIVE_CODE, 0, sizeof(gEeprom.REVIVE_CODE)); - strcpy(gEeprom.REVIVE_CODE, "9DCBA"); + memset(g_eeprom.revive_code, 0, sizeof(g_eeprom.revive_code)); + strcpy(g_eeprom.revive_code, "9DCBA"); } // 0EF8..0F07 EEPROM_ReadBuffer(0x0EF8, Data, 16); if (DTMF_ValidateCodes((char *)Data, 16)) - memmove(gEeprom.DTMF_UP_CODE, Data, 16); + memmove(g_eeprom.DTMF_up_code, Data, 16); else { - memset(gEeprom.DTMF_UP_CODE, 0, sizeof(gEeprom.DTMF_UP_CODE)); - strcpy(gEeprom.DTMF_UP_CODE, "12345"); + memset(g_eeprom.DTMF_up_code, 0, sizeof(g_eeprom.DTMF_up_code)); + strcpy(g_eeprom.DTMF_up_code, "12345"); } // 0F08..0F17 EEPROM_ReadBuffer(0x0F08, Data, 16); if (DTMF_ValidateCodes((char *)Data, 16)) - memmove(gEeprom.DTMF_DOWN_CODE, Data, 16); + memmove(g_eeprom.DTMF_down_code, Data, 16); else { - memset(gEeprom.DTMF_DOWN_CODE, 0, sizeof(gEeprom.DTMF_DOWN_CODE)); - strcpy(gEeprom.DTMF_DOWN_CODE, "54321"); + memset(g_eeprom.DTMF_down_code, 0, sizeof(g_eeprom.DTMF_down_code)); + strcpy(g_eeprom.DTMF_down_code, "54321"); } // 0F18..0F1F EEPROM_ReadBuffer(0x0F18, Data, 8); -// gEeprom.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] < 2) ? Data[0] : false; + g_eeprom.scan_list_default = (Data[0] < 3) ? Data[0] : false; // we now have 'all' channel scan option for (i = 0; i < 2; i++) { const unsigned int j = 1 + (i * 3); - gEeprom.SCAN_LIST_ENABLED[i] = (Data[j + 0] < 2) ? Data[j] : false; - gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1]; - gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2]; + g_eeprom.scan_list_enabled[i] = (Data[j + 0] < 2) ? Data[j] : false; + g_eeprom.scan_list_priority_ch1[i] = Data[j + 1]; + g_eeprom.scan_list_priority_ch2[i] = Data[j + 2]; } // 0F40..0F47 @@ -717,14 +717,14 @@ void BOARD_EEPROM_Init(void) #endif gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; - if (!gEeprom.VFO_OPEN) + if (!g_eeprom.vfo_open) { - gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0]; - gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1]; + g_eeprom.screen_channel[0] = g_eeprom.user_channel[0]; + g_eeprom.screen_channel[1] = g_eeprom.user_channel[1]; } // 0D60..0E27 - EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes)); + EEPROM_ReadBuffer(0x0D60, gUSER_ChannelAttributes, sizeof(gUSER_ChannelAttributes)); // 0F30..0F3F EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); @@ -743,14 +743,14 @@ void BOARD_EEPROM_LoadMoreSettings(void) { // uint8_t Mic; - EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8); - memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); - memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); - memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); + EEPROM_ReadBuffer(0x1EC0, g_eeprom_1EC0_0, 8); + memmove(g_eeprom_1EC0_1, g_eeprom_1EC0_0, 8); + memmove(g_eeprom_1EC0_2, g_eeprom_1EC0_0, 8); + memmove(g_eeprom_1EC0_3, g_eeprom_1EC0_0, 8); // 8 * 16-bit values - EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8); - EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[1], 8); + EEPROM_ReadBuffer(0x1EC0, g_eeprom_RSSI_CALIB[0], 8); + EEPROM_ReadBuffer(0x1EC8, g_eeprom_RSSI_CALIB[1], 8); EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12); if (gBatteryCalibration[0] >= 5000) @@ -761,13 +761,13 @@ void BOARD_EEPROM_LoadMoreSettings(void) gBatteryCalibration[5] = 2300; #ifdef ENABLE_VOX - EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2); - EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2); + EEPROM_ReadBuffer(0x1F50 + (g_eeprom.vox_level * 2), &g_eeprom.vox1_threshold, 2); + EEPROM_ReadBuffer(0x1F68 + (g_eeprom.vox_level * 2), &g_eeprom.vox0_threshold, 2); #endif - //EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1); - //gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15; - gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY]; + //EEPROM_ReadBuffer(0x1F80 + g_eeprom.mic_sensitivity, &Mic, 1); + //g_eeprom.mic_sensitivity_tuning = (Mic < 32) ? Mic : 15; + g_eeprom.mic_sensitivity_tuning = gMicGain_dB2[g_eeprom.mic_sensitivity]; { struct @@ -775,22 +775,22 @@ void BOARD_EEPROM_LoadMoreSettings(void) int16_t BK4819_XtalFreqLow; uint16_t EEPROM_1F8A; uint16_t EEPROM_1F8C; - uint8_t VOLUME_GAIN; - uint8_t DAC_GAIN; + uint8_t volume_gain; + uint8_t dac_gain; } __attribute__((packed)) Misc; // radio 1 .. 04 00 46 00 50 00 2C 0E // radio 2 .. 05 00 46 00 50 00 2C 0E EEPROM_ReadBuffer(0x1F88, &Misc, 8); - gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0; - gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF; - gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF; - gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58; - gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8; + g_eeprom.BK4819_xtal_freq_low = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0; + g_eeprom_1F8A = Misc.EEPROM_1F8A & 0x01FF; + g_eeprom_1F8C = Misc.EEPROM_1F8C & 0x01FF; + g_eeprom.volume_gain = (Misc.volume_gain < 64) ? Misc.volume_gain : 58; + 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_3C, gEeprom.BK4819_XTAL_FREQ_HIGH); + BK4819_WriteRegister(BK4819_REG_3B, 22656 + g_eeprom.BK4819_xtal_freq_low); +// 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++) { const uint32_t Frequency = gDefaultFrequencyTable[i]; - gRxVfo->freq_config_RX.Frequency = Frequency; - gRxVfo->freq_config_TX.Frequency = Frequency; - gRxVfo->Band = FREQUENCY_GetBand(Frequency); - SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2); + gRxVfo->freq_config_rx.frequency = Frequency; + gRxVfo->freq_config_tx.frequency = Frequency; + gRxVfo->band = FREQUENCY_GetBand(Frequency); + SETTINGS_SaveChannel(USER_CHANNEL_FIRST + i, 0, gRxVfo, 2); } } } diff --git a/dcs.c b/dcs.c index 4615dc5..2a482ef 100644 --- a/dcs.c +++ b/dcs.c @@ -58,12 +58,12 @@ static uint32_t DCS_CalculateGolay(uint32_t CodeWord) 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); - if (CodeType == CODE_TYPE_REVERSE_DIGITAL) - Code ^= 0x7FFFFF; - return Code; + uint32_t code = DCS_CalculateGolay(DCS_Options[Option] + 0x800U); + if (code_type == CODE_TYPE_REVERSE_DIGITAL) + code ^= 0x7FFFFF; + return code; } uint8_t DCS_GetCdcssCode(uint32_t Code) diff --git a/dcs.h b/dcs.h index 873ddb6..d902f24 100644 --- a/dcs.h +++ b/dcs.h @@ -19,7 +19,7 @@ #include -enum DCS_CodeType_t +enum dcs_code_type_e { CODE_TYPE_OFF = 0, CODE_TYPE_CONTINUOUS_TONE, @@ -27,7 +27,7 @@ enum DCS_CodeType_t CODE_TYPE_REVERSE_DIGITAL }; -typedef enum DCS_CodeType_t DCS_CodeType_t; +typedef enum dcs_code_type_e dcs_code_type_t; enum { CDCSS_POSITIVE_CODE = 1U, @@ -37,7 +37,7 @@ enum { extern const uint16_t CTCSS_Options[50]; 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_GetCtcssCode(int Code); diff --git a/driver/backlight.c b/driver/backlight.c index bfeedfe..66f4f71 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -22,15 +22,15 @@ // this is decremented once every 500ms uint16_t gBacklightCountdown = 0; -void BACKLIGHT_TurnOn(void) +void backlight_turn_on(void) { - if (gEeprom.BACKLIGHT == 0) + if (g_eeprom.backlight == 0) return; // turn the backlight ON GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); - switch (gEeprom.BACKLIGHT) + switch (g_eeprom.backlight) { default: case 1: // 5 sec diff --git a/driver/backlight.h b/driver/backlight.h index 67967bf..ec53119 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -21,7 +21,7 @@ extern uint16_t gBacklightCountdown; -void BACKLIGHT_TurnOn(void); +void backlight_turn_on(void); #endif diff --git a/driver/bk4819.c b/driver/bk4819.c index 4bd0622..d9e24da 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -31,7 +31,7 @@ static const uint16_t FSK_RogerTable[7] = {0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8 static uint16_t gBK4819_GpioOutState; -bool gRxIdleMode; +bool g_rx_idle_mode; __inline uint16_t scale_freq(const uint16_t freq) { @@ -713,12 +713,12 @@ void BK4819_SetFrequency(uint32_t Frequency) } void BK4819_SetupSquelch( - uint8_t SquelchOpenRSSIThresh, - uint8_t SquelchCloseRSSIThresh, - uint8_t SquelchOpenNoiseThresh, - uint8_t SquelchCloseNoiseThresh, - uint8_t SquelchCloseGlitchThresh, - uint8_t SquelchOpenGlitchThresh) + uint8_t squelch_open_RSSI_thresh, + uint8_t squelch_close_RSSI_thresh, + uint8_t squelch_open_noise_thresh, + uint8_t squelch_close_noise_thresh, + uint8_t squelch_close_glitch_thresh, + uint8_t squelch_open_glitch_thresh) { // REG_70 // @@ -742,7 +742,7 @@ void BK4819_SetupSquelch( // // 0 ~ 255 // - BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); + BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | squelch_close_glitch_thresh); // REG_4E // @@ -765,13 +765,13 @@ void BK4819_SetupSquelch( (1u << 14) | // 1 ??? (3u << 11) | // *5 squelch = open delay .. 0 ~ 7 (2u << 9) | // *3 squelch = close delay .. 0 ~ 3 - SquelchOpenGlitchThresh); // 0 ~ 255 + squelch_open_glitch_thresh); // 0 ~ 255 #else // faster (but twitchier) (1u << 14) | // 1 ??? (2u << 11) | // *5 squelch = open delay .. 0 ~ 7 (1u << 9) | // *3 squelch = close delay .. 0 ~ 3 - SquelchOpenGlitchThresh); // 0 ~ 255 + squelch_open_glitch_thresh); // 0 ~ 255 #endif // REG_4F @@ -784,7 +784,7 @@ void BK4819_SetupSquelch( // <6:0> 46 Ex-noise threshold for Squelch = open // 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 // @@ -792,7 +792,7 @@ void BK4819_SetupSquelch( // // <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); @@ -1196,7 +1196,7 @@ void BK4819_ExitSubAu(void) void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void) { - if (gRxIdleMode) + if (g_rx_idle_mode) { BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true); BK4819_RX_TurnOn(); @@ -1670,7 +1670,7 @@ uint8_t BK4819_GetDTMF_5TONE_Code(void) 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; } diff --git a/driver/bk4819.h b/driver/bk4819.h index 736b171..53f02c3 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -62,7 +62,7 @@ enum BK4819_CssScanResult_t typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t; -extern bool gRxIdleMode; +extern bool g_rx_idle_mode; void BK4819_Init(void); 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_GetCDCSSCodeType(void); +uint8_t BK4819_get_CDCSS_code_type(void); uint8_t BK4819_GetCTCShift(void); uint8_t BK4819_GetCTCType(void); diff --git a/driver/keyboard.c b/driver/keyboard.c index 62882df..9b2c1e7 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -22,10 +22,10 @@ #include "driver/i2c.h" #include "misc.h" -KEY_Code_t gKeyReading0 = KEY_INVALID; -KEY_Code_t gKeyReading1 = KEY_INVALID; -uint16_t gDebounceCounter = 0; -bool gWasFKeyPressed = false; +key_code_t g_key_reading_0 = KEY_INVALID; +key_code_t g_key_reading_1 = KEY_INVALID; +uint16_t g_debounce_counter = 0; +bool g_was_f_key_pressed = false; static const struct { @@ -36,7 +36,7 @@ static const struct { // We are very fortunate. // The key and pin defines fit together in a single u8, making this very efficient struct { - KEY_Code_t key : 5; + key_code_t key : 5; uint8_t pin : 3; // Pin 6 is highest } 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)) // return KEY_PTT; diff --git a/driver/keyboard.h b/driver/keyboard.h index 5a7d839..dd9b040 100644 --- a/driver/keyboard.h +++ b/driver/keyboard.h @@ -21,7 +21,7 @@ #include #include -enum KEY_Code_e { +enum key_code_e { KEY_0 = 0, // 0 KEY_1, // 1 KEY_2, // 2 @@ -43,14 +43,14 @@ enum KEY_Code_e { KEY_SIDE1, // 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 gKeyReading1; -extern uint16_t gDebounceCounter; -extern bool gWasFKeyPressed; +extern key_code_t g_key_reading_0; +extern key_code_t g_key_reading_1; +extern uint16_t g_debounce_counter; +extern bool g_was_f_key_pressed; -KEY_Code_t KEYBOARD_Poll(void); +key_code_t KEYBOARD_Poll(void); #endif diff --git a/firmware.bin b/firmware.bin index a4f56aa..f56de8d 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 2e66f57..fbdc7e5 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/frequencies.h b/frequencies.h index f7b07cb..30c4dc7 100644 --- a/frequencies.h +++ b/frequencies.h @@ -43,7 +43,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t; #ifdef ENABLE_1250HZ_STEP // includes 1.25kHz step - enum STEP_Setting_t { + enum step_setting_t { STEP_1_25kHz = 0, STEP_2_5kHz, STEP_6_25kHz, @@ -54,7 +54,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t; }; #else // QS steps - enum STEP_Setting_t { + enum step_setting_t { STEP_2_5kHz = 0, STEP_5_0kHz, STEP_6_25kHz, @@ -64,7 +64,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t; STEP_8_33kHz }; #endif -typedef enum STEP_Setting_t STEP_Setting_t; +typedef enum step_setting_t step_setting_t; extern const uint16_t StepFrequencyTable[7]; diff --git a/functions.c b/functions.c index 49d8cff..765c7db 100644 --- a/functions.c +++ b/functions.c @@ -43,26 +43,26 @@ FUNCTION_Type_t gCurrentFunction; void FUNCTION_Init(void) { #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) #endif { - gCurrentCodeType = gSelectedCodeType; + gCurrentcode_type = gSelectedcode_type; 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 else - gCurrentCodeType = CODE_TYPE_CONTINUOUS_TONE; + gCurrentcode_type = CODE_TYPE_CONTINUOUS_TONE; #endif DTMF_clear_RX(); - g_CxCSS_TAIL_Found = false; - g_CDCSS_Lost = false; - g_CTCSS_Lost = false; + g_CxCSS_tailL_found = false; + g_CDCSS_lost = false; + g_CTCSS_lost = false; #ifdef ENABLE_VOX - g_VOX_Lost = false; + g_vox_lost = false; #endif g_SquelchLost = false; @@ -92,7 +92,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) { BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); - gRxIdleMode = false; + g_rx_idle_mode = 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_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; @@ -135,10 +135,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function) break; case FUNCTION_POWER_SAVE: - gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; + gPowerSave_10ms = g_eeprom.battery_save * 10; gPowerSaveCountdownExpired = false; - gRxIdleMode = true; + g_rx_idle_mode = true; gMonitor = false; @@ -173,7 +173,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) #endif #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; @@ -208,8 +208,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function) DTMF_Reply(); - if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) - BK4819_PlaySingleTone(2525, 250, 0, gEeprom.DTMF_SIDE_TONE); + if (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO) + BK4819_PlaySingleTone(2525, 250, 0, g_eeprom.DTMF_side_tone); #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState != ALARM_STATE_OFF) @@ -232,13 +232,13 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } #endif - if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); + if (gCurrentVfo->scrambling_type > 0 && gSetting_ScrambleEnable) + BK4819_EnableScramble(gCurrentVfo->scrambling_type - 1); else BK4819_DisableScramble(); if (gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3) - BACKLIGHT_TurnOn(); + backlight_turn_on(); break; diff --git a/helper/battery.c b/helper/battery.c index 241090d..cb434fd 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -125,7 +125,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel) { gUpdateStatus = true; gUpdateDisplay = true; - BACKLIGHT_TurnOn(); + backlight_turn_on(); } gChargingWithTypeC = true; diff --git a/helper/boot.c b/helper/boot.c index a0e6d6d..a1df270 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -34,7 +34,7 @@ BOOT_Mode_t BOOT_GetMode(void) { unsigned int i; - KEY_Code_t Keys[2]; + key_code_t Keys[2]; for (i = 0; i < 2; i++) { @@ -46,10 +46,10 @@ BOOT_Mode_t BOOT_GetMode(void) if (Keys[0] == Keys[1]) { - gKeyReading0 = Keys[0]; - gKeyReading1 = Keys[0]; + g_key_reading_0 = Keys[0]; + g_key_reading_1 = Keys[0]; - gDebounceCounter = 2; + g_debounce_counter = 2; if (Keys[0] == KEY_SIDE1) return BOOT_MODE_F_LOCK; @@ -73,22 +73,22 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) else if (Mode == BOOT_MODE_AIRCOPY) { - gEeprom.DUAL_WATCH = DUAL_WATCH_OFF; - gEeprom.BATTERY_SAVE = 0; + g_eeprom.dual_watch = DUAL_WATCH_OFF; + g_eeprom.battery_save = 0; #ifdef ENABLE_VOX - gEeprom.VOX_SWITCH = false; + g_eeprom.vox_switch = false; #endif - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; - gEeprom.AUTO_KEYPAD_LOCK = false; - gEeprom.KEY_1_SHORT_PRESS_ACTION = ACTION_OPT_NONE; - gEeprom.KEY_1_LONG_PRESS_ACTION = ACTION_OPT_NONE; - gEeprom.KEY_2_SHORT_PRESS_ACTION = ACTION_OPT_NONE; - gEeprom.KEY_2_LONG_PRESS_ACTION = ACTION_OPT_NONE; + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; + g_eeprom.auto_keypad_lock = false; + g_eeprom.key1_short_press_action = ACTION_OPT_NONE; + g_eeprom.key1_long_press_action = ACTION_OPT_NONE; + g_eeprom.key2_short_press_action = ACTION_OPT_NONE; + g_eeprom.key2_long_press_action = ACTION_OPT_NONE; RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 41002500); - gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_WIDE; - gRxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW; + gRxVfo->channel_bandwidth = BANDWIDTH_WIDE; + gRxVfo->output_power = OUTPUT_POWER_LOW; RADIO_ConfigureSquelchAndOutputPower(gRxVfo); diff --git a/main.c b/main.c index 6718c24..794138a 100644 --- a/main.c +++ b/main.c @@ -73,7 +73,7 @@ void Main(void) // Not implementing authentic device checks - memset(&gEeprom, 0, sizeof(gEeprom)); + memset(&g_eeprom, 0, sizeof(g_eeprom)); memset(gDTMF_String, '-', sizeof(gDTMF_String)); gDTMF_String[sizeof(gDTMF_String) - 1] = 0; @@ -115,23 +115,23 @@ void Main(void) BootMode != BOOT_MODE_NORMAL) { // keys are pressed UI_DisplayReleaseKeys(); - BACKLIGHT_TurnOn(); + backlight_turn_on(); i = 0; while (i < 50) // 500ms { i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0; SYSTEM_DelayMs(10); } - gKeyReading0 = KEY_INVALID; - gKeyReading1 = KEY_INVALID; - gDebounceCounter = 0; + g_key_reading_0 = KEY_INVALID; + g_key_reading_1 = KEY_INVALID; + g_debounce_counter = 0; } if (!gChargingWithTypeC && gBatteryDisplayLevel == 0) { 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 else GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON @@ -142,9 +142,9 @@ void Main(void) { 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 while (boot_counter_10ms > 0) { @@ -161,7 +161,7 @@ void Main(void) } #ifdef ENABLE_PWRON_PASSWORD - if (gEeprom.POWER_ON_PASSWORD < 1000000) + if (g_eeprom.power_on_password < 1000000) { bIsInLockScreen = true; UI_DisplayLock(); @@ -181,8 +181,8 @@ void Main(void) AUDIO_SetVoiceID(0, VOICE_ID_WELCOME); - Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO]; - if (IS_MR_CHANNEL(Channel)) + Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo]; + if (IS_USER_CHANNEL(Channel)) { AUDIO_SetVoiceID(1, VOICE_ID_CHANNEL_MODE); AUDIO_SetDigitVoice(2, Channel + 1); diff --git a/misc.c b/misc.c index 5e2dbd9..e3666ec 100644 --- a/misc.c +++ b/misc.c @@ -113,17 +113,17 @@ bool bHasCustomAesKey; uint32_t gChallenge[4]; uint8_t gTryCount; -uint8_t gEEPROM_1EC0_0[8]; -uint8_t gEEPROM_1EC0_1[8]; -uint8_t gEEPROM_1EC0_2[8]; -uint8_t gEEPROM_1EC0_3[8]; +uint8_t g_eeprom_1EC0_0[8]; +uint8_t g_eeprom_1EC0_1[8]; +uint8_t g_eeprom_1EC0_2[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 gEEPROM_1F8C; +uint16_t g_eeprom_1F8A; +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; @@ -193,25 +193,25 @@ bool gFlagSaveChannel; #ifdef ENABLE_FMRADIO bool gFlagSaveFM; #endif -bool g_CDCSS_Lost; -uint8_t gCDCSSCodeType; -bool g_CTCSS_Lost; -bool g_CxCSS_TAIL_Found; +bool g_CDCSS_lost; +uint8_t g_CDCSS_code_type; +bool g_CTCSS_lost; +bool g_CxCSS_tailL_found; #ifdef ENABLE_VOX - bool g_VOX_Lost; + bool g_vox_lost; bool gVOX_NoiseDetected; uint16_t gVoxResumeCountdown; - uint16_t gVoxPauseCountdown; + uint16_t g_vox_pause_count_down; #endif bool g_SquelchLost; uint8_t gFlashLightState; volatile uint16_t gFlashLightBlinkCounter; bool gFlagEndTransmission; uint16_t gLowBatteryCountdown; -uint8_t gNextMrChannel; +uint8_t gNextChannel; ReceptionMode_t gRxReceptionMode; -uint8_t gRestoreMrChannel; +uint8_t gRestoreUSER_CHANNEL; enum scan_next_chan_t gCurrentScanList; uint32_t gRestoreFrequency; @@ -224,7 +224,7 @@ bool gKeyBeingHeld; bool gPttIsPressed; uint8_t gPttDebounceCounter; uint8_t gMenuListCount; -uint8_t gBackup_CROSS_BAND_RX_TX; +uint8_t gBackup_cross_vfo_rx_tx; uint8_t gScanDelay_10ms; #ifdef ENABLE_AIRCOPY uint8_t gAircopySendCountdown; @@ -266,34 +266,34 @@ uint8_t gIsLocked = 0xFF; unsigned int get_rx_VFO(void) { - unsigned int rx_vfo = gEeprom.TX_VFO; - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) + unsigned int rx_vfo = g_eeprom.tx_vfo; + if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B) rx_vfo = 0; 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; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B) rx_vfo = 1; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A) rx_vfo = 0; return rx_vfo; } unsigned int get_tx_VFO(void) { - unsigned int tx_vfo = gEeprom.TX_VFO; - if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B) + unsigned int tx_vfo = g_eeprom.tx_vfo; + if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B) tx_vfo = 1; 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; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B) + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_B) tx_vfo = 1; else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A) + if (g_eeprom.dual_watch == DUAL_WATCH_CHAN_A) tx_vfo = 0; return tx_vfo; } diff --git a/misc.h b/misc.h index 4b87ce6..3667ba0 100644 --- a/misc.h +++ b/misc.h @@ -32,16 +32,16 @@ #define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) #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_VALID_CHANNEL(x) ((x) < LAST_CHANNEL) #define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST) -#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) +#define IS_NOT_NOAA_CHANNEL(x) ((x) >= USER_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) enum { - MR_CHANNEL_FIRST = 0, - MR_CHANNEL_LAST = 199u, + USER_CHANNEL_FIRST = 0, + USER_CHANNEL_LAST = 199u, FREQ_CHANNEL_FIRST = 200u, FREQ_CHANNEL_LAST = 206u, NOAA_CHANNEL_FIRST = 207u, @@ -87,8 +87,8 @@ typedef enum CssScanMode_t CssScanMode_t; enum scan_next_chan_t { SCAN_NEXT_CHAN_SCANLIST1 = 0, SCAN_NEXT_CHAN_SCANLIST2, - SCAN_NEXT_CHAN_DUAL_WATCH, - SCAN_NEXT_CHAN_MR, + SCAN_NEXT_CHAN_dual_watch, + SCAN_NEXT_CHAN_USER, SCAN_NEXT_NUM }; typedef enum scan_next_chan_t scan_next_chan_t; @@ -187,17 +187,17 @@ extern bool bHasCustomAesKey; extern uint32_t gChallenge[4]; extern uint8_t gTryCount; -extern uint8_t gEEPROM_1EC0_0[8]; -extern uint8_t gEEPROM_1EC0_1[8]; -extern uint8_t gEEPROM_1EC0_2[8]; -extern uint8_t gEEPROM_1EC0_3[8]; +extern uint8_t g_eeprom_1EC0_0[8]; +extern uint8_t g_eeprom_1EC0_1[8]; +extern uint8_t g_eeprom_1EC0_2[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 gEEPROM_1F8C; +extern uint16_t g_eeprom_1F8A; +extern uint16_t g_eeprom_1F8C; -extern uint8_t gMR_ChannelAttributes[207]; +extern uint8_t gUSER_ChannelAttributes[207]; extern volatile uint16_t gBatterySaveCountdown_10ms; @@ -267,25 +267,25 @@ extern bool gFlagSaveChannel; #ifdef ENABLE_FMRADIO extern bool gFlagSaveFM; #endif -extern bool g_CDCSS_Lost; -extern uint8_t gCDCSSCodeType; -extern bool g_CTCSS_Lost; -extern bool g_CxCSS_TAIL_Found; +extern bool g_CDCSS_lost; +extern uint8_t g_CDCSS_code_type; +extern bool g_CTCSS_lost; +extern bool g_CxCSS_tailL_found; #ifdef ENABLE_VOX - extern bool g_VOX_Lost; + extern bool g_vox_lost; extern bool gVOX_NoiseDetected; extern uint16_t gVoxResumeCountdown; - extern uint16_t gVoxPauseCountdown; + extern uint16_t g_vox_pause_count_down; #endif extern bool g_SquelchLost; extern uint8_t gFlashLightState; extern volatile uint16_t gFlashLightBlinkCounter; extern bool gFlagEndTransmission; extern uint16_t gLowBatteryCountdown; -extern uint8_t gNextMrChannel; +extern uint8_t gNextChannel; extern ReceptionMode_t gRxReceptionMode; -extern uint8_t gRestoreMrChannel; +extern uint8_t gRestoreUSER_CHANNEL; extern scan_next_chan_t gCurrentScanList; extern uint32_t gRestoreFrequency; @@ -296,7 +296,7 @@ extern bool gKeyBeingHeld; extern bool gPttIsPressed; extern uint8_t gPttDebounceCounter; 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; #ifdef ENABLE_AIRCOPY extern uint8_t gAircopySendCountdown; diff --git a/radio.c b/radio.c index 745132d..c2169da 100644 --- a/radio.c +++ b/radio.c @@ -35,14 +35,14 @@ #include "settings.h" #include "ui/menu.h" -VFO_Info_t *gTxVfo; -VFO_Info_t *gRxVfo; -VFO_Info_t *gCurrentVfo; -DCS_CodeType_t gSelectedCodeType; -DCS_CodeType_t gCurrentCodeType; -uint8_t gSelectedCode; -STEP_Setting_t gStepSetting; -VfoState_t VfoState[2]; +VFO_Info_t *gTxVfo; +VFO_Info_t *gRxVfo; +VFO_Info_t *gCurrentVfo; +dcs_code_type_t gSelectedcode_type; +dcs_code_type_t gCurrentcode_type; +uint8_t gSelectedCode; +step_setting_t gStepSetting; +VfoState_t VfoState[2]; bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) { // 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 PriorityCh2; - if (Channel > MR_CHANNEL_LAST) + if (Channel > USER_CHANNEL_LAST) 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; if (bCheckScanList) @@ -64,19 +64,19 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) switch (VFO) { case 0: - if ((Attributes & MR_CH_SCANLIST1) == 0) + if ((Attributes & USER_CH_SCANLIST1) == 0) return false; - PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[0]; - PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[0]; + PriorityCh1 = g_eeprom.scan_list_priority_ch1[0]; + PriorityCh2 = g_eeprom.scan_list_priority_ch2[0]; break; case 1: - if ((Attributes & MR_CH_SCANLIST2) == 0) + if ((Attributes & USER_CH_SCANLIST2) == 0) return false; - PriorityCh1 = gEeprom.SCANLIST_PRIORITY_CH1[1]; - PriorityCh2 = gEeprom.SCANLIST_PRIORITY_CH2[1]; + PriorityCh1 = g_eeprom.scan_list_priority_ch1[1]; + PriorityCh2 = g_eeprom.scan_list_priority_ch2[1]; break; default: @@ -97,13 +97,13 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan { unsigned int i; - for (i = 0; i <= MR_CHANNEL_LAST; i++) + for (i = 0; i <= USER_CHANNEL_LAST; i++) { if (Channel == 0xFF) - Channel = MR_CHANNEL_LAST; + Channel = USER_CHANNEL_LAST; else - if (Channel > MR_CHANNEL_LAST) - Channel = MR_CHANNEL_FIRST; + if (Channel > USER_CHANNEL_LAST) + Channel = USER_CHANNEL_FIRST; if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) 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)); - pInfo->Band = FREQUENCY_GetBand(Frequency); - pInfo->SCANLIST1_PARTICIPATION = true; - pInfo->SCANLIST2_PARTICIPATION = true; - pInfo->STEP_SETTING = STEP_12_5kHz; - pInfo->StepFrequency = StepFrequencyTable[pInfo->STEP_SETTING]; - pInfo->CHANNEL_SAVE = ChannelSave; - pInfo->FrequencyReverse = false; - pInfo->OUTPUT_POWER = OUTPUT_POWER_LOW; - pInfo->freq_config_RX.Frequency = Frequency; - pInfo->freq_config_TX.Frequency = Frequency; - pInfo->pRX = &pInfo->freq_config_RX; - pInfo->pTX = &pInfo->freq_config_TX; - pInfo->Compander = 0; // off + pInfo->band = FREQUENCY_GetBand(Frequency); + pInfo->scanlist_1_participation = true; + pInfo->scanlist_2_participation = true; + pInfo->step_setting = STEP_12_5kHz; + pInfo->step_freq = StepFrequencyTable[pInfo->step_setting]; + pInfo->channel_save = ChannelSave; + pInfo->frequency_reverse = false; + pInfo->output_power = OUTPUT_POWER_LOW; + pInfo->freq_config_rx.frequency = Frequency; + pInfo->freq_config_tx.frequency = Frequency; + pInfo->pRX = &pInfo->freq_config_rx; + pInfo->pTX = &pInfo->freq_config_tx; + pInfo->compander = 0; // off if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) - pInfo->AM_mode = 1; + pInfo->am_mode = 1; RADIO_ConfigureSquelchAndOutputPower(pInfo); } @@ -146,64 +146,64 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure bool bParticipation2; uint16_t Base; uint32_t Frequency; - VFO_Info_t *pRadio = &gEeprom.VfoInfo[VFO]; + VFO_Info_t *pRadio = &g_eeprom.VfoInfo[VFO]; if (!gSetting_350EN) { - if (gEeprom.FreqChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) - gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_LAST - 1; + if (g_eeprom.freq_channel[VFO] == (FREQ_CHANNEL_LAST - 2)) + g_eeprom.freq_channel[VFO] = FREQ_CHANNEL_LAST - 1; - if (gEeprom.ScreenChannel[VFO] == (FREQ_CHANNEL_LAST - 2)) - gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_LAST - 1; + if (g_eeprom.screen_channel[VFO] == (FREQ_CHANNEL_LAST - 2)) + g_eeprom.screen_channel[VFO] = FREQ_CHANNEL_LAST - 1; } - Channel = gEeprom.ScreenChannel[VFO]; + Channel = g_eeprom.screen_channel[VFO]; if (IS_VALID_CHANNEL(Channel)) { #ifdef ENABLE_NOAA 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; - gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; + g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; gUpdateStatus = true; return; } #endif - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO); if (Channel == 0xFF) { - Channel = gEeprom.FreqChannel[VFO]; - gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO]; + Channel = g_eeprom.freq_channel[VFO]; + g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO]; } else { - gEeprom.ScreenChannel[VFO] = Channel; - gEeprom.MrChannel[VFO] = Channel; + g_eeprom.screen_channel[VFO] = Channel; + g_eeprom.user_channel[VFO] = Channel; } } } else Channel = FREQ_CHANNEL_LAST - 1; - Attributes = gMR_ChannelAttributes[Channel]; + Attributes = gUSER_ChannelAttributes[Channel]; if (Attributes == 0xFF) { // invalid/unused channel uint8_t Index; - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { - Channel = gEeprom.FreqChannel[VFO]; - gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO]; + Channel = g_eeprom.freq_channel[VFO]; + g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO]; } Index = Channel - FREQ_CHANNEL_FIRST; @@ -212,30 +212,30 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure return; } - Band = Attributes & MR_CH_BAND_MASK; + Band = Attributes & USER_CH_BAND_MASK; if (Band > BAND7_470MHz) { Band = BAND6_400MHz; } - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { - gEeprom.VfoInfo[VFO].Band = Band; - gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = !!(Attributes & MR_CH_SCANLIST1); - bParticipation2 = !!(Attributes & MR_CH_SCANLIST2); + g_eeprom.VfoInfo[VFO].band = Band; + g_eeprom.VfoInfo[VFO].scanlist_1_participation = !!(Attributes & USER_CH_SCANLIST1); + bParticipation2 = !!(Attributes & USER_CH_SCANLIST2); } else { Band = Channel - FREQ_CHANNEL_FIRST; - gEeprom.VfoInfo[VFO].Band = Band; + g_eeprom.VfoInfo[VFO].band = Band; bParticipation2 = true; - gEeprom.VfoInfo[VFO].SCANLIST1_PARTICIPATION = true; + g_eeprom.VfoInfo[VFO].scanlist_1_participation = true; } - gEeprom.VfoInfo[VFO].SCANLIST2_PARTICIPATION = bParticipation2; - gEeprom.VfoInfo[VFO].CHANNEL_SAVE = Channel; + g_eeprom.VfoInfo[VFO].scanlist_2_participation = bParticipation2; + g_eeprom.VfoInfo[VFO].channel_save = Channel; - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) Base = Channel * 16; else 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)); Tmp = Data[3] & 0x0F; - if (Tmp > TX_OFFSET_FREQUENCY_DIRECTION_SUB) + if (Tmp > TX_OFFSET_FREQ_DIR_SUB) Tmp = 0; - gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY_DIRECTION = Tmp; - gEeprom.VfoInfo[VFO].AM_mode = (Data[3] >> 4) & 1u; + g_eeprom.VfoInfo[VFO].tx_offset_freq_dir = Tmp; + g_eeprom.VfoInfo[VFO].am_mode = (Data[3] >> 4) & 1u; Tmp = Data[6]; if (Tmp >= ARRAY_SIZE(StepFrequencyTable)) Tmp = STEP_12_5kHz; - gEeprom.VfoInfo[VFO].STEP_SETTING = Tmp; - gEeprom.VfoInfo[VFO].StepFrequency = StepFrequencyTable[Tmp]; + g_eeprom.VfoInfo[VFO].step_setting = Tmp; + g_eeprom.VfoInfo[VFO].step_freq = StepFrequencyTable[Tmp]; Tmp = Data[7]; if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1)) 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; - gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = (Data[2] >> 4) & 0x0F; + g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = (Data[2] >> 0) & 0x0F; + g_eeprom.VfoInfo[VFO].freq_config_tx.code_type = (Data[2] >> 4) & 0x0F; Tmp = Data[0]; - switch (gEeprom.VfoInfo[VFO].freq_config_RX.CodeType) + switch (g_eeprom.VfoInfo[VFO].freq_config_rx.code_type) { default: 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; break; @@ -289,14 +289,14 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Tmp = 0; break; } - gEeprom.VfoInfo[VFO].freq_config_RX.Code = Tmp; + g_eeprom.VfoInfo[VFO].freq_config_rx.code = Tmp; Tmp = Data[1]; - switch (gEeprom.VfoInfo[VFO].freq_config_TX.CodeType) + switch (g_eeprom.VfoInfo[VFO].freq_config_tx.code_type) { default: 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; break; @@ -311,55 +311,55 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Tmp = 0; break; } - gEeprom.VfoInfo[VFO].freq_config_TX.Code = Tmp; + g_eeprom.VfoInfo[VFO].freq_config_tx.code = Tmp; if (Data[4] == 0xFF) { - gEeprom.VfoInfo[VFO].FrequencyReverse = false; - gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE; - gEeprom.VfoInfo[VFO].OUTPUT_POWER = OUTPUT_POWER_LOW; - gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = false; + g_eeprom.VfoInfo[VFO].frequency_reverse = false; + g_eeprom.VfoInfo[VFO].channel_bandwidth = BK4819_FILTER_BW_WIDE; + g_eeprom.VfoInfo[VFO].output_power = OUTPUT_POWER_LOW; + g_eeprom.VfoInfo[VFO].busy_channel_lock = false; } else { const uint8_t d4 = Data[4]; - gEeprom.VfoInfo[VFO].FrequencyReverse = !!((d4 >> 0) & 1u); - gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u); - gEeprom.VfoInfo[VFO].OUTPUT_POWER = ((d4 >> 2) & 3u); - gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = !!((d4 >> 4) & 1u); + g_eeprom.VfoInfo[VFO].frequency_reverse = !!((d4 >> 0) & 1u); + g_eeprom.VfoInfo[VFO].channel_bandwidth = !!((d4 >> 1) & 1u); + g_eeprom.VfoInfo[VFO].output_power = ((d4 >> 2) & 3u); + g_eeprom.VfoInfo[VFO].busy_channel_lock = !!((d4 >> 4) & 1u); } if (Data[5] == 0xFF) { - gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; - gEeprom.VfoInfo[VFO].DTMF_PTT_ID_TX_MODE = PTT_ID_OFF; + g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = false; + g_eeprom.VfoInfo[VFO].DTMF_ptt_id_tx_mode = PTT_ID_OFF; } else { - gEeprom.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_decoding_enable = ((Data[5] >> 0) & 1u) ? true : false; + g_eeprom.VfoInfo[VFO].DTMF_ptt_id_tx_mode = ((Data[5] >> 1) & 7u); } // *************** struct { - uint32_t Frequency; - uint32_t Offset; - } __attribute__((packed)) Info; + uint32_t frequency; + uint32_t offset; + } __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) - Info.Offset = 1000000; - gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset; + if (info.offset >= 100000000) + info.offset = 1000000; + g_eeprom.VfoInfo[VFO].tx_offset_freq = info.offset; // *************** } - Frequency = pRadio->freq_config_RX.Frequency; + Frequency = pRadio->freq_config_rx.frequency; #if 1 // fix previously set incorrect band @@ -373,52 +373,52 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Frequency = frequencyBandTable[Band].upper; else 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) - 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 - if (Channel > MR_CHANNEL_LAST) - gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = FREQUENCY_FloorToStep(gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY, gEeprom.VfoInfo[VFO].StepFrequency, 0); + if (Channel > USER_CHANNEL_LAST) + 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); - memset(gEeprom.VfoInfo[VFO].Name, 0, sizeof(gEeprom.VfoInfo[VFO].Name)); - if (Channel < MR_CHANNEL_LAST) + memset(g_eeprom.VfoInfo[VFO].name, 0, sizeof(g_eeprom.VfoInfo[VFO].name)); + if (Channel < USER_CHANNEL_LAST) { // 16 bytes allocated to the channel name but only 10 used, the rest are 0's - EEPROM_ReadBuffer(0x0F50 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 0, 8); - EEPROM_ReadBuffer(0x0F58 + (Channel * 16), gEeprom.VfoInfo[VFO].Name + 8, 2); + EEPROM_ReadBuffer(0x0F50 + (Channel * 16), g_eeprom.VfoInfo[VFO].name + 0, 8); + 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; - gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_TX; + g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_rx; + g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_tx; } else { - gEeprom.VfoInfo[VFO].pRX = &gEeprom.VfoInfo[VFO].freq_config_TX; - gEeprom.VfoInfo[VFO].pTX = &gEeprom.VfoInfo[VFO].freq_config_RX; + g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_tx; + g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_rx; } if (!gSetting_350EN) { - FREQ_Config_t *pConfig = gEeprom.VfoInfo[VFO].pRX; - if (pConfig->Frequency >= 35000000 && pConfig->Frequency < 40000000) - pConfig->Frequency = 43300000; + FREQ_Config_t *pConfig = g_eeprom.VfoInfo[VFO].pRX; + if (pConfig->frequency >= 35000000 && pConfig->frequency < 40000000) + pConfig->frequency = 43300000; } - if (gEeprom.VfoInfo[VFO].AM_mode) + if (g_eeprom.VfoInfo[VFO].am_mode) { // freq/chan is in AM mode - gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0; -// gEeprom.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; - gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; + g_eeprom.VfoInfo[VFO].scrambling_type = 0; +// g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = false; // no reason to disable DTMF decoding, aircraft use it on SSB + g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = 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); } @@ -431,38 +431,38 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) // ******************************* // squelch - Band = FREQUENCY_GetBand(pInfo->pRX->Frequency); + Band = FREQUENCY_GetBand(pInfo->pRX->frequency); uint16_t Base = (Band < BAND4_174MHz) ? 0x1E60 : 0x1E00; - if (gEeprom.SQUELCH_LEVEL == 0) + if (g_eeprom.squelch_level == 0) { // squelch == 0 (off) - pInfo->SquelchOpenRSSIThresh = 0; // 0 ~ 255 - pInfo->SquelchOpenNoiseThresh = 127; // 127 ~ 0 - pInfo->SquelchCloseGlitchThresh = 255; // 255 ~ 0 + pInfo->squelch_open_RSSI_thresh = 0; // 0 ~ 255 + pInfo->squelch_open_noise_thresh = 127; // 127 ~ 0 + pInfo->squelch_close_glitch_thresh = 255; // 255 ~ 0 - pInfo->SquelchCloseRSSIThresh = 0; // 0 ~ 255 - pInfo->SquelchCloseNoiseThresh = 127; // 127 ~ 0 - pInfo->SquelchOpenGlitchThresh = 255; // 255 ~ 0 + pInfo->squelch_close_RSSI_thresh = 0; // 0 ~ 255 + pInfo->squelch_close_noise_thresh = 127; // 127 ~ 0 + pInfo->squelch_open_glitch_thresh = 255; // 255 ~ 0 } else { // squelch >= 1 - Base += gEeprom.SQUELCH_LEVEL; // my eeprom squelch-1 + Base += g_eeprom.squelch_level; // my eeprom squelch-1 // VHF UHF - EEPROM_ReadBuffer(Base + 0x00, &pInfo->SquelchOpenRSSIThresh, 1); // 50 10 - EEPROM_ReadBuffer(Base + 0x10, &pInfo->SquelchCloseRSSIThresh, 1); // 40 5 + EEPROM_ReadBuffer(Base + 0x00, &pInfo->squelch_open_RSSI_thresh, 1); // 50 10 + EEPROM_ReadBuffer(Base + 0x10, &pInfo->squelch_close_RSSI_thresh, 1); // 40 5 - EEPROM_ReadBuffer(Base + 0x20, &pInfo->SquelchOpenNoiseThresh, 1); // 65 90 - EEPROM_ReadBuffer(Base + 0x30, &pInfo->SquelchCloseNoiseThresh, 1); // 70 100 + EEPROM_ReadBuffer(Base + 0x20, &pInfo->squelch_open_noise_thresh, 1); // 65 90 + EEPROM_ReadBuffer(Base + 0x30, &pInfo->squelch_close_noise_thresh, 1); // 70 100 - EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90 - EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100 + EEPROM_ReadBuffer(Base + 0x40, &pInfo->squelch_close_glitch_thresh, 1); // 90 90 + EEPROM_ReadBuffer(Base + 0x50, &pInfo->squelch_open_glitch_thresh, 1); // 100 100 - uint16_t rssi_open = pInfo->SquelchOpenRSSIThresh; - uint16_t rssi_close = pInfo->SquelchCloseRSSIThresh; - uint16_t noise_open = pInfo->SquelchOpenNoiseThresh; - uint16_t noise_close = pInfo->SquelchCloseNoiseThresh; - uint16_t glitch_open = pInfo->SquelchOpenGlitchThresh; - uint16_t glitch_close = pInfo->SquelchCloseGlitchThresh; + uint16_t rssi_open = pInfo->squelch_open_RSSI_thresh; + uint16_t rssi_close = pInfo->squelch_close_RSSI_thresh; + uint16_t noise_open = pInfo->squelch_open_noise_thresh; + uint16_t noise_close = pInfo->squelch_close_noise_thresh; + uint16_t glitch_open = pInfo->squelch_open_glitch_thresh; + uint16_t glitch_close = pInfo->squelch_close_glitch_thresh; #if ENABLE_SQUELCH_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) glitch_close += 2; - pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open; - pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close; - pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open; - pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close; - pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open; - pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close; + pInfo->squelch_open_RSSI_thresh = (rssi_open > 255) ? 255 : rssi_open; + pInfo->squelch_close_RSSI_thresh = (rssi_close > 255) ? 255 : rssi_close; + pInfo->squelch_open_noise_thresh = (noise_open > 127) ? 127 : noise_open; + pInfo->squelch_close_noise_thresh = (noise_close > 127) ? 127 : noise_close; + pInfo->squelch_open_glitch_thresh = (glitch_open > 255) ? 255 : glitch_open; + 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 // 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[1], TX_power[2], frequencyBandTable[Band].lower, (frequencyBandTable[Band].lower + frequencyBandTable[Band].upper) / 2, frequencyBandTable[Band].upper, - pInfo->pTX->Frequency); + pInfo->pTX->frequency); // ******************************* } 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; - case TX_OFFSET_FREQUENCY_DIRECTION_ADD: - Frequency += pInfo->TX_OFFSET_FREQUENCY; + case TX_OFFSET_FREQ_DIR_ADD: + Frequency += pInfo->tx_offset_freq; break; - case TX_OFFSET_FREQUENCY_DIRECTION_SUB: - Frequency -= pInfo->TX_OFFSET_FREQUENCY; + case TX_OFFSET_FREQ_DIR_SUB: + Frequency -= pInfo->tx_offset_freq; break; } @@ -560,28 +560,28 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo) if (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) { - 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) { - gEeprom.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.tx_vfo = get_tx_VFO(); + 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]; - gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; + gTxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; + gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; RADIO_SelectCurrentVfo(); } void RADIO_SetupRegisters(bool bSwitchToFunction0) { - BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH; + BK4819_FilterBandwidth_t Bandwidth = gRxVfo->channel_bandwidth; uint16_t InterruptMask; uint32_t Frequency; @@ -601,7 +601,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #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); #else BK4819_SetFilterBandwidth(Bandwidth, false); @@ -629,22 +629,22 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_WriteRegister(BK4819_REG_3F, 0); // 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 - if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) || !gIsNoaaMode) - Frequency = gRxVfo->pRX->Frequency; + if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save) || !gIsNoaaMode) + Frequency = gRxVfo->pRX->frequency; else Frequency = NoaaFrequencyTable[gNoaaChannel]; #else - Frequency = gRxVfo->pRX->Frequency; + Frequency = gRxVfo->pRX->frequency; #endif BK4819_SetFrequency(Frequency); BK4819_SetupSquelch( - gRxVfo->SquelchOpenRSSIThresh, gRxVfo->SquelchCloseRSSIThresh, - gRxVfo->SquelchOpenNoiseThresh, gRxVfo->SquelchCloseNoiseThresh, - gRxVfo->SquelchCloseGlitchThresh, gRxVfo->SquelchOpenGlitchThresh); + gRxVfo->squelch_open_RSSI_thresh, gRxVfo->squelch_close_RSSI_thresh, + gRxVfo->squelch_open_noise_thresh, gRxVfo->squelch_close_noise_thresh, + gRxVfo->squelch_close_glitch_thresh, gRxVfo->squelch_open_glitch_thresh); BK4819_PickRXFilterPathBasedOnFrequency(Frequency); @@ -657,20 +657,20 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST; #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) #endif { - if (gRxVfo->AM_mode == 0) + if (gRxVfo->am_mode == 0) { // FM - uint8_t CodeType = gSelectedCodeType; + uint8_t code_type = gSelectedcode_type; uint8_t Code = gSelectedCode; if (gCssScanMode == CSS_SCAN_MODE_OFF) { - CodeType = gRxVfo->pRX->CodeType; - Code = gRxVfo->pRX->Code; + code_type = gRxVfo->pRX->code_type; + Code = gRxVfo->pRX->code; } - switch (CodeType) + switch (code_type) { default: case CODE_TYPE_OFF: @@ -705,7 +705,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(CodeType, Code)); + BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code)); InterruptMask = 0 | BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CDCSS_FOUND @@ -715,8 +715,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) break; } - if (gRxVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gRxVfo->SCRAMBLING_TYPE - 1); + if (gRxVfo->scrambling_type > 0 && gSetting_ScrambleEnable) + BK4819_EnableScramble(gRxVfo->scrambling_type - 1); else BK4819_DisableScramble(); } @@ -736,19 +736,19 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #ifdef ENABLE_VOX #ifdef ENABLE_NOAA #ifdef ENABLE_FMRADIO - if (gEeprom.VOX_SWITCH && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0) + if (g_eeprom.vox_switch && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0) #else - if (gEeprom.VOX_SWITCH && IS_NOT_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->AM_mode == 0) + if (g_eeprom.vox_switch && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0) #endif #else #ifdef ENABLE_FMRADIO - if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->AM_mode == 0) + if (g_eeprom.vox_switch && !gFmRadioMode && gCurrentVfo->am_mode == 0) #else - if (gEeprom.VOX_SWITCH && gCurrentVfo->AM_mode == 0) + if (g_eeprom.vox_switch && gCurrentVfo->am_mode == 0) #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; } else @@ -756,10 +756,10 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_DisableVox(); // 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 (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) + if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED) { BK4819_DisableDTMF(); } @@ -797,13 +797,13 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) 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; return; @@ -814,16 +814,16 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) ChanAB = 0; if (!gIsNoaaMode) - gNoaaChannel = gEeprom.VfoInfo[ChanAB].CHANNEL_SAVE - NOAA_CHANNEL_FIRST; + gNoaaChannel = g_eeprom.VfoInfo[ChanAB].channel_save - NOAA_CHANNEL_FIRST; gIsNoaaMode = true; return; } - if (gRxVfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST) + if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST) { gIsNoaaMode = true; - gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; + gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST; gNOAA_Countdown_10ms = NOAA_countdown_2_10ms; gScheduleNOAA = false; } @@ -837,7 +837,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) 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); @@ -855,7 +855,7 @@ void RADIO_SetTxParameters(void) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #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); #else BK4819_SetFilterBandwidth(Bandwidth, false); @@ -865,26 +865,26 @@ void RADIO_SetTxParameters(void) #pragma GCC diagnostic pop - BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); + BK4819_SetFrequency(gCurrentVfo->pTX->frequency); // 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(); SYSTEM_DelayMs(10); - BK4819_PickRXFilterPathBasedOnFrequency(gCurrentVfo->pTX->Frequency); + BK4819_PickRXFilterPathBasedOnFrequency(gCurrentVfo->pTX->frequency); BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, true); SYSTEM_DelayMs(5); - BK4819_SetupPowerAmplifier(gCurrentVfo->TXP_CalculatedSetting, gCurrentVfo->pTX->Frequency); + BK4819_SetupPowerAmplifier(gCurrentVfo->txp_calculated_setting, gCurrentVfo->pTX->frequency); SYSTEM_DelayMs(10); - switch (gCurrentVfo->pTX->CodeType) + switch (gCurrentVfo->pTX->code_type) { default: case CODE_TYPE_OFF: @@ -892,12 +892,12 @@ void RADIO_SetTxParameters(void) break; case CODE_TYPE_CONTINUOUS_TONE: - BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->Code]); + BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->code]); break; case CODE_TYPE_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; } } @@ -922,7 +922,7 @@ void RADIO_SetVfoState(VfoState_t State) } else { // 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; } @@ -938,7 +938,7 @@ void RADIO_PrepareTX(void) { 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 gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms; @@ -947,16 +947,16 @@ void RADIO_PrepareTX(void) #if 0 if (gRxVfoIsActive) { // use the TX vfo - gEeprom.RX_VFO = gEeprom.TX_VFO; - gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; + g_eeprom.rx_vfo = g_eeprom.tx_vfo; + gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; gRxVfoIsActive = false; } gCurrentVfo = gRxVfo; #else if (!gRxVfoIsActive) { // use the current RX vfo - gEeprom.RX_VFO = gEeprom.TX_VFO; - gRxVfo = &gEeprom.VfoInfo[gEeprom.TX_VFO]; + g_eeprom.rx_vfo = g_eeprom.tx_vfo; + gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; gRxVfoIsActive = true; } gCurrentVfo = gRxVfo; @@ -970,7 +970,7 @@ void RADIO_PrepareTX(void) RADIO_SelectCurrentVfo(); #ifndef ENABLE_TX_WHEN_AM - if (gCurrentVfo->AM_mode) + if (gCurrentVfo->am_mode) { // not allowed to TX if in AM mode State = VFO_STATE_TX_DISABLE; } @@ -981,9 +981,9 @@ void RADIO_PrepareTX(void) State = VFO_STATE_TX_DISABLE; } else - if (TX_freq_check(gCurrentVfo->pTX->Frequency) == 0) + if (TX_freq_check(gCurrentVfo->pTX->frequency) == 0) { // 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 else if (gBatteryDisplayLevel == 0) @@ -1035,11 +1035,11 @@ void RADIO_PrepareTX(void) if (gAlarmState == ALARM_STATE_OFF) #endif { - if (gEeprom.TX_TIMEOUT_TIMER == 0) + if (g_eeprom.tx_timeout_timer == 0) gTxTimerCountdown_500ms = 60; // 30 sec else - if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) - gTxTimerCountdown_500ms = 120 * gEeprom.TX_TIMEOUT_TIMER; // minutes + if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1)) + gTxTimerCountdown_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes else gTxTimerCountdown_500ms = 120 * 15; // 15 minutes } @@ -1052,7 +1052,7 @@ void RADIO_PrepareTX(void) void RADIO_EnableCxCSS(void) { - switch (gCurrentVfo->pTX->CodeType) + switch (gCurrentVfo->pTX->code_type) { default: case CODE_TYPE_OFF: @@ -1083,34 +1083,34 @@ void RADIO_PrepareCssTX(void) void RADIO_SendEndOfTransmission(void) { - if (gEeprom.ROGER == ROGER_MODE_ROGER) + if (g_eeprom.roger_mode == ROGER_MODE_ROGER) BK4819_PlayRoger(); else - if (gEeprom.ROGER == ROGER_MODE_MDC) + if (g_eeprom.roger_mode == ROGER_MODE_MDC) BK4819_PlayRogerMDC(); - if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) - BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE); + if (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO) + BK4819_PlaySingleTone(2475, 250, 28, g_eeprom.DTMF_side_tone); 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 - if (gEeprom.DTMF_SIDE_TONE) + if (g_eeprom.DTMF_side_tone) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; SYSTEM_DelayMs(60); } - BK4819_EnterDTMF_TX(gEeprom.DTMF_SIDE_TONE); + BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone); BK4819_PlayDTMFString( - gEeprom.DTMF_DOWN_CODE, + g_eeprom.DTMF_down_code, 0, - gEeprom.DTMF_FIRST_CODE_PERSIST_TIME, - gEeprom.DTMF_HASH_CODE_PERSIST_TIME, - gEeprom.DTMF_CODE_PERSIST_TIME, - gEeprom.DTMF_CODE_INTERVAL_TIME); + g_eeprom.DTMF_first_code_persist_time, + g_eeprom.DTMF_hash_code_persist_time, + g_eeprom.DTMF_code_persist_time, + g_eeprom.DTMF_code_interval_time); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = false; diff --git a/radio.h b/radio.h index e1d03da..91c4b0a 100644 --- a/radio.h +++ b/radio.h @@ -24,10 +24,10 @@ #include "frequencies.h" enum { - MR_CH_BAND_MASK = 0x0F << 0, - MR_CH_COMPAND = 3u << 4, // new - MR_CH_SCANLIST2 = 1u << 6, - MR_CH_SCANLIST1 = 1u << 7 + USER_CH_BAND_MASK = 0x0F << 0, + USER_CH_COMPAND = 3u << 4, // new + USER_CH_SCANLIST2 = 1u << 6, + USER_CH_SCANLIST1 = 1u << 7 }; enum { @@ -63,67 +63,67 @@ typedef enum VfoState_t VfoState_t; typedef struct { - uint32_t Frequency; - DCS_CodeType_t CodeType; - uint8_t Code; - uint8_t Padding[2]; + uint32_t frequency; + dcs_code_type_t code_type; + uint8_t code; + uint8_t padding[2]; } FREQ_Config_t; typedef struct VFO_Info_t { - FREQ_Config_t freq_config_RX; - FREQ_Config_t freq_config_TX; + FREQ_Config_t freq_config_rx; + FREQ_Config_t freq_config_tx; FREQ_Config_t *pRX; FREQ_Config_t *pTX; - uint32_t TX_OFFSET_FREQUENCY; - uint16_t StepFrequency; + uint32_t tx_offset_freq; + 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 SquelchOpenNoiseThresh; - uint8_t SquelchCloseGlitchThresh; - uint8_t SquelchCloseRSSIThresh; - uint8_t SquelchCloseNoiseThresh; - uint8_t SquelchOpenGlitchThresh; + uint8_t squelch_open_RSSI_thresh; + uint8_t squelch_open_noise_thresh; + uint8_t squelch_close_glitch_thresh; + uint8_t squelch_close_RSSI_thresh; + uint8_t squelch_close_noise_thresh; + uint8_t squelch_open_glitch_thresh; - STEP_Setting_t STEP_SETTING; - uint8_t OUTPUT_POWER; - uint8_t TXP_CalculatedSetting; - bool FrequencyReverse; + step_setting_t step_setting; + uint8_t output_power; + uint8_t txp_calculated_setting; + bool frequency_reverse; - uint8_t SCRAMBLING_TYPE; - uint8_t CHANNEL_BANDWIDTH; + uint8_t scrambling_type; + uint8_t channel_bandwidth; - uint8_t SCANLIST1_PARTICIPATION; - uint8_t SCANLIST2_PARTICIPATION; + uint8_t scanlist_1_participation; + uint8_t scanlist_2_participation; - uint8_t Band; + uint8_t band; - uint8_t DTMF_DECODING_ENABLE; - PTT_ID_t DTMF_PTT_ID_TX_MODE; + uint8_t DTMF_decoding_enable; + 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; extern VFO_Info_t *gTxVfo; extern VFO_Info_t *gRxVfo; extern VFO_Info_t *gCurrentVfo; -extern DCS_CodeType_t gSelectedCodeType; -extern DCS_CodeType_t gCurrentCodeType; +extern dcs_code_type_t gSelectedcode_type; +extern dcs_code_type_t gCurrentcode_type; extern uint8_t gSelectedCode; -extern STEP_Setting_t gStepSetting; +extern step_setting_t gStepSetting; extern VfoState_t VfoState[2]; diff --git a/scheduler.c b/scheduler.c index 56e5a57..1a6f3cc 100644 --- a/scheduler.c +++ b/scheduler.c @@ -78,12 +78,12 @@ void SystickHandler(void) if (gCurrentFunction == FUNCTION_POWER_SAVE) 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) DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch); #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 (gCurrentFunction != FUNCTION_RECEIVE) DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA); @@ -96,7 +96,7 @@ void SystickHandler(void) DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete); #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 #ifdef ENABLE_FMRADIO diff --git a/settings.c b/settings.c index bb7f970..5bb200a 100644 --- a/settings.c +++ b/settings.c @@ -24,7 +24,7 @@ #include "misc.h" #include "settings.h" -EEPROM_Config_t gEeprom; +EEPROM_Config_t g_eeprom; #ifdef ENABLE_FMRADIO void SETTINGS_SaveFM(void) @@ -33,18 +33,19 @@ EEPROM_Config_t gEeprom; struct { - uint16_t Frequency; - uint8_t Channel; - bool IsChannelSelected; - uint8_t Padding[4]; - } State; + uint16_t frequency; + uint8_t channel; + bool is_channel_selected; + uint8_t padding[4]; + } state; - memset(&State, 0xFF, sizeof(State)); - State.Channel = gEeprom.FM_SelectedChannel; - State.Frequency = gEeprom.FM_SelectedFrequency; - State.IsChannelSelected = gEeprom.FM_IsMrMode; + memset(&state, 0xFF, sizeof(state)); + state.channel = g_eeprom.fm_selected_channel; + state.frequency = g_eeprom.fm_selected_frequency; + state.is_channel_selected = g_eeprom.fm_is_channel_mode; + + EEPROM_WriteBuffer(0x0E88, &state); - EEPROM_WriteBuffer(0x0E88, &State); for (i = 0; i < 5; i++) EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]); } @@ -58,15 +59,15 @@ void SETTINGS_SaveVfoIndices(void) EEPROM_ReadBuffer(0x0E80, State, sizeof(State)); #endif - State[0] = gEeprom.ScreenChannel[0]; - State[1] = gEeprom.MrChannel[0]; - State[2] = gEeprom.FreqChannel[0]; - State[3] = gEeprom.ScreenChannel[1]; - State[4] = gEeprom.MrChannel[1]; - State[5] = gEeprom.FreqChannel[1]; + State[0] = g_eeprom.screen_channel[0]; + State[1] = g_eeprom.user_channel[0]; + State[2] = g_eeprom.freq_channel[0]; + State[3] = g_eeprom.screen_channel[1]; + State[4] = g_eeprom.user_channel[1]; + State[5] = g_eeprom.freq_channel[1]; #ifdef ENABLE_NOAA - State[6] = gEeprom.NoaaChannel[0]; - State[7] = gEeprom.NoaaChannel[1]; + State[6] = g_eeprom.noaa_channel[0]; + State[7] = g_eeprom.noaa_channel[1]; #endif EEPROM_WriteBuffer(0x0E80, State); @@ -76,43 +77,43 @@ void SETTINGS_SaveSettings(void) { uint8_t State[8]; - State[0] = gEeprom.CHAN_1_CALL; - State[1] = gEeprom.SQUELCH_LEVEL; - State[2] = gEeprom.TX_TIMEOUT_TIMER; + State[0] = g_eeprom.chan_1_call; + State[1] = g_eeprom.squelch_level; + State[2] = g_eeprom.tx_timeout_timer; #ifdef ENABLE_NOAA - State[3] = gEeprom.NOAA_AUTO_SCAN; + State[3] = g_eeprom.NOAA_auto_scan; #else State[3] = false; #endif - State[4] = gEeprom.KEY_LOCK; + State[4] = g_eeprom.key_lock; #ifdef ENABLE_VOX - State[5] = gEeprom.VOX_SWITCH; - State[6] = gEeprom.VOX_LEVEL; + State[5] = g_eeprom.vox_switch; + State[6] = g_eeprom.vox_level; #else State[5] = false; State[6] = 0; #endif - State[7] = gEeprom.MIC_SENSITIVITY; + State[7] = g_eeprom.mic_sensitivity; EEPROM_WriteBuffer(0x0E70, State); State[0] = 0xFF; - State[1] = gEeprom.CHANNEL_DISPLAY_MODE; - State[2] = gEeprom.CROSS_BAND_RX_TX; - State[3] = gEeprom.BATTERY_SAVE; - State[4] = gEeprom.DUAL_WATCH; - State[5] = gEeprom.BACKLIGHT; - State[6] = gEeprom.TAIL_NOTE_ELIMINATION; - State[7] = gEeprom.VFO_OPEN; + State[1] = g_eeprom.channel_display_mode; + State[2] = g_eeprom.cross_vfo_rx_tx; + State[3] = g_eeprom.battery_save; + State[4] = g_eeprom.dual_watch; + State[5] = g_eeprom.backlight; + State[6] = g_eeprom.tail_note_elimination; + State[7] = g_eeprom.vfo_open; EEPROM_WriteBuffer(0x0E78, State); - State[0] = gEeprom.BEEP_CONTROL; - State[1] = gEeprom.KEY_1_SHORT_PRESS_ACTION; - State[2] = gEeprom.KEY_1_LONG_PRESS_ACTION; - State[3] = gEeprom.KEY_2_SHORT_PRESS_ACTION; - State[4] = gEeprom.KEY_2_LONG_PRESS_ACTION; - State[5] = gEeprom.SCAN_RESUME_MODE; - State[6] = gEeprom.AUTO_KEYPAD_LOCK; - State[7] = gEeprom.POWER_ON_DISPLAY_MODE; + State[0] = g_eeprom.beep_control; + State[1] = g_eeprom.key1_short_press_action; + State[2] = g_eeprom.key1_long_press_action; + State[3] = g_eeprom.key2_short_press_action; + State[4] = g_eeprom.key2_long_press_action; + State[5] = g_eeprom.scan_resume_mode; + State[6] = g_eeprom.auto_keypad_lock; + State[7] = g_eeprom.pwr_on_display_mode; EEPROM_WriteBuffer(0x0E90, State); { @@ -123,7 +124,7 @@ void SETTINGS_SaveSettings(void) memset(&array, 0xff, sizeof(array)); #ifdef ENABLE_PWRON_PASSWORD - array.password = gEeprom.POWER_ON_PASSWORD; + array.password = g_eeprom.power_on_password; #endif EEPROM_WriteBuffer(0x0E98, &array); @@ -131,43 +132,43 @@ void SETTINGS_SaveSettings(void) #ifdef ENABLE_VOICE memset(State, 0xFF, sizeof(State)); - State[0] = gEeprom.VOICE_PROMPT; + State[0] = g_eeprom.voice_prompt; EEPROM_WriteBuffer(0x0EA0, State); #endif #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - State[0] = gEeprom.ALARM_MODE; + State[0] = g_eeprom.alarm_mode; #else State[0] = false; #endif - State[1] = gEeprom.ROGER; - State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; - State[3] = gEeprom.TX_VFO; + State[1] = g_eeprom.roger_mode; + State[2] = g_eeprom.repeater_tail_tone_elimination; + State[3] = g_eeprom.tx_vfo; EEPROM_WriteBuffer(0x0EA8, State); - State[0] = gEeprom.DTMF_SIDE_TONE; - State[1] = gEeprom.DTMF_SEPARATE_CODE; - State[2] = gEeprom.DTMF_GROUP_CALL_CODE; - State[3] = gEeprom.DTMF_DECODE_RESPONSE; - State[4] = gEeprom.DTMF_auto_reset_time; - State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U; - State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U; - State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U; + State[0] = g_eeprom.DTMF_side_tone; + State[1] = g_eeprom.DTMF_separate_code; + State[2] = g_eeprom.DTMF_group_call_code; + State[3] = g_eeprom.DTMF_decode_response; + State[4] = g_eeprom.DTMF_auto_reset_time; + State[5] = g_eeprom.DTMF_preload_time / 10U; + State[6] = g_eeprom.DTMF_first_code_persist_time / 10U; + State[7] = g_eeprom.DTMF_hash_code_persist_time / 10U; EEPROM_WriteBuffer(0x0ED0, State); memset(State, 0xFF, sizeof(State)); - State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U; - State[1] = gEeprom.DTMF_CODE_INTERVAL_TIME / 10U; - State[2] = gEeprom.PERMIT_REMOTE_KILL; + State[0] = g_eeprom.DTMF_code_persist_time / 10U; + State[1] = g_eeprom.DTMF_code_interval_time / 10U; + State[2] = g_eeprom.permit_remote_kill; EEPROM_WriteBuffer(0x0ED8, State); - State[0] = gEeprom.SCAN_LIST_DEFAULT; - State[1] = gEeprom.SCAN_LIST_ENABLED[0]; - State[2] = gEeprom.SCANLIST_PRIORITY_CH1[0]; - State[3] = gEeprom.SCANLIST_PRIORITY_CH2[0]; - State[4] = gEeprom.SCAN_LIST_ENABLED[1]; - State[5] = gEeprom.SCANLIST_PRIORITY_CH1[1]; - State[6] = gEeprom.SCANLIST_PRIORITY_CH2[1]; + State[0] = g_eeprom.scan_list_default; + State[1] = g_eeprom.scan_list_enabled[0]; + State[2] = g_eeprom.scan_list_priority_ch1[0]; + State[3] = g_eeprom.scan_list_priority_ch2[0]; + State[4] = g_eeprom.scan_list_enabled[1]; + State[5] = g_eeprom.scan_list_priority_ch1[1]; + State[6] = g_eeprom.scan_list_priority_ch2[1]; State[7] = 0xFF; 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; uint16_t OffsetVFO = OffsetMR; - if (Channel > MR_CHANNEL_LAST) + if (Channel > USER_CHANNEL_LAST) { // it's a VFO, not a channel OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90; OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32; } - if (Mode >= 2 || Channel > MR_CHANNEL_LAST) + if (Mode >= 2 || Channel > USER_CHANNEL_LAST) { // copy VFO to a channel uint8_t State[8]; - ((uint32_t *)State)[0] = pVFO->freq_config_RX.Frequency; - ((uint32_t *)State)[1] = pVFO->TX_OFFSET_FREQUENCY; + ((uint32_t *)State)[0] = pVFO->freq_config_rx.frequency; + ((uint32_t *)State)[1] = pVFO->tx_offset_freq; EEPROM_WriteBuffer(OffsetVFO + 0, State); - State[0] = pVFO->freq_config_RX.Code; - State[1] = pVFO->freq_config_TX.Code; - State[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType; - State[3] = ((pVFO->AM_mode & 1u) << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION; + State[0] = pVFO->freq_config_rx.code; + State[1] = pVFO->freq_config_tx.code; + 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_freq_dir; State[4] = 0 - | (pVFO->BUSY_CHANNEL_LOCK << 4) - | (pVFO->OUTPUT_POWER << 2) - | (pVFO->CHANNEL_BANDWIDTH << 1) - | (pVFO->FrequencyReverse << 0); - State[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1) | ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0); - State[6] = pVFO->STEP_SETTING; - State[7] = pVFO->SCRAMBLING_TYPE; + | (pVFO->busy_channel_lock << 4) + | (pVFO->output_power << 2) + | (pVFO->channel_bandwidth << 1) + | (pVFO->frequency_reverse << 0); + State[5] = ((pVFO->DTMF_ptt_id_tx_mode & 7u) << 1) | ((pVFO->DTMF_decoding_enable & 1u) << 0); + State[6] = pVFO->step_setting; + State[7] = pVFO->scrambling_type; EEPROM_WriteBuffer(OffsetVFO + 8, State); SETTINGS_UpdateChannel(Channel, pVFO, true); - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { // it's a memory channel #ifndef ENABLE_KEEP_MEM_NAME @@ -245,11 +246,11 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, #else if (Mode >= 3) { // save the channel name - memmove(State, pVFO->Name + 0, 8); + memmove(State, pVFO->name + 0, 8); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); //memset(State, 0xFF, sizeof(State)); 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); } #endif @@ -268,13 +269,13 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) uint8_t Attributes = 0xFF; // default attributes 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)); 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) 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); - gMR_ChannelAttributes[Channel] = Attributes; + gUSER_ChannelAttributes[Channel] = Attributes; // #ifndef ENABLE_KEEP_MEM_NAME - if (Channel <= MR_CHANNEL_LAST) + if (Channel <= USER_CHANNEL_LAST) { // it's a memory channel const uint16_t OffsetMR = Channel * 16; @@ -299,11 +300,11 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) } // else // { // update the channel name -// memmove(State, pVFO->Name + 0, 8); +// memmove(State, pVFO->name + 0, 8); // EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); // //memset(State, 0xFF, sizeof(State)); // 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); // } } diff --git a/settings.h b/settings.h index d741138..6ee168c 100644 --- a/settings.h +++ b/settings.h @@ -23,13 +23,13 @@ #include "frequencies.h" #include "radio.h" -enum POWER_OnDisplayMode_t { - POWER_ON_DISPLAY_MODE_FULL_SCREEN = 0, - POWER_ON_DISPLAY_MODE_MESSAGE, - POWER_ON_DISPLAY_MODE_VOLTAGE, - POWER_ON_DISPLAY_MODE_NONE +enum pwr_on_display_mode_e { + PWR_ON_DISPLAY_MODE_FULL_SCREEN = 0, + PWR_ON_DISPLAY_MODE_MESSAGE, + PWR_ON_DISPLAY_MODE_VOLTAGE, + 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 { F_LOCK_OFF = 0, @@ -59,9 +59,9 @@ enum { }; enum { - TX_OFFSET_FREQUENCY_DIRECTION_OFF = 0, - TX_OFFSET_FREQUENCY_DIRECTION_ADD, - TX_OFFSET_FREQUENCY_DIRECTION_SUB + TX_OFFSET_FREQ_DIR_OFF = 0, + TX_OFFSET_FREQ_DIR_ADD, + TX_OFFSET_FREQ_DIR_SUB }; enum { @@ -84,79 +84,79 @@ enum { }; #ifdef ENABLE_VOICE - enum VOICE_Prompt_t + enum voice_prompt_e { VOICE_PROMPT_OFF = 0, VOICE_PROMPT_CHINESE, VOICE_PROMPT_ENGLISH }; - typedef enum VOICE_Prompt_t VOICE_Prompt_t; + typedef enum voice_prompt_e voice_prompt_t; #endif -enum ALARM_Mode_t { - ALARM_MODE_SITE = 0, +enum alarm_mode_e { + alarm_mode_SITE = 0, 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_ROGER, 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_CHANNEL, MDF_NAME, MDF_NAME_FREQ }; -typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t; +typedef enum mdf_display_mode_e mdf_display_mode_t; typedef struct { - uint8_t ScreenChannel[2]; - uint8_t FreqChannel[2]; - uint8_t MrChannel[2]; + uint8_t screen_channel[2]; + uint8_t freq_channel[2]; + uint8_t user_channel[2]; #ifdef ENABLE_NOAA - uint8_t NoaaChannel[2]; + uint8_t noaa_channel[2]; #endif - uint8_t RX_VFO; - uint8_t TX_VFO; + uint8_t rx_vfo; + uint8_t tx_vfo; uint8_t field7_0xa; uint8_t field8_0xb; #ifdef ENABLE_FMRADIO - uint16_t FM_SelectedFrequency; - uint8_t FM_SelectedChannel; - bool FM_IsMrMode; - uint16_t FM_FrequencyPlaying; - uint16_t FM_LowerLimit; - uint16_t FM_UpperLimit; + uint16_t fm_selected_frequency; + uint8_t fm_selected_channel; + bool fm_is_channel_mode; + uint16_t fm_frequency_playing; + uint16_t fm_lower_limit; + uint16_t fm_upper_limit; #endif - uint8_t SQUELCH_LEVEL; - uint8_t TX_TIMEOUT_TIMER; - bool KEY_LOCK; - bool VOX_SWITCH; - uint8_t VOX_LEVEL; + uint8_t squelch_level; + uint8_t tx_timeout_timer; + bool key_lock; + bool vox_switch; + uint8_t vox_level; #ifdef ENABLE_VOICE - VOICE_Prompt_t VOICE_PROMPT; + voice_prompt_t voice_prompt; #endif - bool BEEP_CONTROL; - uint8_t CHANNEL_DISPLAY_MODE; - bool TAIL_NOTE_ELIMINATION; - bool VFO_OPEN; - uint8_t DUAL_WATCH; - uint8_t CROSS_BAND_RX_TX; - uint8_t BATTERY_SAVE; - uint8_t BACKLIGHT; - uint8_t SCAN_RESUME_MODE; - uint8_t SCAN_LIST_DEFAULT; - bool SCAN_LIST_ENABLED[2]; - uint8_t SCANLIST_PRIORITY_CH1[2]; - uint8_t SCANLIST_PRIORITY_CH2[2]; + bool beep_control; + uint8_t channel_display_mode; + bool tail_note_elimination; + bool vfo_open; + uint8_t dual_watch; + uint8_t cross_vfo_rx_tx; + uint8_t battery_save; + uint8_t backlight; + uint8_t scan_resume_mode; + uint8_t scan_list_default; + bool scan_list_enabled[2]; + uint8_t scan_list_priority_ch1[2]; + uint8_t scan_list_priority_ch2[2]; uint8_t field29_0x26; uint8_t field30_0x27; @@ -164,55 +164,54 @@ typedef struct { uint8_t field37_0x32; uint8_t field38_0x33; - bool AUTO_KEYPAD_LOCK; + bool auto_keypad_lock; + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - ALARM_Mode_t ALARM_MODE; + alarm_mode_t alarm_mode; #endif - POWER_OnDisplayMode_t POWER_ON_DISPLAY_MODE; - ROGER_Mode_t ROGER; - uint8_t REPEATER_TAIL_TONE_ELIMINATION; - uint8_t KEY_1_SHORT_PRESS_ACTION; - uint8_t KEY_1_LONG_PRESS_ACTION; - uint8_t KEY_2_SHORT_PRESS_ACTION; - uint8_t KEY_2_LONG_PRESS_ACTION; - uint8_t MIC_SENSITIVITY; - uint8_t MIC_SENSITIVITY_TUNING; - uint8_t CHAN_1_CALL; - char ANI_DTMF_ID[8]; - char KILL_CODE[8]; - char REVIVE_CODE[8]; - char DTMF_UP_CODE[16]; + pwr_on_display_mode_t pwr_on_display_mode; + roger_mode_t roger_mode; + uint8_t repeater_tail_tone_elimination; + uint8_t key1_short_press_action; + uint8_t key1_long_press_action; + uint8_t key2_short_press_action; + uint8_t key2_long_press_action; + uint8_t mic_sensitivity; + uint8_t mic_sensitivity_tuning; + uint8_t chan_1_call; + char ani_DTMF_id[8]; + char kill_code[8]; + char revive_code[8]; + char DTMF_up_code[16]; + char DTMF_down_code[16]; uint8_t field57_0x6c; uint8_t field58_0x6d; - char DTMF_DOWN_CODE[16]; - uint8_t field60_0x7e; uint8_t field61_0x7f; - char DTMF_SEPARATE_CODE; - char DTMF_GROUP_CALL_CODE; - uint8_t DTMF_DECODE_RESPONSE; + char DTMF_separate_code; + char DTMF_group_call_code; + uint8_t DTMF_decode_response; uint8_t DTMF_auto_reset_time; - uint16_t DTMF_PRELOAD_TIME; - uint16_t DTMF_FIRST_CODE_PERSIST_TIME; - uint16_t DTMF_HASH_CODE_PERSIST_TIME; - uint16_t DTMF_CODE_PERSIST_TIME; - uint16_t DTMF_CODE_INTERVAL_TIME; - bool DTMF_SIDE_TONE; - bool PERMIT_REMOTE_KILL; - int16_t BK4819_XTAL_FREQ_LOW; + uint16_t DTMF_preload_time; + uint16_t DTMF_first_code_persist_time; + uint16_t DTMF_hash_code_persist_time; + uint16_t DTMF_code_persist_time; + uint16_t DTMF_code_interval_time; + bool DTMF_side_tone; + bool permit_remote_kill; + int16_t BK4819_xtal_freq_low; #ifdef ENABLE_NOAA - bool NOAA_AUTO_SCAN; + bool NOAA_auto_scan; #endif - uint8_t VOLUME_GAIN; - uint8_t DAC_GAIN; - + uint8_t volume_gain; + uint8_t dac_gain; VFO_Info_t VfoInfo[2]; - uint32_t POWER_ON_PASSWORD; - uint16_t VOX1_THRESHOLD; - uint16_t VOX0_THRESHOLD; + uint32_t power_on_password; + uint16_t vox1_threshold; + uint16_t vox0_threshold; uint8_t field77_0x95; uint8_t field78_0x96; @@ -220,7 +219,8 @@ typedef struct { uint8_t _pad[1]; } EEPROM_Config_t; -extern EEPROM_Config_t gEeprom; + +extern EEPROM_Config_t g_eeprom; #ifdef ENABLE_FMRADIO void SETTINGS_SaveFM(void); diff --git a/ui/aircopy.c b/ui/aircopy.c index 1163275..4dfa6d9 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -44,7 +44,7 @@ void UI_DisplayAircopy(void) 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_DisplaySmallDigits(2, String + 6, 97, 3, true); } diff --git a/ui/fmradio.c b/ui/fmradio.c index 9574f5f..39468c6 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -53,11 +53,11 @@ void UI_DisplayFM(void) { if (gFM_ScanState == FM_SCAN_OFF) { - if (!gEeprom.FM_IsMrMode) + if (!g_eeprom.fm_is_channel_mode) { 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); break; @@ -68,7 +68,7 @@ void UI_DisplayFM(void) strcpy(String, "VFO"); } else - sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1); + sprintf(String, "MR(CH%02u)", g_eeprom.fm_selected_channel + 1); } else { @@ -81,7 +81,7 @@ void UI_DisplayFM(void) UI_PrintString(String, 0, 127, 2, 10); 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); } @@ -90,7 +90,7 @@ void UI_DisplayFM(void) { 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); } else @@ -101,7 +101,7 @@ void UI_DisplayFM(void) } 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); diff --git a/ui/inputbox.c b/ui/inputbox.c index e352cce..0900990 100644 --- a/ui/inputbox.c +++ b/ui/inputbox.c @@ -21,7 +21,7 @@ char gInputBox[8]; uint8_t gInputBoxIndex; -void INPUTBOX_Append(const KEY_Code_t Digit) +void INPUTBOX_Append(const key_code_t Digit) { if (gInputBoxIndex >= sizeof(gInputBox)) return; diff --git a/ui/inputbox.h b/ui/inputbox.h index d7a6d2e..419f2a6 100644 --- a/ui/inputbox.h +++ b/ui/inputbox.h @@ -24,7 +24,7 @@ extern char gInputBox[8]; extern uint8_t gInputBoxIndex; -void INPUTBOX_Append(const KEY_Code_t Digit); +void INPUTBOX_Append(const key_code_t Digit); #endif diff --git a/ui/lock.c b/ui/lock.c index 1dca0a2..3d32ba0 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -50,7 +50,7 @@ static void Render(void) void UI_DisplayLock(void) { - KEY_Code_t Key; + key_code_t Key; BEEP_Type_t Beep; gUpdateDisplay = true; @@ -67,17 +67,17 @@ void UI_DisplayLock(void) 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) { - gKeyReading1 = KEY_INVALID; + g_key_reading_1 = KEY_INVALID; } else { - gKeyReading1 = Key; + g_key_reading_1 = Key; switch (Key) { @@ -105,7 +105,7 @@ void UI_DisplayLock(void) 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); return; @@ -140,8 +140,8 @@ void UI_DisplayLock(void) } else { - gDebounceCounter = 0; - gKeyReading0 = Key; + g_debounce_counter = 0; + g_key_reading_0 = Key; } if (UART_IsCommandAvailable()) diff --git a/ui/main.c b/ui/main.c index ba36039..998c39f 100644 --- a/ui/main.c +++ b/ui/main.c @@ -56,11 +56,11 @@ center_line_t center_line = CENTER_LINE_NONE; if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT) return false; - if (gEeprom.TX_TIMEOUT_TIMER == 0) + if (g_eeprom.tx_timeout_timer == 0) timeout_secs = 30; // 30 sec else - if (gEeprom.TX_TIMEOUT_TIMER < (ARRAY_SIZE(gSubMenu_TOT) - 1)) - timeout_secs = 60 * gEeprom.TX_TIMEOUT_TIMER; // minutes + if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1)) + timeout_secs = 60 * g_eeprom.tx_timeout_timer; // minutes else timeout_secs = 60 * 15; // 15 minutes @@ -240,7 +240,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level) char s[16]; unsigned int i; - if (gEeprom.KEY_LOCK && gKeypadLocked > 0) + if (g_eeprom.key_lock && gKeypadLocked > 0) return; // display is in use 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 // const unsigned int band = 1; - const int16_t level0 = gEEPROM_RSSI_CALIB[band][0]; - const int16_t level1 = gEEPROM_RSSI_CALIB[band][1]; - const int16_t level2 = gEEPROM_RSSI_CALIB[band][2]; - const int16_t level3 = gEEPROM_RSSI_CALIB[band][3]; + const int16_t level0 = g_eeprom_RSSI_CALIB[band][0]; + const int16_t level1 = g_eeprom_RSSI_CALIB[band][1]; + const int16_t level2 = g_eeprom_RSSI_CALIB[band][2]; + const int16_t level3 = g_eeprom_RSSI_CALIB[band][3]; #else const int16_t level0 = (-115 + 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 if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) @@ -385,7 +385,7 @@ void UI_DisplayMain(void) center_line = CENTER_LINE_NONE; // #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 const bool single_vfo = false; // #endif @@ -393,7 +393,7 @@ void UI_DisplayMain(void) // clear the screen 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 UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 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++) { const unsigned int line = (vfo_num == 0) ? line0 : line1; - unsigned int channel = gEeprom.TX_VFO; -// unsigned int tx_channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO; + unsigned int channel = g_eeprom.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; uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line1 = gFrameBuffer[line + 1]; @@ -421,8 +421,8 @@ void UI_DisplayMain(void) } - if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gRxVfoIsActive) - channel = gEeprom.RX_VFO; // we're currently monitoring the other VFO + if (g_eeprom.dual_watch != DUAL_WATCH_OFF && gRxVfoIsActive) + channel = g_eeprom.rx_vfo; // we're currently monitoring the other VFO if (channel != vfo_num) { @@ -472,7 +472,7 @@ void UI_DisplayMain(void) if (!single_vfo && same_vfo) memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); 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)); } else @@ -481,7 +481,7 @@ void UI_DisplayMain(void) if (same_vfo) memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); 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)); } @@ -494,7 +494,7 @@ void UI_DisplayMain(void) else #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) { // show the TX symbol mode = 1; @@ -512,7 +512,7 @@ void UI_DisplayMain(void) if ((gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_INCOMING) && - gEeprom.RX_VFO == vfo_num) + g_eeprom.rx_vfo == vfo_num) { #ifdef ENABLE_SMALL_BOLD 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 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) - 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 memmove(String + 5, gInputBox, 3); // show the input text UI_PrintStringSmall("M", x, 0, line + 1); UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting); } else - if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) + if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num])) { // frequency mode // show the frequency band number const unsigned int x = 2; // was 14 -// sprintf(String, "FB%u", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST); - sprintf(String, "VFO%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 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST); UI_PrintStringSmall(String, x, 0, line + 1); } #ifdef ENABLE_NOAA else { - if (gInputBoxIndex == 0 || gEeprom.TX_VFO != vfo_num) + if (gInputBoxIndex == 0 || g_eeprom.tx_vfo != vfo_num) { // 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 { // user entering channel number @@ -564,7 +564,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_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) state = VFO_STATE_ALARM; } @@ -577,7 +577,7 @@ void UI_DisplayMain(void) UI_PrintString(state_list[state], 31, 0, line, 8); } 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 UI_DisplayFrequency(gInputBox, 32, line, true, false); @@ -585,25 +585,25 @@ void UI_DisplayMain(void) } else { - uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; + uint32_t frequency = g_eeprom.VfoInfo[vfo_num].pRX->frequency; if (gCurrentFunction == FUNCTION_TRANSMIT) { // 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) - 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 // show the channel symbols - const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if (attributes & MR_CH_SCANLIST1) + const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]]; + if (attributes & USER_CH_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)); #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)); #else @@ -614,7 +614,7 @@ void UI_DisplayMain(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gEeprom.CHANNEL_DISPLAY_MODE) + switch (g_eeprom.channel_display_mode) { case MDF_FREQUENCY: // show the channel frequency #ifdef ENABLE_BIG_FREQ @@ -631,20 +631,20 @@ void UI_DisplayMain(void) break; 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); break; case MDF_NAME: // show the channel name 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) { // 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); } @@ -681,8 +681,8 @@ void UI_DisplayMain(void) #endif // show the channel symbols - const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if ((attributes & MR_CH_COMPAND) > 0) + const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]]; + if ((attributes & USER_CH_COMPAND) > 0) #ifdef ENABLE_BIG_FREQ memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); #else @@ -698,7 +698,7 @@ void UI_DisplayMain(void) if (mode == 1) { // TX power level - switch (gRxVfo->OUTPUT_POWER) + switch (gRxVfo->output_power) { case OUTPUT_POWER_LOW: Level = 2; break; case OUTPUT_POWER_MID: Level = 4; break; @@ -721,14 +721,14 @@ void UI_DisplayMain(void) // ************ String[0] = '\0'; - if (gEeprom.VfoInfo[vfo_num].AM_mode) + if (g_eeprom.VfoInfo[vfo_num].am_mode) { // show the AM symbol strcpy(String, "AM"); } else { // or show the CTCSS/DCS symbol - const FREQ_Config_t *pConfig = (mode == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; - const unsigned int code_type = pConfig->CodeType; + 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->code_type; const char *code_list[] = {"", "CT", "DCS", "DCR"}; if (code_type < ARRAY_SIZE(code_list)) strcpy(String, code_list[code_type]); @@ -738,28 +738,28 @@ void UI_DisplayMain(void) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) { // show the TX power 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[1] = '\0'; 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 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[1] = '\0'; UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1); } // 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); { // show the narrow band symbol 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[1] = '\0'; @@ -768,11 +768,11 @@ void UI_DisplayMain(void) } // 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); // 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); } @@ -804,13 +804,13 @@ void UI_DisplayMain(void) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_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) return; 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); } else @@ -821,7 +821,7 @@ void UI_DisplayMain(void) if (rx) { center_line = CENTER_LINE_RSSI; - UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_VFO], false); + UI_DisplayRSSIBar(gCurrentRSSI[g_eeprom.rx_vfo], false); } else #endif diff --git a/ui/menu.c b/ui/menu.c index 706acf8..b4b84b2 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -53,9 +53,9 @@ const t_menu_item MenuList[] = {"RxCTCS", VOICE_ID_CTCSS, MENU_R_CTCS }, // was "R_CTCS" {"Tx DCS", VOICE_ID_DCS, MENU_T_DCS }, // was "T_DCS" {"TxCTCS", VOICE_ID_CTCSS, MENU_T_CTCS }, // was "T_CTCS" - {"Tx DIR", VOICE_ID_TX_OFFSET_FREQUENCY_DIRECTION, MENU_SFT_D }, // was "SFT_D" - {"TxOFFS", VOICE_ID_TX_OFFSET_FREQUENCY, MENU_OFFSET }, // was "OFFSET" - {"Tx TO", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT" + {"Tx DIR", voice_id_tX_OFFSET_FREQ_DIR, MENU_SFT_D }, // was "SFT_D" + {"TxOFFS", voice_id_tX_OFFSET_FREQ, MENU_OFFSET }, // was "OFFSET" + {"Tx TO", voice_id_tRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT" {"Tx VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX" {"2nd RX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR" {"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR" @@ -288,7 +288,7 @@ const char gSubMenu_F_LOCK[6][4] = "438" }; -const char gSubMenu_BACKLIGHT[8][7] = +const char gSubMenu_backlight[8][7] = { "OFF", "5 sec", @@ -556,16 +556,16 @@ void UI_DisplayMenu(void) { #if 1 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) { strcpy(String, "OFF"); - if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) + if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE) break; Code = 0; - pConfig->CodeType = CODE_TYPE_OFF; - pConfig->Code = Code; + pConfig->code_type = CODE_TYPE_OFF; + pConfig->code = Code; BK4819_ExitSubAu(); } @@ -573,9 +573,9 @@ void UI_DisplayMenu(void) { 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; - pConfig->Code = Code; + pConfig->code = Code; BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); } @@ -643,7 +643,7 @@ void UI_DisplayMenu(void) #endif case MENU_ABR: - strcpy(String, gSubMenu_BACKLIGHT[gSubMenuSelection]); + strcpy(String, gSubMenu_backlight[gSubMenuSelection]); break; case MENU_AM: @@ -800,15 +800,15 @@ void UI_DisplayMenu(void) #endif case MENU_ANI_ID: - strcpy(String, gEeprom.ANI_DTMF_ID); + strcpy(String, g_eeprom.ani_DTMF_id); break; case MENU_UPCODE: - strcpy(String, gEeprom.DTMF_UP_CODE); + strcpy(String, g_eeprom.DTMF_up_code); break; case MENU_DWCODE: - strcpy(String, gEeprom.DTMF_DOWN_CODE); + strcpy(String, g_eeprom.DTMF_down_code); break; case MENU_D_RSP: @@ -980,8 +980,8 @@ void UI_DisplayMenu(void) else UI_GenerateChannelStringEx(String, true, gSubMenuSelection); -// if (gSubMenuSelection == 0xFF || !gEeprom.SCAN_LIST_ENABLED[i]) - if (gSubMenuSelection < 0 || !gEeprom.SCAN_LIST_ENABLED[i]) +// if (gSubMenuSelection == 0xFF || !g_eeprom.scan_list_enabled[i]) + if (gSubMenuSelection < 0 || !g_eeprom.scan_list_enabled[i]) { // channel number UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); @@ -1003,15 +1003,15 @@ void UI_DisplayMenu(void) strcpy(String, "--"); 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); } - 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); } } @@ -1032,12 +1032,12 @@ void UI_DisplayMenu(void) UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8); if (gMenuCursor == MENU_UPCODE) - if (strlen(gEeprom.DTMF_UP_CODE) > 8) - UI_PrintString(gEeprom.DTMF_UP_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); + if (strlen(g_eeprom.DTMF_up_code) > 8) + UI_PrintString(g_eeprom.DTMF_up_code + 8, menu_item_x1, menu_item_x2, 4, 8); if (gMenuCursor == MENU_DWCODE) - if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) - UI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, menu_item_x1, menu_item_x2, 4, 8); + if (strlen(g_eeprom.DTMF_down_code) > 8) + UI_PrintString(g_eeprom.DTMF_down_code + 8, menu_item_x1, menu_item_x2, 4, 8); if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid) { diff --git a/ui/menu.h b/ui/menu.h index 8325b78..4bbf2b8 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -20,11 +20,11 @@ #include #include -#include "audio.h" // VOICE_ID_t +#include "audio.h" // voice_id_t typedef struct { 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; } 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_RESET[2][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]; #ifdef ENABLE_AM_FIX_TEST1 extern const char gSubMenu_AM_fix_test1[4][8]; diff --git a/ui/status.c b/ui/status.c index 8a55e23..33ff0f2 100644 --- a/ui/status.c +++ b/ui/status.c @@ -96,15 +96,15 @@ void UI_DisplayStatus(const bool test_display) // SCAN indicator if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display) { - if (gNextMrChannel <= MR_CHANNEL_LAST) + if (gNextChannel <= USER_CHANNEL_LAST) { // channel mode - if (gEeprom.SCAN_LIST_DEFAULT == 0) + if (g_eeprom.scan_list_default == 0) UI_PrintStringSmallBuffer("1", line + x); else - if (gEeprom.SCAN_LIST_DEFAULT == 1) + if (g_eeprom.scan_list_default == 1) UI_PrintStringSmallBuffer("2", line + x); else - if (gEeprom.SCAN_LIST_DEFAULT == 2) + if (g_eeprom.scan_list_default == 2) UI_PrintStringSmallBuffer("*", line + x); } else @@ -117,7 +117,7 @@ void UI_DisplayStatus(const bool test_display) #ifdef ENABLE_VOICE // 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)); x1 = x + sizeof(BITMAP_VoicePrompt); @@ -128,7 +128,7 @@ void UI_DisplayStatus(const bool test_display) #endif // 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) memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1)); @@ -138,7 +138,7 @@ void UI_DisplayStatus(const bool test_display) x += sizeof(BITMAP_TDR1); // 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)); x1 = x + sizeof(BITMAP_XB); @@ -147,7 +147,7 @@ void UI_DisplayStatus(const bool test_display) #ifdef ENABLE_VOX // VOX indicator - if (gEeprom.VOX_SWITCH || test_display) + if (g_eeprom.vox_switch || test_display) { memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); x1 = x + sizeof(BITMAP_VOX); @@ -156,14 +156,14 @@ void UI_DisplayStatus(const bool test_display) #endif // KEY-LOCK indicator - if (gEeprom.KEY_LOCK || test_display) + if (g_eeprom.key_lock || test_display) { memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); x += sizeof(BITMAP_KeyLock); x1 = x; } else - if (gWasFKeyPressed) + if (g_was_f_key_pressed) { memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key)); x += sizeof(BITMAP_F_Key); diff --git a/ui/ui.c b/ui/ui.c index 0ea903a..893a985 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -94,7 +94,7 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display) gAskForConfirmation = 0; gAskToSave = false; gAskToDelete = false; - gWasFKeyPressed = false; + g_was_f_key_pressed = false; gUpdateStatus = true; } diff --git a/ui/welcome.c b/ui/welcome.c index b786751..5368fb3 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -48,12 +48,12 @@ void UI_DisplayWelcome(void) memset(gStatusLine, 0, sizeof(gStatusLine)); 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); } 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); } @@ -63,7 +63,7 @@ void UI_DisplayWelcome(void) memset(WelcomeString1, 0, sizeof(WelcomeString1)); 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"); sprintf(WelcomeString1, "%u.%02uV %u%%", diff --git a/version.c b/version.c index e64486b..8966e6d 100644 --- a/version.c +++ b/version.c @@ -4,7 +4,7 @@ #ifdef GIT_HASH #define VER GIT_HASH #else - #define VER "231007" + #define VER "231009" #endif #ifndef ONE_OF_ELEVEN_VER