diff --git a/am_fix.c b/am_fix.c index 09d67e91..ab2c3d5f 100644 --- a/am_fix.c +++ b/am_fix.c @@ -223,7 +223,7 @@ #ifdef ENABLE_AM_FIX_TEST1 // user manually sets the table index .. used to calibrate the desired dB gain table - unsigned int gain_table_index[2] = {1 + gSetting_AM_fix_test1, 1 + gSetting_AM_fix_test1}; + unsigned int gain_table_index[2] = {1 + g_setting_am_fix_test1, 1 + g_setting_am_fix_test1}; #else unsigned int gain_table_index[2] = {original_index, original_index}; #endif @@ -256,7 +256,7 @@ for (i = 0; i < 2; i++) { #ifdef ENABLE_AM_FIX_TEST1 - gain_table_index[i] = 1 + gSetting_AM_fix_test1; + gain_table_index[i] = 1 + g_setting_am_fix_test1; #else gain_table_index[i] = original_index; // re-start with original QS setting #endif @@ -293,7 +293,7 @@ rssi_gain_diff[vfo] = 0; #ifdef ENABLE_AM_FIX_TEST1 -// gain_table_index[vfo] = 1 + gSetting_AM_fix_test1; +// gain_table_index[vfo] = 1 + g_setting_am_fix_test1; #else // gain_table_index[vfo] = original_index; // re-start with original QS setting #endif @@ -313,7 +313,7 @@ int16_t diff_dB; int16_t rssi; - switch (gCurrentFunction) + switch (g_current_function) { case FUNCTION_TRANSMIT: case FUNCTION_BAND_SCOPE: @@ -337,7 +337,7 @@ if (++counter >= display_update_rate) { // trigger a display update counter = 0; - gUpdateDisplay = true; + g_update_display = true; } } #endif @@ -353,26 +353,26 @@ #ifdef ENABLE_AM_FIX_SHOW_DATA { const int16_t new_rssi = rssi - rssi_gain_diff[vfo]; - if (gCurrentRSSI[vfo] != new_rssi) + if (g_current_rssi[vfo] != new_rssi) { - gCurrentRSSI[vfo] = new_rssi; + g_current_rssi[vfo] = new_rssi; if (counter == 0) { // trigger a display update counter = 1; - gUpdateDisplay = true; + g_update_display = true; } } } #else - gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo]; + g_current_rssi[vfo] = rssi - rssi_gain_diff[vfo]; #endif #ifdef ENABLE_AM_FIX_TEST1 // user is manually adjusting a gain register - don't do anything automatically { - int i = 1 + (int)gSetting_AM_fix_test1; + int i = 1 + (int)g_setting_am_fix_test1; i = (i < 1) ? 1 : (i > ((int)ARRAY_SIZE(gain_table) - 1) ? ARRAY_SIZE(gain_table) - 1 : i; if (gain_table_index[vfo] == i) @@ -460,13 +460,13 @@ } // save the corrected RSSI level - gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo]; + g_current_rssi[vfo] = rssi - rssi_gain_diff[vfo]; #ifdef ENABLE_AM_FIX_SHOW_DATA if (counter == 0) { counter = 1; - gUpdateDisplay = true; + g_update_display = true; } #endif } diff --git a/app/action.c b/app/action.c index 81561199..f4959212 100644 --- a/app/action.c +++ b/app/action.c @@ -38,94 +38,94 @@ static void ACTION_FlashLight(void) { - switch (gFlashLightState) + switch (g_flash_light_state) { case 0: - gFlashLightState++; + g_flash_light_state++; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); break; case 1: - gFlashLightState++; + g_flash_light_state++; break; default: - gFlashLightState = 0; + g_flash_light_state = 0; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); } } void ACTION_Power(void) { - if (++gTxVfo->output_power > OUTPUT_POWER_HIGH) - gTxVfo->output_power = OUTPUT_POWER_LOW; + if (++g_tx_vfo->output_power > OUTPUT_POWER_HIGH) + g_tx_vfo->output_power = OUTPUT_POWER_LOW; - gRequestSaveChannel = 1; - //gRequestSaveChannel = 2; // auto save the channel + g_request_save_channel = 1; + //g_request_save_channel = 2; // auto save the channel #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_POWER; #endif - gRequestDisplayScreen = gScreenToDisplay; + g_request_display_screen = g_screen_to_display; } void ACTION_Monitor(void) { - if (gCurrentFunction != FUNCTION_MONITOR) + if (g_current_function != FUNCTION_MONITOR) { // enable the monitor RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST && gIsNoaaMode) - gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST; + if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode) + g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST; #endif RADIO_SetupRegisters(true); APP_StartListening(FUNCTION_MONITOR, false); return; } - gMonitor = false; + g_monitor_enabled = false; - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { - gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_1_10ms; + g_schedule_scan_listen = false; gScanPauseMode = true; } #ifdef ENABLE_NOAA - if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode) { - gNOAA_Countdown_10ms = NOAA_countdown_10ms; - gScheduleNOAA = false; + g_noaa_count_down_10ms = noaa_count_down_10ms; + g_schedule_noaa = false; } #endif RADIO_SetupRegisters(true); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) { FM_Start(); - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; } else #endif - gRequestDisplayScreen = gScreenToDisplay; + g_request_display_screen = g_screen_to_display; } void ACTION_Scan(bool bRestart) { #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) { - if (gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_MONITOR && - gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_RECEIVE && + g_current_function != FUNCTION_MONITOR && + g_current_function != FUNCTION_TRANSMIT) { GUI_SelectNextDisplay(DISPLAY_FM); - gMonitor = false; + g_monitor_enabled = false; - if (gFM_ScanState != FM_SCAN_OFF) + if (g_fm_scan_state != FM_SCAN_OFF) { FM_PlayAndUpdate(); @@ -139,15 +139,15 @@ void ACTION_Scan(bool bRestart) if (bRestart) { - gFM_AutoScan = true; - gFM_ChannelPosition = 0; + g_fm_auto_scan = true; + g_fm_channel_position = 0; FM_EraseChannels(); Frequency = g_eeprom.fm_lower_limit; } else { - gFM_AutoScan = false; - gFM_ChannelPosition = 0; + g_fm_auto_scan = false; + g_fm_channel_position = 0; Frequency = g_eeprom.fm_frequency_playing; } @@ -164,39 +164,39 @@ void ACTION_Scan(bool bRestart) } #endif - if (gScreenToDisplay != DISPLAY_SCANNER) + if (g_screen_to_display != DISPLAY_SCANNER) { // not scanning - gMonitor = false; + g_monitor_enabled = false; DTMF_clear_RX(); - gDTMF_RX_live_timeout = 0; - memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); RADIO_SelectVfos(); #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) + if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) #endif { GUI_SelectNextDisplay(DISPLAY_MAIN); - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { // already scanning - if (gNextChannel <= USER_CHANNEL_LAST) + if (g_next_channel <= USER_CHANNEL_LAST) { // channel mode // keep scanning but toggle between scan lists g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3; // jump to the next channel - CHANNEL_Next(true, gScanStateDir); - gScanPauseDelayIn_10ms = 1; - gScheduleScanListen = false; + CHANNEL_Next(true, g_scan_state_dir); + g_scan_pause_delay_in_10ms = 1; + g_schedule_scan_listen = false; - gUpdateStatus = true; + g_update_status = true; } else { // stop scanning @@ -219,30 +219,30 @@ void ACTION_Scan(bool bRestart) #endif // clear the other vfo's rssi level (to hide the antenna symbol) - gVFO_RSSI_bar_level[(g_eeprom.rx_vfo + 1) & 1u] = 0; + g_vfo_rssi_bar_level[(g_eeprom.rx_vfo + 1) & 1u] = 0; // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; } } } else // if (!bRestart) - if (!bRestart && gNextChannel <= USER_CHANNEL_LAST) + if (!bRestart && g_next_channel <= USER_CHANNEL_LAST) { // channel mode, keep scanning but toggle between scan lists g_eeprom.scan_list_default = (g_eeprom.scan_list_default + 1) % 3; // jump to the next channel - CHANNEL_Next(true, gScanStateDir); - gScanPauseDelayIn_10ms = 1; - gScheduleScanListen = false; + CHANNEL_Next(true, g_scan_state_dir); + g_scan_pause_delay_in_10ms = 1; + g_schedule_scan_listen = false; - gUpdateStatus = true; + g_update_status = true; } else { // stop scanning - gMonitor = false; + g_monitor_enabled = false; SCANNER_Stop(); @@ -250,7 +250,7 @@ void ACTION_Scan(bool bRestart) g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; } } @@ -258,34 +258,34 @@ void ACTION_Scan(bool bRestart) void ACTION_Vox(void) { g_eeprom.vox_switch = !g_eeprom.vox_switch; - gRequestSaveSettings = true; - gFlagReconfigureVfos = true; + g_request_save_settings = true; + g_flag_reconfigure_vfos = true; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_VOX; #endif - gUpdateStatus = true; + g_update_status = true; } #endif #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) static void ACTION_AlarmOr1750(const bool b1750) { - gInputBoxIndex = 0; + g_input_box_index = 0; #if defined(ENABLE_ALARM) && defined(ENABLE_TX1750) - gAlarmState = b1750 ? ALARM_STATE_TX1750 : ALARM_STATE_TXALARM; - gAlarmRunningCounter = 0; + g_alarm_state = b1750 ? ALARM_STATE_TX1750 : ALARM_STATE_TXALARM; + g_alarm_running_counter = 0; #elif defined(ENABLE_ALARM) - gAlarmState = ALARM_STATE_TXALARM; - gAlarmRunningCounter = 0; + g_alarm_state = ALARM_STATE_TXALARM; + g_alarm_running_counter = 0; #else - gAlarmState = ALARM_STATE_TX1750; + g_alarm_state = ALARM_STATE_TX1750; #endif - gFlagPrepareTX = true; + g_flag_prepare_tx = true; - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu + g_request_display_screen = DISPLAY_MAIN; } #endif @@ -293,54 +293,54 @@ void ACTION_Scan(bool bRestart) #ifdef ENABLE_FMRADIO void ACTION_FM(void) { - if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR) + if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_MONITOR) { - if (gFmRadioMode) + if (g_fm_radio_mode) { FM_TurnOff(); - gInputBoxIndex = 0; + g_input_box_index = 0; #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + g_vox_resume_count_down = 80; #endif - gFlagReconfigureVfos = true; + g_flag_reconfigure_vfos = true; - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; return; } - gMonitor = false; + g_monitor_enabled = false; RADIO_SelectVfos(); RADIO_SetupRegisters(true); FM_Start(); - gInputBoxIndex = 0; + g_input_box_index = 0; - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; } } #endif -void ACTION_Handle(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +void ACTION_Handle(key_code_t Key, bool key_pressed, bool key_held) { uint8_t Short = ACTION_OPT_NONE; uint8_t Long = ACTION_OPT_NONE; - if (gScreenToDisplay == DISPLAY_MAIN && gDTMF_InputMode) + if (g_screen_to_display == DISPLAY_MAIN && g_dtmf_input_mode) { - if (Key == KEY_SIDE1 && !bKeyHeld && bKeyPressed) + if (Key == KEY_SIDE1 && !key_held && key_pressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gDTMF_InputBox_Index > 0) + if (g_dtmf_input_box_index > 0) { - gDTMF_InputBox[--gDTMF_InputBox_Index] = '-'; - if (gDTMF_InputBox_Index > 0) + g_dtmf_input_box[--g_dtmf_input_box_index] = '-'; + if (g_dtmf_input_box_index > 0) { - gPttWasReleased = true; - gRequestDisplayScreen = DISPLAY_MAIN; + g_ptt_was_released = true; + g_request_display_screen = DISPLAY_MAIN; return; } } @@ -349,11 +349,11 @@ void ACTION_Handle(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_another_voice_id = VOICE_ID_CANCEL; #endif - gRequestDisplayScreen = DISPLAY_MAIN; - gDTMF_InputMode = false; + g_request_display_screen = DISPLAY_MAIN; + g_dtmf_input_mode = false; } - gPttWasReleased = true; + g_ptt_was_released = true; return; } @@ -369,20 +369,20 @@ void ACTION_Handle(key_code_t Key, bool bKeyPressed, bool bKeyHeld) Long = g_eeprom.key2_long_press_action; } - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } - if (bKeyHeld || bKeyPressed) + if (key_held || key_pressed) { - if (!bKeyHeld) + if (!key_held) return; Short = Long; - if (!bKeyPressed) + if (!key_pressed) return; } diff --git a/app/aircopy.c b/app/aircopy.c index 8e9cd85c..4fd5fcbd 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -30,99 +30,99 @@ static const uint16_t Obfuscation[8] = {0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9}; -AIRCOPY_State_t gAircopyState; -uint16_t gAirCopyBlockNumber; -uint16_t gErrorsDuringAirCopy; -uint8_t gAirCopyIsSendMode; +aircopy_state_t g_aircopy_state; +uint16_t g_air_copy_block_number; +uint16_t g_errors_during_air_copyy; +uint8_t g_air_copy_is_send_mode; -uint16_t g_FSK_Buffer[36]; +uint16_t g_fsk_buffer[36]; void AIRCOPY_SendMessage(void) { unsigned int i; - g_FSK_Buffer[1] = (gAirCopyBlockNumber & 0x3FF) << 6; + g_fsk_buffer[1] = (g_air_copy_block_number & 0x3FF) << 6; - EEPROM_ReadBuffer(g_FSK_Buffer[1], &g_FSK_Buffer[2], 64); + EEPROM_ReadBuffer(g_fsk_buffer[1], &g_fsk_buffer[2], 64); - g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64); + g_fsk_buffer[34] = CRC_Calculate(&g_fsk_buffer[1], 2 + 64); for (i = 0; i < 34; i++) - g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8]; + g_fsk_buffer[i + 1] ^= Obfuscation[i % 8]; - if (++gAirCopyBlockNumber >= 0x78) - gAircopyState = AIRCOPY_COMPLETE; + if (++g_air_copy_block_number >= 0x78) + g_aircopy_state = AIRCOPY_COMPLETE; RADIO_SetTxParameters(); - BK4819_SendFSKData(g_FSK_Buffer); + BK4819_SendFSKData(g_fsk_buffer); BK4819_SetupPowerAmplifier(0, 0); BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false); - gAircopySendCountdown = 30; + g_air_copy_send_count_down = 30; } void AIRCOPY_StorePacket(void) { uint16_t Status; - if (gFSKWriteIndex < 36) + if (g_fsk_wite_index < 36) return; - gFSKWriteIndex = 0; - gUpdateDisplay = true; - Status = BK4819_ReadRegister(BK4819_REG_0B); + g_fsk_wite_index = 0; + g_update_display = true; + Status = BK4819_ReadRegister(BK4819_REG_0B); BK4819_PrepareFSKReceive(); // Doc says bit 4 should be 1 = CRC OK, 0 = CRC FAIL, but original firmware checks for FAIL. - if ((Status & 0x0010U) == 0 && g_FSK_Buffer[0] == 0xABCD && g_FSK_Buffer[35] == 0xDCBA) + if ((Status & 0x0010U) == 0 && g_fsk_buffer[0] == 0xABCD && g_fsk_buffer[35] == 0xDCBA) { uint16_t CRC; unsigned int i; for (i = 0; i < 34; i++) - g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8]; + g_fsk_buffer[i + 1] ^= Obfuscation[i % 8]; - CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64); - if (g_FSK_Buffer[34] == CRC) + CRC = CRC_Calculate(&g_fsk_buffer[1], 2 + 64); + if (g_fsk_buffer[34] == CRC) { const uint16_t *pData; uint16_t Offset; - Offset = g_FSK_Buffer[1]; + Offset = g_fsk_buffer[1]; if (Offset < 0x1E00) { - pData = &g_FSK_Buffer[2]; + pData = &g_fsk_buffer[2]; for (i = 0; i < 8; i++) { EEPROM_WriteBuffer(Offset, pData); pData += 4; Offset += 8; } - + if (Offset == 0x1E00) - gAircopyState = AIRCOPY_COMPLETE; + g_aircopy_state = AIRCOPY_COMPLETE; - gAirCopyBlockNumber++; + g_air_copy_block_number++; return; } } } - gErrorsDuringAirCopy++; + g_errors_during_air_copyy++; } -static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { uint32_t Frequency; unsigned int i; INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_AIRCOPY; - if (gInputBoxIndex < 6) + g_request_display_screen = DISPLAY_AIRCOPY; + if (g_input_box_index < 6) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; @@ -130,24 +130,24 @@ static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - NUMBER_Get(gInputBox, &Frequency); + NUMBER_Get(g_input_box, &Frequency); - for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++) + for (i = 0; i < ARRAY_SIZE(FREQ_BAND_TABLE); i++) { - if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper) + if (Frequency >= FREQ_BAND_TABLE[i].lower && Frequency < FREQ_BAND_TABLE[i].upper) { #ifdef ENABLE_VOICE - g_another_voice_id = (voice_id_t)Key; + g_another_voice_id = (voice_id_t)Key; #endif - gRxVfo->band = i; - Frequency += 75; - 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; + g_rx_vfo->band = i; + Frequency += 75; + Frequency = FREQUENCY_FloorToStep(Frequency, g_rx_vfo->step_freq, 0); + g_rx_vfo->freq_config_rx.frequency = Frequency; + g_rx_vfo->freq_config_tx.frequency = Frequency; + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); + g_current_vfo = g_rx_vfo; RADIO_SetupRegisters(true); BK4819_SetupAircopy(); BK4819_ResetFSK(); @@ -155,54 +155,54 @@ static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) } } - gRequestDisplayScreen = DISPLAY_AIRCOPY; + g_request_display_screen = DISPLAY_AIRCOPY; } } -static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_EXIT(bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { - gFSKWriteIndex = 0; - gAirCopyBlockNumber = 0; - gErrorsDuringAirCopy = 0; - gInputBoxIndex = 0; - gAirCopyIsSendMode = 0; + g_fsk_wite_index = 0; + g_air_copy_block_number = 0; + g_errors_during_air_copyy = 0; + g_input_box_index = 0; + g_air_copy_is_send_mode = 0; BK4819_PrepareFSKReceive(); - gAircopyState = AIRCOPY_TRANSFER; + g_aircopy_state = AIRCOPY_TRANSFER; } else - gInputBox[--gInputBoxIndex] = 10; + g_input_box[--g_input_box_index] = 10; - gRequestDisplayScreen = DISPLAY_AIRCOPY; + g_request_display_screen = DISPLAY_AIRCOPY; } } -static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_MENU(bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - gFSKWriteIndex = 0; - gAirCopyBlockNumber = 0; - gInputBoxIndex = 0; - gAirCopyIsSendMode = 1; - g_FSK_Buffer[0] = 0xABCD; - g_FSK_Buffer[1] = 0; - g_FSK_Buffer[35] = 0xDCBA; + g_fsk_wite_index = 0; + g_air_copy_block_number = 0; + g_input_box_index = 0; + g_air_copy_is_send_mode = 1; + g_fsk_buffer[0] = 0xABCD; + g_fsk_buffer[1] = 0; + g_fsk_buffer[35] = 0xDCBA; AIRCOPY_SendMessage(); GUI_DisplayScreen(); - gAircopyState = AIRCOPY_TRANSFER; + g_aircopy_state = AIRCOPY_TRANSFER; } } -void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +void AIRCOPY_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held) { switch (Key) { @@ -216,13 +216,13 @@ void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) case KEY_7: case KEY_8: case KEY_9: - AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + AIRCOPY_Key_DIGITS(Key, key_pressed, key_held); break; case KEY_MENU: - AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld); + AIRCOPY_Key_MENU(key_pressed, key_held); break; case KEY_EXIT: - AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld); + AIRCOPY_Key_EXIT(key_pressed, key_held); break; default: break; diff --git a/app/app.c b/app/app.c index e5b52a9b..504d87c3 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 key_pressed, bool key_held); static void updateRSSI(const int vfo) { @@ -77,54 +77,54 @@ static void updateRSSI(const int vfo) #ifdef ENABLE_AM_FIX // add RF gain adjust compensation - if (g_eeprom.VfoInfo[vfo].am_mode && gSetting_AM_fix) + if (g_eeprom.vfo_info[vfo].am_mode && g_setting_am_fix) rssi -= rssi_gain_diff[vfo]; #endif - if (gCurrentRSSI[vfo] == rssi) + if (g_current_rssi[vfo] == rssi) return; // no change - gCurrentRSSI[vfo] = rssi; + g_current_rssi[vfo] = rssi; UI_UpdateRSSI(rssi, vfo); } static void APP_CheckForIncoming(void) { - if (!g_SquelchLost) + if (!g_squelch_lost) return; // squelch is closed // squelch is open - if (gScanStateDir == SCAN_OFF) + if (g_scan_state_dir == SCAN_OFF) { // not RF scanning - if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE) + if (g_css_scan_mode != CSS_SCAN_MODE_OFF && g_rx_reception_mode == RX_MODE_NONE) { // CTCSS/DTS scanning - gScanPauseDelayIn_10ms = scan_pause_delay_in_5_10ms; - gScheduleScanListen = false; - gRxReceptionMode = RX_MODE_DETECTED; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_5_10ms; + g_schedule_scan_listen = false; + g_rx_reception_mode = RX_MODE_DETECTED; } if (g_eeprom.dual_watch == DUAL_WATCH_OFF) { // dual watch is disabled #ifdef ENABLE_NOAA - if (gIsNoaaMode) + if (g_is_noaa_mode) { - gNOAA_Countdown_10ms = NOAA_countdown_3_10ms; - gScheduleNOAA = false; + g_noaa_count_down_10ms = noaa_count_down_3_10ms; + g_schedule_noaa = false; } #endif - if (gCurrentFunction != FUNCTION_INCOMING) + if (g_current_function != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); - //gUpdateDisplay = true; + //g_update_display = true; updateRSSI(g_eeprom.rx_vfo); - gUpdateRSSI = true; + g_update_rssi = true; } return; @@ -132,127 +132,127 @@ static void APP_CheckForIncoming(void) // dual watch is enabled and we're RX'ing a signal - if (gRxReceptionMode != RX_MODE_NONE) + if (g_rx_reception_mode != RX_MODE_NONE) { - if (gCurrentFunction != FUNCTION_INCOMING) + if (g_current_function != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); - //gUpdateDisplay = true; + //g_update_display = true; updateRSSI(g_eeprom.rx_vfo); - gUpdateRSSI = true; + g_update_rssi = true; } return; } - gDualWatchCountdown_10ms = dual_watch_count_after_rx_10ms; - gScheduleDualWatch = false; + g_dual_watch_count_down_10ms = dual_watch_count_after_rx_10ms; + g_schedule_dual_watch = false; // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; } else { // RF scanning - if (gRxReceptionMode != RX_MODE_NONE) + if (g_rx_reception_mode != RX_MODE_NONE) { - if (gCurrentFunction != FUNCTION_INCOMING) + if (g_current_function != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); - //gUpdateDisplay = true; + //g_update_display = true; updateRSSI(g_eeprom.rx_vfo); - gUpdateRSSI = true; + g_update_rssi = true; } return; } - gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_3_10ms; + g_schedule_scan_listen = false; } - gRxReceptionMode = RX_MODE_DETECTED; + g_rx_reception_mode = RX_MODE_DETECTED; - if (gCurrentFunction != FUNCTION_INCOMING) + if (g_current_function != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); - //gUpdateDisplay = true; + //g_update_display = true; updateRSSI(g_eeprom.rx_vfo); - gUpdateRSSI = true; + g_update_rssi = true; } } static void APP_HandleIncoming(void) { - bool bFlag; + bool flag; - if (!g_SquelchLost) + if (!g_squelch_lost) { // squelch is closed - if (gDTMF_RX_index > 0) + if (g_dtmf_rx_index > 0) DTMF_clear_RX(); - if (gCurrentFunction != FUNCTION_FOREGROUND) + if (g_current_function != FUNCTION_FOREGROUND) { FUNCTION_Select(FUNCTION_FOREGROUND); - gUpdateDisplay = true; + g_update_display = true; } return; } - bFlag = (gScanStateDir == SCAN_OFF && gCurrentcode_type == CODE_TYPE_OFF); + flag = (g_scan_state_dir == SCAN_OFF && g_current_code_type == CODE_TYPE_OFF); #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->channel_save) && gNOAACountdown_10ms > 0) + if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_count_down_10ms > 0) { - gNOAACountdown_10ms = 0; - bFlag = true; + g_noaa_count_down_10ms = 0; + flag = true; } #endif - if (g_CTCSS_lost && gCurrentcode_type == CODE_TYPE_CONTINUOUS_TONE) + if (g_CTCSS_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE) { - bFlag = true; - gFoundCTCSS = false; + flag = true; + g_found_CTCSS = false; } - if (g_CDCSS_lost && g_CDCSS_code_type == CDCSS_POSITIVE_CODE && (gCurrentcode_type == CODE_TYPE_DIGITAL || gCurrentcode_type == CODE_TYPE_REVERSE_DIGITAL)) + if (g_CDCSS_lost && g_CDCSS_code_type == CDCSS_POSITIVE_CODE && (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL)) { - gFoundCDCSS = false; + g_found_CDCSS = false; } else - if (!bFlag) + if (!flag) return; - if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF) { // not scanning - if (gRxVfo->DTMF_decoding_enable || gSetting_KILLED) + if (g_rx_vfo->dtmf_decoding_enable || g_setting_killed) { // DTMF DCD is enabled DTMF_HandleRequest(); - if (gDTMF_CallState == DTMF_CALL_STATE_NONE) + if (g_dtmf_call_state == DTMF_CALL_STATE_NONE) { - if (gRxReceptionMode == RX_MODE_DETECTED) + if (g_rx_reception_mode == RX_MODE_DETECTED) { - gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms; - gScheduleDualWatch = false; + g_dual_watch_count_down_10ms = dual_watch_count_after_1_10ms; + g_schedule_dual_watch = false; - gRxReceptionMode = RX_MODE_LISTENING; + g_rx_reception_mode = RX_MODE_LISTENING; // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; - gUpdateDisplay = true; + g_update_display = true; return; } } } } - APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false); + APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false); } static void APP_HandleReceive(void) @@ -263,32 +263,32 @@ static void APP_HandleReceive(void) uint8_t Mode = END_OF_RX_MODE_SKIP; - if (gFlagTailNoteEliminationComplete) + if (g_flag_tail_tone_elimination_complete) { Mode = END_OF_RX_MODE_END; goto Skip; } - if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextChannel)) + if (g_scan_state_dir != SCAN_OFF && IS_FREQ_CHANNEL(g_next_channel)) { - if (g_SquelchLost) + if (g_squelch_lost) return; Mode = END_OF_RX_MODE_END; goto Skip; } - switch (gCurrentcode_type) + switch (g_current_code_type) { default: case CODE_TYPE_OFF: break; case CODE_TYPE_CONTINUOUS_TONE: - if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) + if (g_found_CTCSS && g_found_CTCSS_count_down_10ms == 0) { - gFoundCTCSS = false; - gFoundCDCSS = false; + g_found_CTCSS = false; + g_found_CDCSS = false; Mode = END_OF_RX_MODE_END; goto Skip; } @@ -296,33 +296,33 @@ static void APP_HandleReceive(void) case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0) + if (g_found_CDCSS && g_found_CDCSS_count_down_10ms == 0) { - gFoundCTCSS = false; - gFoundCDCSS = false; + g_found_CTCSS = false; + g_found_CDCSS = false; Mode = END_OF_RX_MODE_END; goto Skip; } break; } - if (g_SquelchLost) + if (g_squelch_lost) { #ifdef ENABLE_NOAA - if (!gEndOfRxDetectedMaybe && IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) + if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) #else - if (!gEndOfRxDetectedMaybe) + if (!g_end_of_rx_detected_maybe) #endif { - switch (gCurrentcode_type) + switch (g_current_code_type) { case CODE_TYPE_OFF: if (g_eeprom.squelch_level) { - if (g_CxCSS_tailL_found) + if (g_CxCSS_tail_found) { Mode = END_OF_RX_MODE_TTE; - g_CxCSS_tailL_found = false; + g_CxCSS_tail_found = false; } } break; @@ -330,19 +330,19 @@ static void APP_HandleReceive(void) case CODE_TYPE_CONTINUOUS_TONE: if (g_CTCSS_lost) { - gFoundCTCSS = false; + g_found_CTCSS = false; } else - if (!gFoundCTCSS) + if (!g_found_CTCSS) { - gFoundCTCSS = true; - gFoundCTCSSCountdown_10ms = 100; // 1 sec + g_found_CTCSS = true; + g_found_CTCSS_count_down_10ms = 100; // 1 sec } - if (g_CxCSS_tailL_found) + if (g_CxCSS_tail_found) { Mode = END_OF_RX_MODE_TTE; - g_CxCSS_tailL_found = false; + g_CxCSS_tail_found = false; } break; @@ -350,21 +350,21 @@ static void APP_HandleReceive(void) case CODE_TYPE_REVERSE_DIGITAL: if (g_CDCSS_lost && g_CDCSS_code_type == CDCSS_POSITIVE_CODE) { - gFoundCDCSS = false; + g_found_CDCSS = false; } else - if (!gFoundCDCSS) + if (!g_found_CDCSS) { - gFoundCDCSS = true; - gFoundCDCSSCountdown_10ms = 100; // 1 sec + g_found_CDCSS = true; + g_found_CDCSS_count_down_10ms = 100; // 1 sec } - if (g_CxCSS_tailL_found) + if (g_CxCSS_tail_found) { if (BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; - g_CxCSS_tailL_found = false; + g_CxCSS_tail_found = false; } break; @@ -374,15 +374,15 @@ static void APP_HandleReceive(void) else Mode = END_OF_RX_MODE_END; - if (!gEndOfRxDetectedMaybe && + if (!g_end_of_rx_detected_maybe && Mode == END_OF_RX_MODE_SKIP && - gNextTimeslice40ms && + g_next_time_slice_40ms && g_eeprom.tail_note_elimination && - (gCurrentcode_type == CODE_TYPE_DIGITAL || gCurrentcode_type == CODE_TYPE_REVERSE_DIGITAL) && + (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) && BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; else - gNextTimeslice40ms = false; + g_next_time_slice_40ms = false; Skip: switch (Mode) @@ -394,13 +394,13 @@ static void APP_HandleReceive(void) RADIO_SetupRegisters(true); #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->channel_save)) - gNOAACountdown_10ms = 300; // 3 sec + if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save)) + g_noaa_count_down_10ms = 300; // 3 sec #endif - gUpdateDisplay = true; + g_update_display = true; - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { switch (g_eeprom.scan_resume_mode) { @@ -408,8 +408,8 @@ static void APP_HandleReceive(void) break; case SCAN_RESUME_CO: - gScanPauseDelayIn_10ms = scan_pause_delay_in_7_10ms; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_7_10ms; + g_schedule_scan_listen = false; break; case SCAN_RESUME_SE: @@ -425,10 +425,10 @@ static void APP_HandleReceive(void) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gTailNoteEliminationCountdown_10ms = 20; - gFlagTailNoteEliminationComplete = false; - gEndOfRxDetectedMaybe = true; - gEnableSpeaker = false; + g_tail_tone_elimination_count_down_10ms = 20; + g_flag_tail_tone_elimination_complete = false; + g_end_of_rx_detected_maybe = true; + g_enable_speaker = false; } break; } @@ -436,7 +436,7 @@ static void APP_HandleReceive(void) static void APP_HandleFunction(void) { - switch (gCurrentFunction) + switch (g_current_function) { case FUNCTION_FOREGROUND: APP_CheckForIncoming(); @@ -466,46 +466,46 @@ static void APP_HandleFunction(void) } } -void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) +void APP_StartListening(function_type_t Function, const bool reset_am_fix) { const unsigned int chan = g_eeprom.rx_vfo; -// const unsigned int chan = gRxVfo->channel_save; +// const unsigned int chan = g_rx_vfo->channel_save; - if (gSetting_KILLED) + if (g_setting_killed) return; #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Init(0, false); #endif // clear the other vfo's rssi level (to hide the antenna symbol) - gVFO_RSSI_bar_level[(chan + 1) & 1u] = 0; + g_vfo_rssi_bar_level[(chan + 1) & 1u] = 0; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; + g_enable_speaker = true; - if (gSetting_backlight_on_tx_rx >= 2) + if (g_setting_backlight_on_tx_rx >= 2) backlight_turn_on(); - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { switch (g_eeprom.scan_resume_mode) { case SCAN_RESUME_TO: if (!gScanPauseMode) { - gScanPauseDelayIn_10ms = scan_pause_delay_in_1_10ms; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_1_10ms; + g_schedule_scan_listen = false; gScanPauseMode = true; } break; case SCAN_RESUME_CO: case SCAN_RESUME_SE: - gScanPauseDelayIn_10ms = 0; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = 0; + g_schedule_scan_listen = false; break; } @@ -513,34 +513,34 @@ 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(g_rx_vfo->channel_save) && g_is_noaa_mode) { - 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; + g_rx_vfo->channel_save = g_noaa_channel + NOAA_CHANNEL_FIRST; + g_rx_vfo->pRX->frequency = NoaaFrequencyTable[g_noaa_channel]; + g_rx_vfo->pTX->frequency = NoaaFrequencyTable[g_noaa_channel]; + g_eeprom.screen_channel[chan] = g_rx_vfo->channel_save; - gNOAA_Countdown_10ms = 500; // 5 sec - gScheduleNOAA = false; + g_noaa_count_down_10ms = 500; // 5 sec + g_schedule_noaa = false; } #endif - if (gCssScanMode != CSS_SCAN_MODE_OFF) - gCssScanMode = CSS_SCAN_MODE_FOUND; + if (g_css_scan_mode != CSS_SCAN_MODE_OFF) + g_css_scan_mode = CSS_SCAN_MODE_FOUND; - if (gScanStateDir == SCAN_OFF && - gCssScanMode == CSS_SCAN_MODE_OFF && + if (g_scan_state_dir == SCAN_OFF && + g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF) { // not scanning, dual watch is enabled - gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms; - gScheduleDualWatch = false; + g_dual_watch_count_down_10ms = dual_watch_count_after_2_10ms; + g_schedule_dual_watch = false; - gRxVfoIsActive = true; + g_rx_vfo_is_active = true; // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; } { // RF RX front end gain @@ -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 (g_rx_vfo->am_mode && g_setting_am_fix) { // AM RX mode if (reset_am_fix) AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency @@ -577,32 +577,32 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) #ifdef ENABLE_VOICE 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(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now FUNCTION_Select(Function); #ifdef ENABLE_FMRADIO - if (Function == FUNCTION_MONITOR || gFmRadioMode) + if (Function == FUNCTION_MONITOR || g_fm_radio_mode) #else if (Function == FUNCTION_MONITOR) #endif { // squelch is disabled - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu GUI_SelectNextDisplay(DISPLAY_MAIN); } else - gUpdateDisplay = true; + g_update_display = true; - gUpdateStatus = true; + g_update_status = true; } -uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) +uint32_t APP_SetFrequencyByStep(vfo_info_t *pInfo, int8_t Step) { uint32_t Frequency = pInfo->freq_config_rx.frequency + (Step * pInfo->step_freq); if (pInfo->step_freq == 833) { - const uint32_t Lower = frequencyBandTable[pInfo->band].lower; + const uint32_t Lower = FREQ_BAND_TABLE[pInfo->band].lower; const uint32_t Delta = Frequency - Lower; uint32_t Base = (Delta / 2500) * 2500; const uint32_t Index = ((Delta - Base) % 2500) / 833; @@ -613,31 +613,31 @@ 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 >= FREQ_BAND_TABLE[pInfo->band].upper) + Frequency = FREQ_BAND_TABLE[pInfo->band].lower; else - if (Frequency < frequencyBandTable[pInfo->band].lower) - Frequency = FREQUENCY_FloorToStep(frequencyBandTable[pInfo->band].upper, pInfo->step_freq, frequencyBandTable[pInfo->band].lower); + if (Frequency < FREQ_BAND_TABLE[pInfo->band].lower) + Frequency = FREQUENCY_FloorToStep(FREQ_BAND_TABLE[pInfo->band].upper, pInfo->step_freq, FREQ_BAND_TABLE[pInfo->band].lower); return Frequency; } static void FREQ_NextChannel(void) { - gRxVfo->freq_config_rx.frequency = APP_SetFrequencyByStep(gRxVfo, gScanStateDir); + g_rx_vfo->freq_config_rx.frequency = APP_SetFrequencyByStep(g_rx_vfo, g_scan_state_dir); - RADIO_ApplyOffset(gRxVfo); - RADIO_ConfigureSquelchAndOutputPower(gRxVfo); + RADIO_ApplyOffset(g_rx_vfo); + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); RADIO_SetupRegisters(true); #ifdef ENABLE_FASTER_CHANNEL_SCAN - gScanPauseDelayIn_10ms = 9; // 90ms + g_scan_pause_delay_in_10ms = 9; // 90ms #else - gScanPauseDelayIn_10ms = scan_pause_delay_in_6_10ms; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_6_10ms; #endif bScanKeepFrequency = false; - gUpdateDisplay = true; + g_update_display = true; } static void USER_NextChannel(void) @@ -646,7 +646,7 @@ static void USER_NextChannel(void) 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; + const unsigned int prev_chan = g_next_channel; unsigned int chan = 0; if (enabled) @@ -654,17 +654,17 @@ static void USER_NextChannel(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gCurrentScanList) + switch (g_current_scan_list) { case SCAN_NEXT_CHAN_SCANLIST1: - prevChannel = gNextChannel; + prevChannel = g_next_channel; if (chan1 >= 0) { if (RADIO_CheckValidChannel(chan1, false, 0)) { - gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; - gNextChannel = chan1; + g_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; + g_next_channel = chan1; break; } } @@ -674,14 +674,14 @@ static void USER_NextChannel(void) { if (RADIO_CheckValidChannel(chan2, false, 0)) { - gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST2; - gNextChannel = chan2; + g_current_scan_list = SCAN_NEXT_CHAN_SCANLIST2; + g_next_channel = 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 (g_eeprom.dual_watch != DUAL_WATCH_OFF) // { @@ -689,16 +689,16 @@ static void USER_NextChannel(void) // chan = g_eeprom.screen_channel[chan]; // if (chan <= USER_CHANNEL_LAST) // { -// gCurrentScanList = SCAN_NEXT_CHAN_dual_watch; -// gNextChannel = chan; +// g_current_scan_list = SCAN_NEXT_CHAN_DUAL_WATCH; +// g_next_channel = chan; // break; // } // } default: case SCAN_NEXT_CHAN_USER: - gCurrentScanList = SCAN_NEXT_CHAN_USER; - gNextChannel = prevChannel; + g_current_scan_list = SCAN_NEXT_CHAN_USER; + g_next_channel = prevChannel; chan = 0xff; break; } @@ -708,7 +708,7 @@ static void USER_NextChannel(void) if (!enabled || chan == 0xff) { - chan = RADIO_FindNextChannel(gNextChannel + gScanStateDir, gScanStateDir, (g_eeprom.scan_list_default < 2) ? true : false, g_eeprom.scan_list_default); + chan = RADIO_FindNextChannel(g_next_channel + g_scan_state_dir, g_scan_state_dir, (g_eeprom.scan_list_default < 2) ? true : false, g_eeprom.scan_list_default); if (chan == 0xFF) { // no valid channel found @@ -716,81 +716,81 @@ static void USER_NextChannel(void) // return; } - gNextChannel = chan; + g_next_channel = chan; } - if (gNextChannel != prev_chan) + if (g_next_channel != prev_chan) { - g_eeprom.user_channel[g_eeprom.rx_vfo] = gNextChannel; - g_eeprom.screen_channel[g_eeprom.rx_vfo] = gNextChannel; + g_eeprom.user_channel[g_eeprom.rx_vfo] = g_next_channel; + g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_next_channel; RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD); RADIO_SetupRegisters(true); - gUpdateDisplay = true; + g_update_display = true; } #ifdef ENABLE_FASTER_CHANNEL_SCAN - gScanPauseDelayIn_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ? + g_scan_pause_delay_in_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ? #else - gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_3_10ms; #endif bScanKeepFrequency = false; if (enabled) - if (++gCurrentScanList >= SCAN_NEXT_NUM) - gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; // back round we go + if (++g_current_scan_list >= SCAN_NEXT_NUM) + g_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; // back round we go } #ifdef ENABLE_NOAA static void NOAA_IncreaseChannel(void) { - if (++gNoaaChannel > 9) - gNoaaChannel = 0; + if (++g_noaa_channel > 9) + g_noaa_channel = 0; } #endif static void DUALWATCH_Alternate(void) { #ifdef ENABLE_NOAA - if (gIsNoaaMode) + if (g_is_noaa_mode) { 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 g_eeprom.rx_vfo = 0; - gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; + g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.rx_vfo]; - if (g_eeprom.VfoInfo[0].channel_save >= NOAA_CHANNEL_FIRST) + if (g_eeprom.vfo_info[0].channel_save >= NOAA_CHANNEL_FIRST) NOAA_IncreaseChannel(); } else #endif { // toggle between VFO's g_eeprom.rx_vfo = (g_eeprom.rx_vfo + 1) & 1; - gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; + g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.rx_vfo]; - if (!gDualWatchActive) + if (!g_dual_watch_active) { // let the user see DW is active - gDualWatchActive = true; - gUpdateStatus = true; + g_dual_watch_active = true; + g_update_status = true; } } RADIO_SetupRegisters(false); #ifdef ENABLE_NOAA - gDualWatchCountdown_10ms = gIsNoaaMode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms; + g_dual_watch_count_down_10ms = g_is_noaa_mode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms; #else - gDualWatchCountdown_10ms = dual_watch_count_toggle_10ms; + g_dual_watch_count_down_10ms = dual_watch_count_toggle_10ms; #endif } void APP_CheckRadioInterrupts(void) { - if (gScreenToDisplay == DISPLAY_SCANNER) + if (g_screen_to_display == DISPLAY_SCANNER) return; while (BK4819_ReadRegister(BK4819_REG_0C) & 1u) @@ -817,33 +817,33 @@ void APP_CheckRadioInterrupts(void) const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); if (c != 0xff) { - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) { - if (gSetting_live_DTMF_decoder) + if (g_setting_live_dtmf_decoder) { - size_t len = strlen(gDTMF_RX_live); - if (len >= (sizeof(gDTMF_RX_live) - 1)) + size_t len = strlen(g_dtmf_rx_live); + if (len >= (sizeof(g_dtmf_rx_live) - 1)) { // make room - memmove(&gDTMF_RX_live[0], &gDTMF_RX_live[1], sizeof(gDTMF_RX_live) - 1); + memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1); len--; } - gDTMF_RX_live[len++] = c; - gDTMF_RX_live[len] = 0; - gDTMF_RX_live_timeout = DTMF_RX_live_timeout_500ms; // time till we delete it - gUpdateDisplay = true; + g_dtmf_rx_live[len++] = c; + g_dtmf_rx_live[len] = 0; + g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it + g_update_display = true; } - if (gRxVfo->DTMF_decoding_enable || gSetting_KILLED) + if (g_rx_vfo->dtmf_decoding_enable || g_setting_killed) { - if (gDTMF_RX_index >= (sizeof(gDTMF_RX) - 1)) + if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1)) { // make room - memmove(&gDTMF_RX[0], &gDTMF_RX[1], sizeof(gDTMF_RX) - 1); - gDTMF_RX_index--; + memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1); + g_dtmf_rx_index--; } - gDTMF_RX[gDTMF_RX_index++] = c; - gDTMF_RX[gDTMF_RX_index] = 0; - gDTMF_RX_timeout = DTMF_RX_timeout_500ms; // time till we delete it - gDTMF_RX_pending = true; + g_dtmf_rx[g_dtmf_rx_index++] = c; + g_dtmf_rx[g_dtmf_rx_index] = 0; + g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it + g_dtmf_rx_pending = true; DTMF_HandleRequest(); } @@ -852,7 +852,7 @@ void APP_CheckRadioInterrupts(void) } if (interrupt_status_bits & BK4819_REG_02_CxCSS_TAIL) - g_CxCSS_tailL_found = true; + g_CxCSS_tail_found = true; if (interrupt_status_bits & BK4819_REG_02_CDCSS_LOST) { @@ -877,20 +877,20 @@ void APP_CheckRadioInterrupts(void) if (g_eeprom.vox_switch) { - if (gCurrentFunction == FUNCTION_POWER_SAVE && !g_rx_idle_mode) + if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode) { - gPowerSave_10ms = power_save2_10ms; - gPowerSaveCountdownExpired = 0; + g_power_save_10ms = power_save2_10ms; + g_power_save_count_down_expired = 0; } - if (g_eeprom.dual_watch != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) + if (g_eeprom.dual_watch != DUAL_WATCH_OFF && (g_schedule_dual_watch || g_dual_watch_count_down_10ms < dual_watch_count_after_vox_10ms)) { - gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms; - gScheduleDualWatch = false; + g_dual_watch_count_down_10ms = dual_watch_count_after_vox_10ms; + g_schedule_dual_watch = false; // let the user see DW is not active - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; } } } @@ -904,25 +904,25 @@ void APP_CheckRadioInterrupts(void) if (interrupt_status_bits & BK4819_REG_02_SQUELCH_LOST) { - g_SquelchLost = true; + g_squelch_lost = true; BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, true); } if (interrupt_status_bits & BK4819_REG_02_SQUELCH_FOUND) { - g_SquelchLost = false; + g_squelch_lost = false; BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); } #ifdef ENABLE_AIRCOPY if (interrupt_status_bits & BK4819_REG_02_FSK_FIFO_ALMOST_FULL && - gScreenToDisplay == DISPLAY_AIRCOPY && - gAircopyState == AIRCOPY_TRANSFER && - gAirCopyIsSendMode == 0) + g_screen_to_display == DISPLAY_AIRCOPY && + g_aircopy_state == AIRCOPY_TRANSFER && + g_air_copy_is_send_mode == 0) { unsigned int i; for (i = 0; i < 4; i++) - g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F); + g_fsk_buffer[g_fsk_wite_index++] = BK4819_ReadRegister(BK4819_REG_5F); AIRCOPY_StorePacket(); } #endif @@ -934,7 +934,7 @@ void APP_EndTransmission(void) RADIO_SendEndOfTransmission(); - if (gCurrentVfo->pTX->code_type != CODE_TYPE_OFF) + if (g_current_vfo->pTX->code_type != CODE_TYPE_OFF) { // CTCSS/DCS is enabled //if (g_eeprom.tail_note_elimination && g_eeprom.repeater_tail_tone_elimination > 0) @@ -958,10 +958,10 @@ void APP_EndTransmission(void) #ifdef ENABLE_VOX static void APP_HandleVox(void) { - if (gSetting_KILLED) + if (g_setting_killed) return; - if (gVoxResumeCountdown == 0) + if (g_vox_resume_count_down == 0) { if (g_vox_pause_count_down) return; @@ -973,29 +973,29 @@ void APP_EndTransmission(void) } #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) return; #endif - if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) + if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR) return; - if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF) return; - if (gVOX_NoiseDetected) + if (g_vox_noise_detected) { if (g_vox_lost) - gVoxStopCountdown_10ms = vox_stop_count_down_10ms; + g_vox_stop_count_down_10ms = vox_stop_count_down_10ms; else - if (gVoxStopCountdown_10ms == 0) - gVOX_NoiseDetected = false; + if (g_vox_stop_count_down_10ms == 0) + g_vox_noise_detected = false; - if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) + if (g_current_function == FUNCTION_TRANSMIT && !g_ptt_is_pressed && !g_vox_noise_detected) { - if (gFlagEndTransmission) + if (g_flag_end_tx) { - //if (gCurrentFunction != FUNCTION_FOREGROUND) + //if (g_current_function != FUNCTION_FOREGROUND) FUNCTION_Select(FUNCTION_FOREGROUND); } else @@ -1004,32 +1004,32 @@ void APP_EndTransmission(void) if (g_eeprom.repeater_tail_tone_elimination == 0) { - //if (gCurrentFunction != FUNCTION_FOREGROUND) + //if (g_current_function != FUNCTION_FOREGROUND) FUNCTION_Select(FUNCTION_FOREGROUND); } else - gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; + g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10; } - gUpdateStatus = true; - gUpdateDisplay = true; - gFlagEndTransmission = false; + g_update_status = true; + g_update_display = true; + g_flag_end_tx = false; } return; } if (g_vox_lost) { - gVOX_NoiseDetected = true; + g_vox_noise_detected = true; - if (gCurrentFunction == FUNCTION_POWER_SAVE) + if (g_current_function == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0) + if (g_current_function != FUNCTION_TRANSMIT && g_serial_config_count_down_500ms == 0) { - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_reply_state = DTMF_REPLY_NONE; RADIO_PrepareTX(); - gUpdateDisplay = true; + g_update_display = true; } } } @@ -1045,126 +1045,126 @@ void APP_Update(void) } #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimeoutReached || gSerialConfigCountDown_500ms > 0)) + if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timeout_reached || g_serial_config_count_down_500ms > 0)) { // transmitter timed out or must de-key - gTxTimeoutReached = false; + g_tx_timeout_reached = false; - gFlagEndTransmission = true; + g_flag_end_tx = true; APP_EndTransmission(); AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP); - RADIO_SetVfoState(VFO_STATE_TIMEOUT); + RADIO_Setg_vfo_state(VFO_STATE_TIMEOUT); GUI_DisplayScreen(); } - if (gReducedService) + if (g_reduced_service) return; - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) APP_HandleFunction(); #ifdef ENABLE_FMRADIO -// if (gFmRadioCountdown_500ms > 0) - if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 +// if (g_fm_radio_count_down_500ms > 0) + if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) // 1of11 return; #endif #ifdef ENABLE_VOICE - if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed && g_voice_write_index == 0) + if (g_screen_to_display != DISPLAY_SCANNER && g_scan_state_dir != SCAN_OFF && g_schedule_scan_listen && !g_ptt_is_pressed && g_voice_write_index == 0) #else - if (gScreenToDisplay != DISPLAY_SCANNER && gScanStateDir != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) + if (g_screen_to_display != DISPLAY_SCANNER && g_scan_state_dir != SCAN_OFF && g_schedule_scan_listen && !g_ptt_is_pressed) #endif { // scanning - if (IS_FREQ_CHANNEL(gNextChannel)) + if (IS_FREQ_CHANNEL(g_next_channel)) { - if (gCurrentFunction == FUNCTION_INCOMING) - APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + if (g_current_function == FUNCTION_INCOMING) + APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); else FREQ_NextChannel(); // switch to next frequency } else { - if (gCurrentcode_type == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING) - APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + if (g_current_code_type == CODE_TYPE_OFF && g_current_function == FUNCTION_INCOMING) + APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); else USER_NextChannel(); // switch to next channel } gScanPauseMode = false; - gRxReceptionMode = RX_MODE_NONE; - gScheduleScanListen = false; + g_rx_reception_mode = RX_MODE_NONE; + g_schedule_scan_listen = false; } #ifdef ENABLE_VOICE - if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen && g_voice_write_index == 0) + if (g_css_scan_mode == CSS_SCAN_MODE_SCANNING && g_schedule_scan_listen && g_voice_write_index == 0) #else - if (gCssScanMode == CSS_SCAN_MODE_SCANNING && gScheduleScanListen) + if (g_css_scan_mode == CSS_SCAN_MODE_SCANNING && g_schedule_scan_listen) #endif { MENU_SelectNextCode(); - gScheduleScanListen = false; + g_schedule_scan_listen = false; } #ifdef ENABLE_NOAA #ifdef ENABLE_VOICE - if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && g_voice_write_index == 0) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa && g_voice_write_index == 0) #else - if (g_eeprom.dual_watch == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa) #endif { NOAA_IncreaseChannel(); RADIO_SetupRegisters(false); - gNOAA_Countdown_10ms = 7; // 70ms - gScheduleNOAA = false; + g_noaa_count_down_10ms = 7; // 70ms + g_schedule_noaa = false; } #endif // toggle between the VFO's if dual watch is enabled - if (gScreenToDisplay != DISPLAY_SCANNER && g_eeprom.dual_watch != DUAL_WATCH_OFF) + if (g_screen_to_display != DISPLAY_SCANNER && g_eeprom.dual_watch != DUAL_WATCH_OFF) { #ifdef ENABLE_VOICE - if (gScheduleDualWatch && g_voice_write_index == 0) + if (g_schedule_dual_watch && g_voice_write_index == 0) #else - if (gScheduleDualWatch) + if (g_schedule_dual_watch) #endif { - if (gScanStateDir == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF) { - if (!gPttIsPressed && + if (!g_ptt_is_pressed && #ifdef ENABLE_FMRADIO - !gFmRadioMode && + !g_fm_radio_mode && #endif - gDTMF_CallState == DTMF_CALL_STATE_NONE && - gCurrentFunction != FUNCTION_POWER_SAVE) + g_dtmf_call_state == DTMF_CALL_STATE_NONE && + g_current_function != FUNCTION_POWER_SAVE) { DUALWATCH_Alternate(); // toggle between the two VFO's - if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) + if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN) GUI_SelectNextDisplay(DISPLAY_MAIN); - gRxVfoIsActive = false; + g_rx_vfo_is_active = false; gScanPauseMode = false; - gRxReceptionMode = RX_MODE_NONE; - gScheduleDualWatch = false; + g_rx_reception_mode = RX_MODE_NONE; + g_schedule_dual_watch = false; } } } } #ifdef ENABLE_FMRADIO - if (gScheduleFM && - gFM_ScanState != FM_SCAN_OFF && - gCurrentFunction != FUNCTION_MONITOR && - gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_TRANSMIT) + if (g_schedule_fm && + g_fm_scan_state != FM_SCAN_OFF && + g_current_function != FUNCTION_MONITOR && + g_current_function != FUNCTION_RECEIVE && + g_current_function != FUNCTION_TRANSMIT) { // switch to FM radio mode FM_Play(); - gScheduleFM = false; + g_schedule_fm = false; } #endif @@ -1173,62 +1173,62 @@ void APP_Update(void) APP_HandleVox(); #endif - if (gSchedulePowerSave) + if (g_schedule_power_save) { #ifdef ENABLE_NOAA if ( #ifdef ENABLE_FMRADIO - gFmRadioMode || + g_fm_radio_mode || #endif - gPttIsPressed || - gKeyBeingHeld || + g_ptt_is_pressed || + g_key_being_held || g_eeprom.battery_save == 0 || - gScanStateDir != SCAN_OFF || - gCssScanMode != CSS_SCAN_MODE_OFF || - gScreenToDisplay != DISPLAY_MAIN || - gDTMF_CallState != DTMF_CALL_STATE_NONE) + g_scan_state_dir != SCAN_OFF || + g_css_scan_mode != CSS_SCAN_MODE_OFF || + g_screen_to_display != DISPLAY_MAIN || + g_dtmf_call_state != DTMF_CALL_STATE_NONE) { - gBatterySaveCountdown_10ms = battery_save_count_10ms; + g_battery_save_count_down_10ms = battery_save_count_10ms; } else - if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) && IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) || !gIsNoaaMode) + if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) && IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) || !g_is_noaa_mode) { - //if (gCurrentFunction != FUNCTION_POWER_SAVE) + //if (g_current_function != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE); } else { - gBatterySaveCountdown_10ms = battery_save_count_10ms; + g_battery_save_count_down_10ms = battery_save_count_10ms; } #else if ( #ifdef ENABLE_FMRADIO - gFmRadioMode || + g_fm_radio_mode || #endif - gPttIsPressed || - gKeyBeingHeld || + g_ptt_is_pressed || + g_key_being_held || g_eeprom.battery_save == 0 || - gScanStateDir != SCAN_OFF || - gCssScanMode != CSS_SCAN_MODE_OFF || - gScreenToDisplay != DISPLAY_MAIN || - gDTMF_CallState != DTMF_CALL_STATE_NONE) + g_scan_state_dir != SCAN_OFF || + g_css_scan_mode != CSS_SCAN_MODE_OFF || + g_screen_to_display != DISPLAY_MAIN || + g_dtmf_call_state != DTMF_CALL_STATE_NONE) { - gBatterySaveCountdown_10ms = battery_save_count_10ms; + g_battery_save_count_down_10ms = battery_save_count_10ms; } else { - //if (gCurrentFunction != FUNCTION_POWER_SAVE) + //if (g_current_function != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE); } - gSchedulePowerSave = false; + g_schedule_power_save = false; #endif } #ifdef ENABLE_VOICE - if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE && g_voice_write_index == 0) + if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE && g_voice_write_index == 0) #else - if (gPowerSaveCountdownExpired && gCurrentFunction == FUNCTION_POWER_SAVE) + if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE) #endif { // wake up, enable RX then go back to sleep @@ -1242,28 +1242,28 @@ void APP_Update(void) #endif if (g_eeprom.dual_watch != DUAL_WATCH_OFF && - gScanStateDir == SCAN_OFF && - gCssScanMode == CSS_SCAN_MODE_OFF) + g_scan_state_dir == SCAN_OFF && + g_css_scan_mode == CSS_SCAN_MODE_OFF) { // dual watch mode, toggle between the two VFO's DUALWATCH_Alternate(); - gUpdateRSSI = false; + g_update_rssi = false; } FUNCTION_Init(); - gPowerSave_10ms = power_save1_10ms; // come back here in a bit + g_power_save_10ms = power_save1_10ms; // come back here in a bit g_rx_idle_mode = false; // RX is awake } else - if (g_eeprom.dual_watch == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gUpdateRSSI) + if (g_eeprom.dual_watch == DUAL_WATCH_OFF || g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF || g_update_rssi) { // dual watch mode, go back to sleep updateRSSI(g_eeprom.rx_vfo); // go back to sleep - gPowerSave_10ms = g_eeprom.battery_save * 10; + g_power_save_10ms = g_eeprom.battery_save * 10; g_rx_idle_mode = true; BK4819_DisableVox(); @@ -1278,11 +1278,11 @@ void APP_Update(void) // toggle between the two VFO's DUALWATCH_Alternate(); - gUpdateRSSI = true; - gPowerSave_10ms = power_save1_10ms; + g_update_rssi = true; + g_power_save_10ms = power_save1_10ms; } - gPowerSaveCountdownExpired = false; + g_power_save_count_down_expired = false; } } @@ -1292,41 +1292,41 @@ void APP_CheckKeys(void) key_code_t Key; #ifdef ENABLE_AIRCOPY - if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY)) + if (g_setting_killed || (g_screen_to_display == DISPLAY_AIRCOPY && g_aircopy_state != AIRCOPY_READY)) return; #else - if (gSetting_KILLED) + if (g_setting_killed) return; #endif - if (gPttIsPressed) + if (g_ptt_is_pressed) { - if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || gSerialConfigCountDown_500ms > 0) + if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || g_serial_config_count_down_500ms > 0) { // PTT released or serial comms config in progress - if (++gPttDebounceCounter >= 3 || gSerialConfigCountDown_500ms > 0) // 30ms + if (++g_ptt_debounce_counter >= 3 || g_serial_config_count_down_500ms > 0) // 30ms { // stop transmitting APP_ProcessKey(KEY_PTT, false, false); - gPttIsPressed = false; + g_ptt_is_pressed = false; if (g_key_reading_1 != KEY_INVALID) - gPttWasReleased = true; + g_ptt_was_released = true; } } else - gPttDebounceCounter = 0; + g_ptt_debounce_counter = 0; } else - if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && gSerialConfigCountDown_500ms == 0) + if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && g_serial_config_count_down_500ms == 0) { // PTT pressed - if (++gPttDebounceCounter >= 3) // 30ms + if (++g_ptt_debounce_counter >= 3) // 30ms { // start transmitting - boot_counter_10ms = 0; // cancel the boot-up screen - gPttDebounceCounter = 0; - gPttIsPressed = true; + g_boot_counter_10ms = 0; // cancel the boot-up screen + g_ptt_debounce_counter = 0; + g_ptt_is_pressed = true; APP_ProcessKey(KEY_PTT, true, false); } } else - gPttDebounceCounter = 0; + g_ptt_debounce_counter = 0; // ***************** @@ -1338,17 +1338,17 @@ void APP_CheckKeys(void) // g_key_reading_0 = KEY_INVALID; // g_key_reading_1 = KEY_INVALID; // g_debounce_counter = 0; -// gKeyBeingHeld = false; +// g_key_being_held = false; // return; } - boot_counter_10ms = 0; // cancel boot screen/beeps + g_boot_counter_10ms = 0; // cancel boot screen/beeps if (g_key_reading_0 != Key) { // new key pressed if (g_key_reading_0 != KEY_INVALID && Key != KEY_INVALID) - APP_ProcessKey(g_key_reading_1, false, gKeyBeingHeld); // key pressed without releasing previous key + APP_ProcessKey(g_key_reading_1, false, g_key_being_held); // key pressed without releasing previous key g_key_reading_0 = Key; g_debounce_counter = 0; @@ -1362,7 +1362,7 @@ void APP_CheckKeys(void) { if (g_key_reading_1 != KEY_INVALID) { - APP_ProcessKey(g_key_reading_1, false, gKeyBeingHeld); + APP_ProcessKey(g_key_reading_1, false, g_key_being_held); g_key_reading_1 = KEY_INVALID; } } @@ -1372,7 +1372,7 @@ void APP_CheckKeys(void) APP_ProcessKey(Key, true, false); } - gKeyBeingHeld = false; + g_key_being_held = false; return; } @@ -1385,7 +1385,7 @@ void APP_CheckKeys(void) { // initial key repeat delay after pressed if (Key != KEY_PTT) { - gKeyBeingHeld = true; + g_key_being_held = true; APP_ProcessKey(Key, true, true); } } @@ -1393,7 +1393,7 @@ void APP_CheckKeys(void) { // key repeat if (Key == KEY_UP || Key == KEY_DOWN) { - gKeyBeingHeld = true; + g_key_being_held = true; if ((g_debounce_counter % key_repeat_10ms) == 0) APP_ProcessKey(Key, true, true); } @@ -1407,17 +1407,17 @@ void APP_CheckKeys(void) void APP_TimeSlice10ms(void) { - gFlashLightBlinkCounter++; + g_flash_light_bBlink_counter++; #ifdef ENABLE_BOOT_BEEPS - if (boot_counter_10ms > 0) - if ((boot_counter_10ms % 25) == 0) + if (g_boot_counter_10ms > 0) + if ((g_boot_counter_10ms % 25) == 0) AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); #endif #ifdef ENABLE_AM_FIX -// if (g_eeprom.VfoInfo[g_eeprom.rx_vfo].am_mode && gSetting_AM_fix) - if (gRxVfo->am_mode && gSetting_AM_fix) +// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix) + if (g_rx_vfo->am_mode && g_setting_am_fix) AM_fix_10ms(g_eeprom.rx_vfo); #endif @@ -1428,73 +1428,73 @@ void APP_TimeSlice10ms(void) __enable_irq(); } - if (gReducedService) + if (g_reduced_service) return; - if (gCurrentFunction != FUNCTION_POWER_SAVE || !g_rx_idle_mode) + if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode) APP_CheckRadioInterrupts(); - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { // transmitting #ifdef ENABLE_AUDIO_BAR - if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms + if (g_setting_mic_bar && (g_flash_light_bBlink_counter % (150 / 10)) == 0) // once every 150ms UI_DisplayAudioBar(); #endif } - if (gUpdateDisplay) + if (g_update_display) { - gUpdateDisplay = false; + g_update_display = false; GUI_DisplayScreen(); } - if (gUpdateStatus) + if (g_update_status) UI_DisplayStatus(false); // Skipping authentic device checks #ifdef ENABLE_FMRADIO - if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 + if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) // 1of11 return; #endif - if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) + if (g_flash_light_state == FLASHLIGHT_BLINK && (g_flash_light_bBlink_counter & 15u) == 0) GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); #ifdef ENABLE_VOX - if (gVoxResumeCountdown > 0) - gVoxResumeCountdown--; + if (g_vox_resume_count_down > 0) + g_vox_resume_count_down--; if (g_vox_pause_count_down > 0) g_vox_pause_count_down--; #endif - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_TXALARM || gAlarmState == ALARM_STATE_ALARM) + if (g_alarm_state == ALARM_STATE_TXALARM || g_alarm_state == ALARM_STATE_ALARM) { uint16_t Tone; - gAlarmRunningCounter++; - gAlarmToneCounter++; + g_alarm_running_counter++; + g_alarm_tone_counter++; - Tone = 500 + (gAlarmToneCounter * 25); + Tone = 500 + (g_alarm_tone_counter * 25); if (Tone > 1500) { Tone = 500; - gAlarmToneCounter = 0; + g_alarm_tone_counter = 0; } BK4819_SetScrambleFrequencyControlWord(Tone); - if (g_eeprom.alarm_mode == ALARM_MODE_TONE && gAlarmRunningCounter == 512) + if (g_eeprom.alarm_mode == ALARM_MODE_TONE && g_alarm_running_counter == 512) { - gAlarmRunningCounter = 0; + g_alarm_running_counter = 0; - if (gAlarmState == ALARM_STATE_TXALARM) + if (g_alarm_state == ALARM_STATE_TXALARM) { - gAlarmState = ALARM_STATE_ALARM; + g_alarm_state = ALARM_STATE_ALARM; RADIO_EnableCxCSS(); BK4819_SetupPowerAmplifier(0, 0); @@ -1506,7 +1506,7 @@ void APP_TimeSlice10ms(void) } else { - gAlarmState = ALARM_STATE_TXALARM; + g_alarm_state = ALARM_STATE_TXALARM; GUI_DisplayScreen(); @@ -1516,31 +1516,31 @@ void APP_TimeSlice10ms(void) SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; - gAlarmToneCounter = 0; + g_enable_speaker = true; + g_alarm_tone_counter = 0; } } } #endif // repeater tail tone elimination - if (gRTTECountdown > 0) + if (g_rtte_count_down > 0) { - if (--gRTTECountdown == 0) + if (--g_rtte_count_down == 0) { - //if (gCurrentFunction != FUNCTION_FOREGROUND) + //if (g_current_function != FUNCTION_FOREGROUND) FUNCTION_Select(FUNCTION_FOREGROUND); - gUpdateStatus = true; - gUpdateDisplay = true; + g_update_status = true; + g_update_display = true; } } } #ifdef ENABLE_FMRADIO - if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0) + if (g_fm_radio_mode && g_fm_restore_count_down_10ms > 0) { - if (--gFM_RestoreCountdown_10ms == 0) + if (--g_fm_restore_count_down_10ms == 0) { // switch back to FM radio mode FM_Start(); GUI_SelectNextDisplay(DISPLAY_FM); @@ -1548,16 +1548,16 @@ void APP_TimeSlice10ms(void) } #endif - if (gScreenToDisplay == DISPLAY_SCANNER) + if (g_screen_to_display == DISPLAY_SCANNER) { uint32_t Result; int32_t Delta; - BK4819_CssScanResult_t ScanResult; + BK4819_CSS_scan_result_t ScanResult; uint16_t CtcssFreq; - if (gScanDelay_10ms > 0) + if (g_scan_delay_10ms > 0) { - if (--gScanDelay_10ms > 0) + if (--g_scan_delay_10ms > 0) { APP_CheckKeys(); return; @@ -1587,7 +1587,7 @@ void APP_TimeSlice10ms(void) gScanFrequency = Result; #else { // round to nearest step multiple - const uint32_t step = StepFrequencyTable[gStepSetting]; + const uint32_t step = STEP_FREQ_TABLE[g_step_setting]; gScanFrequency = ((Result + (step / 2)) / step) * step; } #endif @@ -1609,10 +1609,10 @@ void APP_TimeSlice10ms(void) gScanCssState = SCAN_CSS_STATE_SCANNING; GUI_SelectNextDisplay(DISPLAY_SCANNER); - gUpdateStatus = true; + g_update_status = true; } - gScanDelay_10ms = scan_freq_css_delay_10ms; + g_scan_delay_10ms = scan_freq_css_delay_10ms; break; case SCAN_CSS_STATE_SCANNING: @@ -1631,7 +1631,7 @@ void APP_TimeSlice10ms(void) gScanCssResultType = CODE_TYPE_DIGITAL; gScanCssState = SCAN_CSS_STATE_FOUND; gScanUseCssResult = true; - gUpdateStatus = true; + g_update_status = true; } } else @@ -1646,7 +1646,7 @@ void APP_TimeSlice10ms(void) { gScanCssState = SCAN_CSS_STATE_FOUND; gScanUseCssResult = true; - gUpdateStatus = true; + g_update_status = true; } } else @@ -1660,7 +1660,7 @@ void APP_TimeSlice10ms(void) if (gScanCssState == SCAN_CSS_STATE_OFF || gScanCssState == SCAN_CSS_STATE_SCANNING) { // re-start scan BK4819_SetScanFrequency(gScanFrequency); - gScanDelay_10ms = scan_freq_css_delay_10ms; + g_scan_delay_10ms = scan_freq_css_delay_10ms; break; } @@ -1673,11 +1673,11 @@ void APP_TimeSlice10ms(void) } #ifdef ENABLE_AIRCOPY - if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) + if (g_screen_to_display == DISPLAY_AIRCOPY && g_aircopy_state == AIRCOPY_TRANSFER && g_air_copy_is_send_mode == 1) { - if (gAircopySendCountdown > 0) + if (g_air_copy_send_count_down > 0) { - if (--gAircopySendCountdown == 0) + if (--g_air_copy_send_count_down == 0) { AIRCOPY_SendMessage(); GUI_DisplayScreen(); @@ -1691,22 +1691,22 @@ void APP_TimeSlice10ms(void) void cancelUserInputModes(void) { - if (gDTMF_InputMode || gDTMF_InputBox_Index > 0) + if (g_dtmf_input_mode || g_dtmf_input_box_index > 0) { DTMF_clear_input_box(); - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gRequestDisplayScreen = DISPLAY_MAIN; - gUpdateDisplay = true; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_request_display_screen = DISPLAY_MAIN; + g_update_display = true; } - if (g_was_f_key_pressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) + if (g_f_key_was_pressed || g_key_input_count_down > 0 || g_input_box_index > 0) { - g_was_f_key_pressed = false; - gInputBoxIndex = 0; - gKeyInputCountdown = 0; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gUpdateStatus = true; - gUpdateDisplay = true; + g_f_key_was_pressed = false; + g_input_box_index = 0; + g_key_input_count_down = 0; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_update_status = true; + g_update_display = true; } } @@ -1717,76 +1717,76 @@ void APP_TimeSlice500ms(void) // Skipped authentic device check - if (gKeypadLocked > 0) - if (--gKeypadLocked == 0) - gUpdateDisplay = true; + if (g_keypad_locked > 0) + if (--g_keypad_locked == 0) + g_update_display = true; - if (gKeyInputCountdown > 0) + if (g_key_input_count_down > 0) { - if (--gKeyInputCountdown == 0) + if (--g_key_input_count_down == 0) { cancelUserInputModes(); - if (gBeepToPlay != BEEP_NONE) + if (g_beep_to_play != BEEP_NONE) { - AUDIO_PlayBeep(gBeepToPlay); - gBeepToPlay = BEEP_NONE; + AUDIO_PlayBeep(g_beep_to_play); + g_beep_to_play = BEEP_NONE; } } } - if (gDTMF_RX_live_timeout > 0) + if (g_dtmf_rx_live_timeout > 0) { #ifdef ENABLE_RSSI_BAR if (center_line == CENTER_LINE_DTMF_DEC || center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out #endif { - if (--gDTMF_RX_live_timeout == 0) + if (--g_dtmf_rx_live_timeout == 0) { - if (gDTMF_RX_live[0] != 0) + if (g_dtmf_rx_live[0] != 0) { - memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); - gUpdateDisplay = true; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + g_update_display = true; } } } } - if (gMenuCountdown > 0) - if (--gMenuCountdown == 0) - exit_menu = (gScreenToDisplay == DISPLAY_MENU); // exit menu mode + if (g_menu_count_down > 0) + if (--g_menu_count_down == 0) + exit_menu = (g_screen_to_display == DISPLAY_MENU); // exit menu mode - if (gDTMF_RX_timeout > 0) - if (--gDTMF_RX_timeout == 0) + if (g_dtmf_rx_timeout > 0) + if (--g_dtmf_rx_timeout == 0) DTMF_clear_RX(); // Skipped authentic device check #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown_500ms > 0) + if (g_fm_radio_count_down_500ms > 0) { - gFmRadioCountdown_500ms--; - if (gFmRadioMode) // 1of11 + g_fm_radio_count_down_500ms--; + if (g_fm_radio_mode) // 1of11 return; } #endif - 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 (g_eeprom.backlight < (ARRAY_SIZE(gSubMenu_backlight) - 1)) + if (g_backlight_count_down > 0 && !g_ask_to_save && g_css_scan_mode == CSS_SCAN_MODE_OFF) + if (g_screen_to_display != DISPLAY_MENU || g_menu_cursor != MENU_ABR) // don't turn off backlight if user is in backlight menu option + if (--g_backlight_count_down == 0) + if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1)) GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off - if (gSerialConfigCountDown_500ms > 0) + if (g_serial_config_count_down_500ms > 0) { } - if (gReducedService) + if (g_reduced_service) { - BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); + BOARD_ADC_GetBatteryInfo(&g_battery_current_voltage, &g_battery_current); - if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) + if (g_battery_current > 500 || g_battery_calibration[3] < g_battery_current_voltage) { #ifdef ENABLE_OVERLAY overlay_FLASH_RebootToBootloader(); @@ -1798,62 +1798,62 @@ void APP_TimeSlice500ms(void) return; } - gBatteryCheckCounter++; + g_battery_check_counter++; // Skipped authentic device check - if ((gBatteryCheckCounter & 1) == 0) + if ((g_battery_check_counter & 1) == 0) { - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); - if (gBatteryVoltageIndex > 3) - gBatteryVoltageIndex = 0; + BOARD_ADC_GetBatteryInfo(&g_battery_voltages[g_battery_voltage_index++], &g_battery_current); + if (g_battery_voltage_index > 3) + g_battery_voltage_index = 0; BATTERY_GetReadings(true); } // regular display updates (once every 2 sec) - if need be - if ((gBatteryCheckCounter & 3) == 0) + if ((g_battery_check_counter & 3) == 0) { - if (gChargingWithTypeC || gSetting_battery_text > 0) - gUpdateStatus = true; + if (g_charging_with_type_c || g_setting_battery_text > 0) + g_update_status = true; #ifdef ENABLE_SHOW_CHARGE_LEVEL - if (gChargingWithTypeC) - gUpdateDisplay = true; + if (g_charging_with_type_c) + g_update_display = true; #endif } #ifdef ENABLE_FMRADIO - if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && gCssScanMode == CSS_SCAN_MODE_OFF) + if ((g_fm_scan_state == FM_SCAN_OFF || g_ask_to_save) && g_css_scan_mode == CSS_SCAN_MODE_OFF) #else - if (gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_css_scan_mode == CSS_SCAN_MODE_OFF) #endif { #ifdef ENABLE_AIRCOPY - if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) + if (g_scan_state_dir == SCAN_OFF && g_screen_to_display != DISPLAY_AIRCOPY && (g_screen_to_display != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) #else - if (gScanStateDir == SCAN_OFF && (gScreenToDisplay != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) + if (g_scan_state_dir == SCAN_OFF && (g_screen_to_display != DISPLAY_SCANNER || gScanCssState >= SCAN_CSS_STATE_FOUND)) #endif { - if (g_eeprom.auto_keypad_lock && gKeyLockCountdown > 0 && !gDTMF_InputMode) + if (g_eeprom.auto_keypad_lock && g_key_lock_count_down > 0 && !g_dtmf_input_mode) { - if (--gKeyLockCountdown == 0) + if (--g_key_lock_count_down == 0) g_eeprom.key_lock = true; // lock the keyboard - gUpdateStatus = true; // lock symbol needs showing + g_update_status = true; // lock symbol needs showing } if (exit_menu) { - gMenuCountdown = 0; + g_menu_count_down = 0; if (g_eeprom.backlight == 0) { - gBacklightCountdown = 0; + g_backlight_count_down = 0; GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF } - if (gInputBoxIndex > 0 || gDTMF_InputMode) + if (g_input_box_index > 0 || g_dtmf_input_mode) AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); /* - if (gScreenToDisplay == DISPLAY_SCANNER) + if (g_screen_to_display == DISPLAY_SCANNER) { BK4819_StopScan(); @@ -1865,23 +1865,23 @@ void APP_TimeSlice500ms(void) */ DTMF_clear_input_box(); - g_was_f_key_pressed = false; - gInputBoxIndex = 0; + g_f_key_was_pressed = false; + g_input_box_index = 0; - gAskToSave = false; - gAskToDelete = false; + g_ask_to_save = false; + g_ask_to_delete = false; - gUpdateStatus = true; - gUpdateDisplay = true; + g_update_status = true; + g_update_display = true; { - GUI_DisplayType_t disp = DISPLAY_INVALID; + gui_display_type_t disp = DISPLAY_INVALID; #ifdef ENABLE_FMRADIO - if (gFmRadioMode && - gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_MONITOR && - gCurrentFunction != FUNCTION_TRANSMIT) + if (g_fm_radio_mode && + g_current_function != FUNCTION_RECEIVE && + g_current_function != FUNCTION_MONITOR && + g_current_function != FUNCTION_TRANSMIT) { disp = DISPLAY_FM; } @@ -1890,7 +1890,7 @@ void APP_TimeSlice500ms(void) if (disp == DISPLAY_INVALID) { #ifndef ENABLE_CODE_SCAN_TIMEOUT - if (gScreenToDisplay != DISPLAY_SCANNER) + if (g_screen_to_display != DISPLAY_SCANNER) #endif disp = DISPLAY_MAIN; } @@ -1902,20 +1902,20 @@ void APP_TimeSlice500ms(void) } } - if (gCurrentFunction != FUNCTION_POWER_SAVE && gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT) updateRSSI(g_eeprom.rx_vfo); #ifdef ENABLE_FMRADIO - if (!gPttIsPressed && gFM_ResumeCountdown_500ms > 0) + if (!g_ptt_is_pressed && g_fm_resume_count_down_500ms > 0) { - if (--gFM_ResumeCountdown_500ms == 0) + if (--g_fm_resume_count_down_500ms == 0) { - RADIO_SetVfoState(VFO_STATE_NORMAL); + RADIO_Setg_vfo_state(VFO_STATE_NORMAL); - if (gCurrentFunction != FUNCTION_RECEIVE && - gCurrentFunction != FUNCTION_TRANSMIT && - gCurrentFunction != FUNCTION_MONITOR && - gFmRadioMode) + if (g_current_function != FUNCTION_RECEIVE && + g_current_function != FUNCTION_TRANSMIT && + g_current_function != FUNCTION_MONITOR && + g_fm_radio_mode) { // switch back to FM radio mode FM_Start(); GUI_SelectNextDisplay(DISPLAY_FM); @@ -1924,25 +1924,25 @@ void APP_TimeSlice500ms(void) } #endif - if (gLowBattery) + if (g_low_battery) { - gLowBatteryBlink = ++gLowBatteryCountdown & 1; + g_low_battery_blink = ++g_low_batteryCountdown & 1; - UI_DisplayBattery(0, gLowBatteryBlink); + UI_DisplayBattery(0, g_low_battery_blink); - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) { // not transmitting - if (gLowBatteryCountdown < 30) + if (g_low_batteryCountdown < 30) { - if (gLowBatteryCountdown == 29 && !gChargingWithTypeC) + if (g_low_batteryCountdown == 29 && !g_charging_with_type_c) AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); } else { - gLowBatteryCountdown = 0; + g_low_batteryCountdown = 0; - if (!gChargingWithTypeC) + if (!g_charging_with_type_c) { // not on charge AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); @@ -1951,20 +1951,20 @@ void APP_TimeSlice500ms(void) AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE); #endif - if (gBatteryDisplayLevel == 0) + if (g_battery_display_level == 0) { #ifdef ENABLE_VOICE AUDIO_PlaySingleVoice(true); #endif - gReducedService = true; + g_reduced_service = true; - //if (gCurrentFunction != FUNCTION_POWER_SAVE) + //if (g_current_function != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE); ST7565_HardwareReset(); - if (g_eeprom.backlight < (ARRAY_SIZE(gSubMenu_backlight) - 1)) + if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1)) GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight off } #ifdef ENABLE_VOICE @@ -1976,7 +1976,7 @@ void APP_TimeSlice500ms(void) } } - if (gScreenToDisplay == DISPLAY_SCANNER && + if (g_screen_to_display == DISPLAY_SCANNER && gScannerEditState == SCAN_EDIT_STATE_NONE && gScanCssState < SCAN_CSS_STATE_FOUND) { @@ -1985,63 +1985,63 @@ void APP_TimeSlice500ms(void) #ifdef ENABLE_CODE_SCAN_TIMEOUT if (gScanProgressIndicator > 32) { - if (gScanCssState == SCAN_CSS_STATE_SCANNING && !gScanSingleFrequency) + if (gScanCssState == SCAN_CSS_STATE_SCANNING && !g_scan_single_frequency) gScanCssState = SCAN_CSS_STATE_FOUND; else gScanCssState = SCAN_CSS_STATE_FAILED; - gUpdateStatus = true; + g_update_status = true; } #endif - gUpdateDisplay = true; + g_update_display = true; } - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) { - if (gDTMF_DecodeRingCountdown_500ms > 0) + if (g_dtmf_decode_ring_count_down_500ms > 0) { // make "ring-ring" sound - gDTMF_DecodeRingCountdown_500ms--; + g_dtmf_decode_ring_count_down_500ms--; AUDIO_PlayBeep(BEEP_880HZ_200MS); } } else - gDTMF_DecodeRingCountdown_500ms = 0; + g_dtmf_decode_ring_count_down_500ms = 0; - if (gDTMF_CallState != DTMF_CALL_STATE_NONE && - gCurrentFunction != FUNCTION_TRANSMIT && - gCurrentFunction != FUNCTION_RECEIVE) + if (g_dtmf_call_state != DTMF_CALL_STATE_NONE && + g_current_function != FUNCTION_TRANSMIT && + g_current_function != FUNCTION_RECEIVE) { - if (gDTMF_auto_reset_time_500ms > 0) + if (g_dtmf_auto_reset_time_500ms > 0) { - if (--gDTMF_auto_reset_time_500ms == 0) + if (--g_dtmf_auto_reset_time_500ms == 0) { - 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 + if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED && g_eeprom.dtmf_auto_reset_time >= DTMF_HOLD_MAX) + g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed else - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + g_update_display = true; } } -// if (gDTMF_CallState != DTMF_CALL_STATE_RECEIVED_STAY) +// if (g_dtmf_call_state != DTMF_CALL_STATE_RECEIVED_STAY) // { -// gDTMF_CallState = DTMF_CALL_STATE_NONE; -// gUpdateDisplay = true; +// g_dtmf_call_state = DTMF_CALL_STATE_NONE; +// g_update_display = true; // } } - if (gDTMF_IsTx && gDTMF_TxStopCountdown_500ms > 0) + if (g_dtmf_is_tx && g_dtmf_tx_stop_count_down_500ms > 0) { - if (--gDTMF_TxStopCountdown_500ms == 0) + if (--g_dtmf_tx_stop_count_down_500ms == 0) { - gDTMF_IsTx = false; - gUpdateDisplay = true; + g_dtmf_is_tx = false; + g_update_display = true; } } #ifdef ENABLE_SHOW_TX_TIMEOUT - if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimerCountdown_500ms & 1)) + if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timer_count_down_500ms & 1)) UI_DisplayTXCountdown(true); #endif } @@ -2049,10 +2049,10 @@ void APP_TimeSlice500ms(void) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) static void ALARM_Off(void) { - gAlarmState = ALARM_STATE_OFF; + g_alarm_state = ALARM_STATE_OFF; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; if (g_eeprom.alarm_mode == ALARM_MODE_TONE) { @@ -2061,96 +2061,99 @@ void APP_TimeSlice500ms(void) } #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + g_vox_resume_count_down = 80; #endif SYSTEM_DelayMs(5); RADIO_SetupRegisters(true); - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu + g_request_display_screen = DISPLAY_MAIN; } #endif -void CHANNEL_Next(const bool bFlag, const int8_t scan_direction) +void CHANNEL_Next(const bool flag, const int8_t scan_direction) { RADIO_SelectVfos(); - gNextChannel = gRxVfo->channel_save; - gCurrentScanList = SCAN_NEXT_CHAN_SCANLIST1; - gScanStateDir = scan_direction; + g_next_channel = g_rx_vfo->channel_save; + g_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; + g_scan_state_dir = scan_direction; - if (gNextChannel <= USER_CHANNEL_LAST) + if (g_next_channel <= USER_CHANNEL_LAST) { // channel mode - if (bFlag) - gRestoreUSER_CHANNEL = gNextChannel; + if (flag) + g_restore_channel = g_next_channel; USER_NextChannel(); } else { // frequency mode - if (bFlag) - gRestoreFrequency = gRxVfo->freq_config_rx.frequency; + if (flag) + g_restore_frequency = g_rx_vfo->freq_config_rx.frequency; FREQ_NextChannel(); } - gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms; - gScheduleScanListen = false; - gRxReceptionMode = RX_MODE_NONE; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_2_10ms; + g_schedule_scan_listen = false; + g_rx_reception_mode = RX_MODE_NONE; gScanPauseMode = false; 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 key_pressed, const bool key_held) { - bool bFlag = false; + bool flag = false; // if (Key == KEY_INVALID) // return; + if (Key != KEY_INVALID && Key != KEY_PTT) + RADIO_Setg_vfo_state(VFO_STATE_NORMAL); // reset the state + const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); 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_turn_on(); - gBeepToPlay = BEEP_NONE; + g_beep_to_play = BEEP_NONE; return; } - if (gCurrentFunction == FUNCTION_POWER_SAVE) + if (g_current_function == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - gBatterySaveCountdown_10ms = battery_save_count_10ms; + g_battery_save_count_down_10ms = battery_save_count_10ms; if (g_eeprom.auto_keypad_lock) - gKeyLockCountdown = 30; // 15 seconds + g_key_lock_count_down = 30; // 15 seconds - if (!bKeyPressed) + if (!key_pressed) { - if (gFlagSaveVfo) + if (g_flag_SaveVfo) { SETTINGS_SaveVfoIndices(); - gFlagSaveVfo = false; + g_flag_SaveVfo = false; } - if (gFlagSaveSettings) + if (g_flag_SaveSettings) { SETTINGS_SaveSettings(); - gFlagSaveSettings = false; + g_flag_SaveSettings = false; } #ifdef ENABLE_FMRADIO - if (gFlagSaveFM) + if (g_flag_SaveFM) { SETTINGS_SaveFM(); - gFlagSaveFM = false; + g_flag_SaveFM = false; } #endif - if (gFlagSaveChannel) + if (g_flag_SaveChannel) { - SETTINGS_SaveChannel(gTxVfo->channel_save, g_eeprom.tx_vfo, gTxVfo, gFlagSaveChannel); - gFlagSaveChannel = false; + SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_SaveChannel); + g_flag_SaveChannel = false; RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE); RADIO_SetupRegisters(true); @@ -2160,77 +2163,77 @@ 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) + if (Key != KEY_PTT || g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3) backlight_turn_on(); - if (Key == KEY_EXIT && bKeyHeld) + if (Key == KEY_EXIT && key_held) { // exit key held pressed // clear the live DTMF decoder - if (gDTMF_RX_live[0] != 0) + if (g_dtmf_rx_live[0] != 0) { - memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); - gDTMF_RX_live_timeout = 0; - gUpdateDisplay = true; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + g_dtmf_rx_live_timeout = 0; + g_update_display = true; } // cancel user input cancelUserInputModes(); } - if (gScreenToDisplay == DISPLAY_MENU) // 1of11 - gMenuCountdown = menu_timeout_500ms; + if (g_screen_to_display == DISPLAY_MENU) // 1of11 + g_menu_count_down = menu_timeout_500ms; - if (gDTMF_DecodeRingCountdown_500ms > 0) + if (g_dtmf_decode_ring_count_down_500ms > 0) { // cancel the ringing - gDTMF_DecodeRingCountdown_500ms = 0; + g_dtmf_decode_ring_count_down_500ms = 0; AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); if (Key != KEY_PTT) { - gPttWasReleased = true; + g_ptt_was_released = true; return; } } } - if (g_eeprom.key_lock && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) + if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT) { // keyboard is locked if (Key == KEY_F) { // function/key-lock key - if (!bKeyPressed) + if (!key_pressed) return; - if (!bKeyHeld) + if (!key_held) { // keypad is locked, tell the user AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - gKeypadLocked = 4; // 2 seconds - gUpdateDisplay = true; + g_keypad_locked = 4; // 2 seconds + g_update_display = true; return; } } else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) { - if (!bKeyPressed || bKeyHeld) + if (!key_pressed || key_held) return; // keypad is locked, tell the user AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - gKeypadLocked = 4; // 2 seconds - gUpdateDisplay = true; + g_keypad_locked = 4; // 2 seconds + g_update_display = true; return; } } if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F) { - if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF) { // FREQ/CTCSS/DCS scanning - if (bKeyPressed && !bKeyHeld) + if (key_pressed && !key_held) AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); return; } @@ -2238,48 +2241,48 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b if (Key == KEY_PTT) { - if (gPttWasPressed) + if (g_ptt_was_pressed) { - bFlag = bKeyHeld; - if (!bKeyPressed) + flag = key_held; + if (!key_pressed) { - bFlag = true; - gPttWasPressed = false; + flag = true; + g_ptt_was_pressed = false; } } } else - if (gPttWasReleased) + if (g_ptt_was_released) { - if (bKeyHeld) - bFlag = true; - if (!bKeyPressed) + if (key_held) + flag = true; + if (!key_pressed) { - bFlag = true; - gPttWasReleased = false; + flag = true; + g_ptt_was_released = false; } } - if (g_was_f_key_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) + if (g_f_key_was_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) { // cancel the F-key - g_was_f_key_pressed = false; - gUpdateStatus = true; + g_f_key_was_pressed = false; + g_update_status = true; } - if (!bFlag) + if (!flag) { - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { // transmitting #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF) + if (g_alarm_state == ALARM_STATE_OFF) #endif { char Code; if (Key == KEY_PTT) { - GENERIC_Key_PTT(bKeyPressed); + GENERIC_Key_PTT(key_pressed); goto Skip; } @@ -2296,84 +2299,84 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b // transmit DTMF keys } - if (!bKeyPressed || bKeyHeld) + if (!key_pressed || key_held) { - if (!bKeyPressed) + if (!key_pressed) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; BK4819_ExitDTMF_TX(false); - if (gCurrentVfo->scrambling_type == 0 || !gSetting_ScrambleEnable) + if (g_current_vfo->scrambling_type == 0 || !g_setting_scramble_enable) BK4819_DisableScramble(); else - BK4819_EnableScramble(gCurrentVfo->scrambling_type - 1); + BK4819_EnableScramble(g_current_vfo->scrambling_type - 1); } } else { - if (g_eeprom.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; + g_enable_speaker = true; } BK4819_DisableScramble(); if (Code == 0xFE) - BK4819_TransmitTone(g_eeprom.DTMF_side_tone, 1750); + BK4819_TransmitTone(g_eeprom.dtmf_side_tone, 1750); else - BK4819_PlayDTMFEx(g_eeprom.DTMF_side_tone, Code); + BK4819_PlayDTMFEx(g_eeprom.dtmf_side_tone, Code); } } #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) else - if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) + if ((!key_held && key_pressed) || (g_alarm_state == ALARM_STATE_TX1750 && key_held && !key_pressed)) { ALARM_Off(); if (g_eeprom.repeater_tail_tone_elimination == 0) FUNCTION_Select(FUNCTION_FOREGROUND); else - gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; + g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10; if (Key == KEY_PTT) - gPttWasPressed = true; + g_ptt_was_pressed = true; else - if (!bKeyHeld) - gPttWasReleased = true; + if (!key_held) + g_ptt_was_released = true; } #endif } else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) { - switch (gScreenToDisplay) + switch (g_screen_to_display) { case DISPLAY_MAIN: - MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); -// bKeyHeld = false; // allow the channel setting to be saved + MAIN_ProcessKeys(Key, key_pressed, key_held); +// key_held = false; // allow the channel setting to be saved break; #ifdef ENABLE_FMRADIO case DISPLAY_FM: - FM_ProcessKeys(Key, bKeyPressed, bKeyHeld); + FM_ProcessKeys(Key, key_pressed, key_held); break; #endif case DISPLAY_MENU: - MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld); + MENU_ProcessKeys(Key, key_pressed, key_held); break; case DISPLAY_SCANNER: - SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld); + SCANNER_ProcessKeys(Key, key_pressed, key_held); break; #ifdef ENABLE_AIRCOPY case DISPLAY_AIRCOPY: - AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld); + AIRCOPY_ProcessKeys(Key, key_pressed, key_held); break; #endif @@ -2384,111 +2387,111 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b } else #ifdef ENABLE_AIRCOPY - if (gScreenToDisplay != DISPLAY_SCANNER && gScreenToDisplay != DISPLAY_AIRCOPY) + if (g_screen_to_display != DISPLAY_SCANNER && g_screen_to_display != DISPLAY_AIRCOPY) #else - if (gScreenToDisplay != DISPLAY_SCANNER) + if (g_screen_to_display != DISPLAY_SCANNER) #endif { - ACTION_Handle(Key, bKeyPressed, bKeyHeld); + ACTION_Handle(Key, key_pressed, key_held); } else - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } Skip: - if (gBeepToPlay != BEEP_NONE) + if (g_beep_to_play != BEEP_NONE) { - AUDIO_PlayBeep(gBeepToPlay); - gBeepToPlay = BEEP_NONE; + AUDIO_PlayBeep(g_beep_to_play); + g_beep_to_play = BEEP_NONE; } - if (gFlagAcceptSetting) + if (g_flag_AcceptSetting) { - gMenuCountdown = menu_timeout_500ms; + g_menu_count_down = menu_timeout_500ms; MENU_AcceptSetting(); - gFlagRefreshSetting = true; - gFlagAcceptSetting = false; + g_flag_refresh_menu = true; + g_flag_AcceptSetting = false; } - if (gFlagStopScan) + if (g_flag_stop_scan) { BK4819_StopScan(); - gFlagStopScan = false; + g_flag_stop_scan = false; } - if (gRequestSaveSettings) + if (g_request_save_settings) { - if (!bKeyHeld) + if (!key_held) SETTINGS_SaveSettings(); else - gFlagSaveSettings = 1; - gRequestSaveSettings = false; - gUpdateStatus = true; + g_flag_SaveSettings = 1; + g_request_save_settings = false; + g_update_status = true; } #ifdef ENABLE_FMRADIO - if (gRequestSaveFM) + if (g_request_save_fm) { - if (!bKeyHeld) + if (!key_held) SETTINGS_SaveFM(); else - gFlagSaveFM = true; - gRequestSaveFM = false; + g_flag_SaveFM = true; + g_request_save_fm = false; } #endif - if (gRequestSaveVFO) + if (g_request_save_vfo) { - if (!bKeyHeld) + if (!key_held) SETTINGS_SaveVfoIndices(); else - gFlagSaveVfo = true; - gRequestSaveVFO = false; + g_flag_SaveVfo = true; + g_request_save_vfo = false; } - if (gRequestSaveChannel > 0) + if (g_request_save_channel > 0) { - if (!bKeyHeld) + if (!key_held) { - SETTINGS_SaveChannel(gTxVfo->channel_save, g_eeprom.tx_vfo, gTxVfo, gRequestSaveChannel); + SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_request_save_channel); - if (gScreenToDisplay != DISPLAY_SCANNER) - if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere - gVfoConfigureMode = VFO_CONFIGURE; + if (g_screen_to_display != DISPLAY_SCANNER) + if (g_vfo_configure_mode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere + g_vfo_configure_mode = VFO_CONFIGURE; } else { - gFlagSaveChannel = gRequestSaveChannel; + g_flag_SaveChannel = g_request_save_channel; - if (gRequestDisplayScreen == DISPLAY_INVALID) - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_request_display_screen == DISPLAY_INVALID) + g_request_display_screen = DISPLAY_MAIN; } - gRequestSaveChannel = 0; + g_request_save_channel = 0; } - if (gVfoConfigureMode != VFO_CONFIGURE_NONE) + if (g_vfo_configure_mode != VFO_CONFIGURE_NONE) { - if (gFlagResetVfos) + if (g_flag_reset_vfos) { - RADIO_ConfigureChannel(0, gVfoConfigureMode); - RADIO_ConfigureChannel(1, gVfoConfigureMode); + RADIO_ConfigureChannel(0, g_vfo_configure_mode); + RADIO_ConfigureChannel(1, g_vfo_configure_mode); } else - RADIO_ConfigureChannel(g_eeprom.tx_vfo, gVfoConfigureMode); + RADIO_ConfigureChannel(g_eeprom.tx_vfo, g_vfo_configure_mode); - if (gRequestDisplayScreen == DISPLAY_INVALID) - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_request_display_screen == DISPLAY_INVALID) + g_request_display_screen = DISPLAY_MAIN; - gFlagReconfigureVfos = true; - gVfoConfigureMode = VFO_CONFIGURE_NONE; - gFlagResetVfos = false; + g_flag_reconfigure_vfos = true; + g_vfo_configure_mode = VFO_CONFIGURE_NONE; + g_flag_reset_vfos = false; } - if (gFlagReconfigureVfos) + if (g_flag_reconfigure_vfos) { RADIO_SelectVfos(); @@ -2498,33 +2501,33 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b RADIO_SetupRegisters(true); - gDTMF_auto_reset_time_500ms = 0; - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gDTMF_TxStopCountdown_500ms = 0; - gDTMF_IsTx = false; + g_dtmf_auto_reset_time_500ms = 0; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + g_dtmf_tx_stop_count_down_500ms = 0; + g_dtmf_is_tx = false; - gVFO_RSSI_bar_level[0] = 0; - gVFO_RSSI_bar_level[1] = 0; + g_vfo_rssi_bar_level[0] = 0; + g_vfo_rssi_bar_level[1] = 0; - gFlagReconfigureVfos = false; + g_flag_reconfigure_vfos = false; - if (gMonitor) + if (g_monitor_enabled) ACTION_Monitor(); // 1of11 } - if (gFlagRefreshSetting) + if (g_flag_refresh_menu) { - gFlagRefreshSetting = false; - gMenuCountdown = menu_timeout_500ms; + g_flag_refresh_menu = false; + g_menu_count_down = menu_timeout_500ms; MENU_ShowCurrentSetting(); } - if (gFlagStartScan) + if (g_flag_start_scan) { - gFlagStartScan = false; + g_flag_start_scan = false; - gMonitor = false; + g_monitor_enabled = false; #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); @@ -2533,13 +2536,13 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b SCANNER_Start(); - gRequestDisplayScreen = DISPLAY_SCANNER; + g_request_display_screen = DISPLAY_SCANNER; } - if (gFlagPrepareTX) + if (g_flag_prepare_tx) { RADIO_PrepareTX(); - gFlagPrepareTX = false; + g_flag_prepare_tx = false; } #ifdef ENABLE_VOICE @@ -2552,8 +2555,8 @@ static void APP_ProcessKey(const key_code_t Key, const bool bKeyPressed, const b } #endif - GUI_SelectNextDisplay(gRequestDisplayScreen); - gRequestDisplayScreen = DISPLAY_INVALID; + GUI_SelectNextDisplay(g_request_display_screen); + g_request_display_screen = DISPLAY_INVALID; - gUpdateDisplay = true; + g_update_display = true; } diff --git a/app/app.h b/app/app.h index 6f958da8..64231bea 100644 --- a/app/app.h +++ b/app/app.h @@ -29,9 +29,9 @@ extern const uint8_t orig_mixer; extern const uint8_t orig_pga; void APP_EndTransmission(void); -void CHANNEL_Next(const bool bFlag, const int8_t scan_direction); -void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); -uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step); +void CHANNEL_Next(const bool flag, const int8_t scan_direction); +void APP_StartListening(function_type_t Function, const bool reset_am_fix); +uint32_t APP_SetFrequencyByStep(vfo_info_t *pInfo, int8_t Step); void APP_Update(void); void APP_TimeSlice10ms(void); void APP_TimeSlice500ms(void); diff --git a/app/dtmf.c b/app/dtmf.c index 872f6be1..662b52ec 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -33,42 +33,42 @@ #include "settings.h" #include "ui/ui.h" -char gDTMF_String[15]; - -char gDTMF_InputBox[15]; -uint8_t gDTMF_InputBox_Index = 0; -bool gDTMF_InputMode = false; -uint8_t gDTMF_PreviousIndex = 0; - -char gDTMF_RX[17]; -uint8_t gDTMF_RX_index = 0; -uint8_t gDTMF_RX_timeout = 0; -bool gDTMF_RX_pending = false; - -char gDTMF_RX_live[20]; -uint8_t gDTMF_RX_live_timeout = 0; - -bool gIsDtmfContactValid; -char gDTMF_ID[4]; -char gDTMF_Caller[4]; -char gDTMF_Callee[4]; -DTMF_State_t gDTMF_State; -uint8_t gDTMF_DecodeRingCountdown_500ms; -uint8_t gDTMF_chosen_contact; -uint8_t gDTMF_auto_reset_time_500ms; -DTMF_CallState_t gDTMF_CallState; -DTMF_ReplyState_t gDTMF_ReplyState; -DTMF_CallMode_t gDTMF_CallMode; -bool gDTMF_IsTx; -uint8_t gDTMF_TxStopCountdown_500ms; -bool gDTMF_IsGroupCall; +char g_dtmf_string[15]; + +char g_dtmf_input_box[15]; +uint8_t g_dtmf_input_box_index; +bool g_dtmf_input_mode; +uint8_t g_dtmf_prev_index; + +char g_dtmf_rx[17]; +uint8_t g_dtmf_rx_index; +uint8_t g_dtmf_rx_timeout; +bool g_dtmf_rx_pending; + +char g_dtmf_rx_live[20]; +uint8_t g_dtmf_rx_live_timeout; + +bool g_dtmf_is_contact_valid; +char g_dtmf_id[4]; +char g_dtmf_caller[4]; +char g_dtmf_callee[4]; +dtmf_state_t g_dtmf_state; +uint8_t g_dtmf_decode_ring_count_down_500ms; +uint8_t g_dtmf_chosen_contact; +uint8_t g_dtmf_auto_reset_time_500ms; +dtmf_call_state_t g_dtmf_call_state; +dtmf_reply_state_t g_dtmf_reply_state; +dtmf_call_mode_t g_dtmf_call_mode; +bool g_dtmf_is_tx; +uint8_t g_dtmf_tx_stop_count_down_500ms; +bool g_dtmf_IsGroupCall; void DTMF_clear_RX(void) { - gDTMF_RX_timeout = 0; - gDTMF_RX_index = 0; - gDTMF_RX_pending = false; - memset(gDTMF_RX, 0, sizeof(gDTMF_RX)); + g_dtmf_rx_timeout = 0; + g_dtmf_rx_index = 0; + g_dtmf_rx_pending = false; + memset(g_dtmf_rx, 0, sizeof(g_dtmf_rx)); } bool DTMF_ValidateCodes(char *pCode, const unsigned int size) @@ -162,20 +162,20 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned { if (pMsg[i] != pTemplate[i]) { - if (!bCheckGroup || pMsg[i] != g_eeprom.DTMF_group_call_code) + if (!bCheckGroup || pMsg[i] != g_eeprom.dtmf_group_call_code) return false; - gDTMF_IsGroupCall = true; + g_dtmf_IsGroupCall = true; } } return true; } -DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size) +dtmf_call_mode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size) { unsigned int i; for (i = 0; i < size; i++) - if (pMsg[i] == g_eeprom.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; @@ -183,21 +183,21 @@ DTMF_CallMode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size) void DTMF_clear_input_box(void) { - memset(gDTMF_InputBox, 0, sizeof(gDTMF_InputBox)); - gDTMF_InputBox_Index = 0; - gDTMF_InputMode = false; + memset(g_dtmf_input_box, 0, sizeof(g_dtmf_input_box)); + g_dtmf_input_box_index = 0; + g_dtmf_input_mode = false; } void DTMF_Append(const char code) { - if (gDTMF_InputBox_Index == 0) + if (g_dtmf_input_box_index == 0) { - memset(gDTMF_InputBox, '-', sizeof(gDTMF_InputBox) - 1); - gDTMF_InputBox[sizeof(gDTMF_InputBox) - 1] = 0; + memset(g_dtmf_input_box, '-', sizeof(g_dtmf_input_box) - 1); + g_dtmf_input_box[sizeof(g_dtmf_input_box) - 1] = 0; } - if (gDTMF_InputBox_Index < (sizeof(gDTMF_InputBox) - 1)) - gDTMF_InputBox[gDTMF_InputBox_Index++] = code; + if (g_dtmf_input_box_index < (sizeof(g_dtmf_input_box) - 1)) + g_dtmf_input_box[g_dtmf_input_box_index++] = code; } void DTMF_HandleRequest(void) @@ -206,45 +206,45 @@ void DTMF_HandleRequest(void) char String[20]; unsigned int Offset; - if (!gDTMF_RX_pending) + if (!g_dtmf_rx_pending) return; // nothing new received - if (gScanStateDir != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF) { // we're busy scanning DTMF_clear_RX(); return; } - if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED) + if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_killed) { // D-DCD is disabled or we're alive DTMF_clear_RX(); return; } - gDTMF_RX_pending = false; + g_dtmf_rx_pending = false; - if (gDTMF_RX_index >= 9) + if (g_dtmf_rx_index >= 9) { // look for the KILL code - sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code, g_eeprom.kill_code); + sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.kill_code); - Offset = gDTMF_RX_index - strlen(String); + Offset = g_dtmf_rx_index - strlen(String); - if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) { // bugger if (g_eeprom.permit_remote_kill) { - gSetting_KILLED = true; // oooerr ! + g_setting_killed = true; // oooerr ! DTMF_clear_RX(); SETTINGS_SaveSettings(); - gDTMF_ReplyState = DTMF_REPLY_AB; + g_dtmf_reply_state = DTMF_REPLY_AB; #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) { FM_TurnOff(); GUI_SelectNextDisplay(DISPLAY_MAIN); @@ -253,133 +253,133 @@ void DTMF_HandleRequest(void) } else { - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_reply_state = DTMF_REPLY_NONE; } - gDTMF_CallState = DTMF_CALL_STATE_NONE; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; - gUpdateStatus = true; + g_update_display = true; + g_update_status = true; return; } } - if (gDTMF_RX_index >= 9) + if (g_dtmf_rx_index >= 9) { // look for the REVIVE code - sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code, g_eeprom.revive_code); + sprintf(String, "%s%c%s", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code, g_eeprom.revive_code); - Offset = gDTMF_RX_index - strlen(String); + Offset = g_dtmf_rx_index - strlen(String); - if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) { // shit, we're back ! - gSetting_KILLED = false; + g_setting_killed = false; DTMF_clear_RX(); SETTINGS_SaveSettings(); - gDTMF_ReplyState = DTMF_REPLY_AB; - gDTMF_CallState = DTMF_CALL_STATE_NONE; + g_dtmf_reply_state = DTMF_REPLY_AB; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; - gUpdateStatus = true; + g_update_display = true; + g_update_status = true; return; } } - if (gDTMF_RX_index >= 2) + if (g_dtmf_rx_index >= 2) { // look for ACK reply strcpy(String, "AB"); - Offset = gDTMF_RX_index - strlen(String); + Offset = g_dtmf_rx_index - strlen(String); - if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) { // ends with "AB" - if (gDTMF_ReplyState != DTMF_REPLY_NONE) // 1of11 -// if (gDTMF_CallState != DTMF_CALL_STATE_NONE) // 1of11 -// if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) // 1of11 + if (g_dtmf_reply_state != DTMF_REPLY_NONE) // 1of11 +// if (g_dtmf_call_state != DTMF_CALL_STATE_NONE) // 1of11 +// if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) // 1of11 { - gDTMF_State = DTMF_STATE_TX_SUCC; + g_dtmf_state = DTMF_STATE_TX_SUCC; DTMF_clear_RX(); - gUpdateDisplay = true; + g_update_display = true; return; } } } - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && - gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && - gDTMF_RX_index >= 9) + if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT && + g_dtmf_call_mode == DTMF_CALL_MODE_NOT_GROUP && + g_dtmf_rx_index >= 9) { // waiting for a reply - sprintf(String, "%s%c%s", gDTMF_String, g_eeprom.DTMF_separate_code, "AAAAA"); + sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.dtmf_separate_code, "AAAAA"); - Offset = gDTMF_RX_index - strlen(String); + Offset = g_dtmf_rx_index - strlen(String); - if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), false)) + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), false)) { // we got a response - gDTMF_State = DTMF_STATE_CALL_OUT_RSP; + g_dtmf_state = DTMF_STATE_CALL_OUT_RSP; DTMF_clear_RX(); - gUpdateDisplay = true; + g_update_display = true; } } - if (gSetting_KILLED || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_setting_killed || g_dtmf_call_state != DTMF_CALL_STATE_NONE) { // we've been killed or expecting a reply return; } - if (gDTMF_RX_index >= 7) + if (g_dtmf_rx_index >= 7) { // see if we're being called - gDTMF_IsGroupCall = false; + g_dtmf_IsGroupCall = false; - sprintf(String, "%s%c", g_eeprom.ani_DTMF_id, g_eeprom.DTMF_separate_code); + sprintf(String, "%s%c", g_eeprom.ani_dtmf_id, g_eeprom.dtmf_separate_code); - Offset = gDTMF_RX_index - strlen(String) - 3; + Offset = g_dtmf_rx_index - strlen(String) - 3; - if (DTMF_CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) + if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true)) { // it's for us ! - gDTMF_CallState = DTMF_CALL_STATE_RECEIVED; + g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED; - memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee)); - memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller)); - memmove(gDTMF_Callee, gDTMF_RX + Offset + 0, 3); - memmove(gDTMF_Caller, gDTMF_RX + Offset + 4, 3); + memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee)); + memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller)); + memmove(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3); + memmove(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3); DTMF_clear_RX(); - gUpdateDisplay = true; + g_update_display = true; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (g_eeprom.DTMF_decode_response) + switch (g_eeprom.dtmf_decode_response) { case DTMF_DEC_RESPONSE_BOTH: - gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; + g_dtmf_decode_ring_count_down_500ms = dtmf_decode_ring_countdown_500ms; case DTMF_DEC_RESPONSE_REPLY: - gDTMF_ReplyState = DTMF_REPLY_AAAAA; + g_dtmf_reply_state = DTMF_REPLY_AAAAA; break; case DTMF_DEC_RESPONSE_RING: - gDTMF_DecodeRingCountdown_500ms = DTMF_decode_ring_countdown_500ms; + g_dtmf_decode_ring_count_down_500ms = dtmf_decode_ring_countdown_500ms; break; default: case DTMF_DEC_RESPONSE_NONE: - gDTMF_DecodeRingCountdown_500ms = 0; - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_decode_ring_count_down_500ms = 0; + g_dtmf_reply_state = DTMF_REPLY_NONE; break; } #pragma GCC diagnostic pop - if (gDTMF_IsGroupCall) - gDTMF_ReplyState = DTMF_REPLY_NONE; + if (g_dtmf_IsGroupCall) + g_dtmf_reply_state = DTMF_REPLY_NONE; } } } @@ -390,16 +390,16 @@ void DTMF_Reply(void) char String[20]; const char *pString = NULL; - switch (gDTMF_ReplyState) + switch (g_dtmf_reply_state) { case DTMF_REPLY_ANI: - if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) + if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF) { - pString = gDTMF_String; + pString = g_dtmf_string; } else { // append our ID code onto the end of the DTMF code to send - sprintf(String, "%s%c%s", gDTMF_String, g_eeprom.DTMF_separate_code, g_eeprom.ani_DTMF_id); + sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.dtmf_separate_code, g_eeprom.ani_dtmf_id); pString = String; } break; @@ -409,54 +409,54 @@ void DTMF_Reply(void) break; case DTMF_REPLY_AAAAA: - sprintf(String, "%s%c%s", g_eeprom.ani_DTMF_id, g_eeprom.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) + if (g_dtmf_call_state != DTMF_CALL_STATE_NONE || + g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO || + g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_OFF || + g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN) { - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_reply_state = DTMF_REPLY_NONE; return; } // send TX-UP DTMF - pString = g_eeprom.DTMF_up_code; + pString = g_eeprom.dtmf_up_code; break; } - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_reply_state = DTMF_REPLY_NONE; if (pString == NULL) return; - Delay = (g_eeprom.DTMF_preload_time < 200) ? 200 : g_eeprom.DTMF_preload_time; + Delay = (g_eeprom.dtmf_preload_time < 200) ? 200 : g_eeprom.dtmf_preload_time; - if (g_eeprom.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; + g_enable_speaker = true; } SYSTEM_DelayMs(Delay); - BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone); + BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone); BK4819_PlayDTMFString( pString, 1, - 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); + 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; + g_enable_speaker = false; BK4819_ExitDTMF_TX(false); } diff --git a/app/dtmf.h b/app/dtmf.h index d06ba861..232b82b8 100644 --- a/app/dtmf.h +++ b/app/dtmf.h @@ -22,88 +22,85 @@ #define MAX_DTMF_CONTACTS 16 -enum DTMF_State_t { +enum { // seconds + DTMF_HOLD_MIN = 5, + DTMF_HOLD_MAX = 60 +}; + +enum dtmf_state_e { DTMF_STATE_0 = 0, DTMF_STATE_TX_SUCC, DTMF_STATE_CALL_OUT_RSP }; +typedef enum dtmf_state_e dtmf_state_t; -typedef enum DTMF_State_t DTMF_State_t; - -enum DTMF_CallState_t { +enum dtmf_call_state_e { DTMF_CALL_STATE_NONE = 0, DTMF_CALL_STATE_CALL_OUT, DTMF_CALL_STATE_RECEIVED, DTMF_CALL_STATE_RECEIVED_STAY }; +typedef enum dtmf_call_state_e dtmf_call_state_t; -enum DTMF_DecodeResponse_t { +enum dtmf_decode_response_e { DTMF_DEC_RESPONSE_NONE = 0, DTMF_DEC_RESPONSE_RING, DTMF_DEC_RESPONSE_REPLY, DTMF_DEC_RESPONSE_BOTH }; +typedef enum dtmf_decode_response_e dtmf_decode_response_t; -typedef enum DTMF_CallState_t DTMF_CallState_t; - -enum DTMF_ReplyState_t { +enum dtmf_reply_state_e { DTMF_REPLY_NONE = 0, DTMF_REPLY_ANI, DTMF_REPLY_AB, DTMF_REPLY_AAAAA }; +typedef enum dtmf_reply_state_e dtmf_reply_state_t; -typedef enum DTMF_ReplyState_t DTMF_ReplyState_t; - -enum DTMF_CallMode_t { +enum dtmf_call_mode_e { DTMF_CALL_MODE_NOT_GROUP = 0, DTMF_CALL_MODE_GROUP, DTMF_CALL_MODE_DTMF }; - -enum { // seconds - DTMF_HOLD_MIN = 5, - DTMF_HOLD_MAX = 60 -}; - -typedef enum DTMF_CallMode_t DTMF_CallMode_t; - -extern char gDTMF_String[15]; - -extern char gDTMF_InputBox[15]; -extern uint8_t gDTMF_InputBox_Index; -extern bool gDTMF_InputMode; -extern uint8_t gDTMF_PreviousIndex; - -extern char gDTMF_RX[17]; -extern uint8_t gDTMF_RX_index; -extern uint8_t gDTMF_RX_timeout; -extern bool gDTMF_RX_pending; - -extern char gDTMF_RX_live[20]; -extern uint8_t gDTMF_RX_live_timeout; - -extern bool gIsDtmfContactValid; -extern char gDTMF_ID[4]; -extern char gDTMF_Caller[4]; -extern char gDTMF_Callee[4]; -extern DTMF_State_t gDTMF_State; -extern uint8_t gDTMF_DecodeRingCountdown_500ms; -extern uint8_t gDTMF_chosen_contact; -extern uint8_t gDTMF_auto_reset_time_500ms; -extern DTMF_CallState_t gDTMF_CallState; -extern DTMF_ReplyState_t gDTMF_ReplyState; -extern DTMF_CallMode_t gDTMF_CallMode; -extern bool gDTMF_IsTx; -extern uint8_t gDTMF_TxStopCountdown_500ms; +typedef enum dtmf_call_mode_e dtmf_call_mode_t; + +extern char g_dtmf_string[15]; + +extern char g_dtmf_input_box[15]; +extern uint8_t g_dtmf_input_box_index; +extern bool g_dtmf_input_mode; +extern uint8_t g_dtmf_prev_index; + +extern char g_dtmf_rx[17]; +extern uint8_t g_dtmf_rx_index; +extern uint8_t g_dtmf_rx_timeout; +extern bool g_dtmf_rx_pending; + +extern char g_dtmf_rx_live[20]; +extern uint8_t g_dtmf_rx_live_timeout; + +extern bool g_dtmf_is_contact_valid; +extern char g_dtmf_id[4]; +extern char g_dtmf_caller[4]; +extern char g_dtmf_callee[4]; +extern dtmf_state_t g_dtmf_state; +extern uint8_t g_dtmf_decode_ring_count_down_500ms; +extern uint8_t g_dtmf_chosen_contact; +extern uint8_t g_dtmf_auto_reset_time_500ms; +extern dtmf_call_state_t g_dtmf_call_state; +extern dtmf_reply_state_t g_dtmf_reply_state; +extern dtmf_call_mode_t g_dtmf_call_mode; +extern bool g_dtmf_is_tx; +extern uint8_t g_dtmf_tx_stop_count_down_500ms; void DTMF_clear_RX(void); bool DTMF_ValidateCodes(char *pCode, const unsigned int size); bool DTMF_GetContact(const int Index, char *pContact); bool DTMF_FindContact(const char *pContact, char *pResult); char DTMF_GetCharacter(const unsigned int code); -bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool bFlag); -DTMF_CallMode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size); +bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool flag); +dtmf_call_mode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size); void DTMF_clear_input_box(void); void DTMF_Append(const char vode); void DTMF_HandleRequest(void); diff --git a/app/fm.c b/app/fm.c index 5beae5bc..a6650beb 100644 --- a/app/fm.c +++ b/app/fm.c @@ -36,33 +36,33 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif -uint16_t gFM_Channels[20]; -bool gFmRadioMode; -uint8_t gFmRadioCountdown_500ms; -volatile uint16_t gFmPlayCountdown_10ms; -volatile int8_t gFM_ScanState; -bool gFM_AutoScan; -uint8_t gFM_ChannelPosition; -bool gFM_FoundFrequency; -bool gFM_AutoScan; -uint8_t gFM_ResumeCountdown_500ms; -uint16_t gFM_RestoreCountdown_10ms; +uint16_t g_fm_channels[20]; +bool g_fm_radio_mode; +uint8_t g_fm_radio_count_down_500ms; +volatile uint16_t g_fm_play_count_down_10ms; +volatile int8_t g_fm_scan_state; +bool g_fm_auto_scan; +uint8_t g_fm_channel_position; +bool g_fm_found_frequency; +bool g_fm_auto_scan; +uint8_t g_fm_resume_count_down_500ms; +uint16_t g_fm_restore_count_down_10ms; bool FM_CheckValidChannel(uint8_t Channel) { - return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false; + return (Channel < ARRAY_SIZE(g_fm_channels) && (g_fm_channels[Channel] >= 760 && g_fm_channels[Channel] < 1080)) ? true : false; } uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) { unsigned int i; - for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++) + for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++) { if (Channel == 0xFF) - Channel = ARRAY_SIZE(gFM_Channels) - 1; + Channel = ARRAY_SIZE(g_fm_channels) - 1; else - if (Channel >= ARRAY_SIZE(gFM_Channels)) + if (Channel >= ARRAY_SIZE(g_fm_channels)) Channel = 0; if (FM_CheckValidChannel(Channel)) return Channel; @@ -85,7 +85,7 @@ int FM_ConfigureChannelState(void) return -1; } g_eeprom.fm_selected_channel = Channel; - g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; + g_eeprom.fm_frequency_playing = g_fm_channels[Channel]; } return 0; @@ -93,17 +93,17 @@ int FM_ConfigureChannelState(void) void FM_TurnOff(void) { - gFmRadioMode = false; - gFM_ScanState = FM_SCAN_OFF; - gFM_RestoreCountdown_10ms = 0; + g_fm_radio_mode = false; + g_fm_scan_state = FM_SCAN_OFF; + g_fm_restore_count_down_10ms = 0; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; BK1080_Init(0, false); - gUpdateStatus = true; + g_update_status = true; } void FM_EraseChannels(void) @@ -115,24 +115,24 @@ void FM_EraseChannels(void) for (i = 0; i < 5; i++) EEPROM_WriteBuffer(0x0E40 + (i * 8), Template); - memset(gFM_Channels, 0xFF, sizeof(gFM_Channels)); + memset(g_fm_channels, 0xFF, sizeof(g_fm_channels)); } -void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag) +void FM_Tune(uint16_t Frequency, int8_t Step, bool flag) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; - gFmPlayCountdown_10ms = (gFM_ScanState == FM_SCAN_OFF) ? fm_play_countdown_noscan_10ms : fm_play_countdown_scan_10ms; + g_fm_play_count_down_10ms = (g_fm_scan_state == FM_SCAN_OFF) ? fm_play_countdown_noscan_10ms : fm_play_countdown_scan_10ms; - gScheduleFM = false; - gFM_FoundFrequency = false; - gAskToSave = false; - gAskToDelete = false; + g_schedule_fm = false; + g_fm_found_frequency = false; + g_ask_to_save = false; + g_ask_to_delete = false; g_eeprom.fm_frequency_playing = Frequency; - if (!bFlag) + if (!flag) { Frequency += Step; if (Frequency < g_eeprom.fm_lower_limit) @@ -144,16 +144,16 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag) g_eeprom.fm_frequency_playing = Frequency; } - gFM_ScanState = Step; + g_fm_scan_state = Step; BK1080_SetFrequency(g_eeprom.fm_frequency_playing); } void FM_PlayAndUpdate(void) { - gFM_ScanState = FM_SCAN_OFF; + g_fm_scan_state = FM_SCAN_OFF; - if (gFM_AutoScan) + if (g_fm_auto_scan) { g_eeprom.fm_is_channel_mode = true; g_eeprom.fm_selected_channel = 0; @@ -163,13 +163,13 @@ void FM_PlayAndUpdate(void) BK1080_SetFrequency(g_eeprom.fm_frequency_playing); SETTINGS_SaveFM(); - gFmPlayCountdown_10ms = 0; - gScheduleFM = false; - gAskToSave = false; + g_fm_play_count_down_10ms = 0; + g_schedule_fm = false; + g_ask_to_save = false; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; + g_enable_speaker = true; } int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) @@ -224,33 +224,33 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) 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 key_pressed, bool key_held) { #define STATE_FREQ_MODE 0 #define STATE_USER_MODE 1 #define STATE_SAVE 2 - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - if (!g_was_f_key_pressed) + if (!g_f_key_was_pressed) { uint8_t State; - if (gAskToDelete) + if (g_ask_to_delete) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (gAskToSave) + if (g_ask_to_save) { State = STATE_SAVE; } else { - if (gFM_ScanState != FM_SCAN_OFF) + if (g_fm_scan_state != FM_SCAN_OFF) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } @@ -259,32 +259,32 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; if (State == STATE_FREQ_MODE) { - if (gInputBoxIndex == 1) + if (g_input_box_index == 1) { - if (gInputBox[0] > 1) + if (g_input_box[0] > 1) { - gInputBox[1] = gInputBox[0]; - gInputBox[0] = 0; - gInputBoxIndex = 2; + g_input_box[1] = g_input_box[0]; + g_input_box[0] = 0; + g_input_box_index = 2; } } else - if (gInputBoxIndex > 3) + if (g_input_box_index > 3) { uint32_t Frequency; - gInputBoxIndex = 0; - NUMBER_Get(gInputBox, &Frequency); + g_input_box_index = 0; + NUMBER_Get(g_input_box, &Frequency); Frequency /= 10000; if (Frequency < g_eeprom.fm_lower_limit || g_eeprom.fm_upper_limit < Frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gRequestDisplayScreen = DISPLAY_FM; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_request_display_screen = DISPLAY_FM; return; } @@ -296,17 +296,17 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency; BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - gRequestSaveFM = true; + g_request_save_fm = true; return; } } else - if (gInputBoxIndex == 2) + if (g_input_box_index == 2) { uint8_t Channel; - gInputBoxIndex = 0; - Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; + g_input_box_index = 0; + Channel = ((g_input_box[0] * 10) + g_input_box[1]) - 1; if (State == STATE_USER_MODE) { @@ -316,9 +316,9 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_another_voice_id = (voice_id_t)Key; #endif g_eeprom.fm_selected_channel = Channel; - g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; + g_eeprom.fm_frequency_playing = g_fm_channels[Channel]; BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - gRequestSaveFM = true; + g_request_save_fm = true; return; } } @@ -328,13 +328,13 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gRequestDisplayScreen = DISPLAY_FM; - gInputBoxIndex = 0; - gFM_ChannelPosition = Channel; + g_request_display_screen = DISPLAY_FM; + g_input_box_index = 0; + g_fm_channel_position = Channel; return; } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } @@ -345,10 +345,10 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - g_was_f_key_pressed = false; - gUpdateStatus = true; - gRequestDisplayScreen = DISPLAY_FM; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + g_f_key_was_pressed = false; + g_update_status = true; + g_request_display_screen = DISPLAY_FM; switch (Key) { @@ -362,10 +362,10 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) if (!FM_ConfigureChannelState()) { BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - gRequestSaveFM = true; + g_request_save_fm = true; } else - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; case KEY_2: @@ -377,55 +377,55 @@ static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) break; default: - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } } } -static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void FM_Key_EXIT(bool key_pressed, bool key_held) { - if (bKeyHeld) + if (key_held) return; - if (!bKeyPressed) + if (!key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gFM_ScanState == FM_SCAN_OFF) + if (g_fm_scan_state == FM_SCAN_OFF) { - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { - if (!gAskToSave && !gAskToDelete) + if (!g_ask_to_save && !g_ask_to_delete) { ACTION_FM(); return; } - gAskToSave = false; - gAskToDelete = false; + g_ask_to_save = false; + g_ask_to_delete = false; } else { - gInputBox[--gInputBoxIndex] = 10; + g_input_box[--g_input_box_index] = 10; - if (gInputBoxIndex) + if (g_input_box_index) { - if (gInputBoxIndex != 1) + if (g_input_box_index != 1) { - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; return; } - if (gInputBox[0] != 0) + if (g_input_box[0] != 0) { - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; return; } } - gInputBoxIndex = 0; + g_input_box_index = 0; } #ifdef ENABLE_VOICE @@ -440,107 +440,107 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) #endif } - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; } -static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) +static void FM_Key_MENU(bool key_pressed, bool key_held) { - if (bKeyHeld) + if (key_held) return; - if (!bKeyPressed) + if (!key_pressed) return; - gRequestDisplayScreen = DISPLAY_FM; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_request_display_screen = DISPLAY_FM; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gFM_ScanState == FM_SCAN_OFF) + if (g_fm_scan_state == FM_SCAN_OFF) { if (!g_eeprom.fm_is_channel_mode) { - if (gAskToSave) + if (g_ask_to_save) { - gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing; - gAskToSave = false; - gRequestSaveFM = true; + g_fm_channels[g_fm_channel_position] = g_eeprom.fm_frequency_playing; + g_ask_to_save = false; + g_request_save_fm = true; } else - gAskToSave = true; + g_ask_to_save = true; } else { - if (gAskToDelete) + if (g_ask_to_delete) { - gFM_Channels[g_eeprom.fm_selected_channel] = 0xFFFF; + g_fm_channels[g_eeprom.fm_selected_channel] = 0xFFFF; FM_ConfigureChannelState(); BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - gRequestSaveFM = true; - gAskToDelete = false; + g_request_save_fm = true; + g_ask_to_delete = false; } else - gAskToDelete = true; + g_ask_to_delete = true; } } else { - if (gFM_AutoScan || !gFM_FoundFrequency) + if (g_fm_auto_scan || !g_fm_found_frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gInputBoxIndex = 0; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_input_box_index = 0; return; } - if (gAskToSave) + if (g_ask_to_save) { - gFM_Channels[gFM_ChannelPosition] = g_eeprom.fm_frequency_playing; - gAskToSave = false; - gRequestSaveFM = true; + g_fm_channels[g_fm_channel_position] = g_eeprom.fm_frequency_playing; + g_ask_to_save = false; + g_request_save_fm = true; } else - gAskToSave = true; + g_ask_to_save = true; } } -static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) +static void FM_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Step) { - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) { - if (gInputBoxIndex) + if (g_input_box_index) return; - if (!bKeyPressed) + if (!key_pressed) return; } else { - if (gInputBoxIndex) + if (g_input_box_index) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; } - if (gAskToSave) + if (g_ask_to_save) { - gRequestDisplayScreen = DISPLAY_FM; - gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); + g_request_display_screen = DISPLAY_FM; + g_fm_channel_position = NUMBER_AddWithWraparound(g_fm_channel_position, Step, 0, 19); return; } - if (gFM_ScanState != FM_SCAN_OFF) + if (g_fm_scan_state != FM_SCAN_OFF) { - if (gFM_AutoScan) + if (g_fm_auto_scan) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } FM_Tune(g_eeprom.fm_frequency_playing, Step, false); - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; return; } @@ -551,7 +551,7 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) goto Bail; g_eeprom.fm_selected_channel = Channel; - g_eeprom.fm_frequency_playing = gFM_Channels[Channel]; + g_eeprom.fm_frequency_playing = g_fm_channels[Channel]; } else { @@ -566,15 +566,15 @@ static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; } - gRequestSaveFM = true; + g_request_save_fm = true; Bail: BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; } -void FM_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +void FM_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held) { switch (Key) { @@ -588,29 +588,29 @@ void FM_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) case KEY_7: case KEY_8: case KEY_9: - FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + FM_Key_DIGITS(Key, key_pressed, key_held); break; case KEY_MENU: - FM_Key_MENU(bKeyPressed, bKeyHeld); + FM_Key_MENU(key_pressed, key_held); return; case KEY_UP: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + FM_Key_UP_DOWN(key_pressed, key_held, 1); break; case KEY_DOWN: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + FM_Key_UP_DOWN(key_pressed, key_held, -1); break;; case KEY_EXIT: - FM_Key_EXIT(bKeyPressed, bKeyHeld); + FM_Key_EXIT(key_pressed, key_held); break; case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); + GENERIC_Key_F(key_pressed, key_held); break; case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); + GENERIC_Key_PTT(key_pressed); break; default: - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } } @@ -619,25 +619,25 @@ void FM_Play(void) { if (!FM_CheckFrequencyLock(g_eeprom.fm_frequency_playing, g_eeprom.fm_lower_limit)) { - if (!gFM_AutoScan) + if (!g_fm_auto_scan) { - gFmPlayCountdown_10ms = 0; - gFM_FoundFrequency = true; + g_fm_play_count_down_10ms = 0; + g_fm_found_frequency = true; 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; + g_enable_speaker = true; GUI_SelectNextDisplay(DISPLAY_FM); return; } - if (gFM_ChannelPosition < 20) - gFM_Channels[gFM_ChannelPosition++] = g_eeprom.fm_frequency_playing; + if (g_fm_channel_position < 20) + g_fm_channels[g_fm_channel_position++] = g_eeprom.fm_frequency_playing; - if (gFM_ChannelPosition >= 20) + if (g_fm_channel_position >= 20) { FM_PlayAndUpdate(); GUI_SelectNextDisplay(DISPLAY_FM); @@ -645,26 +645,26 @@ void FM_Play(void) } } - if (gFM_AutoScan && g_eeprom.fm_frequency_playing >= g_eeprom.fm_upper_limit) + if (g_fm_auto_scan && g_eeprom.fm_frequency_playing >= g_eeprom.fm_upper_limit) FM_PlayAndUpdate(); else - FM_Tune(g_eeprom.fm_frequency_playing, gFM_ScanState, false); + FM_Tune(g_eeprom.fm_frequency_playing, g_fm_scan_state, false); GUI_SelectNextDisplay(DISPLAY_FM); } void FM_Start(void) { - gFmRadioMode = true; - gFM_ScanState = FM_SCAN_OFF; - gFM_RestoreCountdown_10ms = 0; + g_fm_radio_mode = true; + g_fm_scan_state = FM_SCAN_OFF; + g_fm_restore_count_down_10ms = 0; BK1080_Init(g_eeprom.fm_frequency_playing, true); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; - gUpdateStatus = true; + g_enable_speaker = true; + g_update_status = true; } #endif diff --git a/app/fm.h b/app/fm.h index 41947dc7..57ed8490 100644 --- a/app/fm.h +++ b/app/fm.h @@ -28,19 +28,19 @@ enum { FM_SCAN_OFF = 0U, }; -extern uint16_t gFM_Channels[20]; -extern bool gFmRadioMode; -extern uint8_t gFmRadioCountdown_500ms; -extern volatile uint16_t gFmPlayCountdown_10ms; -extern volatile int8_t gFM_ScanState; -extern bool gFM_AutoScan; -extern uint8_t gFM_ChannelPosition; +extern uint16_t g_fm_channels[20]; +extern bool g_fm_radio_mode; +extern uint8_t g_fm_radio_count_down_500ms; +extern volatile uint16_t g_fm_play_count_down_10ms; +extern volatile int8_t g_fm_scan_state; +extern bool g_fm_auto_scan; +extern uint8_t g_fm_channel_position; // Doubts about whether this should be signed or not -extern uint16_t gFM_FrequencyDeviation; -extern bool gFM_FoundFrequency; -extern bool gFM_AutoScan; -extern uint8_t gFM_ResumeCountdown_500ms; -extern uint16_t gFM_RestoreCountdown_10ms; +extern uint16_t g_fm_frequency_deviation; +extern bool g_fm_found_frequency; +extern bool g_fm_auto_scan; +extern uint8_t g_fm_resume_count_down_500ms; +extern uint16_t g_fm_restore_count_down_10ms; bool FM_CheckValidChannel(uint8_t Channel); uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction); diff --git a/app/generic.c b/app/generic.c index 25c223c2..332c64e8 100644 --- a/app/generic.c +++ b/app/generic.c @@ -33,31 +33,31 @@ #include "ui/inputbox.h" #include "ui/ui.h" -void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) +void GENERIC_Key_F(bool key_pressed, bool key_held) { - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) { - if (bKeyHeld || bKeyPressed) + if (key_held || key_pressed) { - if (!bKeyHeld) + if (!key_held) return; - if (!bKeyPressed) + if (!key_pressed) return; - if (gScreenToDisplay != DISPLAY_MENU && - gScreenToDisplay != DISPLAY_FM && + if (g_screen_to_display != DISPLAY_MENU && + g_screen_to_display != DISPLAY_FM && #ifdef ENABLE_FMRADIO - !gFmRadioMode && + !g_fm_radio_mode && #endif - gCurrentFunction != FUNCTION_TRANSMIT) + g_current_function != FUNCTION_TRANSMIT) { // toggle the keyboad lock #ifdef ENABLE_VOICE @@ -66,65 +66,65 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) g_eeprom.key_lock = !g_eeprom.key_lock; - gRequestSaveSettings = true; + g_request_save_settings = true; } } else { #ifdef ENABLE_FMRADIO - if ((gFmRadioMode || gScreenToDisplay != DISPLAY_MAIN) && gScreenToDisplay != DISPLAY_FM) + if ((g_fm_radio_mode || g_screen_to_display != DISPLAY_MAIN) && g_screen_to_display != DISPLAY_FM) return; #else - if (gScreenToDisplay != DISPLAY_MAIN) + if (g_screen_to_display != DISPLAY_MAIN) return; #endif - g_was_f_key_pressed = !g_was_f_key_pressed; + g_f_key_was_pressed = !g_f_key_was_pressed; - if (g_was_f_key_pressed) - gKeyInputCountdown = key_input_timeout_500ms; + if (g_f_key_was_pressed) + g_key_input_count_down = key_input_timeout_500ms; #ifdef ENABLE_VOICE - if (!g_was_f_key_pressed) + if (!g_f_key_was_pressed) g_another_voice_id = VOICE_ID_CANCEL; #endif - gUpdateStatus = true; + g_update_status = true; } } else { - if (gScreenToDisplay != DISPLAY_FM) + if (g_screen_to_display != DISPLAY_FM) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } #ifdef ENABLE_FMRADIO - if (gFM_ScanState == FM_SCAN_OFF) + if (g_fm_scan_state == FM_SCAN_OFF) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } #endif - gBeepToPlay = BEEP_440HZ_500MS; + g_beep_to_play = BEEP_440HZ_500MS; - gPttWasReleased = true; + g_ptt_was_released = true; } } -void GENERIC_Key_PTT(bool bKeyPressed) +void GENERIC_Key_PTT(bool key_pressed) { - gInputBoxIndex = 0; + g_input_box_index = 0; - if (!bKeyPressed || gSerialConfigCountDown_500ms > 0) + if (!key_pressed || g_serial_config_count_down_500ms > 0) { // PTT released - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { // we are transmitting .. stop - if (gFlagEndTransmission) + if (g_flag_end_tx) { FUNCTION_Select(FUNCTION_FOREGROUND); } @@ -135,19 +135,19 @@ void GENERIC_Key_PTT(bool bKeyPressed) if (g_eeprom.repeater_tail_tone_elimination == 0) FUNCTION_Select(FUNCTION_FOREGROUND); else - gRTTECountdown = g_eeprom.repeater_tail_tone_elimination * 10; + g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10; } - gFlagEndTransmission = false; + g_flag_end_tx = false; #ifdef ENABLE_VOX - gVOX_NoiseDetected = false; + g_vox_noise_detected = false; #endif - RADIO_SetVfoState(VFO_STATE_NORMAL); + RADIO_Setg_vfo_state(VFO_STATE_NORMAL); - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu + g_request_display_screen = DISPLAY_MAIN; } return; @@ -155,25 +155,25 @@ void GENERIC_Key_PTT(bool bKeyPressed) // PTT pressed - if (gScanStateDir != SCAN_OFF || // frequency/channel scanning - gScreenToDisplay == DISPLAY_SCANNER || // CTCSS/CDCSS scanning - gCssScanMode != CSS_SCAN_MODE_OFF) // " " + if (g_scan_state_dir != SCAN_OFF || // frequency/channel scanning + g_screen_to_display == DISPLAY_SCANNER || // CTCSS/CDCSS scanning + g_css_scan_mode != CSS_SCAN_MODE_OFF) // " " { // we're scanning .. stop - if (gScreenToDisplay == DISPLAY_SCANNER) + if (g_screen_to_display == DISPLAY_SCANNER) { // CTCSS/CDCSS scanning .. stop - g_eeprom.cross_vfo_rx_tx = gBackup_cross_vfo_rx_tx; - gFlagStopScan = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx; + g_flag_stop_scan = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; } else - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { // frequency/channel scanning . .stop SCANNER_Stop(); } else - if (gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_css_scan_mode != CSS_SCAN_MODE_OFF) { // CTCSS/CDCSS scanning .. stop MENU_StopCssScan(); @@ -186,87 +186,87 @@ void GENERIC_Key_PTT(bool bKeyPressed) } #ifdef ENABLE_FMRADIO - if (gFM_ScanState != FM_SCAN_OFF) + if (g_fm_scan_state != FM_SCAN_OFF) { // FM radio is scanning .. stop FM_PlayAndUpdate(); #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif - gRequestDisplayScreen = DISPLAY_FM; + g_request_display_screen = DISPLAY_FM; goto cancel_tx; } #endif #ifdef ENABLE_FMRADIO - if (gScreenToDisplay == DISPLAY_FM) + if (g_screen_to_display == DISPLAY_FM) goto start_tx; // listening to the FM radio .. start TX'ing #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && gRTTECountdown == 0) + if (g_current_function == FUNCTION_TRANSMIT && g_rtte_count_down == 0) { // already transmitting - gInputBoxIndex = 0; + g_input_box_index = 0; return; } - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu - gRequestDisplayScreen = DISPLAY_MAIN; + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu + g_request_display_screen = DISPLAY_MAIN; - if (!gDTMF_InputMode && gDTMF_InputBox_Index == 0) + if (!g_dtmf_input_mode && g_dtmf_input_box_index == 0) goto start_tx; // wasn't entering a DTMF code .. start TX'ing (maybe) // was entering a DTMF string - if (gDTMF_InputBox_Index > 0 || gDTMF_PreviousIndex > 0) + if (g_dtmf_input_box_index > 0 || g_dtmf_prev_index > 0) { // going to transmit a DTMF string - if (gDTMF_InputBox_Index == 0 && gDTMF_PreviousIndex > 0) - gDTMF_InputBox_Index = gDTMF_PreviousIndex; // use the previous DTMF string + if (g_dtmf_input_box_index == 0 && g_dtmf_prev_index > 0) + g_dtmf_input_box_index = g_dtmf_prev_index; // use the previous DTMF string - if (gDTMF_InputBox_Index < sizeof(gDTMF_InputBox)) - gDTMF_InputBox[gDTMF_InputBox_Index] = 0; // NULL term the string + if (g_dtmf_input_box_index < sizeof(g_dtmf_input_box)) + g_dtmf_input_box[g_dtmf_input_box_index] = 0; // NULL term the string #if 0 // append our DTMF ID to the inputted DTMF code - // IF the user inputted code is exactly 3 digits long - if (gDTMF_InputBox_Index == 3) - gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); + if (g_dtmf_input_box_index == 3) + g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3); else - gDTMF_CallMode = DTMF_CALL_MODE_DTMF; + g_dtmf_call_mode = DTMF_CALL_MODE_DTMF; #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) - gDTMF_CallMode = DTMF_CheckGroupCall(gDTMF_InputBox, 3); + if (g_dtmf_input_box_index == 3 && g_tx_vfo->dtmf_decoding_enable > 0) + g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3); else - gDTMF_CallMode = DTMF_CALL_MODE_DTMF; + g_dtmf_call_mode = DTMF_CALL_MODE_DTMF; #endif // remember the DTMF string - gDTMF_PreviousIndex = gDTMF_InputBox_Index; - strcpy(gDTMF_String, gDTMF_InputBox); + g_dtmf_prev_index = g_dtmf_input_box_index; + strcpy(g_dtmf_string, g_dtmf_input_box); - gDTMF_ReplyState = DTMF_REPLY_ANI; - gDTMF_State = DTMF_STATE_0; + g_dtmf_reply_state = DTMF_REPLY_ANI; + g_dtmf_state = DTMF_STATE_0; } DTMF_clear_input_box(); start_tx: // request start TX - gFlagPrepareTX = true; + g_flag_prepare_tx = true; goto done; - + cancel_tx: - if (gPttIsPressed) + if (g_ptt_is_pressed) { - gPttIsPressed = false; - gPttWasPressed = true; + g_ptt_is_pressed = false; + g_ptt_was_pressed = true; } -done: - gPttDebounceCounter = 0; - if (gScreenToDisplay != DISPLAY_MENU && gRequestDisplayScreen != DISPLAY_FM) // 1of11 .. don't close the menu - gRequestDisplayScreen = DISPLAY_MAIN; - gUpdateStatus = true; - gUpdateDisplay = true; +done: + g_ptt_debounce_counter = 0; + if (g_screen_to_display != DISPLAY_MENU && g_request_display_screen != DISPLAY_FM) // 1of11 .. don't close the menu + g_request_display_screen = DISPLAY_MAIN; + g_update_status = true; + g_update_display = true; } diff --git a/app/main.c b/app/main.c index 75b380ef..4853ca92 100644 --- a/app/main.c +++ b/app/main.c @@ -41,28 +41,28 @@ void toggle_chan_scanlist(void) { // toggle the selected channels scanlist setting - if (gScreenToDisplay == DISPLAY_SCANNER || !IS_USER_CHANNEL(gTxVfo->channel_save)) + if (g_screen_to_display == DISPLAY_SCANNER || !IS_USER_CHANNEL(g_tx_vfo->channel_save)) return; - if (gTxVfo->scanlist_1_participation) + if (g_tx_vfo->scanlist_1_participation) { - if (gTxVfo->scanlist_2_participation) - gTxVfo->scanlist_1_participation = 0; + if (g_tx_vfo->scanlist_2_participation) + g_tx_vfo->scanlist_1_participation = 0; else - gTxVfo->scanlist_2_participation = 1; + g_tx_vfo->scanlist_2_participation = 1; } else { - if (gTxVfo->scanlist_2_participation) - gTxVfo->scanlist_2_participation = 0; + if (g_tx_vfo->scanlist_2_participation) + g_tx_vfo->scanlist_2_participation = 0; else - gTxVfo->scanlist_1_participation = 1; + g_tx_vfo->scanlist_1_participation = 1; } - SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); + SETTINGS_UpdateChannel(g_tx_vfo->channel_save, g_tx_vfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + g_vfo_configure_mode = VFO_CONFIGURE; + g_flag_reset_vfos = true; } static void processFKeyFunction(const key_code_t Key, const bool beep) @@ -70,15 +70,15 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) uint8_t Band; uint8_t Vfo = g_eeprom.tx_vfo; - if (gScreenToDisplay == DISPLAY_MENU) + if (g_screen_to_display == DISPLAY_MENU) { // if (beep) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - + // if (beep) - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; switch (Key) { @@ -95,34 +95,34 @@ 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(g_tx_vfo->channel_save)) { - g_was_f_key_pressed = false; - gUpdateStatus = true; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_f_key_was_pressed = false; + g_update_status = true; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } - Band = gTxVfo->band + 1; - if (gSetting_350EN || Band != BAND5_350MHz) + Band = g_tx_vfo->band + 1; + if (g_setting_350_enable || Band != BAND5_350MHz) { if (Band > BAND7_470MHz) Band = BAND1_50MHz; } else Band = BAND6_400MHz; - gTxVfo->band = Band; + g_tx_vfo->band = 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; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; if (beep) - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; break; @@ -141,33 +141,33 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) else g_eeprom.tx_vfo = (Vfo + 1) & 1u; - gRequestSaveSettings = 1; - gFlagReconfigureVfos = true; + g_request_save_settings = 1; + g_flag_reconfigure_vfos = true; - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; if (beep) - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; break; case KEY_3: #ifdef ENABLE_NOAA - if (g_eeprom.vfo_open && IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save)) + if (g_eeprom.vfo_open && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save)) #else if (g_eeprom.vfo_open) #endif { uint8_t Channel; - if (IS_USER_CHANNEL(gTxVfo->channel_save)) + if (IS_USER_CHANNEL(g_tx_vfo->channel_save)) { // swap to frequency mode g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo]; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_FREQUENCY_MODE; #endif - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; break; } @@ -180,34 +180,34 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) AUDIO_SetDigitVoice(1, Channel + 1); g_another_voice_id = (voice_id_t)0xFE; #endif - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; break; } } if (beep) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; case KEY_4: - g_was_f_key_pressed = false; - gFlagStartScan = true; - gScanSingleFrequency = false; - gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; + g_f_key_was_pressed = false; + g_flag_start_scan = true; + g_scan_single_frequency = false; + g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; - gUpdateStatus = true; + g_update_status = true; // if (beep) -// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; +// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; break; case KEY_5: #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save)) + if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save)) { g_eeprom.screen_channel[Vfo] = g_eeprom.noaa_channel[g_eeprom.tx_vfo]; } @@ -218,8 +218,8 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) g_another_voice_id = VOICE_ID_FREQUENCY_MODE; #endif } - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; #else #ifdef ENABLE_VOX @@ -242,8 +242,8 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) break; case KEY_8: - gTxVfo->frequency_reverse = gTxVfo->frequency_reverse == false; - gRequestSaveChannel = 1; + g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false; + g_request_save_channel = 1; break; case KEY_9: @@ -256,42 +256,42 @@ static void processFKeyFunction(const key_code_t Key, const bool beep) AUDIO_SetDigitVoice(1, g_eeprom.chan_1_call + 1); g_another_voice_id = (voice_id_t)0xFE; #endif - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; break; } if (beep) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; default: - gUpdateStatus = true; - g_was_f_key_pressed = false; + g_update_status = true; + g_f_key_was_pressed = false; if (beep) - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; break; } } -static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held) { - if (bKeyHeld) + if (key_held) { // key held down - if (bKeyPressed) + if (key_pressed) { - if (gScreenToDisplay == DISPLAY_MAIN) + if (g_screen_to_display == DISPLAY_MAIN) { - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { // delete any inputted chars - gInputBoxIndex = 0; - gRequestDisplayScreen = DISPLAY_MAIN; + g_input_box_index = 0; + g_request_display_screen = DISPLAY_MAIN; } - g_was_f_key_pressed = false; - gUpdateStatus = true; + g_f_key_was_pressed = false; + g_update_status = true; processFKeyFunction(Key, false); } @@ -300,44 +300,44 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - if (bKeyPressed) + if (key_pressed) { // key is pressed - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed return; // don't use the key till it's released } - if (!g_was_f_key_pressed) + if (!g_f_key_was_pressed) { // F-key wasn't pressed const uint8_t Vfo = g_eeprom.tx_vfo; - gKeyInputCountdown = key_input_timeout_500ms; + g_key_input_count_down = key_input_timeout_500ms; INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; - if (IS_USER_CHANNEL(gTxVfo->channel_save)) + if (IS_USER_CHANNEL(g_tx_vfo->channel_save)) { // user is entering channel number uint16_t Channel; - if (gInputBoxIndex != 3) + if (g_input_box_index != 3) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1; if (!RADIO_CheckValidChannel(Channel, false, 0)) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } @@ -347,21 +347,21 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_eeprom.user_channel[Vfo] = (uint8_t)Channel; g_eeprom.screen_channel[Vfo] = (uint8_t)Channel; - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; return; } // #ifdef ENABLE_NOAA -// if (IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save)) +// if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save)) // #endif - if (IS_FREQ_CHANNEL(gTxVfo->channel_save)) + if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) { // user is entering a frequency uint32_t Frequency; - if (gInputBoxIndex < 6) + if (g_input_box_index < 6) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; @@ -370,14 +370,14 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - NUMBER_Get(gInputBox, &Frequency); + NUMBER_Get(g_input_box, &Frequency); // clamp the frequency entered to some valid value - if (Frequency < frequencyBandTable[0].lower) + if (Frequency < FREQ_BAND_TABLE[0].lower) { - Frequency = frequencyBandTable[0].lower; + Frequency = FREQ_BAND_TABLE[0].lower; } else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) @@ -386,9 +386,9 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower; } else - if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper) + if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) { - Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper; + Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper; } { @@ -398,9 +398,9 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_another_voice_id = (voice_id_t)Key; #endif - if (gTxVfo->band != band) + if (g_tx_vfo->band != band) { - gTxVfo->band = band; + g_tx_vfo->band = band; g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST; g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST; @@ -410,42 +410,42 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) } // Frequency += 75; // is this meant to be rounding ? - Frequency += gTxVfo->step_freq / 2; // no idea, but this is + Frequency += g_tx_vfo->step_freq / 2; // no idea, but this is - Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->step_freq, frequencyBandTable[gTxVfo->band].lower); + Frequency = FREQUENCY_FloorToStep(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->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->step_freq : BX4819_band2.lower; + Frequency = (Frequency < center) ? BX4819_band1.upper - g_tx_vfo->step_freq : BX4819_band2.lower; } - gTxVfo->freq_config_rx.frequency = Frequency; + g_tx_vfo->freq_config_rx.frequency = Frequency; - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; } } #ifdef ENABLE_NOAA else - if (IS_NOAA_CHANNEL(gTxVfo->channel_save)) + if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save)) { // user is entering NOAA channel uint8_t Channel; - if (gInputBoxIndex != 2) + if (g_input_box_index != 2) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - Channel = (gInputBox[0] * 10) + gInputBox[1]; + Channel = (g_input_box[0] * 10) + g_input_box[1]; if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) { Channel += NOAA_CHANNEL_FIRST; @@ -454,52 +454,52 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) #endif g_eeprom.noaa_channel[Vfo] = Channel; g_eeprom.screen_channel[Vfo] = Channel; - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; return; } } #endif - gRequestDisplayScreen = DISPLAY_MAIN; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_request_display_screen = DISPLAY_MAIN; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - g_was_f_key_pressed = false; - gUpdateStatus = true; + g_f_key_was_pressed = false; + g_update_status = true; processFKeyFunction(Key, true); } -static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void MAIN_Key_EXIT(bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { // exit key pressed - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT) + if (g_dtmf_call_state != DTMF_CALL_STATE_NONE && g_current_function != FUNCTION_TRANSMIT) { // clear CALL mode being displayed - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + g_update_display = true; return; } #ifdef ENABLE_FMRADIO - if (!gFmRadioMode) + if (!g_fm_radio_mode) #endif { - if (gScanStateDir == SCAN_OFF) + if (g_scan_state_dir == SCAN_OFF) { - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) return; - gInputBox[--gInputBoxIndex] = 10; + g_input_box[--g_input_box_index] = 10; - gKeyInputCountdown = key_input_timeout_500ms; + g_key_input_count_down = key_input_timeout_500ms; #ifdef ENABLE_VOICE - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) g_another_voice_id = VOICE_ID_CANCEL; #endif } @@ -512,7 +512,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) #endif } - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; return; } @@ -523,88 +523,88 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) return; } - if (bKeyHeld && bKeyPressed) + if (key_held && key_pressed) { // exit key held down - if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode) + if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode) { // cancel key input mode (channel/frequency entry) - gDTMF_InputMode = false; - gDTMF_InputBox_Index = 0; - memset(gDTMF_String, 0, sizeof(gDTMF_String)); - gInputBoxIndex = 0; - gRequestDisplayScreen = DISPLAY_MAIN; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_dtmf_input_mode = false; + g_dtmf_input_box_index = 0; + memset(g_dtmf_string, 0, sizeof(g_dtmf_string)); + g_input_box_index = 0; + g_request_display_screen = DISPLAY_MAIN; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; } } } -static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) +static void MAIN_Key_MENU(const bool key_pressed, const bool key_held) { - if (bKeyPressed && !bKeyHeld) + if (key_pressed && !key_held) // menu key pressed - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (bKeyHeld) + if (key_held) { // menu key held down (long press) - if (bKeyPressed) + if (key_pressed) { // long press MENU key - g_was_f_key_pressed = false; + g_f_key_was_pressed = false; - if (gScreenToDisplay == DISPLAY_MAIN) + if (g_screen_to_display == DISPLAY_MAIN) { - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { // delete any inputted chars - gInputBoxIndex = 0; - gRequestDisplayScreen = DISPLAY_MAIN; + g_input_box_index = 0; + g_request_display_screen = DISPLAY_MAIN; } - g_was_f_key_pressed = false; - gUpdateStatus = true; + g_f_key_was_pressed = false; + g_update_status = true; #ifdef ENABLE_COPY_CHAN_TO_VFO - if (g_eeprom.vfo_open && gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_eeprom.vfo_open && g_css_scan_mode == CSS_SCAN_MODE_OFF) { - if (gScanStateDir != SCAN_OFF) + if (g_scan_state_dir != SCAN_OFF) { - if (gCurrentFunction != FUNCTION_INCOMING || - gRxReceptionMode == RX_MODE_NONE || - gScanPauseDelayIn_10ms == 0) + if (g_current_function != FUNCTION_INCOMING || + g_rx_reception_mode == RX_MODE_NONE || + g_scan_pause_delay_in_10ms == 0) { // scan is running (not paused) return; } } - - const unsigned int vfo = get_rx_VFO(); + + const unsigned int vfo = get_RX_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 + g_eeprom.VfoInfo[vfo].band; + + const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band; g_eeprom.screen_channel[vfo] = channel; - g_eeprom.VfoInfo[vfo].channel_save = channel; + g_eeprom.vfo_info[vfo].channel_save = channel; g_eeprom.tx_vfo = vfo; RADIO_SelectVfos(); - RADIO_ApplyOffset(gRxVfo); - RADIO_ConfigureSquelchAndOutputPower(gRxVfo); + RADIO_ApplyOffset(g_rx_vfo); + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); RADIO_SetupRegisters(true); - //SETTINGS_SaveChannel(channel, g_eeprom.rx_vfo, gRxVfo, 1); + g_request_save_vfo = true; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - gUpdateStatus = true; - gUpdateDisplay = true; + g_update_status = true; + g_update_display = true; } } else { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } #endif @@ -614,121 +614,121 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) return; } - if (!bKeyPressed && !gDTMF_InputMode) + if (!key_pressed && !g_dtmf_input_mode) { // menu key released - const bool bFlag = (gInputBoxIndex == 0); - gInputBoxIndex = 0; + const bool flag = (g_input_box_index == 0); + g_input_box_index = 0; - if (bFlag) + if (flag) { - gFlagRefreshSetting = true; - gRequestDisplayScreen = DISPLAY_MENU; + g_flag_refresh_menu = true; + g_request_display_screen = DISPLAY_MENU; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_MENU; #endif } else { - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; } } } -static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) +static void MAIN_Key_STAR(bool key_pressed, bool key_held) { - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) return; - - if (gInputBoxIndex > 0) + + if (g_input_box_index > 0) { // entering a frequency or DTMF string - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (bKeyHeld && !g_was_f_key_pressed) + if (key_held && !g_f_key_was_pressed) { // long press .. toggle scanning - if (!bKeyPressed) + if (!key_pressed) return; // released ACTION_Scan(false); - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } - if (bKeyPressed) + if (key_pressed) { // just pressed -// gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; +// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_880HZ_40MS_OPTIONAL; return; } - + // just released - - if (!g_was_f_key_pressed) + + if (!g_f_key_was_pressed) { // pressed without the F-key #ifdef ENABLE_NOAA - if (gScanStateDir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(gTxVfo->channel_save)) + if (g_scan_state_dir == SCAN_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save)) #else - if (gScanStateDir == SCAN_OFF) + if (g_scan_state_dir == SCAN_OFF) #endif { // start entering a DTMF string - memmove(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1)); - gDTMF_InputBox_Index = 0; - gDTMF_InputMode = true; + memmove(g_dtmf_input_box, g_dtmf_string, MIN(sizeof(g_dtmf_input_box), sizeof(g_dtmf_string) - 1)); + g_dtmf_input_box_index = 0; + g_dtmf_input_mode = true; - gKeyInputCountdown = key_input_timeout_500ms; + g_key_input_count_down = key_input_timeout_500ms; - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; } } else { // with the F-key - g_was_f_key_pressed = false; + g_f_key_was_pressed = false; #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gTxVfo->channel_save)) + if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save)) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; - } + } #endif // scan the CTCSS/DCS code - gFlagStartScan = true; - gScanSingleFrequency = true; - gBackup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; + g_flag_start_scan = true; + g_scan_single_frequency = true; + g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; } - - gPttWasReleased = true; - gUpdateStatus = true; + g_ptt_was_released = true; + + g_update_status = true; } -static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) +static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction) { uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo]; - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) { // long press - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) return; - if (!bKeyPressed) + if (!key_pressed) { - if (!bKeyHeld) + if (!key_held) return; if (IS_FREQ_CHANNEL(Channel)) return; #ifdef ENABLE_VOICE - AUDIO_SetDigitVoice(0, gTxVfo->channel_save + 1); + AUDIO_SetDigitVoice(0, g_tx_vfo->channel_save + 1); g_another_voice_id = (voice_id_t)0xFE; #endif @@ -737,16 +737,16 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) } else { - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; } - if (gScanStateDir == SCAN_OFF) + if (g_scan_state_dir == SCAN_OFF) { #ifdef ENABLE_NOAA if (IS_NOT_NOAA_CHANNEL(Channel)) @@ -756,17 +756,17 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) if (IS_FREQ_CHANNEL(Channel)) { // step/down in frequency - const uint32_t frequency = APP_SetFrequencyByStep(gTxVfo, Direction); + const uint32_t frequency = APP_SetFrequencyByStep(g_tx_vfo, Direction); if (RX_freq_check(frequency) < 0) { // frequency not allowed - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - gTxVfo->freq_config_rx.frequency = frequency; + g_tx_vfo->freq_config_rx.frequency = frequency; - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; } @@ -777,10 +777,10 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) if (Channel == Next) return; - g_eeprom.user_channel[g_eeprom.tx_vfo] = Next; + g_eeprom.user_channel[g_eeprom.tx_vfo] = Next; g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next; - if (!bKeyHeld) + if (!key_held) { #ifdef ENABLE_VOICE AUDIO_SetDigitVoice(0, Next + 1); @@ -797,40 +797,40 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) } #endif - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + g_request_save_vfo = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; return; } // jump to the next channel CHANNEL_Next(false, Direction); - gScanPauseDelayIn_10ms = 1; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = 1; + g_schedule_scan_listen = false; - gPttWasReleased = true; + g_ptt_was_released = true; } -void MAIN_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held) { #ifdef ENABLE_FMRADIO - if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) + if (g_fm_radio_mode && Key != KEY_PTT && Key != KEY_EXIT) { - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } #endif - if (gDTMF_InputMode && bKeyPressed && !bKeyHeld) + if (g_dtmf_input_mode && key_pressed && !key_held) { const char Character = DTMF_GetCharacter(Key); if (Character != 0xFF) { // add key to DTMF string DTMF_Append(Character); - gKeyInputCountdown = key_input_timeout_500ms; - gRequestDisplayScreen = DISPLAY_MAIN; - gPttWasReleased = true; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_key_input_count_down = key_input_timeout_500ms; + g_request_display_screen = DISPLAY_MAIN; + g_ptt_was_released = true; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; return; } } @@ -853,32 +853,32 @@ void MAIN_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) case KEY_7: case KEY_8: case KEY_9: - MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + MAIN_Key_DIGITS(Key, key_pressed, key_held); break; case KEY_MENU: - MAIN_Key_MENU(bKeyPressed, bKeyHeld); + MAIN_Key_MENU(key_pressed, key_held); break; case KEY_UP: - MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + MAIN_Key_UP_DOWN(key_pressed, key_held, 1); break; case KEY_DOWN: - MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + MAIN_Key_UP_DOWN(key_pressed, key_held, -1); break; case KEY_EXIT: - MAIN_Key_EXIT(bKeyPressed, bKeyHeld); + MAIN_Key_EXIT(key_pressed, key_held); break; case KEY_STAR: - MAIN_Key_STAR(bKeyPressed, bKeyHeld); + MAIN_Key_STAR(key_pressed, key_held); break; case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); + GENERIC_Key_F(key_pressed, key_held); break; case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); + GENERIC_Key_PTT(key_pressed); break; default: - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } } diff --git a/app/menu.c b/app/menu.c index a358973a..2e4f7af9 100644 --- a/app/menu.c +++ b/app/menu.c @@ -77,23 +77,23 @@ void MENU_StartCssScan(int8_t Direction) { - gCssScanMode = CSS_SCAN_MODE_SCANNING; - gUpdateStatus = true; + g_css_scan_mode = CSS_SCAN_MODE_SCANNING; + g_update_status = true; - gMenuScrollDirection = Direction; + g_menu_scroll_direction = Direction; RADIO_SelectVfos(); MENU_SelectNextCode(); - gScanPauseDelayIn_10ms = scan_pause_delay_in_2_10ms; - gScheduleScanListen = false; + g_scan_pause_delay_in_10ms = scan_pause_delay_in_2_10ms; + g_schedule_scan_listen = false; } void MENU_StopCssScan(void) { - gCssScanMode = CSS_SCAN_MODE_OFF; - gUpdateStatus = true; + g_css_scan_mode = CSS_SCAN_MODE_OFF; + g_update_status = true; RADIO_SetupRegisters(true); } @@ -109,89 +109,89 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_STEP: *pMin = 0; - *pMax = ARRAY_SIZE(StepFrequencyTable) - 1; + *pMax = ARRAY_SIZE(STEP_FREQ_TABLE) - 1; break; case MENU_ABR: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_backlight) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_backlight) - 1; break; case MENU_F_LOCK: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_F_LOCK) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_f_lock) - 1; break; case MENU_MDF: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_MDF) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_mdf) - 1; break; case MENU_TXP: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_TXP) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_txp) - 1; break; case MENU_SFT_D: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SFT_D) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_shift_dir) - 1; break; case MENU_TDR: *pMin = 0; -// *pMax = ARRAY_SIZE(gSubMenu_TDR) - 1; - *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; +// *pMax = ARRAY_SIZE(g_sub_menu_tdr) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1; break; case MENU_XB: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_XB) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_xb) - 1; break; #ifdef ENABLE_VOICE case MENU_VOICE: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_VOICE) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_voice) - 1; break; #endif case MENU_SC_REV: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SC_REV) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_sc_rev) - 1; break; case MENU_ROGER: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_ROGER) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_roger_mode) - 1; break; case MENU_PONMSG: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_PONMSG) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_pwr_on_msg) - 1; break; case MENU_R_DCS: case MENU_T_DCS: *pMin = 0; *pMax = 208; - //*pMax = (ARRAY_SIZE(DCS_Options) * 2); + //*pMax = (ARRAY_SIZE(DCS_OPTIONS) * 2); break; case MENU_R_CTCS: case MENU_T_CTCS: *pMin = 0; - *pMax = ARRAY_SIZE(CTCSS_Options) - 1; + *pMax = ARRAY_SIZE(CTCSS_OPTIONS) - 1; break; case MENU_W_N: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_W_N) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_w_n) - 1; break; #ifdef ENABLE_ALARM case MENU_AL_MOD: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_AL_MOD) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_AL_MOD) - 1; break; #endif @@ -200,24 +200,24 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_SIDE2_SHORT: case MENU_SIDE2_LONG: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SIDE_BUTT) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_SIDE_BUTT) - 1; break; case MENU_RESET: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_RESET) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_RESET) - 1; break; case MENU_COMPAND: case MENU_ABR_ON_TX_RX: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_rx_tx) - 1; break; #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_AM_fix_test1) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_AM_fix_test1) - 1; break; #endif @@ -247,17 +247,17 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_SCREN: case MENU_TX_EN: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1; break; case MENU_SCR: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_SCRAMBLER) - 1; break; case MENU_TOT: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_TOT) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_TOT) - 1; break; #ifdef ENABLE_VOX @@ -284,7 +284,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_SAVE: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SAVE) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_SAVE) - 1; break; case MENU_MIC: @@ -300,17 +300,17 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_D_RSP: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_D_RSP) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_D_RSP) - 1; break; case MENU_PTT_ID: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_PTT_ID) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_PTT_ID) - 1; break; case MENU_BAT_TXT: *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_BAT_TXT) - 1; + *pMax = ARRAY_SIZE(g_sub_menu_BAT_TXT) - 1; break; case MENU_D_HOLD: @@ -352,86 +352,86 @@ 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 = &g_tx_vfo->freq_config_rx; - if (!MENU_GetLimits(gMenuCursor, &Min, &Max)) + if (!MENU_GetLimits(g_menu_cursor, &Min, &Max)) { - if (gSubMenuSelection < Min) gSubMenuSelection = Min; + if (g_sub_menu_selection < Min) g_sub_menu_selection = Min; else - if (gSubMenuSelection > Max) gSubMenuSelection = Max; + if (g_sub_menu_selection > Max) g_sub_menu_selection = Max; } - switch (gMenuCursor) + switch (g_menu_cursor) { default: return; case MENU_SQL: - g_eeprom.squelch_level = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE; + g_eeprom.squelch_level = g_sub_menu_selection; + g_vfo_configure_mode = VFO_CONFIGURE; break; case MENU_STEP: - gTxVfo->step_setting = gSubMenuSelection; - if (IS_FREQ_CHANNEL(gTxVfo->channel_save)) + g_tx_vfo->step_setting = g_sub_menu_selection; + if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) { - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; } return; case MENU_TXP: - gTxVfo->output_power = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->output_power = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_T_DCS: - pConfig = &gTxVfo->freq_config_tx; + pConfig = &g_tx_vfo->freq_config_tx; // Fallthrough case MENU_R_DCS: - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) { if (pConfig->code_type != CODE_TYPE_DIGITAL && pConfig->code_type != CODE_TYPE_REVERSE_DIGITAL) { - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; } Code = 0; pConfig->code_type = CODE_TYPE_OFF; } else - if (gSubMenuSelection < 105) + if (g_sub_menu_selection < 105) { pConfig->code_type = CODE_TYPE_DIGITAL; - Code = gSubMenuSelection - 1; + Code = g_sub_menu_selection - 1; } else { pConfig->code_type = CODE_TYPE_REVERSE_DIGITAL; - Code = gSubMenuSelection - 105; + Code = g_sub_menu_selection - 105; } pConfig->code = Code; - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" case MENU_T_CTCS: - pConfig = &gTxVfo->freq_config_tx; + pConfig = &g_tx_vfo->freq_config_tx; case MENU_R_CTCS: - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) { if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE) { - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; } - Code = 0; - pConfig->code = Code; + Code = 0; + pConfig->code = Code; pConfig->code_type = CODE_TYPE_OFF; BK4819_ExitSubAu(); @@ -439,106 +439,106 @@ void MENU_AcceptSetting(void) else { pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE; - Code = gSubMenuSelection - 1; - pConfig->code = Code; + Code = g_sub_menu_selection - 1; + pConfig->code = Code; - BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); + BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]); } - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; #pragma GCC diagnostic pop case MENU_SFT_D: - gTxVfo->tx_offset_freq_dir = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->tx_offset_freq_dir = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_OFFSET: - gTxVfo->tx_offset_freq = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->tx_offset_freq = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_W_N: - gTxVfo->channel_bandwidth = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->channel_bandwidth = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_SCR: - gTxVfo->scrambling_type = gSubMenuSelection; + g_tx_vfo->scrambling_type = g_sub_menu_selection; #if 0 - if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gSubMenuSelection - 1); + if (g_sub_menu_selection > 0 && g_setting_scramble_enable) + BK4819_EnableScramble(g_sub_menu_selection - 1); else BK4819_DisableScramble(); #endif - gRequestSaveChannel = 1; + g_request_save_channel= 1; return; case MENU_BCL: - gTxVfo->busy_channel_lock = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->busy_channel_lock = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_MEM_CH: - gTxVfo->channel_save = gSubMenuSelection; + g_tx_vfo->channel_save = g_sub_menu_selection; #if 0 - g_eeprom.user_channel[0] = gSubMenuSelection; + g_eeprom.user_channel[0] = g_sub_menu_selection; #else - g_eeprom.user_channel[g_eeprom.tx_vfo] = gSubMenuSelection; + g_eeprom.user_channel[g_eeprom.tx_vfo] = g_sub_menu_selection; #endif - gRequestSaveChannel = 2; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_request_save_channel = 2; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; return; case MENU_MEM_NAME: { // trailing trim for (int i = 9; i >= 0; i--) { - if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0x00 && edit[i] != 0xff) + if (g_edit[i] != ' ' && g_edit[i] != '_' && g_edit[i] != 0x00 && g_edit[i] != 0xff) break; - edit[i] = ' '; + g_edit[i] = ' '; } } // save the channel name - memset(gTxVfo->name, 0, sizeof(gTxVfo->name)); - memmove(gTxVfo->name, edit, 10); - SETTINGS_SaveChannel(gSubMenuSelection, g_eeprom.tx_vfo, gTxVfo, 3); - gFlagReconfigureVfos = true; + memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name)); + memmove(g_tx_vfo->name, g_edit, 10); + SETTINGS_SaveChannel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3); + g_flag_reconfigure_vfos = true; return; case MENU_SAVE: - g_eeprom.battery_save = gSubMenuSelection; + g_eeprom.battery_save = g_sub_menu_selection; break; #ifdef ENABLE_VOX case MENU_VOX: - g_eeprom.vox_switch = gSubMenuSelection != 0; + g_eeprom.vox_switch = g_sub_menu_selection != 0; if (g_eeprom.vox_switch) - g_eeprom.vox_level = gSubMenuSelection - 1; + g_eeprom.vox_level = g_sub_menu_selection - 1; BOARD_EEPROM_LoadMoreSettings(); - gFlagReconfigureVfos = true; - gUpdateStatus = true; + g_flag_reconfigure_vfos = true; + g_update_status = true; break; #endif case MENU_ABR: - g_eeprom.backlight = gSubMenuSelection; + g_eeprom.backlight = g_sub_menu_selection; break; case MENU_ABR_ON_TX_RX: - gSetting_backlight_on_tx_rx = gSubMenuSelection; + g_setting_backlight_on_tx_rx = g_sub_menu_selection; break; case MENU_TDR: -// g_eeprom.dual_watch = gSubMenuSelection; - g_eeprom.dual_watch = (gSubMenuSelection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF; +// g_eeprom.dual_watch = g_sub_menu_selection; + g_eeprom.dual_watch = (g_sub_menu_selection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF; - gFlagReconfigureVfos = true; - gUpdateStatus = true; + g_flag_reconfigure_vfos = true; + g_update_status = true; break; case MENU_XB: @@ -549,244 +549,244 @@ void MENU_AcceptSetting(void) return; #endif - g_eeprom.cross_vfo_rx_tx = gSubMenuSelection; - gFlagReconfigureVfos = true; - gUpdateStatus = true; + g_eeprom.cross_vfo_rx_tx = g_sub_menu_selection; + g_flag_reconfigure_vfos = true; + g_update_status = true; break; case MENU_BEEP: - g_eeprom.beep_control = gSubMenuSelection; + g_eeprom.beep_control = g_sub_menu_selection; break; case MENU_TOT: - g_eeprom.tx_timeout_timer = gSubMenuSelection; + g_eeprom.tx_timeout_timer = g_sub_menu_selection; break; #ifdef ENABLE_VOICE case MENU_VOICE: - g_eeprom.voice_prompt = gSubMenuSelection; - gUpdateStatus = true; + g_eeprom.voice_prompt = g_sub_menu_selection; + g_update_status = true; break; #endif case MENU_SC_REV: - g_eeprom.scan_resume_mode = gSubMenuSelection; + g_eeprom.scan_resume_mode = g_sub_menu_selection; break; case MENU_MDF: - g_eeprom.channel_display_mode = gSubMenuSelection; + g_eeprom.channel_display_mode = g_sub_menu_selection; break; case MENU_AUTOLK: - g_eeprom.auto_keypad_lock = gSubMenuSelection; - gKeyLockCountdown = 30; + g_eeprom.auto_keypad_lock = g_sub_menu_selection; + g_key_lock_count_down = 30; break; case MENU_S_ADD1: - gTxVfo->scanlist_1_participation = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + g_tx_vfo->scanlist_1_participation = g_sub_menu_selection; + SETTINGS_UpdateChannel(g_tx_vfo->channel_save, g_tx_vfo, true); + g_vfo_configure_mode = VFO_CONFIGURE; + g_flag_reset_vfos = true; return; case MENU_S_ADD2: - gTxVfo->scanlist_2_participation = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + g_tx_vfo->scanlist_2_participation = g_sub_menu_selection; + SETTINGS_UpdateChannel(g_tx_vfo->channel_save, g_tx_vfo, true); + g_vfo_configure_mode = VFO_CONFIGURE; + g_flag_reset_vfos = true; return; case MENU_STE: - g_eeprom.tail_note_elimination = gSubMenuSelection; + g_eeprom.tail_note_elimination = g_sub_menu_selection; break; case MENU_RP_STE: - g_eeprom.repeater_tail_tone_elimination = gSubMenuSelection; + g_eeprom.repeater_tail_tone_elimination = g_sub_menu_selection; break; case MENU_MIC: - g_eeprom.mic_sensitivity = gSubMenuSelection; + g_eeprom.mic_sensitivity = g_sub_menu_selection; BOARD_EEPROM_LoadMoreSettings(); - gFlagReconfigureVfos = true; + g_flag_reconfigure_vfos = true; break; #ifdef ENABLE_AUDIO_BAR case MENU_MIC_BAR: - gSetting_mic_bar = gSubMenuSelection; + g_setting_mic_bar = g_sub_menu_selection; break; #endif case MENU_COMPAND: - gTxVfo->compander = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->channel_save, gTxVfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; -// gRequestSaveChannel = 1; + g_tx_vfo->compander = g_sub_menu_selection; + SETTINGS_UpdateChannel(g_tx_vfo->channel_save, g_tx_vfo, true); + g_vfo_configure_mode = VFO_CONFIGURE; + g_flag_reset_vfos = true; +// g_request_save_channel = 1; return; case MENU_1_CALL: - g_eeprom.chan_1_call = gSubMenuSelection; + g_eeprom.chan_1_call = g_sub_menu_selection; break; case MENU_S_LIST: - g_eeprom.scan_list_default = gSubMenuSelection; + g_eeprom.scan_list_default = g_sub_menu_selection; break; #ifdef ENABLE_ALARM case MENU_AL_MOD: - g_eeprom.alarm_mode = gSubMenuSelection; + g_eeprom.alarm_mode = g_sub_menu_selection; break; #endif case MENU_D_ST: - g_eeprom.DTMF_side_tone = gSubMenuSelection; + g_eeprom.dtmf_side_tone = g_sub_menu_selection; break; case MENU_D_RSP: - g_eeprom.DTMF_decode_response = gSubMenuSelection; + g_eeprom.dtmf_decode_response = g_sub_menu_selection; break; case MENU_D_HOLD: - g_eeprom.DTMF_auto_reset_time = gSubMenuSelection; + g_eeprom.dtmf_auto_reset_time = g_sub_menu_selection; break; case MENU_D_PRE: - g_eeprom.DTMF_preload_time = gSubMenuSelection * 10; + g_eeprom.dtmf_preload_time = g_sub_menu_selection * 10; break; case MENU_PTT_ID: - gTxVfo->DTMF_ptt_id_tx_mode = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->dtmf_ptt_id_tx_mode = g_sub_menu_selection; + g_request_save_channel = 1; return; case MENU_BAT_TXT: - gSetting_battery_text = gSubMenuSelection; + g_setting_battery_text = g_sub_menu_selection; break; case MENU_D_DCD: - gTxVfo->DTMF_decoding_enable = gSubMenuSelection; + g_tx_vfo->dtmf_decoding_enable = g_sub_menu_selection; DTMF_clear_RX(); - gRequestSaveChannel = 1; + g_request_save_channel = 1; return; case MENU_D_LIVE_DEC: - gSetting_live_DTMF_decoder = gSubMenuSelection; - gDTMF_RX_live_timeout = 0; - memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); - if (!gSetting_live_DTMF_decoder) + g_setting_live_dtmf_decoder = g_sub_menu_selection; + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + if (!g_setting_live_dtmf_decoder) BK4819_DisableDTMF(); - gFlagReconfigureVfos = true; - gUpdateStatus = true; + g_flag_reconfigure_vfos = true; + g_update_status = true; break; case MENU_D_LIST: - gDTMF_chosen_contact = gSubMenuSelection - 1; - if (gIsDtmfContactValid) + g_dtmf_chosen_contact = g_sub_menu_selection - 1; + if (g_dtmf_is_contact_valid) { GUI_SelectNextDisplay(DISPLAY_MAIN); - gDTMF_InputMode = true; - gDTMF_InputBox_Index = 3; - memmove(gDTMF_InputBox, gDTMF_ID, 4); - gRequestDisplayScreen = DISPLAY_INVALID; + g_dtmf_input_mode = true; + g_dtmf_input_box_index = 3; + memmove(g_dtmf_input_box, g_dtmf_id, 4); + g_request_display_screen = DISPLAY_INVALID; } return; case MENU_PONMSG: - g_eeprom.pwr_on_display_mode = gSubMenuSelection; + g_eeprom.pwr_on_display_mode = g_sub_menu_selection; break; case MENU_ROGER: - g_eeprom.roger_mode = gSubMenuSelection; + g_eeprom.roger_mode = g_sub_menu_selection; break; case MENU_AM: - gTxVfo->am_mode = gSubMenuSelection; - gRequestSaveChannel = 1; + g_tx_vfo->am_mode = g_sub_menu_selection; + g_request_save_channel = 1; return; #ifdef ENABLE_AM_FIX case MENU_AM_FIX: - gSetting_AM_fix = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_setting_am_fix = g_sub_menu_selection; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; break; #endif #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: - gSetting_AM_fix_test1 = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_setting_am_fix_test1 = g_sub_menu_selection; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; break; #endif #ifdef ENABLE_NOAA case MENU_NOAA_S: - g_eeprom.NOAA_auto_scan = gSubMenuSelection; - gFlagReconfigureVfos = true; + g_eeprom.noaa_auto_scan = g_sub_menu_selection; + g_flag_reconfigure_vfos = true; break; #endif case MENU_DEL_CH: - SETTINGS_UpdateChannel(gSubMenuSelection, NULL, false); - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + SETTINGS_UpdateChannel(g_sub_menu_selection, NULL, false); + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; return; case MENU_SIDE1_SHORT: - g_eeprom.key1_short_press_action = gSubMenuSelection; + g_eeprom.key1_short_press_action = g_sub_menu_selection; break; case MENU_SIDE1_LONG: - g_eeprom.key1_long_press_action = gSubMenuSelection; + g_eeprom.key1_long_press_action = g_sub_menu_selection; break; case MENU_SIDE2_SHORT: - g_eeprom.key2_short_press_action = gSubMenuSelection; + g_eeprom.key2_short_press_action = g_sub_menu_selection; break; case MENU_SIDE2_LONG: - g_eeprom.key2_long_press_action = gSubMenuSelection; + g_eeprom.key2_long_press_action = g_sub_menu_selection; break; case MENU_RESET: - BOARD_FactoryReset(gSubMenuSelection); + BOARD_FactoryReset(g_sub_menu_selection); return; case MENU_350TX: - gSetting_350TX = gSubMenuSelection; + g_setting_350_tx_enable = g_sub_menu_selection; break; case MENU_F_LOCK: - gSetting_F_LOCK = gSubMenuSelection; + g_setting_f_lock = g_sub_menu_selection; break; case MENU_200TX: - gSetting_200TX = gSubMenuSelection; + g_setting_200_tx_enable = g_sub_menu_selection; break; case MENU_500TX: - gSetting_500TX = gSubMenuSelection; + g_setting_500_tx_enable = g_sub_menu_selection; break; case MENU_350EN: - gSetting_350EN = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_setting_350_enable = g_sub_menu_selection; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; break; case MENU_SCREN: - gSetting_ScrambleEnable = gSubMenuSelection; - gFlagReconfigureVfos = true; + g_setting_scramble_enable = g_sub_menu_selection; + g_flag_reconfigure_vfos = true; break; case MENU_TX_EN: - gSetting_TX_EN = gSubMenuSelection; + g_Setting_tx_enable = g_sub_menu_selection; break; #ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: - writeXtalFreqCal(gSubMenuSelection, true); + writeXtalFreqCal(g_sub_menu_selection, true); return; #endif @@ -794,66 +794,66 @@ void MENU_AcceptSetting(void) { uint16_t buf[4]; - gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below - gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value - gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value - gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value - gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value - gBatteryCalibration[5] = 2300; - EEPROM_WriteBuffer(0x1F40, gBatteryCalibration); + g_battery_calibration[0] = (520ul * g_sub_menu_selection) / 760; // 5.20V empty, blinking above this value, reduced functionality below + g_battery_calibration[1] = (700ul * g_sub_menu_selection) / 760; // 7.00V, ~5%, 1 bars above this value + g_battery_calibration[2] = (745ul * g_sub_menu_selection) / 760; // 7.45V, ~17%, 2 bars above this value + g_battery_calibration[3] = g_sub_menu_selection; // 7.6V, ~29%, 3 bars above this value + g_battery_calibration[4] = (788ul * g_sub_menu_selection) / 760; // 7.88V, ~65%, 4 bars above this value + g_battery_calibration[5] = 2300; + EEPROM_WriteBuffer(0x1F40, g_battery_calibration); EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf)); - buf[0] = gBatteryCalibration[4]; - buf[1] = gBatteryCalibration[5]; + buf[0] = g_battery_calibration[4]; + buf[1] = g_battery_calibration[5]; EEPROM_WriteBuffer(0x1F48, buf); break; } } - gRequestSaveSettings = true; + g_request_save_settings = true; } void MENU_SelectNextCode(void) { int32_t UpperLimit; - if (gMenuCursor == MENU_R_DCS) + if (g_menu_cursor == MENU_R_DCS) UpperLimit = 208; - //UpperLimit = ARRAY_SIZE(DCS_Options); + //UpperLimit = ARRAY_SIZE(DCS_OPTIONS); else - if (gMenuCursor == MENU_R_CTCS) - UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1; + if (g_menu_cursor == MENU_R_CTCS) + UpperLimit = ARRAY_SIZE(CTCSS_OPTIONS) - 1; else return; - gSubMenuSelection = NUMBER_AddWithWraparound(gSubMenuSelection, gMenuScrollDirection, 1, UpperLimit); + g_sub_menu_selection = NUMBER_AddWithWraparound(g_sub_menu_selection, g_menu_scroll_direction, 1, UpperLimit); - if (gMenuCursor == MENU_R_DCS) + if (g_menu_cursor == MENU_R_DCS) { - if (gSubMenuSelection > 104) + if (g_sub_menu_selection > 104) { - gSelectedcode_type = CODE_TYPE_REVERSE_DIGITAL; - gSelectedCode = gSubMenuSelection - 105; + g_selected_code_type = CODE_TYPE_REVERSE_DIGITAL; + g_selected_code = g_sub_menu_selection - 105; } else { - gSelectedcode_type = CODE_TYPE_DIGITAL; - gSelectedCode = gSubMenuSelection - 1; + g_selected_code_type = CODE_TYPE_DIGITAL; + g_selected_code = g_sub_menu_selection - 1; } } else { - gSelectedcode_type = CODE_TYPE_CONTINUOUS_TONE; - gSelectedCode = gSubMenuSelection - 1; + g_selected_code_type = CODE_TYPE_CONTINUOUS_TONE; + g_selected_code = g_sub_menu_selection - 1; } RADIO_SetupRegisters(true); - gScanPauseDelayIn_10ms = (gSelectedcode_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms; + g_scan_pause_delay_in_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms; - gUpdateDisplay = true; + g_update_display = true; } static void MENU_ClampSelection(int8_t Direction) @@ -861,364 +861,364 @@ static void MENU_ClampSelection(int8_t Direction) int32_t Min; int32_t Max; - if (!MENU_GetLimits(gMenuCursor, &Min, &Max)) + if (!MENU_GetLimits(g_menu_cursor, &Min, &Max)) { - int32_t Selection = gSubMenuSelection; + int32_t Selection = g_sub_menu_selection; if (Selection < Min) Selection = Min; else if (Selection > Max) Selection = Max; - gSubMenuSelection = NUMBER_AddWithWraparound(Selection, Direction, Min, Max); + g_sub_menu_selection = NUMBER_AddWithWraparound(Selection, Direction, Min, Max); } } void MENU_ShowCurrentSetting(void) { - switch (gMenuCursor) + switch (g_menu_cursor) { case MENU_SQL: - gSubMenuSelection = g_eeprom.squelch_level; + g_sub_menu_selection = g_eeprom.squelch_level; break; case MENU_STEP: - gSubMenuSelection = gTxVfo->step_setting; + g_sub_menu_selection = g_tx_vfo->step_setting; break; case MENU_TXP: - gSubMenuSelection = gTxVfo->output_power; + g_sub_menu_selection = g_tx_vfo->output_power; break; case MENU_R_DCS: - switch (gTxVfo->freq_config_rx.code_type) + switch (g_tx_vfo->freq_config_rx.code_type) { case CODE_TYPE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_rx.code + 1; + g_sub_menu_selection = g_tx_vfo->freq_config_rx.code + 1; break; case CODE_TYPE_REVERSE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_rx.code + 105; + g_sub_menu_selection = g_tx_vfo->freq_config_rx.code + 105; break; default: - gSubMenuSelection = 0; + g_sub_menu_selection = 0; break; } break; case MENU_RESET: - gSubMenuSelection = 0; + g_sub_menu_selection = 0; break; case MENU_R_CTCS: - gSubMenuSelection = (gTxVfo->freq_config_rx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_rx.code + 1 : 0; + g_sub_menu_selection = (g_tx_vfo->freq_config_rx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? g_tx_vfo->freq_config_rx.code + 1 : 0; break; case MENU_T_DCS: - switch (gTxVfo->freq_config_tx.code_type) + switch (g_tx_vfo->freq_config_tx.code_type) { case CODE_TYPE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_tx.code + 1; + g_sub_menu_selection = g_tx_vfo->freq_config_tx.code + 1; break; case CODE_TYPE_REVERSE_DIGITAL: - gSubMenuSelection = gTxVfo->freq_config_tx.code + 105; + g_sub_menu_selection = g_tx_vfo->freq_config_tx.code + 105; break; default: - gSubMenuSelection = 0; + g_sub_menu_selection = 0; break; } break; case MENU_T_CTCS: - gSubMenuSelection = (gTxVfo->freq_config_tx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_tx.code + 1 : 0; + g_sub_menu_selection = (g_tx_vfo->freq_config_tx.code_type == CODE_TYPE_CONTINUOUS_TONE) ? g_tx_vfo->freq_config_tx.code + 1 : 0; break; case MENU_SFT_D: - gSubMenuSelection = gTxVfo->tx_offset_freq_dir; + g_sub_menu_selection = g_tx_vfo->tx_offset_freq_dir; break; case MENU_OFFSET: - gSubMenuSelection = gTxVfo->tx_offset_freq; + g_sub_menu_selection = g_tx_vfo->tx_offset_freq; break; case MENU_W_N: - gSubMenuSelection = gTxVfo->channel_bandwidth; + g_sub_menu_selection = g_tx_vfo->channel_bandwidth; break; case MENU_SCR: - gSubMenuSelection = gTxVfo->scrambling_type; + g_sub_menu_selection = g_tx_vfo->scrambling_type; break; case MENU_BCL: - gSubMenuSelection = gTxVfo->busy_channel_lock; + g_sub_menu_selection = g_tx_vfo->busy_channel_lock; break; case MENU_MEM_CH: #if 0 - gSubMenuSelection = g_eeprom.user_channel[0]; + g_sub_menu_selection = g_eeprom.user_channel[0]; #else - gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo]; + g_sub_menu_selection = g_eeprom.user_channel[g_eeprom.tx_vfo]; #endif break; case MENU_MEM_NAME: - gSubMenuSelection = g_eeprom.user_channel[g_eeprom.tx_vfo]; + g_sub_menu_selection = g_eeprom.user_channel[g_eeprom.tx_vfo]; break; case MENU_SAVE: - gSubMenuSelection = g_eeprom.battery_save; + g_sub_menu_selection = g_eeprom.battery_save; break; #ifdef ENABLE_VOX case MENU_VOX: - gSubMenuSelection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0; + g_sub_menu_selection = g_eeprom.vox_switch ? g_eeprom.vox_level + 1 : 0; break; #endif case MENU_ABR: - gSubMenuSelection = g_eeprom.backlight; + g_sub_menu_selection = g_eeprom.backlight; - gBacklightCountdown = 0; + g_backlight_count_down = 0; GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu break; case MENU_ABR_ON_TX_RX: - gSubMenuSelection = gSetting_backlight_on_tx_rx; + g_sub_menu_selection = g_setting_backlight_on_tx_rx; break; case MENU_TDR: -// gSubMenuSelection = g_eeprom.dual_watch; - gSubMenuSelection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1; +// g_sub_menu_selection = g_eeprom.dual_watch; + g_sub_menu_selection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1; break; case MENU_XB: - gSubMenuSelection = g_eeprom.cross_vfo_rx_tx; + g_sub_menu_selection = g_eeprom.cross_vfo_rx_tx; break; case MENU_BEEP: - gSubMenuSelection = g_eeprom.beep_control; + g_sub_menu_selection = g_eeprom.beep_control; break; case MENU_TOT: - gSubMenuSelection = g_eeprom.tx_timeout_timer; + g_sub_menu_selection = g_eeprom.tx_timeout_timer; break; #ifdef ENABLE_VOICE case MENU_VOICE: - gSubMenuSelection = g_eeprom.voice_prompt; + g_sub_menu_selection = g_eeprom.voice_prompt; break; #endif case MENU_SC_REV: - gSubMenuSelection = g_eeprom.scan_resume_mode; + g_sub_menu_selection = g_eeprom.scan_resume_mode; break; case MENU_MDF: - gSubMenuSelection = g_eeprom.channel_display_mode; + g_sub_menu_selection = g_eeprom.channel_display_mode; break; case MENU_AUTOLK: - gSubMenuSelection = g_eeprom.auto_keypad_lock; + g_sub_menu_selection = g_eeprom.auto_keypad_lock; break; case MENU_S_ADD1: - gSubMenuSelection = gTxVfo->scanlist_1_participation; + g_sub_menu_selection = g_tx_vfo->scanlist_1_participation; break; case MENU_S_ADD2: - gSubMenuSelection = gTxVfo->scanlist_2_participation; + g_sub_menu_selection = g_tx_vfo->scanlist_2_participation; break; case MENU_STE: - gSubMenuSelection = g_eeprom.tail_note_elimination; + g_sub_menu_selection = g_eeprom.tail_note_elimination; break; case MENU_RP_STE: - gSubMenuSelection = g_eeprom.repeater_tail_tone_elimination; + g_sub_menu_selection = g_eeprom.repeater_tail_tone_elimination; break; case MENU_MIC: - gSubMenuSelection = g_eeprom.mic_sensitivity; + g_sub_menu_selection = g_eeprom.mic_sensitivity; break; #ifdef ENABLE_AUDIO_BAR case MENU_MIC_BAR: - gSubMenuSelection = gSetting_mic_bar; + g_sub_menu_selection = g_setting_mic_bar; break; #endif case MENU_COMPAND: - gSubMenuSelection = gTxVfo->compander; + g_sub_menu_selection = g_tx_vfo->compander; return; case MENU_1_CALL: - gSubMenuSelection = g_eeprom.chan_1_call; + g_sub_menu_selection = g_eeprom.chan_1_call; break; case MENU_S_LIST: - gSubMenuSelection = g_eeprom.scan_list_default; + g_sub_menu_selection = g_eeprom.scan_list_default; break; case MENU_SLIST1: - gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 0); + g_sub_menu_selection = RADIO_FindNextChannel(0, 1, true, 0); break; case MENU_SLIST2: - gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, 1); + g_sub_menu_selection = RADIO_FindNextChannel(0, 1, true, 1); break; #ifdef ENABLE_ALARM case MENU_AL_MOD: - gSubMenuSelection = g_eeprom.alarm_mode; + g_sub_menu_selection = g_eeprom.alarm_mode; break; #endif case MENU_D_ST: - gSubMenuSelection = g_eeprom.DTMF_side_tone; + g_sub_menu_selection = g_eeprom.dtmf_side_tone; break; case MENU_D_RSP: - gSubMenuSelection = g_eeprom.DTMF_decode_response; + g_sub_menu_selection = g_eeprom.dtmf_decode_response; break; case MENU_D_HOLD: - gSubMenuSelection = g_eeprom.DTMF_auto_reset_time; + g_sub_menu_selection = g_eeprom.dtmf_auto_reset_time; - if (gSubMenuSelection <= DTMF_HOLD_MIN) - gSubMenuSelection = DTMF_HOLD_MIN; + if (g_sub_menu_selection <= DTMF_HOLD_MIN) + g_sub_menu_selection = DTMF_HOLD_MIN; else - if (gSubMenuSelection <= 10) - gSubMenuSelection = 10; + if (g_sub_menu_selection <= 10) + g_sub_menu_selection = 10; else - if (gSubMenuSelection <= 20) - gSubMenuSelection = 20; + if (g_sub_menu_selection <= 20) + g_sub_menu_selection = 20; else - if (gSubMenuSelection <= 30) - gSubMenuSelection = 30; + if (g_sub_menu_selection <= 30) + g_sub_menu_selection = 30; else - if (gSubMenuSelection <= 40) - gSubMenuSelection = 40; + if (g_sub_menu_selection <= 40) + g_sub_menu_selection = 40; else - if (gSubMenuSelection <= 50) - gSubMenuSelection = 50; + if (g_sub_menu_selection <= 50) + g_sub_menu_selection = 50; else - if (gSubMenuSelection < DTMF_HOLD_MAX) - gSubMenuSelection = 50; + if (g_sub_menu_selection < DTMF_HOLD_MAX) + g_sub_menu_selection = 50; else - gSubMenuSelection = DTMF_HOLD_MAX; + g_sub_menu_selection = DTMF_HOLD_MAX; break; case MENU_D_PRE: - gSubMenuSelection = g_eeprom.DTMF_preload_time / 10; + g_sub_menu_selection = g_eeprom.dtmf_preload_time / 10; break; case MENU_PTT_ID: - gSubMenuSelection = gTxVfo->DTMF_ptt_id_tx_mode; + g_sub_menu_selection = g_tx_vfo->dtmf_ptt_id_tx_mode; break; case MENU_BAT_TXT: - gSubMenuSelection = gSetting_battery_text; + g_sub_menu_selection = g_setting_battery_text; return; case MENU_D_DCD: - gSubMenuSelection = gTxVfo->DTMF_decoding_enable; + g_sub_menu_selection = g_tx_vfo->dtmf_decoding_enable; break; case MENU_D_LIST: - gSubMenuSelection = gDTMF_chosen_contact + 1; + g_sub_menu_selection = g_dtmf_chosen_contact + 1; break; case MENU_D_LIVE_DEC: - gSubMenuSelection = gSetting_live_DTMF_decoder; + g_sub_menu_selection = g_setting_live_dtmf_decoder; break; case MENU_PONMSG: - gSubMenuSelection = g_eeprom.pwr_on_display_mode; + g_sub_menu_selection = g_eeprom.pwr_on_display_mode; break; case MENU_ROGER: - gSubMenuSelection = g_eeprom.roger_mode; + g_sub_menu_selection = g_eeprom.roger_mode; break; case MENU_AM: - gSubMenuSelection = gTxVfo->am_mode; + g_sub_menu_selection = g_tx_vfo->am_mode; break; #ifdef ENABLE_AM_FIX case MENU_AM_FIX: - gSubMenuSelection = gSetting_AM_fix; + g_sub_menu_selection = g_setting_am_fix; break; #endif #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: - gSubMenuSelection = gSetting_AM_fix_test1; + g_sub_menu_selection = g_setting_am_fix_test1; break; #endif #ifdef ENABLE_NOAA case MENU_NOAA_S: - gSubMenuSelection = g_eeprom.NOAA_auto_scan; + g_sub_menu_selection = g_eeprom.noaa_auto_scan; break; #endif case MENU_DEL_CH: #if 0 - gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1); + g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.user_channel[0], 1, false, 1); #else - gSubMenuSelection = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 1); + g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.user_channel[g_eeprom.tx_vfo], 1, false, 1); #endif break; case MENU_SIDE1_SHORT: - gSubMenuSelection = g_eeprom.key1_short_press_action; + g_sub_menu_selection = g_eeprom.key1_short_press_action; break; case MENU_SIDE1_LONG: - gSubMenuSelection = g_eeprom.key1_long_press_action; + g_sub_menu_selection = g_eeprom.key1_long_press_action; break; case MENU_SIDE2_SHORT: - gSubMenuSelection = g_eeprom.key2_short_press_action; + g_sub_menu_selection = g_eeprom.key2_short_press_action; break; case MENU_SIDE2_LONG: - gSubMenuSelection = g_eeprom.key2_long_press_action; + g_sub_menu_selection = g_eeprom.key2_long_press_action; break; case MENU_350TX: - gSubMenuSelection = gSetting_350TX; + g_sub_menu_selection = g_setting_350_tx_enable; break; case MENU_F_LOCK: - gSubMenuSelection = gSetting_F_LOCK; + g_sub_menu_selection = g_setting_f_lock; break; case MENU_200TX: - gSubMenuSelection = gSetting_200TX; + g_sub_menu_selection = g_setting_200_tx_enable; break; case MENU_500TX: - gSubMenuSelection = gSetting_500TX; + g_sub_menu_selection = g_setting_500_tx_enable; break; case MENU_350EN: - gSubMenuSelection = gSetting_350EN; + g_sub_menu_selection = g_setting_350_enable; break; case MENU_SCREN: - gSubMenuSelection = gSetting_ScrambleEnable; + g_sub_menu_selection = g_setting_scramble_enable; break; case MENU_TX_EN: - gSubMenuSelection = gSetting_TX_EN; + g_sub_menu_selection = g_Setting_tx_enable; break; #ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: - gSubMenuSelection = g_eeprom.BK4819_xtal_freq_low; + g_sub_menu_selection = g_eeprom.BK4819_xtal_freq_low; break; #endif case MENU_BATCAL: - gSubMenuSelection = gBatteryCalibration[3]; + g_sub_menu_selection = g_battery_calibration[3]; break; default: @@ -1226,34 +1226,34 @@ 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 key_pressed, bool key_held) { uint8_t Offset; int32_t Min; int32_t Max; uint16_t Value = 0; - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) + if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0) { // currently editing the channel name - if (edit_index < 10) + if (g_edit_index < 10) { if (Key >= KEY_0 && Key <= KEY_9) { - edit[edit_index] = '0' + Key - KEY_0; + g_edit[g_edit_index] = '0' + Key - KEY_0; - if (++edit_index >= 10) + if (++g_edit_index >= 10) { // exit edit - gFlagAcceptSetting = false; - gAskForConfirmation = 1; + g_flag_AcceptSetting = false; + g_ask_for_confirmation = 1; } - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } } @@ -1262,39 +1262,39 @@ static void MENU_Key_0_to_9(key_code_t Key, bool bKeyPressed, bool bKeyHeld) INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; - if (!gIsInSubMenu) + if (!g_is_in_sub_menu) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gInputBoxIndex) + switch (g_input_box_index) { case 2: - gInputBoxIndex = 0; + g_input_box_index = 0; - Value = (gInputBox[0] * 10) + gInputBox[1]; + Value = (g_input_box[0] * 10) + g_input_box[1]; - if (Value > 0 && Value <= gMenuListCount) + if (Value > 0 && Value <= g_menu_list_count) { - gMenuCursor = Value - 1; - gFlagRefreshSetting = true; + g_menu_cursor = Value - 1; + g_flag_refresh_menu = true; return; } - if (Value <= gMenuListCount) + if (Value <= g_menu_list_count) break; - gInputBox[0] = gInputBox[1]; - gInputBoxIndex = 1; + g_input_box[0] = g_input_box[1]; + g_input_box_index = 1; case 1: - Value = gInputBox[0]; - if (Value > 0 && Value <= gMenuListCount) + Value = g_input_box[0]; + if (Value > 0 && Value <= g_menu_list_count) { - gMenuCursor = Value - 1; - gFlagRefreshSetting = true; + g_menu_cursor = Value - 1; + g_flag_refresh_menu = true; return; } break; @@ -1302,17 +1302,17 @@ static void MENU_Key_0_to_9(key_code_t Key, bool bKeyPressed, bool bKeyHeld) #pragma GCC diagnostic pop - gInputBoxIndex = 0; + g_input_box_index = 0; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (gMenuCursor == MENU_OFFSET) + if (g_menu_cursor == MENU_OFFSET) { uint32_t Frequency; - if (gInputBoxIndex < 6) + if (g_input_box_index < 6) { // invalid frequency #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; @@ -1324,104 +1324,107 @@ static void MENU_Key_0_to_9(key_code_t Key, bool bKeyPressed, bool bKeyHeld) g_another_voice_id = (voice_id_t)Key; #endif - NUMBER_Get(gInputBox, &Frequency); - gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 75, gTxVfo->step_freq, 0); + NUMBER_Get(g_input_box, &Frequency); + g_sub_menu_selection = FREQUENCY_FloorToStep(Frequency + 75, g_tx_vfo->step_freq, 0); - gInputBoxIndex = 0; + g_input_box_index = 0; return; } - if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL || gMenuCursor == MENU_MEM_NAME) + if (g_menu_cursor == MENU_MEM_CH || + g_menu_cursor == MENU_DEL_CH || + g_menu_cursor == MENU_1_CALL || + g_menu_cursor == MENU_MEM_NAME) { // enter 3-digit channel number - if (gInputBoxIndex < 3) + if (g_input_box_index < 3) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + Value = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1; if (Value <= USER_CHANNEL_LAST) - { + { // user channel #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gSubMenuSelection = Value; + g_sub_menu_selection = Value; return; } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (MENU_GetLimits(gMenuCursor, &Min, &Max)) + if (MENU_GetLimits(g_menu_cursor, &Min, &Max)) { - gInputBoxIndex = 0; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_input_box_index = 0; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1; - switch (gInputBoxIndex) + switch (g_input_box_index) { case 1: - Value = gInputBox[0]; + Value = g_input_box[0]; break; case 2: - Value = (gInputBox[0] * 10) + gInputBox[1]; + Value = (g_input_box[0] * 10) + g_input_box[1]; break; case 3: - Value = (gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]; + Value = (g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]; break; } - if (Offset == gInputBoxIndex) - gInputBoxIndex = 0; + if (Offset == g_input_box_index) + g_input_box_index = 0; if (Value <= Max) { - gSubMenuSelection = Value; + g_sub_menu_selection = Value; return; } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } -static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void MENU_Key_EXIT(bool key_pressed, bool key_held) { - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_css_scan_mode == CSS_SCAN_MODE_OFF) { - if (gIsInSubMenu) + if (g_is_in_sub_menu) { - if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET) + if (g_input_box_index == 0 || g_menu_cursor != MENU_OFFSET) { - gAskForConfirmation = 0; - gIsInSubMenu = false; - gInputBoxIndex = 0; - gFlagRefreshSetting = true; + g_ask_for_confirmation = 0; + g_is_in_sub_menu = false; + g_input_box_index = 0; + g_flag_refresh_menu = true; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_CANCEL; #endif } else - gInputBox[--gInputBoxIndex] = 10; + g_input_box[--g_input_box_index] = 10; // *********************** - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; return; } @@ -1429,11 +1432,11 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) g_another_voice_id = VOICE_ID_CANCEL; #endif - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; if (g_eeprom.backlight == 0) { - gBacklightCountdown = 0; + g_backlight_count_down = 0; GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF } } @@ -1445,109 +1448,109 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } - gPttWasReleased = true; + g_ptt_was_released = true; } -static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) +static void MENU_Key_MENU(const bool key_pressed, const bool key_held) { - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gRequestDisplayScreen = DISPLAY_MENU; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + g_request_display_screen = DISPLAY_MENU; - if (!gIsInSubMenu) + if (!g_is_in_sub_menu) { #ifdef ENABLE_VOICE - if (gMenuCursor != MENU_SCR) - g_another_voice_id = MenuList[MenuList_sorted[gMenuCursor]].voice_id; + if (g_menu_cursor != MENU_SCR) + g_another_voice_id = g_menu_list[g_menu_list_sorted[g_menu_cursor]].voice_id; #endif #if 1 - if (gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_MEM_NAME) - if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) + if (g_menu_cursor == MENU_DEL_CH || g_menu_cursor == MENU_MEM_NAME) + if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0)) return; // invalid channel #endif - gAskForConfirmation = 0; - gIsInSubMenu = true; + g_ask_for_confirmation = 0; + g_is_in_sub_menu = true; -// if (gMenuCursor != MENU_D_LIST) +// if (g_menu_cursor != MENU_D_LIST) { - gInputBoxIndex = 0; - edit_index = -1; + g_input_box_index = 0; + g_edit_index = -1; } return; } - if (gMenuCursor == MENU_MEM_NAME) + if (g_menu_cursor == MENU_MEM_NAME) { - if (edit_index < 0) + if (g_edit_index < 0) { // enter channel name edit mode - if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) + if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0)) return; - BOARD_fetchChannelName(edit, gSubMenuSelection); + BOARD_fetchChannelName(g_edit, g_sub_menu_selection); // pad the channel name out with '_' - edit_index = strlen(edit); - while (edit_index < 10) - edit[edit_index++] = '_'; - edit[edit_index] = 0; - edit_index = 0; // 'edit_index' is going to be used as the cursor position + g_edit_index = strlen(g_edit); + while (g_edit_index < 10) + g_edit[g_edit_index++] = '_'; + g_edit[g_edit_index] = 0; + g_edit_index = 0; // 'g_edit_index' is going to be used as the cursor position // make a copy so we can test for change when exiting the menu item - memmove(edit_original, edit, sizeof(edit_original)); + memmove(g_edit_original, g_edit, sizeof(g_edit_original)); return; } else - if (edit_index >= 0 && edit_index < 10) + if (g_edit_index >= 0 && g_edit_index < 10) { // editing the channel name characters - if (++edit_index < 10) + if (++g_edit_index < 10) return; // next char // exit - if (memcmp(edit_original, edit, sizeof(edit_original)) == 0) + if (memcmp(g_edit_original, g_edit, sizeof(g_edit_original)) == 0) { // no change - drop it - gFlagAcceptSetting = false; - gIsInSubMenu = false; - gAskForConfirmation = 0; + g_flag_AcceptSetting = false; + g_is_in_sub_menu = false; + g_ask_for_confirmation = 0; } else { - gFlagAcceptSetting = false; - gAskForConfirmation = 0; + g_flag_AcceptSetting = false; + g_ask_for_confirmation = 0; } } } // exiting the sub menu - if (gIsInSubMenu) + if (g_is_in_sub_menu) { - if (gMenuCursor == MENU_RESET || - gMenuCursor == MENU_MEM_CH || - gMenuCursor == MENU_DEL_CH || - gMenuCursor == MENU_MEM_NAME) + if (g_menu_cursor == MENU_RESET || + g_menu_cursor == MENU_MEM_CH || + g_menu_cursor == MENU_DEL_CH || + g_menu_cursor == MENU_MEM_NAME) { - switch (gAskForConfirmation) + switch (g_ask_for_confirmation) { case 0: - gAskForConfirmation = 1; + g_ask_for_confirmation = 1; break; case 1: - gAskForConfirmation = 2; + g_ask_for_confirmation = 2; UI_DisplayMenu(); - if (gMenuCursor == MENU_RESET) + if (g_menu_cursor == MENU_RESET) { #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); @@ -1563,55 +1566,55 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) #endif } - gFlagAcceptSetting = true; - gIsInSubMenu = false; - gAskForConfirmation = 0; + g_flag_AcceptSetting = true; + g_is_in_sub_menu = false; + g_ask_for_confirmation = 0; } } else { - gFlagAcceptSetting = true; - gIsInSubMenu = false; + g_flag_AcceptSetting = true; + g_is_in_sub_menu = false; } } - if (gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_css_scan_mode != CSS_SCAN_MODE_OFF) { - gCssScanMode = CSS_SCAN_MODE_OFF; - gUpdateStatus = true; + g_css_scan_mode = CSS_SCAN_MODE_OFF; + g_update_status = true; } #ifdef ENABLE_VOICE - if (gMenuCursor == MENU_SCR) - g_another_voice_id = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; + if (g_menu_cursor == MENU_SCR) + g_another_voice_id = (g_sub_menu_selection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; else g_another_voice_id = VOICE_ID_CONFIRM; #endif - gInputBoxIndex = 0; + g_input_box_index = 0; } -static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) +static void MENU_Key_STAR(const bool key_pressed, const bool key_held) { - if (bKeyHeld || !bKeyPressed) + if (key_held || !key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) + if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0) { // currently editing the channel name - if (edit_index < 10) + if (g_edit_index < 10) { - edit[edit_index] = '-'; + g_edit[g_edit_index] = '-'; - if (++edit_index >= 10) + if (++g_edit_index >= 10) { // exit edit - gFlagAcceptSetting = false; - gAskForConfirmation = 1; + g_flag_AcceptSetting = false; + g_ask_for_confirmation = 1; } - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } return; @@ -1620,18 +1623,18 @@ 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(g_rx_vfo->channel_save) && g_rx_vfo->am_mode == 0) #else - if (gRxVfo->am_mode == 0) + if (g_rx_vfo->am_mode == 0) #endif { - if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) + if (g_menu_cursor == MENU_R_CTCS || g_menu_cursor == MENU_R_DCS) { // scan CTCSS or DCS to find the tone/code of the incoming signal - if (gCssScanMode == CSS_SCAN_MODE_OFF) + if (g_css_scan_mode == CSS_SCAN_MODE_OFF) { MENU_StartCssScan(1); - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); AUDIO_PlaySingleVoice(1); @@ -1640,32 +1643,32 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) else { MENU_StopCssScan(); - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_SCANNING_STOP; #endif } } - gPttWasReleased = true; + g_ptt_was_released = true; return; } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } -static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) +static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction) { uint8_t VFO; uint8_t Channel; bool bCheckScanList; - if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) + if (g_menu_cursor == MENU_MEM_NAME && g_is_in_sub_menu && g_edit_index >= 0) { // change the character - if (bKeyPressed && edit_index < 10 && Direction != 0) + if (key_pressed && g_edit_index < 10 && Direction != 0) { const char unwanted[] = "$%&!\"':;?^`|{}"; - char c = edit[edit_index] + Direction; + char c = g_edit[g_edit_index] + Direction; unsigned int i = 0; while (i < sizeof(unwanted) && c >= 32 && c <= 126) { @@ -1675,55 +1678,55 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) i = 0; } } - edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c; + g_edit[g_edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c; - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } return; } - if (!bKeyHeld) + if (!key_held) { - if (!bKeyPressed) + if (!key_pressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - gInputBoxIndex = 0; + g_input_box_index = 0; } else - if (!bKeyPressed) + if (!key_pressed) return; - if (gCssScanMode != CSS_SCAN_MODE_OFF) + if (g_css_scan_mode != CSS_SCAN_MODE_OFF) { MENU_StartCssScan(Direction); - gPttWasReleased = true; - gRequestDisplayScreen = DISPLAY_MENU; + g_ptt_was_released = true; + g_request_display_screen = DISPLAY_MENU; return; } - if (!gIsInSubMenu) + if (!g_is_in_sub_menu) { - gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1); + g_menu_cursor = NUMBER_AddWithWraparound(g_menu_cursor, -Direction, 0, g_menu_list_count - 1); - gFlagRefreshSetting = true; + g_flag_refresh_menu = true; - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; - if (gMenuCursor != MENU_ABR && g_eeprom.backlight == 0) + if (g_menu_cursor != MENU_ABR && g_eeprom.backlight == 0) { - gBacklightCountdown = 0; + g_backlight_count_down = 0; GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF } return; } - if (gMenuCursor == MENU_OFFSET) + if (g_menu_cursor == MENU_OFFSET) { - int32_t Offset = (Direction * gTxVfo->step_freq) + gSubMenuSelection; + int32_t Offset = (Direction * g_tx_vfo->step_freq) + g_sub_menu_selection; if (Offset < 99999990) { if (Offset < 0) @@ -1732,8 +1735,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) else Offset = 0; - gSubMenuSelection = FREQUENCY_FloorToStep(Offset, gTxVfo->step_freq, 0); - gRequestDisplayScreen = DISPLAY_MENU; + g_sub_menu_selection = FREQUENCY_FloorToStep(Offset, g_tx_vfo->step_freq, 0); + g_request_display_screen = DISPLAY_MENU; return; } @@ -1742,7 +1745,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gMenuCursor) + switch (g_menu_cursor) { case MENU_DEL_CH: case MENU_1_CALL: @@ -1758,20 +1761,20 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) default: MENU_ClampSelection(Direction); - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; return; } #pragma GCC diagnostic pop - Channel = RADIO_FindNextChannel(gSubMenuSelection + Direction, Direction, bCheckScanList, VFO); + Channel = RADIO_FindNextChannel(g_sub_menu_selection + Direction, Direction, bCheckScanList, VFO); if (Channel != 0xFF) - gSubMenuSelection = Channel; + g_sub_menu_selection = Channel; - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } -void MENU_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) +void MENU_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held) { switch (Key) { @@ -1785,67 +1788,67 @@ void MENU_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) case KEY_7: case KEY_8: case KEY_9: - MENU_Key_0_to_9(Key, bKeyPressed, bKeyHeld); + MENU_Key_0_to_9(Key, key_pressed, key_held); break; case KEY_MENU: - MENU_Key_MENU(bKeyPressed, bKeyHeld); + MENU_Key_MENU(key_pressed, key_held); break; case KEY_UP: - MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + MENU_Key_UP_DOWN(key_pressed, key_held, 1); break; case KEY_DOWN: - MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + MENU_Key_UP_DOWN(key_pressed, key_held, -1); break; case KEY_EXIT: - MENU_Key_EXIT(bKeyPressed, bKeyHeld); + MENU_Key_EXIT(key_pressed, key_held); break; case KEY_STAR: - MENU_Key_STAR(bKeyPressed, bKeyHeld); + MENU_Key_STAR(key_pressed, key_held); break; case KEY_F: - if (gMenuCursor == MENU_MEM_NAME && edit_index >= 0) + if (g_menu_cursor == MENU_MEM_NAME && g_edit_index >= 0) { // currently editing the channel name - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (edit_index < 10) + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + if (g_edit_index < 10) { - edit[edit_index] = ' '; - if (++edit_index >= 10) + g_edit[g_edit_index] = ' '; + if (++g_edit_index >= 10) { // exit edit - gFlagAcceptSetting = false; - gAskForConfirmation = 1; + g_flag_AcceptSetting = false; + g_ask_for_confirmation = 1; } - gRequestDisplayScreen = DISPLAY_MENU; + g_request_display_screen = DISPLAY_MENU; } } break; } - GENERIC_Key_F(bKeyPressed, bKeyHeld); + GENERIC_Key_F(key_pressed, key_held); break; case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); + GENERIC_Key_PTT(key_pressed); break; default: - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } - if (gScreenToDisplay == DISPLAY_MENU) + if (g_screen_to_display == DISPLAY_MENU) { - if (gMenuCursor == MENU_VOL || + if (g_menu_cursor == MENU_VOL || #ifdef ENABLE_F_CAL_MENU - gMenuCursor == MENU_F_CALI || + g_menu_cursor == MENU_F_CALI || #endif - gMenuCursor == MENU_BATCAL) + g_menu_cursor == MENU_BATCAL) { - gMenuCountdown = menu_timeout_long_500ms; + g_menu_count_down = menu_timeout_long_500ms; } else { - gMenuCountdown = menu_timeout_500ms; + g_menu_count_down = menu_timeout_500ms; } } } diff --git a/app/menu.h b/app/menu.h index 1367fb7c..a2df0655 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 key_pressed, bool key_held); #endif diff --git a/app/scanner.c b/app/scanner.c index d8ff2093..70c851a3 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -28,37 +28,37 @@ dcs_code_type_t gScanCssResultType; uint8_t gScanCssResultCode; -bool gFlagStartScan; -bool gFlagStopScan; -bool gScanSingleFrequency; +bool g_flag_start_scan; +bool g_flag_stop_scan; +bool g_scan_single_frequency; SCAN_edit_state_t gScannerEditState; uint8_t gScanChannel; uint32_t gScanFrequency; bool gScanPauseMode; SCAN_CssState_t gScanCssState; -volatile bool gScheduleScanListen = true; -volatile uint16_t gScanPauseDelayIn_10ms; +volatile bool g_schedule_scan_listen = true; +volatile uint16_t g_scan_pause_delay_in_10ms; uint8_t gScanProgressIndicator; uint8_t gScanHitCount; bool gScanUseCssResult; -int8_t gScanStateDir; +int8_t g_scan_state_dir; 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 key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { if (gScannerEditState == SCAN_EDIT_STATE_BUSY) { uint16_t Channel; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_SCANNER; + g_request_display_screen = DISPLAY_SCANNER; - if (gInputBoxIndex < 3) + if (g_input_box_index < 3) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; @@ -66,50 +66,50 @@ static void SCANNER_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - gInputBoxIndex = 0; + g_input_box_index = 0; - Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; + Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1; if (Channel <= USER_CHANNEL_LAST) { #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - gShowChPrefix = RADIO_CheckValidChannel(Channel, false, 0); + g_show_chan_prefix = RADIO_CheckValidChannel(Channel, false, 0); gScanChannel = (uint8_t)Channel; return; } } - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } } -static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void SCANNER_Key_EXIT(bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; switch (gScannerEditState) { case SCAN_EDIT_STATE_NONE: - gRequestDisplayScreen = DISPLAY_MAIN; + g_request_display_screen = DISPLAY_MAIN; - g_eeprom.cross_vfo_rx_tx = gBackup_cross_vfo_rx_tx; - gUpdateStatus = true; - gFlagStopScan = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx; + g_update_status = true; + g_flag_stop_scan = true; + g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; + g_flag_reset_vfos = true; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_CANCEL; #endif break; case SCAN_EDIT_STATE_BUSY: - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { - gInputBox[--gInputBoxIndex] = 10; - gRequestDisplayScreen = DISPLAY_SCANNER; + g_input_box[--g_input_box_index] = 10; + g_request_display_screen = DISPLAY_SCANNER; break; } @@ -120,49 +120,49 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_CANCEL; #endif - gRequestDisplayScreen = DISPLAY_SCANNER; + g_request_display_screen = DISPLAY_SCANNER; break; } } } -static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) +static void SCANNER_Key_MENU(bool key_pressed, bool key_held) { uint8_t Channel; - if (bKeyHeld) + if (key_held) return; - if (!bKeyPressed) + if (!key_pressed) return; - if (gScanCssState == SCAN_CSS_STATE_OFF && !gScanSingleFrequency) + if (gScanCssState == SCAN_CSS_STATE_OFF && !g_scan_single_frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } if (gScanCssState == SCAN_CSS_STATE_SCANNING) { - if (gScanSingleFrequency) + if (g_scan_single_frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } } if (gScanCssState == SCAN_CSS_STATE_FAILED) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; switch (gScannerEditState) { case SCAN_EDIT_STATE_NONE: - if (!gScanSingleFrequency) + if (!g_scan_single_frequency) { #if 0 @@ -188,12 +188,12 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (Delta625 < Delta250) { - gStepSetting = STEP_6_25kHz; + g_step_setting = STEP_6_25kHz; gScanFrequency = Freq625; } else { - gStepSetting = STEP_2_5kHz; + g_step_setting = STEP_2_5kHz; gScanFrequency = Freq250; } #else @@ -206,8 +206,8 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) const step_setting_t big_step = STEP_6_25kHz; #endif - const uint32_t small_step_freq = StepFrequencyTable[small_step]; - const uint32_t big_step_freq = StepFrequencyTable[big_step]; + const uint32_t small_step_freq = STEP_FREQ_TABLE[small_step]; + const uint32_t big_step_freq = STEP_FREQ_TABLE[big_step]; uint32_t freq_small_step = FREQUENCY_FloorToStep(gScanFrequency, small_step_freq, 0); uint32_t freq_big_step = FREQUENCY_FloorToStep(gScanFrequency, big_step_freq, 0); @@ -217,7 +217,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (delta_small_step > 125) { - delta_small_step = StepFrequencyTable[small_step] - delta_small_step; + delta_small_step = STEP_FREQ_TABLE[small_step] - delta_small_step; freq_big_step += small_step_freq; } @@ -231,22 +231,22 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (delta_small_step >= delta_big_step) { - gStepSetting = small_step; + g_step_setting = small_step; gScanFrequency = freq_small_step; } else { - gStepSetting = big_step; + g_step_setting = big_step; gScanFrequency = freq_big_step; } #endif } - if (gTxVfo->channel_save <= USER_CHANNEL_LAST) + if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST) { gScannerEditState = SCAN_EDIT_STATE_BUSY; - gScanChannel = gTxVfo->channel_save; - gShowChPrefix = RADIO_CheckValidChannel(gTxVfo->channel_save, false, 0); + gScanChannel = g_tx_vfo->channel_save; + g_show_chan_prefix = RADIO_CheckValidChannel(g_tx_vfo->channel_save, false, 0); } else { @@ -259,58 +259,58 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) g_another_voice_id = VOICE_ID_MEMORY_CHANNEL; #endif - gRequestDisplayScreen = DISPLAY_SCANNER; - gUpdateStatus = true; + g_request_display_screen = DISPLAY_SCANNER; + g_update_status = true; break; case SCAN_EDIT_STATE_BUSY: - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gRequestDisplayScreen = DISPLAY_SCANNER; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + g_request_display_screen = DISPLAY_SCANNER; gScannerEditState = SCAN_EDIT_STATE_DONE; } break; case SCAN_EDIT_STATE_DONE: - if (!gScanSingleFrequency) + if (!g_scan_single_frequency) { - RADIO_InitInfo(gTxVfo, gTxVfo->channel_save, gScanFrequency); + RADIO_InitInfo(g_tx_vfo, g_tx_vfo->channel_save, gScanFrequency); if (gScanUseCssResult) { - gTxVfo->freq_config_rx.code_type = gScanCssResultType; - gTxVfo->freq_config_rx.code = gScanCssResultCode; + g_tx_vfo->freq_config_rx.code_type = gScanCssResultType; + g_tx_vfo->freq_config_rx.code = gScanCssResultCode; } - gTxVfo->freq_config_tx = gTxVfo->freq_config_rx; - gTxVfo->step_setting = gStepSetting; + g_tx_vfo->freq_config_tx = g_tx_vfo->freq_config_rx; + g_tx_vfo->step_setting = g_step_setting; } else { RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); - 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; + g_tx_vfo->freq_config_rx.code_type = gScanCssResultType; + g_tx_vfo->freq_config_rx.code = gScanCssResultCode; + g_tx_vfo->freq_config_tx.code_type = gScanCssResultType; + g_tx_vfo->freq_config_tx.code = gScanCssResultCode; } - if (gTxVfo->channel_save <= USER_CHANNEL_LAST) + if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST) { Channel = gScanChannel; g_eeprom.user_channel[g_eeprom.tx_vfo] = Channel; } else { - Channel = gTxVfo->band + FREQ_CHANNEL_FIRST; + Channel = g_tx_vfo->band + FREQ_CHANNEL_FIRST; g_eeprom.freq_channel[g_eeprom.tx_vfo] = Channel; } - gTxVfo->channel_save = Channel; + g_tx_vfo->channel_save = Channel; g_eeprom.screen_channel[g_eeprom.tx_vfo] = Channel; - gRequestSaveChannel = 2; + g_request_save_channel = 2; #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_CONFIRM; @@ -318,52 +318,52 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) gScannerEditState = SCAN_EDIT_STATE_NONE; - gRequestDisplayScreen = DISPLAY_SCANNER; + g_request_display_screen = DISPLAY_SCANNER; break; default: - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; break; } } -static void SCANNER_Key_STAR(bool bKeyPressed, bool bKeyHeld) +static void SCANNER_Key_STAR(bool key_pressed, bool key_held) { - if (!bKeyHeld && bKeyPressed) + if (!key_held && key_pressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gFlagStartScan = true; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; + g_flag_start_scan = true; } return; } -static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Direction) +static void SCANNER_Key_UP_DOWN(bool key_pressed, bool pKeyHeld, int8_t Direction) { if (pKeyHeld) { - if (!bKeyPressed) + if (!key_pressed) return; } else { - if (!bKeyPressed) + if (!key_pressed) return; - gInputBoxIndex = 0; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + g_input_box_index = 0; + g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; } if (gScannerEditState == SCAN_EDIT_STATE_BUSY) { gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, USER_CHANNEL_LAST); - gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0); - gRequestDisplayScreen = DISPLAY_SCANNER; + g_show_chan_prefix = RADIO_CheckValidChannel(gScanChannel, false, 0); + g_request_display_screen = DISPLAY_SCANNER; } else - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + g_beep_to_play = 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 key_pressed, bool key_held) { switch (Key) { @@ -377,29 +377,29 @@ void SCANNER_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld) case KEY_7: case KEY_8: case KEY_9: - SCANNER_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + SCANNER_Key_DIGITS(Key, key_pressed, key_held); break; case KEY_MENU: - SCANNER_Key_MENU(bKeyPressed, bKeyHeld); + SCANNER_Key_MENU(key_pressed, key_held); break; case KEY_UP: - SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + SCANNER_Key_UP_DOWN(key_pressed, key_held, 1); break; case KEY_DOWN: - SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + SCANNER_Key_UP_DOWN(key_pressed, key_held, -1); break; case KEY_EXIT: - SCANNER_Key_EXIT(bKeyPressed, bKeyHeld); + SCANNER_Key_EXIT(key_pressed, key_held); break; case KEY_STAR: - SCANNER_Key_STAR(bKeyPressed, bKeyHeld); + SCANNER_Key_STAR(key_pressed, key_held); break; case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); + GENERIC_Key_PTT(key_pressed); break; default: - if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + if (!key_held && key_pressed) + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } } @@ -414,29 +414,29 @@ 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(g_rx_vfo->channel_save)) + g_rx_vfo->channel_save = FREQ_CHANNEL_FIRST + BAND6_400MHz; #endif - BackupStep = gRxVfo->step_setting; - BackupStepFreq = gRxVfo->step_freq; + BackupStep = g_rx_vfo->step_setting; + BackupStepFreq = g_rx_vfo->step_freq; - RADIO_InitInfo(gRxVfo, gRxVfo->channel_save, gRxVfo->pRX->frequency); + RADIO_InitInfo(g_rx_vfo, g_rx_vfo->channel_save, g_rx_vfo->pRX->frequency); - gRxVfo->step_setting = BackupStep; - gRxVfo->step_freq = BackupStepFreq; + g_rx_vfo->step_setting = BackupStep; + g_rx_vfo->step_freq = BackupStepFreq; RADIO_SetupRegisters(true); #ifdef ENABLE_NOAA - gIsNoaaMode = false; + g_is_noaa_mode = false; #endif - if (gScanSingleFrequency) + if (g_scan_single_frequency) { gScanCssState = SCAN_CSS_STATE_SCANNING; - gScanFrequency = gRxVfo->pRX->frequency; - gStepSetting = gRxVfo->step_setting; + gScanFrequency = g_rx_vfo->pRX->frequency; + g_step_setting = g_rx_vfo->step_setting; BK4819_PickRXFilterPathBasedOnFrequency(gScanFrequency); BK4819_SetScanFrequency(gScanFrequency); @@ -452,64 +452,64 @@ void SCANNER_Start(void) DTMF_clear_RX(); - gScanDelay_10ms = scan_freq_css_delay_10ms; + g_scan_delay_10ms = scan_freq_css_delay_10ms; gScanCssResultCode = 0xFF; gScanCssResultType = 0xFF; gScanHitCount = 0; gScanUseCssResult = false; - g_CxCSS_tailL_found = false; + g_CxCSS_tail_found = false; g_CDCSS_lost = false; g_CDCSS_code_type = 0; g_CTCSS_lost = false; #ifdef ENABLE_VOX g_vox_lost = false; #endif - g_SquelchLost = false; + g_squelch_lost = false; gScannerEditState = SCAN_EDIT_STATE_NONE; gScanProgressIndicator = 0; -// gFlagStartScan = false; +// g_flag_start_scan = false; - gUpdateStatus = true; + g_update_status = true; } void SCANNER_Stop(void) { - const uint8_t Previous = gRestoreUSER_CHANNEL; + const uint8_t Previous = g_restore_channel; - if (gScanStateDir == SCAN_OFF) + if (g_scan_state_dir == SCAN_OFF) return; // but, but, we weren't ! - gScanStateDir = SCAN_OFF; + g_scan_state_dir = SCAN_OFF; if (!bScanKeepFrequency) { - if (gNextChannel <= USER_CHANNEL_LAST) + if (g_next_channel <= USER_CHANNEL_LAST) { - g_eeprom.user_channel[g_eeprom.rx_vfo] = gRestoreUSER_CHANNEL; + g_eeprom.user_channel[g_eeprom.rx_vfo] = g_restore_channel; g_eeprom.screen_channel[g_eeprom.rx_vfo] = Previous; RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD); } else { - gRxVfo->freq_config_rx.frequency = gRestoreFrequency; - RADIO_ApplyOffset(gRxVfo); - RADIO_ConfigureSquelchAndOutputPower(gRxVfo); + g_rx_vfo->freq_config_rx.frequency = g_restore_frequency; + RADIO_ApplyOffset(g_rx_vfo); + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); } RADIO_SetupRegisters(true); - gUpdateDisplay = true; + g_update_display = true; return; } - if (gRxVfo->channel_save > USER_CHANNEL_LAST) + if (g_rx_vfo->channel_save > USER_CHANNEL_LAST) { - RADIO_ApplyOffset(gRxVfo); - RADIO_ConfigureSquelchAndOutputPower(gRxVfo); - SETTINGS_SaveChannel(gRxVfo->channel_save, g_eeprom.rx_vfo, gRxVfo, 1); + RADIO_ApplyOffset(g_rx_vfo); + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); + SETTINGS_SaveChannel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1); return; } SETTINGS_SaveVfoIndices(); - gUpdateStatus = true; + g_update_status = true; } diff --git a/app/scanner.h b/app/scanner.h index 3df99239..3123b754 100644 --- a/app/scanner.h +++ b/app/scanner.h @@ -44,23 +44,23 @@ typedef enum SCAN_edit_state_e SCAN_edit_state_t; extern dcs_code_type_t gScanCssResultType; extern uint8_t gScanCssResultCode; -extern bool gFlagStartScan; -extern bool gFlagStopScan; -extern bool gScanSingleFrequency; +extern bool g_flag_start_scan; +extern bool g_flag_stop_scan; +extern bool g_scan_single_frequency; extern SCAN_edit_state_t gScannerEditState; extern uint8_t gScanChannel; extern uint32_t gScanFrequency; extern bool gScanPauseMode; extern SCAN_CssState_t gScanCssState; -extern volatile bool gScheduleScanListen; -extern volatile uint16_t gScanPauseDelayIn_10ms; +extern volatile bool g_schedule_scan_listen; +extern volatile uint16_t g_scan_pause_delay_in_10ms; extern uint8_t gScanProgressIndicator; extern uint8_t gScanHitCount; extern bool gScanUseCssResult; -extern int8_t gScanStateDir; +extern int8_t g_scan_state_dir; extern bool bScanKeepFrequency; -void SCANNER_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld); +void SCANNER_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held); void SCANNER_Start(void); void SCANNER_Stop(void); diff --git a/app/spectrum.c b/app/spectrum.c index 85c9bc11..3f7f7589 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -342,7 +342,7 @@ uint32_t GetOffsetedF(uint32_t f) { FrequencyBandTable[ARRAY_SIZE(FrequencyBandTable) - 1].upper); } -bool IsTXAllowed() { return gSetting_ALL_TX != 2; } +bool IsTXAllowed() { return g_setting_ALL_TX != 2; } static void ToggleAudio(bool on) { if (on) { @@ -749,19 +749,19 @@ static void UpdateBatteryInfo() { static void DrawStatus() { - gStatusLine[127] = 0b01111110; + g_status_line[127] = 0b01111110; for (int i = 126; i >= 116; i--) { - gStatusLine[i] = 0b01000010; + g_status_line[i] = 0b01000010; } uint8_t v = gBatteryDisplayLevel; v <<= 1; for (int i = 125; i >= 116; i--) { if (126 - i <= v) { - gStatusLine[i + 2] = 0b01111110; + g_status_line[i + 2] = 0b01111110; } } - gStatusLine[117] = 0b01111110; - gStatusLine[116] = 0b00011000; + g_status_line[117] = 0b01111110; + g_status_line[116] = 0b00011000; } static void DrawF(uint32_t f) { @@ -829,25 +829,25 @@ static void DrawTicks() { (f % 50000) < step && (barValue |= 0b00000100); (f % 100000) < step && (barValue |= 0b00011000); - gFrameBuffer[5][i] |= barValue; + g_frame_buffer[5][i] |= barValue; } // center /* if (IsCenterMode()) { - gFrameBuffer[5][62] = 0x80; - gFrameBuffer[5][63] = 0x80; - gFrameBuffer[5][64] = 0xff; - gFrameBuffer[5][65] = 0x80; - gFrameBuffer[5][66] = 0x80; + g_frame_buffer[5][62] = 0x80; + g_frame_buffer[5][63] = 0x80; + g_frame_buffer[5][64] = 0xff; + g_frame_buffer[5][65] = 0x80; + g_frame_buffer[5][66] = 0x80; } else { - gFrameBuffer[5][0] = 0xff; - gFrameBuffer[5][1] = 0x80; - gFrameBuffer[5][2] = 0x80; - gFrameBuffer[5][3] = 0x80; - gFrameBuffer[5][124] = 0x80; - gFrameBuffer[5][125] = 0x80; - gFrameBuffer[5][126] = 0x80; - gFrameBuffer[5][127] = 0xff; + g_frame_buffer[5][0] = 0xff; + g_frame_buffer[5][1] = 0x80; + g_frame_buffer[5][2] = 0x80; + g_frame_buffer[5][3] = 0x80; + g_frame_buffer[5][124] = 0x80; + g_frame_buffer[5][125] = 0x80; + g_frame_buffer[5][126] = 0x80; + g_frame_buffer[5][127] = 0xff; } */ } @@ -856,7 +856,7 @@ static void DrawArrow(uint8_t x) { signed v = x + i; uint8_t a = i > 0 ? i : -i; if (!(v & 128)) { - gFrameBuffer[5][v] |= (0b01111000 << a) & 0b01111000; + g_frame_buffer[5][v] |= (0b01111000 << a) & 0b01111000; } } } @@ -1059,7 +1059,7 @@ static void RenderFreqInput() { } static void RenderStatus() { - memset(gStatusLine, 0, sizeof(gStatusLine)); + memset(g_status_line, 0, sizeof(g_status_line)); DrawStatus(); ST7565_BlitStatusLine(); } @@ -1080,16 +1080,16 @@ static void RenderStill() { for (int i = 0; i < 121; i++) { if (i % 10 == 0) { - gFrameBuffer[2][i + METER_PAD_LEFT] = 0b11000000; + g_frame_buffer[2][i + METER_PAD_LEFT] = 0b11000000; } else { - gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01000000; + g_frame_buffer[2][i + METER_PAD_LEFT] = 0b01000000; } } uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121); for (int i = 0; i < x; ++i) { if (i % 5 && i / 5 < x / 5) { - gFrameBuffer[2][i + METER_PAD_LEFT] |= 0b00011100; + g_frame_buffer[2][i + METER_PAD_LEFT] |= 0b00011100; } } @@ -1108,15 +1108,15 @@ static void RenderStill() { uint8_t afDB = BK4819_ReadRegister(0x6F) & 0b1111111; uint8_t afPX = ConvertDomain(afDB, 26, 194, 0, 121); for (int i = 0; i < afPX; ++i) { - gFrameBuffer[3][i + METER_PAD_LEFT] |= 0b00000011; + g_frame_buffer[3][i + METER_PAD_LEFT] |= 0b00000011; } } if (!monitorMode) { uint8_t x = Rssi2PX(settings.rssiTriggerLevel, 0, 121); - gFrameBuffer[2][METER_PAD_LEFT + x - 1] |= 0b01000001; - gFrameBuffer[2][METER_PAD_LEFT + x] = 0b01111111; - gFrameBuffer[2][METER_PAD_LEFT + x + 1] |= 0b01000001; + g_frame_buffer[2][METER_PAD_LEFT + x - 1] |= 0b01000001; + g_frame_buffer[2][METER_PAD_LEFT + x] = 0b01111111; + g_frame_buffer[2][METER_PAD_LEFT + x + 1] |= 0b01000001; } const uint8_t PAD_LEFT = 4; @@ -1132,8 +1132,8 @@ static void RenderStill() { offset = PAD_LEFT + i * CELL_WIDTH; if (menuState == idx) { for (int j = 0; j < CELL_WIDTH; ++j) { - gFrameBuffer[row][j + offset] = 0xFF; - gFrameBuffer[row + 1][j + offset] = 0xFF; + g_frame_buffer[row][j + offset] = 0xFF; + g_frame_buffer[row + 1][j + offset] = 0xFF; } } RegisterSpec s = registerSpecs[idx]; @@ -1147,7 +1147,7 @@ static void RenderStill() { } static void Render() { - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); switch (currentState) { case SPECTRUM: @@ -1327,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 = g_eeprom.VfoInfo[g_eeprom.TX_CHANNEL]; + VFO_Info_t vfo = g_eeprom.vfo_info[g_eeprom.TX_CHANNEL]; initialFreq = vfo.pRX->Frequency; currentFreq = initialFreq; settings.scanStepIndex = gStepSettingToIndex[vfo.STEP_SETTING]; diff --git a/app/uart.c b/app/uart.c index 561998bf..9cfbca89 100644 --- a/app/uart.c +++ b/app/uart.c @@ -61,8 +61,8 @@ typedef struct { Header_t Header; struct { char Version[16]; - bool bHasCustomAesKey; - bool bIsInLockScreen; + bool g_has_custom_aes_key; + bool g_is_in_lock_screen; uint8_t Padding[2]; uint32_t Challenge[4]; } Data; @@ -153,7 +153,7 @@ static union } UART_Command; static uint32_t Timestamp; -static uint16_t gUART_WriteIndex; +static uint16_t g_uart_write_index; static bool bIsEncrypted = true; static void SendReply(void *pReply, uint16_t Size) @@ -196,12 +196,12 @@ static void SendVersion(void) Reply.Header.ID = 0x0515; Reply.Header.Size = sizeof(Reply.Data); strcpy(Reply.Data.Version, Version); - Reply.Data.bHasCustomAesKey = bHasCustomAesKey; - Reply.Data.bIsInLockScreen = bIsInLockScreen; - Reply.Data.Challenge[0] = gChallenge[0]; - Reply.Data.Challenge[1] = gChallenge[1]; - Reply.Data.Challenge[2] = gChallenge[2]; - Reply.Data.Challenge[3] = gChallenge[3]; + Reply.Data.g_has_custom_aes_key = g_has_custom_aes_key; + Reply.Data.g_is_in_lock_screen = g_is_in_lock_screen; + Reply.Data.Challenge[0] = g_challenge[0]; + Reply.Data.Challenge[1] = g_challenge[1]; + Reply.Data.Challenge[2] = g_challenge[2]; + Reply.Data.Challenge[3] = g_challenge[3]; SendReply(&Reply, sizeof(Reply)); } @@ -232,10 +232,10 @@ static void CMD_0514(const uint8_t *pBuffer) Timestamp = pCmd->Timestamp; #ifdef ENABLE_FMRADIO - gFmRadioCountdown_500ms = fm_radio_countdown_500ms; + g_fm_radio_count_down_500ms = fm_radio_countdown_500ms; #endif - gSerialConfigCountDown_500ms = 12; // 6 sec + g_serial_config_count_down_500ms = 12; // 6 sec // turn the LCD backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); @@ -252,10 +252,10 @@ static void CMD_051B(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; - gSerialConfigCountDown_500ms = 12; // 6 sec + g_serial_config_count_down_500ms = 12; // 6 sec #ifdef ENABLE_FMRADIO - gFmRadioCountdown_500ms = fm_radio_countdown_500ms; + g_fm_radio_count_down_500ms = fm_radio_countdown_500ms; #endif memset(&Reply, 0, sizeof(Reply)); @@ -264,8 +264,8 @@ static void CMD_051B(const uint8_t *pBuffer) Reply.Data.Offset = pCmd->Offset; Reply.Data.Size = pCmd->Size; - if (bHasCustomAesKey) - bLocked = gIsLocked; + if (g_has_custom_aes_key) + bLocked = g_is_locked; if (!bLocked) EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size); @@ -283,19 +283,19 @@ static void CMD_051D(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; - gSerialConfigCountDown_500ms = 12; // 6 sec + g_serial_config_count_down_500ms = 12; // 6 sec bReloadEeprom = false; #ifdef ENABLE_FMRADIO - gFmRadioCountdown_500ms = fm_radio_countdown_500ms; + g_fm_radio_count_down_500ms = fm_radio_countdown_500ms; #endif Reply.Header.ID = 0x051E; Reply.Header.Size = sizeof(Reply.Data); Reply.Data.Offset = pCmd->Offset; - bIsLocked = bHasCustomAesKey ? gIsLocked : bHasCustomAesKey; + bIsLocked = g_has_custom_aes_key ? g_is_locked : g_has_custom_aes_key; if (!bIsLocked) { @@ -305,10 +305,10 @@ static void CMD_051D(const uint8_t *pBuffer) const uint16_t Offset = pCmd->Offset + (i * 8U); if (Offset >= 0x0F30 && Offset < 0x0F40) - if (!gIsLocked) + if (!g_is_locked) bReloadEeprom = true; - if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword) + if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !g_is_in_lock_screen || pCmd->bAllowPassword) EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U]); } @@ -352,35 +352,35 @@ static void CMD_052D(const uint8_t *pBuffer) bool bIsLocked; #ifdef ENABLE_FMRADIO - gFmRadioCountdown_500ms = fm_radio_countdown_500ms; + g_fm_radio_count_down_500ms = fm_radio_countdown_500ms; #endif Reply.Header.ID = 0x052E; Reply.Header.Size = sizeof(Reply.Data); - bIsLocked = bHasCustomAesKey; + bIsLocked = g_has_custom_aes_key; if (!bIsLocked) - bIsLocked = IsBadChallenge(gCustomAesKey, gChallenge, pCmd->Response); + bIsLocked = IsBadChallenge(g_custom_aes_key, g_challenge, pCmd->Response); if (!bIsLocked) { - bIsLocked = IsBadChallenge(gDefaultAesKey, gChallenge, pCmd->Response); + bIsLocked = IsBadChallenge(g_default_aes_key, g_challenge, pCmd->Response); if (bIsLocked) - gTryCount++; + g_try_count++; } - if (gTryCount < 3) + if (g_try_count < 3) { if (!bIsLocked) - gTryCount = 0; + g_try_count = 0; } else { - gTryCount = 3; + g_try_count = 3; bIsLocked = true; } - gIsLocked = bIsLocked; + g_is_locked = bIsLocked; Reply.Data.bIsLocked = bIsLocked; SendReply(&Reply, sizeof(Reply)); @@ -393,22 +393,22 @@ static void CMD_052F(const uint8_t *pBuffer) 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; + g_eeprom.dtmf_side_tone = false; + g_eeprom.vfo_info[0].frequency_reverse = false; + g_eeprom.vfo_info[0].pRX = &g_eeprom.vfo_info[0].freq_config_rx; + g_eeprom.vfo_info[0].pTX = &g_eeprom.vfo_info[0].freq_config_tx; + g_eeprom.vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; + g_eeprom.vfo_info[0].dtmf_ptt_id_tx_mode = PTT_ID_OFF; + g_eeprom.vfo_info[0].dtmf_decoding_enable = false; #ifdef ENABLE_NOAA - gIsNoaaMode = false; + g_is_noaa_mode = false; #endif - if (gCurrentFunction == FUNCTION_POWER_SAVE) + if (g_current_function == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - gSerialConfigCountDown_500ms = 12; // 6 sec + g_serial_config_count_down_500ms = 12; // 6 sec Timestamp = pCmd->Timestamp; @@ -429,35 +429,35 @@ bool UART_IsCommandAvailable(void) while (1) { - if (gUART_WriteIndex == DmaLength) + if (g_uart_write_index == DmaLength) return false; - while (gUART_WriteIndex != DmaLength && UART_DMA_Buffer[gUART_WriteIndex] != 0xABU) - gUART_WriteIndex = DMA_INDEX(gUART_WriteIndex, 1); + while (g_uart_write_index != DmaLength && UART_DMA_Buffer[g_uart_write_index] != 0xABU) + g_uart_write_index = DMA_INDEX(g_uart_write_index, 1); - if (gUART_WriteIndex == DmaLength) + if (g_uart_write_index == DmaLength) return false; - if (gUART_WriteIndex < DmaLength) - CommandLength = DmaLength - gUART_WriteIndex; + if (g_uart_write_index < DmaLength) + CommandLength = DmaLength - g_uart_write_index; else - CommandLength = (DmaLength + sizeof(UART_DMA_Buffer)) - gUART_WriteIndex; + CommandLength = (DmaLength + sizeof(UART_DMA_Buffer)) - g_uart_write_index; if (CommandLength < 8) return 0; - if (UART_DMA_Buffer[DMA_INDEX(gUART_WriteIndex, 1)] == 0xCD) + if (UART_DMA_Buffer[DMA_INDEX(g_uart_write_index, 1)] == 0xCD) break; - gUART_WriteIndex = DMA_INDEX(gUART_WriteIndex, 1); + g_uart_write_index = DMA_INDEX(g_uart_write_index, 1); } - Index = DMA_INDEX(gUART_WriteIndex, 2); + Index = DMA_INDEX(g_uart_write_index, 2); Size = (UART_DMA_Buffer[DMA_INDEX(Index, 1)] << 8) | UART_DMA_Buffer[Index]; if ((Size + 8u) > sizeof(UART_DMA_Buffer)) { - gUART_WriteIndex = DmaLength; + g_uart_write_index = DmaLength; return false; } @@ -469,7 +469,7 @@ bool UART_IsCommandAvailable(void) if (UART_DMA_Buffer[TailIndex] != 0xDC || UART_DMA_Buffer[DMA_INDEX(TailIndex, 1)] != 0xBA) { - gUART_WriteIndex = DmaLength; + g_uart_write_index = DmaLength; return false; } @@ -483,15 +483,15 @@ bool UART_IsCommandAvailable(void) memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); TailIndex = DMA_INDEX(TailIndex, 2); - if (TailIndex < gUART_WriteIndex) + if (TailIndex < g_uart_write_index) { - memset(UART_DMA_Buffer + gUART_WriteIndex, 0, sizeof(UART_DMA_Buffer) - gUART_WriteIndex); + memset(UART_DMA_Buffer + g_uart_write_index, 0, sizeof(UART_DMA_Buffer) - g_uart_write_index); memset(UART_DMA_Buffer, 0, TailIndex); } else - memset(UART_DMA_Buffer + gUART_WriteIndex, 0, TailIndex - gUART_WriteIndex); + memset(UART_DMA_Buffer + g_uart_write_index, 0, TailIndex - g_uart_write_index); - gUART_WriteIndex = TailIndex; + g_uart_write_index = TailIndex; if (UART_Command.Header.ID == 0x0514) bIsEncrypted = false; diff --git a/audio.c b/audio.c index 2fbbde59..4a64d64c 100644 --- a/audio.c +++ b/audio.c @@ -68,9 +68,9 @@ #endif -BEEP_Type_t gBeepToPlay = BEEP_NONE; +beep_type_t g_beep_to_play = BEEP_NONE; -void AUDIO_PlayBeep(BEEP_Type_t Beep) +void AUDIO_PlayBeep(beep_type_t Beep) { uint16_t ToneConfig; uint16_t ToneFrequency; @@ -85,25 +85,25 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) return; #ifdef ENABLE_AIRCOPY - if (gScreenToDisplay == DISPLAY_AIRCOPY) + if (g_screen_to_display == DISPLAY_AIRCOPY) return; #endif - if (gCurrentFunction == FUNCTION_RECEIVE) + if (g_current_function == FUNCTION_RECEIVE) return; - if (gCurrentFunction == FUNCTION_MONITOR) + if (g_current_function == FUNCTION_MONITOR) return; ToneConfig = BK4819_ReadRegister(BK4819_REG_71); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - if (gCurrentFunction == FUNCTION_POWER_SAVE && g_rx_idle_mode) + if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode) BK4819_RX_TurnOn(); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Mute(true); #endif @@ -193,7 +193,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + g_vox_resume_count_down = 80; #endif SYSTEM_DelayMs(5); @@ -201,15 +201,15 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(5); BK4819_WriteRegister(BK4819_REG_71, ToneConfig); - if (gEnableSpeaker) + if (g_enable_speaker) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Mute(false); #endif - if (gCurrentFunction == FUNCTION_POWER_SAVE && g_rx_idle_mode) + if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode) BK4819_Sleep(); } @@ -239,7 +239,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) } } - void AUDIO_PlaySingleVoice(bool bFlag) + void AUDIO_PlaySingleVoice(bool flag) { uint8_t VoiceID; uint8_t Delay; @@ -265,20 +265,20 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) VoiceID += VOICE_ID_ENG_BASE; } - if (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) // 1of11 + if (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) // 1of11 BK4819_SetAF(BK4819_AF_MUTE); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Mute(true); #endif GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); #ifdef ENABLE_VOX - gVoxResumeCountdown = 2000; + g_vox_resume_count_down = 2000; #endif SYSTEM_DelayMs(5); @@ -287,28 +287,28 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) if (g_voice_write_index == 1) Delay += 3; - if (bFlag) + if (flag) { SYSTEM_DelayMs(Delay * 10); - if (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) // 1of11 - BK4819_SetAF(gRxVfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); + if (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) // 1of11 + BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Mute(false); #endif - if (!gEnableSpeaker) + if (!g_enable_speaker) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); g_voice_write_index = 0; g_voice_read_index = 0; #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + g_vox_resume_count_down = 80; #endif return; @@ -425,28 +425,28 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) g_flag_play_queued_voice = false; #ifdef ENABLE_VOX - gVoxResumeCountdown = 2000; + g_vox_resume_count_down = 2000; #endif return; } } - if (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) // 1of11 - BK4819_SetAF(gRxVfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); + if (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) // 1of11 + BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); #ifdef ENABLE_FMRADIO - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Mute(false); #endif - if (!gEnableSpeaker) + if (!g_enable_speaker) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); #ifdef ENABLE_VOX - gVoxResumeCountdown = 80; + g_vox_resume_count_down = 80; #endif g_voice_write_index = 0; diff --git a/audio.h b/audio.h index 7e7dd140..5bfc4a92 100644 --- a/audio.h +++ b/audio.h @@ -20,7 +20,7 @@ #include #include -enum BEEP_Type_t +enum beep_type_e { BEEP_NONE = 0, BEEP_1KHZ_60MS_OPTIONAL, @@ -33,12 +33,11 @@ enum BEEP_Type_t BEEP_880HZ_40MS_OPTIONAL, BEEP_880HZ_60MS_TRIPLE_BEEP }; +typedef enum beep_type_e beep_type_t; -typedef enum BEEP_Type_t BEEP_Type_t; +extern beep_type_t g_beep_to_play; -extern BEEP_Type_t gBeepToPlay; - -void AUDIO_PlayBeep(BEEP_Type_t Beep); +void AUDIO_PlayBeep(beep_type_t Beep); enum { @@ -76,12 +75,12 @@ enum voice_id_e VOICE_ID_DELETE_CHANNEL = 0x19U, VOICE_ID_FREQUENCY_STEP = 0x1AU, VOICE_ID_SQUELCH = 0x1BU, - voice_id_tRANSMIT_OVER_TIME = 0x1CU, + 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_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, @@ -138,7 +137,7 @@ typedef enum voice_id_e voice_id_t; extern voice_id_t g_another_voice_id; void AUDIO_PlayVoice(uint8_t VoiceID); - void AUDIO_PlaySingleVoice(bool bFlag); + void AUDIO_PlaySingleVoice(bool flag); void AUDIO_SetVoiceID(uint8_t Index, voice_id_t VoiceID); uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value); void AUDIO_PlayQueuedVoice(void); diff --git a/bitmaps.c b/bitmaps.c index 88072ee9..25327ccb 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -112,7 +112,7 @@ const uint8_t BITMAP_USB_C[9] = 0b00011100 }; -const uint8_t BITMAP_KeyLock[6] = +const uint8_t BITMAP_KEYLOCK[6] = { // teeny padlock symbol 0b00000000, 0b01111100, @@ -122,7 +122,7 @@ const uint8_t BITMAP_KeyLock[6] = 0b01111100 }; -const uint8_t BITMAP_F_Key[6] = +const uint8_t BITMAP_F_KEY[6] = { // F-Key symbol 0b00000000, 0b01011111, @@ -224,7 +224,7 @@ const uint8_t BITMAP_TDR2[12] = }; #ifdef ENABLE_VOICE - const uint8_t BITMAP_VoicePrompt[9] = + const uint8_t BITMAP_VOICE_PROMPT[9] = { 0b00000000, 0b00011000, @@ -276,7 +276,7 @@ const uint8_t BITMAP_TDR2[12] = }; #endif -const uint8_t BITMAP_Antenna[5] = +const uint8_t BITMAP_ANTENNA[5] = { 0b00000011, 0b00000101, @@ -285,42 +285,42 @@ const uint8_t BITMAP_Antenna[5] = 0b00000011 }; -const uint8_t BITMAP_AntennaLevel1[3] = +const uint8_t BITMAP_ANTENNA_LEVEL1[3] = { 0b01100000, 0b01100000, 0b00000000 }; -const uint8_t BITMAP_AntennaLevel2[3] = +const uint8_t BITMAP_ANTENNA_LEVEL2[3] = { 0b01110000, 0b01110000, 0b00000000 }; -const uint8_t BITMAP_AntennaLevel3[3] = +const uint8_t BITMAP_ANTENNA_LEVEL3[3] = { 0b01111000, 0b01111000, 0b00000000 }; -const uint8_t BITMAP_AntennaLevel4[3] = +const uint8_t BITMAP_ANTENNA_LEVEL4[3] = { 0b01111100, 0b01111100, 0b00000000 }; -const uint8_t BITMAP_AntennaLevel5[3] = +const uint8_t BITMAP_ANTENNA_LEVEL5[3] = { 0b01111110, 0b01111110, 0b00000000 }; -const uint8_t BITMAP_AntennaLevel6[3] = +const uint8_t BITMAP_ANTENNA_LEVEL6[3] = { 0b01111111, 0b01111111, @@ -339,7 +339,7 @@ const uint8_t BITMAP_MARKER[8] = 0b00011000 }; -const uint8_t BITMAP_VFO_Default[8] = +const uint8_t BITMAP_VFO_DEFAULT[8] = { 0b00000000, 0b01111111, @@ -351,7 +351,7 @@ const uint8_t BITMAP_VFO_Default[8] = 0b00001000 }; -const uint8_t BITMAP_VFO_NotDefault[8] = +const uint8_t BITMAP_VFO_NOT_DEFAULT[8] = { 0b00000000, 0b01000001, @@ -363,7 +363,7 @@ const uint8_t BITMAP_VFO_NotDefault[8] = 0b00001000 }; -const uint8_t BITMAP_ScanList1[6] = +const uint8_t BITMAP_SCANLIST1[6] = { // 'I' symbol 0b00000000, 0b00000000, @@ -373,7 +373,7 @@ const uint8_t BITMAP_ScanList1[6] = 0b00000000 }; -const uint8_t BITMAP_ScanList2[6] = +const uint8_t BITMAP_SCANLIST2[6] = { // 'II' symbol 0b00000000, 0b01000010, @@ -383,7 +383,7 @@ const uint8_t BITMAP_ScanList2[6] = 0b01000010 }; -const uint8_t BITMAP_compand[6] = +const uint8_t BITMAP_COMPAND[6] = { 0b00000000, 0b00111100, diff --git a/bitmaps.h b/bitmaps.h index cabe3003..d9507696 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -12,9 +12,9 @@ extern const uint8_t BITMAP_BATTERY_LEVEL[17]; extern const uint8_t BITMAP_USB_C[9]; -extern const uint8_t BITMAP_KeyLock[6]; +extern const uint8_t BITMAP_KEYLOCK[6]; -extern const uint8_t BITMAP_F_Key[6]; +extern const uint8_t BITMAP_F_KEY[6]; #ifdef ENABLE_VOX extern const uint8_t BITMAP_VOX[18]; @@ -30,7 +30,7 @@ extern const uint8_t BITMAP_TDR1[12]; extern const uint8_t BITMAP_TDR2[12]; #ifdef ENABLE_VOICE - extern const uint8_t BITMAP_VoicePrompt[9]; + extern const uint8_t BITMAP_VOICE_PROMPT[9]; #endif #ifdef ENABLE_FMRADIO @@ -41,23 +41,23 @@ extern const uint8_t BITMAP_TDR2[12]; extern const uint8_t BITMAP_NOAA[12]; #endif -extern const uint8_t BITMAP_Antenna[5]; -extern const uint8_t BITMAP_AntennaLevel1[3]; -extern const uint8_t BITMAP_AntennaLevel2[3]; -extern const uint8_t BITMAP_AntennaLevel3[3]; -extern const uint8_t BITMAP_AntennaLevel4[3]; -extern const uint8_t BITMAP_AntennaLevel5[3]; -extern const uint8_t BITMAP_AntennaLevel6[3]; +extern const uint8_t BITMAP_ANTENNA[5]; +extern const uint8_t BITMAP_ANTENNA_LEVEL1[3]; +extern const uint8_t BITMAP_ANTENNA_LEVEL2[3]; +extern const uint8_t BITMAP_ANTENNA_LEVEL3[3]; +extern const uint8_t BITMAP_ANTENNA_LEVEL4[3]; +extern const uint8_t BITMAP_ANTENNA_LEVEL5[3]; +extern const uint8_t BITMAP_ANTENNA_LEVEL6[3]; extern const uint8_t BITMAP_MARKER[8]; -extern const uint8_t BITMAP_VFO_Default[8]; -extern const uint8_t BITMAP_VFO_NotDefault[8]; +extern const uint8_t BITMAP_VFO_DEFAULT[8]; +extern const uint8_t BITMAP_VFO_NOT_DEFAULT[8]; -extern const uint8_t BITMAP_ScanList1[6]; -extern const uint8_t BITMAP_ScanList2[6]; +extern const uint8_t BITMAP_SCANLIST1[6]; +extern const uint8_t BITMAP_SCANLIST2[6]; -extern const uint8_t BITMAP_compand[6]; +extern const uint8_t BITMAP_COMPAND[6]; #endif diff --git a/board.c b/board.c index 44764d61..4812da16 100644 --- a/board.c +++ b/board.c @@ -529,7 +529,7 @@ void BOARD_EEPROM_Init(void) g_eeprom.squelch_level = (Data[1] < 10) ? Data[1] : 1; g_eeprom.tx_timeout_timer = (Data[2] < 11) ? Data[2] : 1; #ifdef ENABLE_NOAA - g_eeprom.NOAA_auto_scan = (Data[3] < 2) ? Data[3] : false; + g_eeprom.noaa_auto_scan = (Data[3] < 2) ? Data[3] : false; #endif g_eeprom.key_lock = (Data[4] < 2) ? Data[4] : false; #ifdef ENABLE_VOX @@ -541,10 +541,10 @@ void BOARD_EEPROM_Init(void) // 0E78..0E7F EEPROM_ReadBuffer(0x0E78, Data, 8); 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.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.backlight = (Data[5] < ARRAY_SIZE(g_sub_menu_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; @@ -584,7 +584,7 @@ void BOARD_EEPROM_Init(void) } // 0E40..0E67 - EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels)); + EEPROM_ReadBuffer(0x0E40, g_fm_channels, sizeof(g_fm_channels)); FM_ConfigureChannelState(); #endif @@ -620,29 +620,29 @@ void BOARD_EEPROM_Init(void) // 0ED0..0ED7 EEPROM_ReadBuffer(0x0ED0, Data, 8); - 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; + 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); - 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.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(g_eeprom.ani_DTMF_id, Data, 8); + memmove(g_eeprom.ani_dtmf_id, Data, 8); else { - memset(g_eeprom.ani_DTMF_id, 0, sizeof(g_eeprom.ani_DTMF_id)); - strcpy(g_eeprom.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 @@ -668,21 +668,21 @@ void BOARD_EEPROM_Init(void) // 0EF8..0F07 EEPROM_ReadBuffer(0x0EF8, Data, 16); if (DTMF_ValidateCodes((char *)Data, 16)) - memmove(g_eeprom.DTMF_up_code, Data, 16); + memmove(g_eeprom.dtmf_up_code, Data, 16); else { - memset(g_eeprom.DTMF_up_code, 0, sizeof(g_eeprom.DTMF_up_code)); - strcpy(g_eeprom.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(g_eeprom.DTMF_down_code, Data, 16); + memmove(g_eeprom.dtmf_down_code, Data, 16); else { - memset(g_eeprom.DTMF_down_code, 0, sizeof(g_eeprom.DTMF_down_code)); - strcpy(g_eeprom.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 @@ -699,23 +699,23 @@ void BOARD_EEPROM_Init(void) // 0F40..0F47 EEPROM_ReadBuffer(0x0F40, Data, 8); - gSetting_F_LOCK = (Data[0] < 6) ? Data[0] : F_LOCK_OFF; - gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true - gSetting_KILLED = (Data[2] < 2) ? Data[2] : false; - gSetting_200TX = (Data[3] < 2) ? Data[3] : false; - gSetting_500TX = (Data[4] < 2) ? Data[4] : false; - gSetting_350EN = (Data[5] < 2) ? Data[5] : true; - gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true; - gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false; - gSetting_live_DTMF_decoder = (Data[7] & (1u << 1)) ? true : false; - gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; + g_setting_f_lock = (Data[0] < 6) ? Data[0] : F_LOCK_OFF; + g_setting_350_tx_enable = (Data[1] < 2) ? Data[1] : false; // was true + g_setting_killed = (Data[2] < 2) ? Data[2] : false; + g_setting_200_tx_enable = (Data[3] < 2) ? Data[3] : false; + g_setting_500_tx_enable = (Data[4] < 2) ? Data[4] : false; + g_setting_350_enable = (Data[5] < 2) ? Data[5] : true; + g_setting_scramble_enable = (Data[6] < 2) ? Data[6] : true; + g_Setting_tx_enable = (Data[7] & (1u << 0)) ? true : false; + g_setting_live_dtmf_decoder = (Data[7] & (1u << 1)) ? true : false; + g_setting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; #ifdef ENABLE_AUDIO_BAR - gSetting_mic_bar = (Data[7] & (1u << 4)) ? true : false; + g_setting_mic_bar = (Data[7] & (1u << 4)) ? true : false; #endif #ifdef ENABLE_AM_FIX - gSetting_AM_fix = (Data[7] & (1u << 5)) ? true : false; + g_setting_am_fix = (Data[7] & (1u << 5)) ? true : false; #endif - gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; + g_setting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; if (!g_eeprom.vfo_open) { @@ -724,16 +724,16 @@ void BOARD_EEPROM_Init(void) } // 0D60..0E27 - EEPROM_ReadBuffer(0x0D60, gUSER_ChannelAttributes, sizeof(gUSER_ChannelAttributes)); + EEPROM_ReadBuffer(0x0D60, g_user_channel_attributes, sizeof(g_user_channel_attributes)); // 0F30..0F3F - EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); - bHasCustomAesKey = false; - for (i = 0; i < ARRAY_SIZE(gCustomAesKey); i++) + EEPROM_ReadBuffer(0x0F30, g_custom_aes_key, sizeof(g_custom_aes_key)); + g_has_custom_aes_key = false; + for (i = 0; i < ARRAY_SIZE(g_custom_aes_key); i++) { - if (gCustomAesKey[i] != 0xFFFFFFFFu) + if (g_custom_aes_key[i] != 0xFFFFFFFFu) { - bHasCustomAesKey = true; + g_has_custom_aes_key = true; return; } } @@ -749,16 +749,16 @@ void BOARD_EEPROM_LoadMoreSettings(void) memmove(g_eeprom_1EC0_3, g_eeprom_1EC0_0, 8); // 8 * 16-bit values - EEPROM_ReadBuffer(0x1EC0, g_eeprom_RSSI_CALIB[0], 8); - EEPROM_ReadBuffer(0x1EC8, g_eeprom_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) + EEPROM_ReadBuffer(0x1F40, g_battery_calibration, 12); + if (g_battery_calibration[0] >= 5000) { - gBatteryCalibration[0] = 1900; - gBatteryCalibration[1] = 2000; + g_battery_calibration[0] = 1900; + g_battery_calibration[1] = 2000; } - gBatteryCalibration[5] = 2300; + g_battery_calibration[5] = 2300; #ifdef ENABLE_VOX EEPROM_ReadBuffer(0x1F50 + (g_eeprom.vox_level * 2), &g_eeprom.vox1_threshold, 2); @@ -767,7 +767,7 @@ void BOARD_EEPROM_LoadMoreSettings(void) //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]; + g_eeprom.mic_sensitivity_tuning = g_mic_gain_dB_2[g_eeprom.mic_sensitivity]; { struct @@ -867,16 +867,16 @@ void BOARD_FactoryReset(bool bIsAll) if (bIsAll) { - RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000); + RADIO_InitInfo(g_rx_vfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000); // set the first few memory channels 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(USER_CHANNEL_FIRST + i, 0, gRxVfo, 2); + g_rx_vfo->freq_config_rx.frequency = Frequency; + g_rx_vfo->freq_config_tx.frequency = Frequency; + g_rx_vfo->band = FREQUENCY_GetBand(Frequency); + SETTINGS_SaveChannel(USER_CHANNEL_FIRST + i, 0, g_rx_vfo, 2); } } } diff --git a/dcs.c b/dcs.c index 2a482ef7..a5fefd51 100644 --- a/dcs.c +++ b/dcs.c @@ -21,7 +21,7 @@ #endif // CTCSS Hz * 10 -const uint16_t CTCSS_Options[50] = { +const uint16_t CTCSS_OPTIONS[50] = { 670, 693, 719, 744, 770, 797, 825, 854, 885, 915, 948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679, @@ -29,7 +29,7 @@ const uint16_t CTCSS_Options[50] = { 2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541 }; -const uint16_t DCS_Options[104] = { +const uint16_t DCS_OPTIONS[104] = { 0x0013, 0x0015, 0x0016, 0x0019, 0x001A, 0x001E, 0x0023, 0x0027, 0x0029, 0x002B, 0x002C, 0x0035, 0x0039, 0x003A, 0x003B, 0x003C, 0x004C, 0x004D, 0x004E, 0x0052, 0x0055, 0x0059, 0x005A, 0x005C, @@ -60,7 +60,7 @@ static uint32_t DCS_CalculateGolay(uint32_t CodeWord) uint32_t DCS_GetGolayCodeWord(dcs_code_type_t code_type, uint8_t Option) { - uint32_t code = DCS_CalculateGolay(DCS_Options[Option] + 0x800U); + uint32_t code = DCS_CalculateGolay(DCS_OPTIONS[Option] + 0x800U); if (code_type == CODE_TYPE_REVERSE_DIGITAL) code ^= 0x7FFFFF; return code; @@ -76,8 +76,8 @@ uint8_t DCS_GetCdcssCode(uint32_t Code) if (((Code >> 9) & 0x7U) == 4) { unsigned int j; - for (j = 0; j < ARRAY_SIZE(DCS_Options); j++) - if (DCS_Options[j] == (Code & 0x1FF)) + for (j = 0; j < ARRAY_SIZE(DCS_OPTIONS); j++) + if (DCS_OPTIONS[j] == (Code & 0x1FF)) if (DCS_GetGolayCodeWord(2, j) == Code) return j; } @@ -95,13 +95,13 @@ uint8_t DCS_GetCtcssCode(int Code) { unsigned int i; uint8_t Result = 0xFF; - int Smallest = ARRAY_SIZE(CTCSS_Options); + int Smallest = ARRAY_SIZE(CTCSS_OPTIONS); - for (i = 0; i < ARRAY_SIZE(CTCSS_Options); i++) + for (i = 0; i < ARRAY_SIZE(CTCSS_OPTIONS); i++) { - int Delta = Code - CTCSS_Options[i]; + int Delta = Code - CTCSS_OPTIONS[i]; if (Delta < 0) - Delta = -(Code - CTCSS_Options[i]); + Delta = -(Code - CTCSS_OPTIONS[i]); if (Smallest > Delta) { Smallest = Delta; diff --git a/dcs.h b/dcs.h index d902f247..67185a70 100644 --- a/dcs.h +++ b/dcs.h @@ -34,12 +34,11 @@ enum { CDCSS_NEGATIVE_CODE = 2U, }; -extern const uint16_t CTCSS_Options[50]; -extern const uint16_t DCS_Options[104]; +extern const uint16_t CTCSS_OPTIONS[50]; +extern const uint16_t DCS_OPTIONS[104]; 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); #endif - diff --git a/driver/backlight.c b/driver/backlight.c index 66f4f713..eb427613 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -20,7 +20,7 @@ #include "settings.h" // this is decremented once every 500ms -uint16_t gBacklightCountdown = 0; +uint16_t g_backlight_count_down = 0; void backlight_turn_on(void) { @@ -34,27 +34,27 @@ void backlight_turn_on(void) { default: case 1: // 5 sec - gBacklightCountdown = 5; + g_backlight_count_down = 5; break; case 2: // 10 sec - gBacklightCountdown = 10; + g_backlight_count_down = 10; break; case 3: // 20 sec - gBacklightCountdown = 20; + g_backlight_count_down = 20; break; case 4: // 1 min - gBacklightCountdown = 60; + g_backlight_count_down = 60; break; case 5: // 2 min - gBacklightCountdown = 60 * 2; + g_backlight_count_down = 60 * 2; break; case 6: // 4 min - gBacklightCountdown = 60 * 4; + g_backlight_count_down = 60 * 4; break; case 7: // always on - gBacklightCountdown = 0; + g_backlight_count_down = 0; break; } - gBacklightCountdown *= 2; + g_backlight_count_down *= 2; } diff --git a/driver/backlight.h b/driver/backlight.h index ec531190..da1b02c6 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -19,7 +19,7 @@ #include -extern uint16_t gBacklightCountdown; +extern uint16_t g_backlight_count_down; void backlight_turn_on(void); diff --git a/driver/bk4819.c b/driver/bk4819.c index d9e24dac..dd380f27 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -542,7 +542,7 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold) BK4819_WriteRegister(BK4819_REG_31, REG_31_Value | (1u << 2)); // VOX Enable } -void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different) +void BK4819_SetFilterBandwidth(const BK4819_filter_bandwidth_t Bandwidth, const bool weak_no_different) { // REG_43 // <15> 0 ??? @@ -713,8 +713,8 @@ void BK4819_SetFrequency(uint32_t Frequency) } void BK4819_SetupSquelch( - uint8_t squelch_open_RSSI_thresh, - uint8_t squelch_close_RSSI_thresh, + 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, @@ -792,14 +792,14 @@ void BK4819_SetupSquelch( // // <7:0> 70 RSSI threshold for Squelch = close 0.5dB/step // - BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)squelch_open_RSSI_thresh << 8) | squelch_close_RSSI_thresh); + BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)squelch_open_rssi_thresh << 8) | squelch_close_rssi_thresh); BK4819_SetAF(BK4819_AF_MUTE); BK4819_RX_TurnOn(); } -void BK4819_SetAF(BK4819_AF_Type_t AF) +void BK4819_SetAF(BK4819_af_type_t AF) { // AF Output Inverse Mode = Inverse // Undocumented bits 0x2040 @@ -1504,7 +1504,7 @@ bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency) return finished; } -BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq) +BK4819_CSS_scan_result_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq) { // ********** // REG_68 read only diff --git a/driver/bk4819.h b/driver/bk4819.h index 53f02c36..bef29f27 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -22,7 +22,7 @@ #include "driver/bk4819-regs.h" -enum BK4819_AF_Type_t +enum BK4819_af_type_e { BK4819_AF_MUTE = 0u, // BK4819_AF_FM = 1u, // FM @@ -38,29 +38,26 @@ enum BK4819_AF_Type_t BK4819_AF_UNKNOWN5 = 11u, // distorted BK4819_AF_UNKNOWN6 = 12u, // distorted BK4819_AF_UNKNOWN7 = 13u, // interesting - BK4819_AF_UNKNOWN8 = 14u, // interesting + BK4819_AF_UNKNOWN8 = 14u, // interesting BK4819_AF_UNKNOWN9 = 15u // not a lot }; +typedef enum BK4819_af_type_e BK4819_af_type_t; -typedef enum BK4819_AF_Type_t BK4819_AF_Type_t; - -enum BK4819_FilterBandwidth_t +enum BK4819_filter_bandwidth_e { BK4819_FILTER_BW_WIDE = 0, BK4819_FILTER_BW_NARROW, BK4819_FILTER_BW_NARROWER }; +typedef enum BK4819_filter_bandwidth_e BK4819_filter_bandwidth_t; -typedef enum BK4819_FilterBandwidth_t BK4819_FilterBandwidth_t; - -enum BK4819_CssScanResult_t +enum BK4819_CSS_scan_result_e { BK4819_CSS_RESULT_NOT_FOUND = 0, BK4819_CSS_RESULT_CTCSS, BK4819_CSS_RESULT_CDCSS }; - -typedef enum BK4819_CssScanResult_t BK4819_CssScanResult_t; +typedef enum BK4819_CSS_scan_result_e BK4819_CSS_scan_result_t; extern bool g_rx_idle_mode; @@ -78,7 +75,7 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord); void BK4819_SetCTCSSFrequency(uint32_t BaudRate); void BK4819_SetTailDetection(const uint32_t freq_10Hz); void BK4819_EnableVox(uint16_t Vox1Threshold, uint16_t Vox0Threshold); -void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different); +void BK4819_SetFilterBandwidth(const BK4819_filter_bandwidth_t Bandwidth, const bool weak_no_different); void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency); void BK4819_SetFrequency(uint32_t Frequency); void BK4819_SetupSquelch( @@ -89,7 +86,7 @@ void BK4819_SetupSquelch( uint8_t SquelchCloseGlitchThresh, uint8_t SquelchOpenGlitchThresh); -void BK4819_SetAF(BK4819_AF_Type_t AF); +void BK4819_SetAF(BK4819_af_type_t AF); void BK4819_RX_TurnOn(void); void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency); void BK4819_DisableScramble(void); @@ -139,7 +136,7 @@ uint16_t BK4819_GetVoiceAmplitudeOut(void); uint8_t BK4819_GetAfTxRx(void); bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency); -BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq); +BK4819_CSS_scan_result_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq); void BK4819_DisableFrequencyScan(void); void BK4819_EnableFrequencyScan(void); void BK4819_SetScanFrequency(uint32_t Frequency); @@ -156,15 +153,14 @@ uint8_t BK4819_GetCTCType(void); void BK4819_SendFSKData(uint16_t *pData); void BK4819_PrepareFSKReceive(void); - + void BK4819_PlayRoger(void); void BK4819_PlayRogerMDC(void); - + void BK4819_Enable_AfDac_DiscMode_TxDsp(void); - + void BK4819_GetVoxAmp(uint16_t *pResult); void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency); void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code); #endif - diff --git a/driver/keyboard.c b/driver/keyboard.c index 9b2c1e76..1cde2565 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -25,7 +25,7 @@ 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; +bool g_f_key_was_pressed = false; static const struct { diff --git a/driver/keyboard.h b/driver/keyboard.h index dd9b040d..910c04e8 100644 --- a/driver/keyboard.h +++ b/driver/keyboard.h @@ -48,7 +48,7 @@ typedef enum key_code_e key_code_t; 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; +extern bool g_f_key_was_pressed; key_code_t KEYBOARD_Poll(void); diff --git a/driver/st7565.c b/driver/st7565.c index 66ee65d7..ca93c1aa 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -25,8 +25,8 @@ #include "driver/system.h" #include "misc.h" -uint8_t gStatusLine[128]; -uint8_t gFrameBuffer[7][128]; +uint8_t g_status_line[128]; +uint8_t g_frame_buffer[7][128]; void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap) { @@ -68,15 +68,15 @@ void ST7565_BlitFullScreen(void) ST7565_WriteByte(0x40); - for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++) + for (Line = 0; Line < ARRAY_SIZE(g_frame_buffer); Line++) { unsigned int Column; ST7565_SelectColumnAndLine(4, Line + 1); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); - for (Column = 0; Column < ARRAY_SIZE(gFrameBuffer[0]); Column++) + for (Column = 0; Column < ARRAY_SIZE(g_frame_buffer[0]); Column++) { while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} - SPI0->WDR = gFrameBuffer[Line][Column]; + SPI0->WDR = g_frame_buffer[Line][Column]; } SPI_WaitForUndocumentedTxFifoStatusBit(); } @@ -104,10 +104,10 @@ void ST7565_BlitStatusLine(void) GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); - for (i = 0; i < ARRAY_SIZE(gStatusLine); i++) + for (i = 0; i < ARRAY_SIZE(g_status_line); i++) { while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} - SPI0->WDR = gStatusLine[i]; + SPI0->WDR = g_status_line[i]; } SPI_WaitForUndocumentedTxFifoStatusBit(); diff --git a/driver/st7565.h b/driver/st7565.h index ac0ffd91..eddb1342 100644 --- a/driver/st7565.h +++ b/driver/st7565.h @@ -23,8 +23,8 @@ #define LCD_WIDTH 128 #define LCD_HEIGHT 64 -extern uint8_t gStatusLine[128]; -extern uint8_t gFrameBuffer[7][128]; +extern uint8_t g_status_line[128]; +extern uint8_t g_frame_buffer[7][128]; void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap); void ST7565_BlitFullScreen(void); diff --git a/driver/uart.c b/driver/uart.c index cb97d94d..ad7183ab 100644 --- a/driver/uart.c +++ b/driver/uart.c @@ -21,7 +21,7 @@ #include "driver/uart.h" static bool UART_IsLogEnabled; -uint8_t UART_DMA_Buffer[256]; +uint8_t UART_DMA_Buffer[256]; void UART_Init(void) { @@ -33,11 +33,7 @@ void UART_Init(void) Delta = SYSCON_RC_FREQ_DELTA; Positive = (Delta & SYSCON_RC_FREQ_DELTA_RCHF_SIG_MASK) >> SYSCON_RC_FREQ_DELTA_RCHF_SIG_SHIFT; Frequency = (Delta & SYSCON_RC_FREQ_DELTA_RCHF_DELTA_MASK) >> SYSCON_RC_FREQ_DELTA_RCHF_DELTA_SHIFT; - if (Positive) { - Frequency += 48000000U; - } else { - Frequency = 48000000U - Frequency; - } + Frequency = Positive ? Frequency + 48000000U : 48000000U - Frequency; UART1->BAUD = Frequency / 39053U; UART1->CTRL = UART_CTRL_RXEN_BITS_ENABLE | UART_CTRL_TXEN_BITS_ENABLE | UART_CTRL_RXDMAEN_BITS_ENABLE; @@ -89,16 +85,15 @@ void UART_Send(const void *pBuffer, uint32_t Size) const uint8_t *pData = (const uint8_t *)pBuffer; uint32_t i; - for (i = 0; i < Size; i++) { + for (i = 0; i < Size; i++) + { UART1->TDR = pData[i]; - while ((UART1->IF & UART_IF_TXFIFO_FULL_MASK) != UART_IF_TXFIFO_FULL_BITS_NOT_SET) { - } + while ((UART1->IF & UART_IF_TXFIFO_FULL_MASK) != UART_IF_TXFIFO_FULL_BITS_NOT_SET) {} } } void UART_LogSend(const void *pBuffer, uint32_t Size) { - if (UART_IsLogEnabled) { + if (UART_IsLogEnabled) UART_Send(pBuffer, Size); - } } diff --git a/firmware.bin b/firmware.bin index f56de8d7..5ec3065f 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index fbdc7e59..3348e9fa 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/font.c b/font.c index 3d0e3b2b..f93efe72 100644 --- a/font.c +++ b/font.c @@ -16,8 +16,8 @@ #include "font.h" -//const uint8_t gFontBig[95][16] = -const uint8_t gFontBig[95][15] = +//const uint8_t g_font_big[95][16] = +const uint8_t g_font_big[95][15] = { #if 0 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ' ' @@ -216,7 +216,7 @@ const uint8_t gFontBig[95][15] = #if 0 // original font - const uint8_t gFontBigDigits[11][26] = + const uint8_t g_font_big_digits[11][26] = { {0x00, 0xC0, 0xF0, 0xF8, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xF8, 0xF0, 0xE0, 0x00, 0x07, 0x1F, 0x3F, 0x78, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x0F}, {0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00}, @@ -232,7 +232,7 @@ const uint8_t gFontBig[95][15] = }; #elif 0 // VCR font - const uint8_t gFontBigDigits[11][26] = + const uint8_t g_font_big_digits[11][26] = { {0x00, 0x00, 0xF8, 0xFC, 0x06, 0x86, 0xC6, 0xE6, 0xF6, 0x76, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x77, 0x67, 0x63, 0x61, 0x60, 0x70, 0x3F, 0x1F, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, 0x00}, @@ -248,7 +248,7 @@ const uint8_t gFontBig[95][15] = }; #else // Terminus font - const uint8_t gFontBigDigits[11][26] = + const uint8_t g_font_big_digits[11][26] = { {0x00, 0x00, 0xFC, 0xFE, 0xFE, 0x06, 0x86, 0xC6, 0xE6, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x3F, 0x7F, 0x7F, 0x67, 0x63, 0x61, 0x60, 0x7F, 0x7F, 0x3F, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00}, @@ -264,7 +264,7 @@ const uint8_t gFontBig[95][15] = }; #endif /* -const uint8_t gFontSmallDigits[11][7] = +const uint8_t g_font_small_digits[11][7] = { {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, // '0' {0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00}, // '1' @@ -279,7 +279,7 @@ const uint8_t gFontSmallDigits[11][7] = {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00} // '-' }; */ -const uint8_t gFontSmall[95][6] = +const uint8_t g_font_small[95][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' ' {0x00, 0x00, 0x5E, 0x00, 0x00, 0x00}, // '!' @@ -379,7 +379,7 @@ const uint8_t gFontSmall[95][6] = }; #ifdef ENABLE_SMALL_BOLD - const uint8_t gFontSmallBold[95][6] = + const uint8_t g_font_small_bold[95][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x5E, 0x5E, 0x00, 0x00}, @@ -480,7 +480,7 @@ const uint8_t gFontSmall[95][6] = #endif #ifdef ENABLE_SPECTRUM - const uint8_t gFont3x5[160][3] = + const uint8_t g_font3x5[160][3] = { {0x00, 0x00, 0x00}, // 32 - space {0x00, 0x17, 0x00}, // 33 - exclam diff --git a/font.h b/font.h index 1c07fb8f..695e1b0c 100644 --- a/font.h +++ b/font.h @@ -19,13 +19,13 @@ #include -//extern const uint8_t gFontBig[95][16]; -extern const uint8_t gFontBig[95][15]; -extern const uint8_t gFontBigDigits[11][26]; -//extern const uint8_t gFontSmallDigits[11][7]; -extern const uint8_t gFontSmall[95][6]; +//extern const uint8_t g_font_big[95][16]; +extern const uint8_t g_font_big[95][15]; +extern const uint8_t g_font_big_digits[11][26]; +//extern const uint8_t g_font_small_digits[11][7]; +extern const uint8_t g_font_small[95][6]; #ifdef ENABLE_SMALL_BOLD - extern const uint8_t gFontSmallBold[95][6]; + extern const uint8_t g_font_small_bold[95][6]; #endif #endif diff --git a/frequencies.c b/frequencies.c index d0cd0c1f..7b9667d5 100644 --- a/frequencies.c +++ b/frequencies.c @@ -22,7 +22,7 @@ const freq_band_table_t BX4819_band1 = { 1800000, 63000000}; const freq_band_table_t BX4819_band2 = {84000000, 130000000}; -const freq_band_table_t frequencyBandTable[7] = +const freq_band_table_t FREQ_BAND_TABLE[7] = { #ifndef ENABLE_WIDE_RX // QS original @@ -63,18 +63,18 @@ const freq_band_table_t frequencyBandTable[7] = #ifdef ENABLE_1250HZ_STEP // includes 1.25kHz step - const uint16_t StepFrequencyTable[7] = {125, 250, 625, 1000, 1250, 2500, 833}; + const uint16_t STEP_FREQ_TABLE[7] = {125, 250, 625, 1000, 1250, 2500, 833}; #else // QS steps (*10 Hz) - const uint16_t StepFrequencyTable[7] = {250, 500, 625, 1000, 1250, 2500, 833}; + const uint16_t STEP_FREQ_TABLE[7] = {250, 500, 625, 1000, 1250, 2500, 833}; #endif FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency) { int band; - for (band = ARRAY_SIZE(frequencyBandTable) - 1; band >= 0; band--) - if (Frequency >= frequencyBandTable[band].lower) -// if (Frequency < frequencyBandTable[band].upper) + for (band = ARRAY_SIZE(FREQ_BAND_TABLE) - 1; band >= 0; band--) + if (Frequency >= FREQ_BAND_TABLE[band].lower) +// if (Frequency < FREQ_BAND_TABLE[band].upper) return (FREQUENCY_Band_t)band; return BAND1_50MHz; @@ -128,27 +128,27 @@ int TX_freq_check(const uint32_t Frequency) { // return '0' if TX frequency is allowed // otherwise return '-1' - if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper) + if (Frequency < FREQ_BAND_TABLE[0].lower || Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) return -1; // not allowed outside this range if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) return -1; // BX chip does not work in this range - switch (gSetting_F_LOCK) + switch (g_setting_f_lock) { case F_LOCK_OFF: if (Frequency >= 13600000 && Frequency < 17400000) return 0; if (Frequency >= 17400000 && Frequency < 35000000) - if (gSetting_200TX) + if (g_setting_200_tx_enable) return 0; if (Frequency >= 35000000 && Frequency < 40000000) - if (gSetting_350TX && gSetting_350EN) + if (g_setting_350_tx_enable && g_setting_350_enable) return 0; if (Frequency >= 40000000 && Frequency < 47000000) return 0; if (Frequency >= 47000000 && Frequency <= 60000000) - if (gSetting_500TX) + if (g_setting_500_tx_enable) return 0; break; @@ -196,7 +196,7 @@ int RX_freq_check(const uint32_t Frequency) { // return '0' if RX frequency is allowed // otherwise return '-1' - if (Frequency < frequencyBandTable[0].lower || Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper) + if (Frequency < FREQ_BAND_TABLE[0].lower || Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) return -1; if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) diff --git a/frequencies.h b/frequencies.h index 30c4dc73..d4d5e1fb 100644 --- a/frequencies.h +++ b/frequencies.h @@ -27,7 +27,7 @@ typedef struct { extern const freq_band_table_t BX4819_band1; extern const freq_band_table_t BX4819_band2; -extern const freq_band_table_t frequencyBandTable[7]; +extern const freq_band_table_t FREQ_BAND_TABLE[7]; enum FREQUENCY_Band_t { BAND_NONE = -1, @@ -66,7 +66,7 @@ typedef enum FREQUENCY_Band_t FREQUENCY_Band_t; #endif typedef enum step_setting_t step_setting_t; -extern const uint16_t StepFrequencyTable[7]; +extern const uint16_t STEP_FREQ_TABLE[7]; #ifdef ENABLE_NOAA extern const uint32_t NoaaFrequencyTable[10]; diff --git a/functions.c b/functions.c index 765c7db0..336a2291 100644 --- a/functions.c +++ b/functions.c @@ -38,26 +38,26 @@ #include "ui/status.h" #include "ui/ui.h" -FUNCTION_Type_t gCurrentFunction; +function_type_t g_current_function; void FUNCTION_Init(void) { #ifdef ENABLE_NOAA - if (IS_NOT_NOAA_CHANNEL(gRxVfo->channel_save)) + if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) #endif { - gCurrentcode_type = gSelectedcode_type; - if (gCssScanMode == CSS_SCAN_MODE_OFF) - gCurrentcode_type = gRxVfo->am_mode ? CODE_TYPE_OFF : gRxVfo->pRX->code_type; + g_current_code_type = g_selected_code_type; + if (g_css_scan_mode == CSS_SCAN_MODE_OFF) + g_current_code_type = g_rx_vfo->am_mode ? CODE_TYPE_OFF : g_rx_vfo->pRX->code_type; } #ifdef ENABLE_NOAA else - gCurrentcode_type = CODE_TYPE_CONTINUOUS_TONE; + g_current_code_type = CODE_TYPE_CONTINUOUS_TONE; #endif DTMF_clear_RX(); - g_CxCSS_tailL_found = false; + g_CxCSS_tail_found = false; g_CDCSS_lost = false; g_CTCSS_lost = false; @@ -65,29 +65,29 @@ void FUNCTION_Init(void) g_vox_lost = false; #endif - g_SquelchLost = false; + g_squelch_lost = false; - gFlagTailNoteEliminationComplete = false; - gTailNoteEliminationCountdown_10ms = 0; - gFoundCTCSS = false; - gFoundCDCSS = false; - gFoundCTCSSCountdown_10ms = 0; - gFoundCDCSSCountdown_10ms = 0; - gEndOfRxDetectedMaybe = false; + g_flag_tail_tone_elimination_complete = false; + g_tail_tone_elimination_count_down_10ms = 0; + g_found_CTCSS = false; + g_found_CDCSS = false; + g_found_CTCSS_count_down_10ms = 0; + g_found_CDCSS_count_down_10ms = 0; + g_end_of_rx_detected_maybe = false; #ifdef ENABLE_NOAA - gNOAACountdown_10ms = 0; + g_noaa_count_down_10ms = 0; #endif - gUpdateStatus = true; + g_update_status = true; } -void FUNCTION_Select(FUNCTION_Type_t Function) +void FUNCTION_Select(function_type_t Function) { - const FUNCTION_Type_t PreviousFunction = gCurrentFunction; + const function_type_t PreviousFunction = g_current_function; const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); - gCurrentFunction = Function; + g_current_function = Function; if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) { @@ -99,35 +99,35 @@ void FUNCTION_Select(FUNCTION_Type_t Function) switch (Function) { case FUNCTION_FOREGROUND: - if (gDTMF_ReplyState != DTMF_REPLY_NONE) + if (g_dtmf_reply_state != DTMF_REPLY_NONE) RADIO_PrepareCssTX(); if (PreviousFunction == FUNCTION_TRANSMIT) { - gVFO_RSSI_bar_level[0] = 0; - gVFO_RSSI_bar_level[1] = 0; + g_vfo_rssi_bar_level[0] = 0; + g_vfo_rssi_bar_level[1] = 0; } else if (PreviousFunction != FUNCTION_RECEIVE) break; #if defined(ENABLE_FMRADIO) - if (gFmRadioMode) - gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms; + if (g_fm_radio_mode) + g_fm_restore_count_down_10ms = fm_restore_countdown_10ms; #endif - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) + if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT || + g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || + g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY) { - gDTMF_auto_reset_time_500ms = g_eeprom.DTMF_auto_reset_time * 2; + g_dtmf_auto_reset_time_500ms = g_eeprom.dtmf_auto_reset_time * 2; } - gUpdateStatus = true; + g_update_status = true; return; case FUNCTION_MONITOR: - gMonitor = true; + g_monitor_enabled = true; break; case FUNCTION_INCOMING: @@ -135,21 +135,21 @@ void FUNCTION_Select(FUNCTION_Type_t Function) break; case FUNCTION_POWER_SAVE: - gPowerSave_10ms = g_eeprom.battery_save * 10; - gPowerSaveCountdownExpired = false; + g_power_save_10ms = g_eeprom.battery_save * 10; + g_power_save_count_down_expired = false; g_rx_idle_mode = true; - gMonitor = false; + g_monitor_enabled = false; BK4819_DisableVox(); BK4819_Sleep(); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); - gUpdateStatus = true; + g_update_status = true; - if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu GUI_SelectNextDisplay(DISPLAY_MAIN); return; @@ -163,19 +163,19 @@ void FUNCTION_Select(FUNCTION_Type_t Function) DTMF_clear_RX(); // clear the DTMF RX live decoder buffer - gDTMF_RX_live_timeout = 0; - gDTMF_RX_live_timeout = 0; - memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); + g_dtmf_rx_live_timeout = 0; + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); #if defined(ENABLE_FMRADIO) - if (gFmRadioMode) + if (g_fm_radio_mode) BK1080_Init(0, false); #endif #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_TXALARM && g_eeprom.alarm_mode != ALARM_MODE_TONE) + if (g_alarm_state == ALARM_STATE_TXALARM && g_eeprom.alarm_mode != ALARM_MODE_TONE) { - gAlarmState = ALARM_STATE_ALARM; + g_alarm_state = ALARM_STATE_ALARM; GUI_DisplayScreen(); @@ -187,17 +187,17 @@ void FUNCTION_Select(FUNCTION_Type_t Function) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; + g_enable_speaker = true; SYSTEM_DelayMs(60); BK4819_ExitTxMute(); - gAlarmToneCounter = 0; + g_alarm_tone_counter = 0; break; } #endif - gUpdateStatus = true; + g_update_status = true; GUI_DisplayScreen(); @@ -208,36 +208,36 @@ void FUNCTION_Select(FUNCTION_Type_t Function) DTMF_Reply(); - if (gCurrentVfo->DTMF_ptt_id_tx_mode == PTT_ID_APOLLO) - BK4819_PlaySingleTone(2525, 250, 0, g_eeprom.DTMF_side_tone); + if (g_current_vfo->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) + if (g_alarm_state != ALARM_STATE_OFF) { #ifdef ENABLE_TX1750 - if (gAlarmState == ALARM_STATE_TX1750) + if (g_alarm_state == ALARM_STATE_TX1750) BK4819_TransmitTone(true, 1750); #endif #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_TXALARM) + if (g_alarm_state == ALARM_STATE_TXALARM) BK4819_TransmitTone(true, 500); #endif SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); #ifdef ENABLE_ALARM - gAlarmToneCounter = 0; + g_alarm_tone_counter = 0; #endif - gEnableSpeaker = true; + g_enable_speaker = true; break; } #endif - if (gCurrentVfo->scrambling_type > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gCurrentVfo->scrambling_type - 1); + if (g_current_vfo->scrambling_type > 0 && g_setting_scramble_enable) + BK4819_EnableScramble(g_current_vfo->scrambling_type - 1); else BK4819_DisableScramble(); - if (gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3) + if (g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3) backlight_turn_on(); break; @@ -246,10 +246,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function) break; } - gBatterySaveCountdown_10ms = battery_save_count_10ms; - gSchedulePowerSave = false; + g_battery_save_count_down_10ms = battery_save_count_10ms; + g_schedule_power_save = false; #if defined(ENABLE_FMRADIO) - gFM_RestoreCountdown_10ms = 0; + g_fm_restore_count_down_10ms = 0; #endif } diff --git a/functions.h b/functions.h index 4194d867..ab80673b 100644 --- a/functions.h +++ b/functions.h @@ -19,7 +19,7 @@ #include -enum FUNCTION_Type_t +enum function_type_e { FUNCTION_FOREGROUND = 0, // ??? FUNCTION_TRANSMIT, // transmitting @@ -29,13 +29,12 @@ enum FUNCTION_Type_t FUNCTION_POWER_SAVE, // sleeping FUNCTION_BAND_SCOPE // bandscope mode (panadpter/spectrum) .. not yet implemented }; +typedef enum function_type_e function_type_t; -typedef enum FUNCTION_Type_t FUNCTION_Type_t; - -extern FUNCTION_Type_t gCurrentFunction; +extern function_type_t g_current_function; void FUNCTION_Init(void); -void FUNCTION_Select(FUNCTION_Type_t Function); +void FUNCTION_Select(function_type_t Function); #endif diff --git a/helper/battery.c b/helper/battery.c index cb434fdf..fc62dc75 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -21,18 +21,18 @@ #include "ui/menu.h" #include "ui/ui.h" -uint16_t gBatteryCalibration[6]; -uint16_t gBatteryCurrentVoltage; -uint16_t gBatteryCurrent; -uint16_t gBatteryVoltages[4]; -uint16_t gBatteryVoltageAverage; -uint8_t gBatteryDisplayLevel; -bool gChargingWithTypeC; -bool gLowBattery; -bool gLowBatteryBlink; -uint16_t gBatteryCheckCounter; - -volatile uint16_t gPowerSave_10ms; +uint16_t g_battery_calibration[6]; +uint16_t g_battery_current_voltage; +uint16_t g_battery_current; +uint16_t g_battery_voltages[4]; +uint16_t g_battery_voltage_average; +uint8_t g_battery_display_level; +bool g_charging_with_type_c; +bool g_low_battery; +bool g_low_battery_blink; +uint16_t g_battery_check_counter; + +volatile uint16_t g_power_save_10ms; /* Based on real measurement @@ -81,70 +81,70 @@ unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV) void BATTERY_GetReadings(const bool bDisplayBatteryLevel) { - const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; - const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; + const uint8_t PreviousBatteryLevel = g_battery_display_level; + const uint16_t Voltage = (g_battery_voltages[0] + g_battery_voltages[1] + g_battery_voltages[2] + g_battery_voltages[3]) / 4; - gBatteryDisplayLevel = 0; + g_battery_display_level = 0; - if (gBatteryCalibration[5] < Voltage) - gBatteryDisplayLevel = 6; + if (g_battery_calibration[5] < Voltage) + g_battery_display_level = 6; else - if (gBatteryCalibration[4] < Voltage) - gBatteryDisplayLevel = 5; + if (g_battery_calibration[4] < Voltage) + g_battery_display_level = 5; else - if (gBatteryCalibration[3] < Voltage) - gBatteryDisplayLevel = 4; + if (g_battery_calibration[3] < Voltage) + g_battery_display_level = 4; else - if (gBatteryCalibration[2] < Voltage) - gBatteryDisplayLevel = 3; + if (g_battery_calibration[2] < Voltage) + g_battery_display_level = 3; else - if (gBatteryCalibration[1] < Voltage) - gBatteryDisplayLevel = 2; + if (g_battery_calibration[1] < Voltage) + g_battery_display_level = 2; else - if (gBatteryCalibration[0] < Voltage) - gBatteryDisplayLevel = 1; + if (g_battery_calibration[0] < Voltage) + g_battery_display_level = 1; - gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; + g_battery_voltage_average = (Voltage * 760) / g_battery_calibration[3]; - if ((gScreenToDisplay == DISPLAY_MENU) && gMenuCursor == MENU_VOL) - gUpdateDisplay = true; + if ((g_screen_to_display == DISPLAY_MENU) && g_menu_cursor == MENU_VOL) + g_update_display = true; - if (gBatteryCurrent < 501) + if (g_battery_current < 501) { - if (gChargingWithTypeC) + if (g_charging_with_type_c) { - gUpdateStatus = true; - gUpdateDisplay = true; + g_update_status = true; + g_update_display = true; } - gChargingWithTypeC = false; + g_charging_with_type_c = false; } else { - if (!gChargingWithTypeC) + if (!g_charging_with_type_c) { - gUpdateStatus = true; - gUpdateDisplay = true; + g_update_status = true; + g_update_display = true; backlight_turn_on(); } - gChargingWithTypeC = true; + g_charging_with_type_c = true; } - if (PreviousBatteryLevel != gBatteryDisplayLevel) + if (PreviousBatteryLevel != g_battery_display_level) { - if (gBatteryDisplayLevel < 2) + if (g_battery_display_level < 2) { - gLowBattery = true; + g_low_battery = true; } else { - gLowBattery = false; + g_low_battery = false; if (bDisplayBatteryLevel) - UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink); + UI_DisplayBattery(g_battery_display_level, g_low_battery_blink); } - gLowBatteryCountdown = 0; + g_low_batteryCountdown = 0; } } diff --git a/helper/battery.h b/helper/battery.h index 336207ca..8b37bf72 100644 --- a/helper/battery.h +++ b/helper/battery.h @@ -20,21 +20,19 @@ #include #include -extern uint16_t gBatteryCalibration[6]; -extern uint16_t gBatteryCurrentVoltage; -extern uint16_t gBatteryCurrent; -extern uint16_t gBatteryVoltages[4]; -extern uint16_t gBatteryVoltageAverage; -extern uint8_t gBatteryDisplayLevel; -extern bool gChargingWithTypeC; -extern bool gLowBattery; -extern bool gLowBatteryBlink; -extern uint16_t gBatteryCheckCounter; - -extern volatile uint16_t gPowerSave_10ms; +extern uint16_t g_battery_calibration[6]; +extern uint16_t g_battery_current_voltage; +extern uint16_t g_battery_current; +extern uint16_t g_battery_voltages[4]; +extern uint16_t g_battery_voltage_average; +extern uint8_t g_battery_display_level; +extern bool g_charging_with_type_c; +extern bool g_low_battery; +extern bool g_low_battery_blink; +extern uint16_t g_battery_check_counter; +extern volatile uint16_t g_power_save_10ms; unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV); void BATTERY_GetReadings(const bool bDisplayBatteryLevel); #endif - diff --git a/helper/boot.c b/helper/boot.c index a1df2705..a299748d 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -85,20 +85,20 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) 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); + RADIO_InitInfo(g_rx_vfo, FREQ_CHANNEL_LAST - 1, 41002500); - gRxVfo->channel_bandwidth = BANDWIDTH_WIDE; - gRxVfo->output_power = OUTPUT_POWER_LOW; + g_rx_vfo->channel_bandwidth = BANDWIDTH_WIDE; + g_rx_vfo->output_power = OUTPUT_POWER_LOW; - RADIO_ConfigureSquelchAndOutputPower(gRxVfo); + RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo); - gCurrentVfo = gRxVfo; + g_current_vfo = g_rx_vfo; RADIO_SetupRegisters(true); BK4819_SetupAircopy(); BK4819_ResetFSK(); - gAircopyState = AIRCOPY_READY; + g_aircopy_state = AIRCOPY_READY; GUI_SelectNextDisplay(DISPLAY_AIRCOPY); } diff --git a/main.c b/main.c index 794138a2..b1b68e40 100644 --- a/main.c +++ b/main.c @@ -67,7 +67,7 @@ void Main(void) BOARD_Init(); UART_Init(); - boot_counter_10ms = 250; // 2.5 sec + g_boot_counter_10ms = 250; // 2.5 sec UART_Send(UART_Version, strlen(UART_Version)); @@ -75,12 +75,12 @@ void Main(void) memset(&g_eeprom, 0, sizeof(g_eeprom)); - memset(gDTMF_String, '-', sizeof(gDTMF_String)); - gDTMF_String[sizeof(gDTMF_String) - 1] = 0; + memset(g_dtmf_string, '-', sizeof(g_dtmf_string)); + g_dtmf_string[sizeof(g_dtmf_string) - 1] = 0; BK4819_Init(); - BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); + BOARD_ADC_GetBatteryInfo(&g_battery_current_voltage, &g_battery_current); BOARD_EEPROM_Init(); @@ -93,8 +93,8 @@ void Main(void) RADIO_SetupRegisters(true); - for (i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++) - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent); + for (i = 0; i < ARRAY_SIZE(g_battery_voltages); i++) + BOARD_ADC_GetBatteryInfo(&g_battery_voltages[i], &g_battery_current); BATTERY_GetReadings(false); @@ -104,10 +104,10 @@ void Main(void) BootMode = BOOT_GetMode(); - gF_LOCK = (BootMode == BOOT_MODE_F_LOCK); // flag to say include the hidden menu items + g_f_lock = (BootMode == BOOT_MODE_F_LOCK); // flag to say include the hidden menu items // sort the menu list - UI_SortMenu(!gF_LOCK); + UI_SortMenu(!g_f_lock); // wait for user to release all butts before moving on if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || @@ -127,16 +127,16 @@ void Main(void) g_debounce_counter = 0; } - if (!gChargingWithTypeC && gBatteryDisplayLevel == 0) + if (!g_charging_with_type_c && g_battery_display_level == 0) { FUNCTION_Select(FUNCTION_POWER_SAVE); - if (g_eeprom.backlight < (ARRAY_SIZE(gSubMenu_backlight) - 1)) + if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_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 - gReducedService = true; + g_reduced_service = true; } else { @@ -146,15 +146,15 @@ void Main(void) if (g_eeprom.pwr_on_display_mode != PWR_ON_DISPLAY_MODE_NONE) { // 2.55 second boot-up screen - while (boot_counter_10ms > 0) + while (g_boot_counter_10ms > 0) { if (KEYBOARD_Poll() != KEY_INVALID) { // halt boot beeps - boot_counter_10ms = 0; + g_boot_counter_10ms = 0; break; } #ifdef ENABLE_BOOT_BEEPS - if ((boot_counter_10ms % 25) == 0) + if ((g_boot_counter_10ms % 25) == 0) AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); #endif } @@ -163,9 +163,9 @@ void Main(void) #ifdef ENABLE_PWRON_PASSWORD if (g_eeprom.power_on_password < 1000000) { - bIsInLockScreen = true; + g_is_in_lock_screen = true; UI_DisplayLock(); - bIsInLockScreen = false; + g_is_in_lock_screen = false; } #endif @@ -173,7 +173,7 @@ void Main(void) GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0); - gUpdateStatus = true; + g_update_status = true; #ifdef ENABLE_VOICE { @@ -206,16 +206,16 @@ void Main(void) { APP_Update(); - if (gNextTimeslice) + if (g_next_time_slice) { APP_TimeSlice10ms(); - gNextTimeslice = false; + g_next_time_slice = false; } - if (gNextTimeslice_500ms) + if (g_next_time_slice_500ms) { APP_TimeSlice500ms(); - gNextTimeslice_500ms = false; + g_next_time_slice_500ms = false; } } } diff --git a/misc.c b/misc.c index e3666ecf..42ee9135 100644 --- a/misc.c +++ b/misc.c @@ -19,252 +19,253 @@ #include "misc.h" #include "settings.h" -const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds -const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds -const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms -const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds -const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds - -const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds -const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes - -const uint8_t DTMF_RX_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen -const uint8_t DTMF_RX_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver -const uint8_t DTMF_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for -const uint8_t DTMF_txstop_countdown_500ms = 3000 / 500; // 6 seconds - -const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds -const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms -const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay' -const uint16_t key_debounce_10ms = 20 / 10; // 20ms - -const uint8_t scan_freq_css_delay_10ms = 210 / 10; // 210ms .. don't reduce this - -const uint16_t dual_watch_count_after_tx_10ms = 3600 / 10; // 3.6 sec after TX ends -const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec after RX ends ? -const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec -const uint16_t dual_watch_count_after_2_10ms = 3600 / 10; // 3.6 sec -const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms +// *********************************************** + +const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds +const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds +const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms +const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds +const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds + +const uint8_t menu_timeout_500ms = 30000 / 500; // 30 seconds +const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes + +const uint8_t dtmf_rx_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen +const uint8_t dtmf_rx_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver +const uint8_t dtmf_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for +const uint8_t dtmf_txstop_countdown_500ms = 3000 / 500; // 6 seconds + +const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds +const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms +const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay' +const uint16_t key_debounce_10ms = 20 / 10; // 20ms + +const uint8_t scan_freq_css_delay_10ms = 210 / 10; // 210ms .. don't reduce this + +const uint16_t dual_watch_count_after_tx_10ms = 3600 / 10; // 3.6 sec after TX ends +const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec after RX ends ? +const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec +const uint16_t dual_watch_count_after_2_10ms = 3600 / 10; // 3.6 sec +const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms #ifdef ENABLE_VOX - const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms + const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms #endif -const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles +const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles -const uint16_t scan_pause_delay_in_1_10ms = 5000 / 10; // 5 seconds -const uint16_t scan_pause_delay_in_2_10ms = 500 / 10; // 500ms -const uint16_t scan_pause_delay_in_3_10ms = 200 / 10; // 200ms -const uint16_t scan_pause_delay_in_4_10ms = 300 / 10; // 300ms -const uint16_t scan_pause_delay_in_5_10ms = 1000 / 10; // 1 sec -const uint16_t scan_pause_delay_in_6_10ms = 100 / 10; // 100ms -const uint16_t scan_pause_delay_in_7_10ms = 3600 / 10; // 3.6 seconds +const uint16_t scan_pause_delay_in_1_10ms = 5000 / 10; // 5 seconds +const uint16_t scan_pause_delay_in_2_10ms = 500 / 10; // 500ms +const uint16_t scan_pause_delay_in_3_10ms = 200 / 10; // 200ms +const uint16_t scan_pause_delay_in_4_10ms = 300 / 10; // 300ms +const uint16_t scan_pause_delay_in_5_10ms = 1000 / 10; // 1 sec +const uint16_t scan_pause_delay_in_6_10ms = 100 / 10; // 100ms +const uint16_t scan_pause_delay_in_7_10ms = 3600 / 10; // 3.6 seconds -const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds +const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds -const uint16_t power_save1_10ms = 100 / 10; // 100ms -const uint16_t power_save2_10ms = 200 / 10; // 200ms +const uint16_t power_save1_10ms = 100 / 10; // 100ms +const uint16_t power_save2_10ms = 200 / 10; // 200ms #ifdef ENABLE_VOX const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second #endif -const uint16_t NOAA_countdown_10ms = 5000 / 10; // 5 seconds -const uint16_t NOAA_countdown_2_10ms = 500 / 10; // 500ms -const uint16_t NOAA_countdown_3_10ms = 200 / 10; // 200ms +const uint16_t noaa_count_down_10ms = 5000 / 10; // 5 seconds +const uint16_t noaa_count_down_2_10ms = 500 / 10; // 500ms +const uint16_t noaa_count_down_3_10ms = 200 / 10; // 200ms -//const uint16_t gMax_bat_v = 840; // 8.4V -//const uint16_t gMin_bat_v = 660; // 6.6V +// *********************************************** -const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BBA7F92}; +const uint32_t g_default_aes_key[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BBA7F92}; -const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; +const uint8_t g_mic_gain_dB_2[5] = {3, 8, 16, 24, 31}; -bool gSetting_350TX; -bool gSetting_KILLED; -bool gSetting_200TX; -bool gSetting_500TX; -bool gSetting_350EN; -bool gSetting_TX_EN; -uint8_t gSetting_F_LOCK; -bool gSetting_ScrambleEnable; +bool g_setting_350_tx_enable; +bool g_setting_killed; +bool g_setting_200_tx_enable; +bool g_setting_500_tx_enable; +bool g_setting_350_enable; +bool g_Setting_tx_enable; +uint8_t g_setting_f_lock; +bool g_setting_scramble_enable; -uint8_t gSetting_backlight_on_tx_rx; +uint8_t g_setting_backlight_on_tx_rx; #ifdef ENABLE_AM_FIX - bool gSetting_AM_fix; + bool g_setting_am_fix; #endif #ifdef ENABLE_AM_FIX_TEST1 - uint8_t gSetting_AM_fix_test1 = 0; + uint8_t g_setting_am_fix_test1 = 0; #endif #ifdef ENABLE_AUDIO_BAR - bool gSetting_mic_bar; + bool g_setting_mic_bar; #endif -bool gSetting_live_DTMF_decoder; -uint8_t gSetting_battery_text; +bool g_setting_live_dtmf_decoder; +uint8_t g_setting_battery_text; -uint8_t gSetting_side1_short; -uint8_t gSetting_side1_long; -uint8_t gSetting_side2_short; -uint8_t gSetting_side2_long; +uint8_t g_setting_side1_short; +uint8_t g_setting_side1_long; +uint8_t g_setting_side2_short; +uint8_t g_setting_side2_long; -bool gMonitor = false; // true opens the squelch +bool g_monitor_enabled = false; // true opens the squelch -uint32_t gCustomAesKey[4]; -bool bHasCustomAesKey; -uint32_t gChallenge[4]; -uint8_t gTryCount; +uint32_t g_custom_aes_key[4]; +bool g_has_custom_aes_key; +uint32_t g_challenge[4]; +uint8_t g_try_count; -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]; +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 g_eeprom_RSSI_CALIB[2][4]; +uint16_t g_eeprom_rssi_calib[2][4]; -uint16_t g_eeprom_1F8A; -uint16_t g_eeprom_1F8C; +uint16_t g_eeprom_1F8A; +uint16_t g_eeprom_1F8C; -uint8_t gUSER_ChannelAttributes[FREQ_CHANNEL_LAST + 1]; +uint8_t g_user_channel_attributes[FREQ_CHANNEL_LAST + 1]; -volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms; +volatile uint16_t g_battery_save_count_down_10ms = battery_save_count_10ms; -volatile bool gPowerSaveCountdownExpired; -volatile bool gSchedulePowerSave; +volatile bool g_power_save_count_down_expired; +volatile bool g_schedule_power_save; -volatile bool gScheduleDualWatch = true; +volatile bool g_schedule_dual_watch = true; -volatile uint16_t gDualWatchCountdown_10ms; -volatile bool gDualWatchCountdownExpired = true; -bool gDualWatchActive = false; +volatile uint16_t g_dual_watch_count_down_10ms; +volatile bool g_dual_watch_count_down_expired = true; +bool g_dual_watch_active; -volatile uint8_t gSerialConfigCountDown_500ms; +volatile uint8_t g_serial_config_count_down_500ms; -volatile bool gNextTimeslice_500ms; +volatile bool g_next_time_slice_500ms; -volatile uint16_t gTxTimerCountdown_500ms; -volatile bool gTxTimeoutReached; +volatile uint16_t g_tx_timer_count_down_500ms; +volatile bool g_tx_timeout_reached; -volatile uint16_t gTailNoteEliminationCountdown_10ms; +volatile uint16_t g_tail_tone_elimination_count_down_10ms; #ifdef ENABLE_NOAA - volatile uint16_t gNOAA_Countdown_10ms; + volatile uint16_t g_noaa_count_down_10ms; #endif -bool gEnableSpeaker; -uint8_t gKeyInputCountdown = 0; -uint8_t gKeyLockCountdown; -uint8_t gRTTECountdown; -bool bIsInLockScreen; -uint8_t gUpdateStatus; -uint8_t gFoundCTCSS; -uint8_t gFoundCDCSS; -bool gEndOfRxDetectedMaybe; - -int16_t gVFO_RSSI[2]; -uint8_t gVFO_RSSI_bar_level[2]; - -uint8_t gReducedService; -uint8_t gBatteryVoltageIndex; -CssScanMode_t gCssScanMode; -bool gUpdateRSSI; +bool g_enable_speaker; +uint8_t g_key_input_count_down = 0; +uint8_t g_key_lock_count_down; +uint8_t g_rtte_count_down; +bool g_is_in_lock_screen; +uint8_t g_update_status; +uint8_t g_found_CTCSS; +uint8_t g_found_CDCSS; +bool g_end_of_rx_detected_maybe; + +int16_t g_vfo_rssi[2]; +uint8_t g_vfo_rssi_bar_level[2]; + +uint8_t g_reduced_service; +uint8_t g_battery_voltage_index; +css_scan_mode_t g_css_scan_mode; +bool g_update_rssi; #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - AlarmState_t gAlarmState; + alarm_state_t g_alarm_state; #endif -uint16_t gMenuCountdown; -bool gPttWasReleased; -bool gPttWasPressed; -uint8_t gKeypadLocked; -bool gFlagReconfigureVfos; -uint8_t gVfoConfigureMode; -bool gFlagResetVfos; -bool gRequestSaveVFO; -uint8_t gRequestSaveChannel; -bool gRequestSaveSettings; +uint16_t g_menu_count_down; +bool g_ptt_was_released; +bool g_ptt_was_pressed; +uint8_t g_keypad_locked; +bool g_flag_reconfigure_vfos; +uint8_t g_vfo_configure_mode; +bool g_flag_reset_vfos; +bool g_request_save_vfo; +uint8_t g_request_save_channel; +bool g_request_save_settings; #ifdef ENABLE_FMRADIO - bool gRequestSaveFM; + bool g_request_save_fm; #endif -bool gFlagPrepareTX; +bool g_flag_prepare_tx; -bool gFlagAcceptSetting; -bool gFlagRefreshSetting; +bool g_flag_AcceptSetting; +bool g_flag_refresh_menu; -bool gFlagSaveVfo; -bool gFlagSaveSettings; -bool gFlagSaveChannel; +bool g_flag_SaveVfo; +bool g_flag_SaveSettings; +bool g_flag_SaveChannel; #ifdef ENABLE_FMRADIO - bool gFlagSaveFM; + bool g_flag_SaveFM; #endif -bool g_CDCSS_lost; -uint8_t g_CDCSS_code_type; -bool g_CTCSS_lost; -bool g_CxCSS_tailL_found; +bool g_CDCSS_lost; +uint8_t g_CDCSS_code_type; +bool g_CTCSS_lost; +bool g_CxCSS_tail_found; #ifdef ENABLE_VOX - bool g_vox_lost; - bool gVOX_NoiseDetected; - uint16_t gVoxResumeCountdown; - uint16_t g_vox_pause_count_down; + bool g_vox_lost; + bool g_vox_noise_detected; + uint16_t g_vox_resume_count_down; + 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 gNextChannel; -ReceptionMode_t gRxReceptionMode; - -uint8_t gRestoreUSER_CHANNEL; -enum scan_next_chan_t gCurrentScanList; -uint32_t gRestoreFrequency; - -bool gRxVfoIsActive; +bool g_squelch_lost; +uint8_t g_flash_light_state; +volatile uint16_t g_flash_light_bBlink_counter; +bool g_flag_end_tx; +uint16_t g_low_batteryCountdown; +uint8_t g_next_channel; +reception_mode_t g_rx_reception_mode; + +uint8_t g_restore_channel; +scan_next_chan_t g_current_scan_list; +uint32_t g_restore_frequency; + +bool g_rx_vfo_is_active; #ifdef ENABLE_ALARM - uint8_t gAlarmToneCounter; - uint16_t gAlarmRunningCounter; + uint8_t g_alarm_tone_counter; + uint16_t g_alarm_running_counter; #endif -bool gKeyBeingHeld; -bool gPttIsPressed; -uint8_t gPttDebounceCounter; -uint8_t gMenuListCount; -uint8_t gBackup_cross_vfo_rx_tx; -uint8_t gScanDelay_10ms; +bool g_key_being_held; +bool g_ptt_is_pressed; +uint8_t g_ptt_debounce_counter; +uint8_t g_menu_list_count; +uint8_t g_backup_cross_vfo_rx_tx; +uint8_t g_scan_delay_10ms; #ifdef ENABLE_AIRCOPY - uint8_t gAircopySendCountdown; + uint8_t g_air_copy_send_count_down; #endif -uint8_t gFSKWriteIndex; +uint8_t g_fsk_wite_index; #ifdef ENABLE_NOAA - bool gIsNoaaMode; - uint8_t gNoaaChannel; + bool g_is_noaa_mode; + uint8_t g_noaa_channel; #endif -bool gUpdateDisplay; +bool g_update_display; -bool gF_LOCK = false; +bool g_f_lock = false; -uint8_t gShowChPrefix; +uint8_t g_show_chan_prefix; -volatile bool gNextTimeslice; -volatile uint8_t gFoundCDCSSCountdown_10ms; -volatile uint8_t gFoundCTCSSCountdown_10ms; +volatile bool g_next_time_slice; +volatile uint8_t g_found_CDCSS_count_down_10ms; +volatile uint8_t g_found_CTCSS_count_down_10ms; #ifdef ENABLE_VOX - volatile uint16_t gVoxStopCountdown_10ms; + volatile uint16_t g_vox_stop_count_down_10ms; #endif -volatile bool gNextTimeslice40ms; +volatile bool g_next_time_slice_40ms; #ifdef ENABLE_NOAA - volatile uint16_t gNOAACountdown_10ms = 0; - volatile bool gScheduleNOAA = true; + volatile uint16_t g_noaa_count_down_10ms = 0; + volatile bool g_schedule_noaa = true; #endif -volatile bool gFlagTailNoteEliminationComplete; +volatile bool g_flag_tail_tone_elimination_complete; #ifdef ENABLE_FMRADIO - volatile bool gScheduleFM; + volatile bool g_schedule_fm; #endif -volatile uint8_t boot_counter_10ms; +volatile uint8_t g_boot_counter_10ms; -int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO +int16_t g_current_rssi[2] = {0, 0}; // now one per VFO -uint8_t gIsLocked = 0xFF; +uint8_t g_is_locked = 0xFF; -unsigned int get_rx_VFO(void) +unsigned int get_RX_VFO(void) { unsigned int rx_vfo = g_eeprom.tx_vfo; if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B) @@ -281,7 +282,7 @@ unsigned int get_rx_VFO(void) return rx_vfo; } -unsigned int get_tx_VFO(void) +unsigned int get_TX_VFO(void) { unsigned int tx_vfo = g_eeprom.tx_vfo; if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_B) diff --git a/misc.h b/misc.h index 3667ba02..69de811b 100644 --- a/misc.h +++ b/misc.h @@ -25,14 +25,14 @@ #endif #ifndef MAX - #define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; }) + #define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; }) #endif #ifndef MIN - #define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) + #define MIN(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; }) #endif -#define IS_USER_CHANNEL(x) ((x) >= USER_CHANNEL_FIRST && (x) <= USER_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) @@ -40,8 +40,8 @@ #define IS_NOT_NOAA_CHANNEL(x) ((x) >= USER_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) enum { - USER_CHANNEL_FIRST = 0, - USER_CHANNEL_LAST = 199u, + USER_CHANNEL_FIRST = 0, + USER_CHANNEL_LAST = 199u, FREQ_CHANNEL_FIRST = 200u, FREQ_CHANNEL_LAST = 206u, NOAA_CHANNEL_FIRST = 207u, @@ -61,37 +61,37 @@ enum { VFO_CONFIGURE_RELOAD }; -enum AlarmState_t { +enum alarm_state_e { ALARM_STATE_OFF = 0, ALARM_STATE_TXALARM, ALARM_STATE_ALARM, ALARM_STATE_TX1750 }; -typedef enum AlarmState_t AlarmState_t; +typedef enum alarm_state_e alarm_state_t; -enum ReceptionMode_t { +enum reception_mode_e { RX_MODE_NONE = 0, // squelch close ? RX_MODE_DETECTED, // signal detected RX_MODE_LISTENING // }; -typedef enum ReceptionMode_t ReceptionMode_t; +typedef enum reception_mode_e reception_mode_t; -enum CssScanMode_t +enum css_scan_mode_e { CSS_SCAN_MODE_OFF = 0, CSS_SCAN_MODE_SCANNING, CSS_SCAN_MODE_FOUND, }; -typedef enum CssScanMode_t CssScanMode_t; +typedef enum css_scan_mode_e css_scan_mode_t; -enum scan_next_chan_t { +enum scan_next_chan_e { SCAN_NEXT_CHAN_SCANLIST1 = 0, SCAN_NEXT_CHAN_SCANLIST2, - SCAN_NEXT_CHAN_dual_watch, + SCAN_NEXT_CHAN_DUAL_WATCH, SCAN_NEXT_CHAN_USER, SCAN_NEXT_NUM }; -typedef enum scan_next_chan_t scan_next_chan_t; +typedef enum scan_next_chan_e scan_next_chan_t; extern const uint8_t fm_resume_countdown_500ms; extern const uint8_t fm_radio_countdown_500ms; @@ -102,10 +102,10 @@ extern const uint16_t fm_restore_countdown_10ms; extern const uint8_t menu_timeout_500ms; extern const uint16_t menu_timeout_long_500ms; -extern const uint8_t DTMF_RX_live_timeout_500ms; -extern const uint8_t DTMF_RX_timeout_500ms; -extern const uint8_t DTMF_decode_ring_countdown_500ms; -extern const uint8_t DTMF_txstop_countdown_500ms; +extern const uint8_t dtmf_rx_live_timeout_500ms; +extern const uint8_t dtmf_rx_timeout_500ms; +extern const uint8_t dtmf_decode_ring_countdown_500ms; +extern const uint8_t dtmf_txstop_countdown_500ms; extern const uint8_t key_input_timeout_500ms; @@ -124,9 +124,9 @@ extern const uint16_t power_save2_10ms; extern const uint16_t vox_stop_count_down_10ms; #endif -extern const uint16_t NOAA_countdown_10ms; -extern const uint16_t NOAA_countdown_2_10ms; -extern const uint16_t NOAA_countdown_3_10ms; +extern const uint16_t noaa_count_down_10ms; +extern const uint16_t noaa_count_down_2_10ms; +extern const uint16_t noaa_count_down_3_10ms; extern const uint16_t dual_watch_count_after_tx_10ms; extern const uint16_t dual_watch_count_after_rx_10ms; @@ -146,197 +146,193 @@ extern const uint16_t scan_pause_delay_in_5_10ms; extern const uint16_t scan_pause_delay_in_6_10ms; extern const uint16_t scan_pause_delay_in_7_10ms; -//extern const uint16_t gMax_bat_v; -//extern const uint16_t gMin_bat_v; +extern const uint8_t g_mic_gain_dB_2[5]; -extern const uint8_t gMicGain_dB2[5]; +extern bool g_setting_350_tx_enable; +extern bool g_setting_killed; +extern bool g_setting_200_tx_enable; +extern bool g_setting_500_tx_enable; +extern bool g_setting_350_enable; +extern bool g_Setting_tx_enable; +extern uint8_t g_setting_f_lock; +extern bool g_setting_scramble_enable; -extern bool gSetting_350TX; -extern bool gSetting_KILLED; -extern bool gSetting_200TX; -extern bool gSetting_500TX; -extern bool gSetting_350EN; -extern bool gSetting_TX_EN; -extern uint8_t gSetting_F_LOCK; -extern bool gSetting_ScrambleEnable; - -extern uint8_t gSetting_backlight_on_tx_rx; +extern uint8_t g_setting_backlight_on_tx_rx; #ifdef ENABLE_AM_FIX - extern bool gSetting_AM_fix; + extern bool g_setting_am_fix; #endif #ifdef ENABLE_AM_FIX_TEST1 - extern uint8_t gSetting_AM_fix_test1; + extern uint8_t g_setting_am_fix_test1; #endif #ifdef ENABLE_AUDIO_BAR - extern bool gSetting_mic_bar; + extern bool g_setting_mic_bar; #endif -extern bool gSetting_live_DTMF_decoder; -extern uint8_t gSetting_battery_text; +extern bool g_setting_live_dtmf_decoder; +extern uint8_t g_setting_battery_text; -extern uint8_t gSetting_side1_short; -extern uint8_t gSetting_side1_long; -extern uint8_t gSetting_side2_short; -extern uint8_t gSetting_side2_long; +extern uint8_t g_setting_side1_short; +extern uint8_t g_setting_side1_long; +extern uint8_t g_setting_side2_short; +extern uint8_t g_setting_side2_long; -extern bool gMonitor; +extern bool g_monitor_enabled; -extern const uint32_t gDefaultAesKey[4]; -extern uint32_t gCustomAesKey[4]; -extern bool bHasCustomAesKey; -extern uint32_t gChallenge[4]; -extern uint8_t gTryCount; +extern const uint32_t g_default_aes_key[4]; +extern uint32_t g_custom_aes_key[4]; +extern bool g_has_custom_aes_key; +extern uint32_t g_challenge[4]; +extern uint8_t g_try_count; 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 g_eeprom_RSSI_CALIB[2][4]; +extern uint16_t g_eeprom_rssi_calib[2][4]; extern uint16_t g_eeprom_1F8A; extern uint16_t g_eeprom_1F8C; -extern uint8_t gUSER_ChannelAttributes[207]; +extern uint8_t g_user_channel_attributes[207]; -extern volatile uint16_t gBatterySaveCountdown_10ms; +extern volatile uint16_t g_battery_save_count_down_10ms; -extern volatile bool gPowerSaveCountdownExpired; -extern volatile bool gSchedulePowerSave; +extern volatile bool g_power_save_count_down_expired; +extern volatile bool g_schedule_power_save; -extern volatile bool gScheduleDualWatch; +extern volatile bool g_schedule_dual_watch; -extern volatile uint16_t gDualWatchCountdown_10ms; -extern volatile bool gDualWatchCountdownExpired; -extern bool gDualWatchActive; +extern volatile uint16_t g_dual_watch_count_down_10ms; +extern volatile bool g_dual_watch_count_down_expired; +extern bool g_dual_watch_active; -extern volatile uint8_t gSerialConfigCountDown_500ms; +extern volatile uint8_t g_serial_config_count_down_500ms; -extern volatile bool gNextTimeslice_500ms; +extern volatile bool g_next_time_slice_500ms; -extern volatile uint16_t gTxTimerCountdown_500ms; -extern volatile bool gTxTimeoutReached; +extern volatile uint16_t g_tx_timer_count_down_500ms; +extern volatile bool g_tx_timeout_reached; -extern volatile uint16_t gTailNoteEliminationCountdown_10ms; +extern volatile uint16_t g_tail_tone_elimination_count_down_10ms; #ifdef ENABLE_FMRADIO - extern volatile uint16_t gFmPlayCountdown_10ms; + extern volatile uint16_t g_fm_play_count_down_10ms; #endif #ifdef ENABLE_NOAA - extern volatile uint16_t gNOAA_Countdown_10ms; + extern volatile uint16_t g_noaa_count_down_10ms; #endif -extern bool gEnableSpeaker; -extern uint8_t gKeyInputCountdown; -extern uint8_t gKeyLockCountdown; -extern uint8_t gRTTECountdown; -extern bool bIsInLockScreen; -extern uint8_t gUpdateStatus; -extern uint8_t gFoundCTCSS; -extern uint8_t gFoundCDCSS; -extern bool gEndOfRxDetectedMaybe; - -extern int16_t gVFO_RSSI[2]; -extern uint8_t gVFO_RSSI_bar_level[2]; - -extern uint8_t gReducedService; -extern uint8_t gBatteryVoltageIndex; -extern CssScanMode_t gCssScanMode; -extern bool gUpdateRSSI; -extern AlarmState_t gAlarmState; -extern uint16_t gMenuCountdown; -extern bool gPttWasReleased; -extern bool gPttWasPressed; -extern bool gFlagReconfigureVfos; -extern uint8_t gVfoConfigureMode; -extern bool gFlagResetVfos; -extern bool gRequestSaveVFO; -extern uint8_t gRequestSaveChannel; -extern bool gRequestSaveSettings; +extern bool g_enable_speaker; +extern uint8_t g_key_input_count_down; +extern uint8_t g_key_lock_count_down; +extern uint8_t g_rtte_count_down; +extern bool g_is_in_lock_screen; +extern uint8_t g_update_status; +extern uint8_t g_found_CTCSS; +extern uint8_t g_found_CDCSS; +extern bool g_end_of_rx_detected_maybe; + +extern int16_t g_vfo_rssi[2]; +extern uint8_t g_vfo_rssi_bar_level[2]; + +extern uint8_t g_reduced_service; +extern uint8_t g_battery_voltage_index; +extern css_scan_mode_t g_css_scan_mode; +extern bool g_update_rssi; +extern alarm_state_t g_alarm_state; +extern uint16_t g_menu_count_down; +extern bool g_ptt_was_released; +extern bool g_ptt_was_pressed; +extern bool g_flag_reconfigure_vfos; +extern uint8_t g_vfo_configure_mode; +extern bool g_flag_reset_vfos; +extern bool g_request_save_vfo; +extern uint8_t g_request_save_channel; +extern bool g_request_save_settings; #ifdef ENABLE_FMRADIO - extern bool gRequestSaveFM; + extern bool g_request_save_fm; #endif -extern uint8_t gKeypadLocked; -extern bool gFlagPrepareTX; +extern uint8_t g_keypad_locked; +extern bool g_flag_prepare_tx; -extern bool gFlagAcceptSetting; // accept menu setting -extern bool gFlagRefreshSetting; // refresh menu display +extern bool g_flag_AcceptSetting; // accept menu setting +extern bool g_flag_refresh_menu; // refresh menu display -extern bool gFlagSaveVfo; -extern bool gFlagSaveSettings; -extern bool gFlagSaveChannel; +extern bool g_flag_SaveVfo; +extern bool g_flag_SaveSettings; +extern bool g_flag_SaveChannel; #ifdef ENABLE_FMRADIO - extern bool gFlagSaveFM; + extern bool g_flag_SaveFM; #endif extern bool g_CDCSS_lost; extern uint8_t g_CDCSS_code_type; extern bool g_CTCSS_lost; -extern bool g_CxCSS_tailL_found; +extern bool g_CxCSS_tail_found; #ifdef ENABLE_VOX extern bool g_vox_lost; - extern bool gVOX_NoiseDetected; - extern uint16_t gVoxResumeCountdown; + extern bool g_vox_noise_detected; + extern uint16_t g_vox_resume_count_down; 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 gNextChannel; -extern ReceptionMode_t gRxReceptionMode; - -extern uint8_t gRestoreUSER_CHANNEL; -extern scan_next_chan_t gCurrentScanList; -extern uint32_t gRestoreFrequency; - -extern bool gRxVfoIsActive; -extern uint8_t gAlarmToneCounter; -extern uint16_t gAlarmRunningCounter; -extern bool gKeyBeingHeld; -extern bool gPttIsPressed; -extern uint8_t gPttDebounceCounter; -extern uint8_t gMenuListCount; -extern uint8_t gBackup_cross_vfo_rx_tx; -extern uint8_t gScanDelay_10ms; +extern bool g_squelch_lost; +extern uint8_t g_flash_light_state; +extern volatile uint16_t g_flash_light_bBlink_counter; +extern bool g_flag_end_tx; +extern uint16_t g_low_batteryCountdown; +extern uint8_t g_next_channel; +extern reception_mode_t g_rx_reception_mode; + +extern uint8_t g_restore_channel; +extern scan_next_chan_t g_current_scan_list; +extern uint32_t g_restore_frequency; + +extern bool g_rx_vfo_is_active; +extern uint8_t g_alarm_tone_counter; +extern uint16_t g_alarm_running_counter; +extern bool g_key_being_held; +extern bool g_ptt_is_pressed; +extern uint8_t g_ptt_debounce_counter; +extern uint8_t g_menu_list_count; +extern uint8_t g_backup_cross_vfo_rx_tx; +extern uint8_t g_scan_delay_10ms; #ifdef ENABLE_AIRCOPY - extern uint8_t gAircopySendCountdown; + extern uint8_t g_air_copy_send_count_down; #endif -extern uint8_t gFSKWriteIndex; +extern uint8_t g_fsk_wite_index; #ifdef ENABLE_NOAA - extern bool gIsNoaaMode; - extern uint8_t gNoaaChannel; + extern bool g_is_noaa_mode; + extern uint8_t g_noaa_channel; #endif -extern volatile bool gNextTimeslice; -extern bool gUpdateDisplay; -extern bool gF_LOCK; +extern volatile bool g_next_time_slice; +extern bool g_update_display; +extern bool g_f_lock; #ifdef ENABLE_FMRADIO - extern uint8_t gFM_ChannelPosition; + extern uint8_t g_fm_channel_position; #endif -extern uint8_t gShowChPrefix; -extern volatile uint8_t gFoundCDCSSCountdown_10ms; -extern volatile uint8_t gFoundCTCSSCountdown_10ms; +extern uint8_t g_show_chan_prefix; +extern volatile uint8_t g_found_CDCSS_count_down_10ms; +extern volatile uint8_t g_found_CTCSS_count_down_10ms; #ifdef ENABLE_VOX - extern volatile uint16_t gVoxStopCountdown_10ms; + extern volatile uint16_t g_vox_stop_count_down_10ms; #endif -extern volatile bool gNextTimeslice40ms; +extern volatile bool g_next_time_slice_40ms; #ifdef ENABLE_NOAA - extern volatile uint16_t gNOAACountdown_10ms; - extern volatile bool gScheduleNOAA; + extern volatile uint16_t g_noaa_count_down_10ms; + extern volatile bool g_schedule_noaa; #endif -extern volatile bool gFlagTailNoteEliminationComplete; +extern volatile bool g_flag_tail_tone_elimination_complete; #ifdef ENABLE_FMRADIO - extern volatile bool gScheduleFM; + extern volatile bool g_schedule_fm; #endif -extern int16_t gCurrentRSSI[2]; // now one per VFO -extern uint8_t gIsLocked; -extern volatile uint8_t boot_counter_10ms; - -unsigned int get_tx_VFO(void); -unsigned int get_rx_VFO(void); - -void NUMBER_Get(char *pDigits, uint32_t *pInteger); -void NUMBER_ToDigits(uint32_t Value, char *pDigits); -int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); +extern int16_t g_current_rssi[2]; // now one per VFO +extern uint8_t g_is_locked; +extern volatile uint8_t g_boot_counter_10ms; + +unsigned int get_TX_VFO(void); +unsigned int get_RX_VFO(void); +void NUMBER_Get(char *pDigits, uint32_t *pInteger); +void NUMBER_ToDigits(uint32_t Value, char *pDigits); +int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); #endif diff --git a/radio.c b/radio.c index c2169daf..f2931fe9 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_code_type_t gSelectedcode_type; -dcs_code_type_t gCurrentcode_type; -uint8_t gSelectedCode; -step_setting_t gStepSetting; -VfoState_t VfoState[2]; +vfo_info_t *g_tx_vfo; +vfo_info_t *g_rx_vfo; +vfo_info_t *g_current_vfo; +dcs_code_type_t g_selected_code_type; +dcs_code_type_t g_current_code_type; +uint8_t g_selected_code; +step_setting_t g_step_setting; +vfo_state_t g_vfo_state[2]; bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) { // return true if the channel appears valid @@ -54,7 +54,7 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) if (Channel > USER_CHANNEL_LAST) return false; - Attributes = gUSER_ChannelAttributes[Channel]; + Attributes = g_user_channel_attributes[Channel]; if ((Attributes & USER_CH_BAND_MASK) > BAND7_470MHz) return false; @@ -114,7 +114,7 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan return 0xFF; } -void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency) +void RADIO_InitInfo(vfo_info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency) { memset(pInfo, 0, sizeof(*pInfo)); @@ -122,7 +122,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t pInfo->scanlist_1_participation = true; pInfo->scanlist_2_participation = true; pInfo->step_setting = STEP_12_5kHz; - pInfo->step_freq = StepFrequencyTable[pInfo->step_setting]; + pInfo->step_freq = STEP_FREQ_TABLE[pInfo->step_setting]; pInfo->channel_save = ChannelSave; pInfo->frequency_reverse = false; pInfo->output_power = OUTPUT_POWER_LOW; @@ -146,9 +146,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure bool bParticipation2; uint16_t Base; uint32_t Frequency; - VFO_Info_t *pRadio = &g_eeprom.VfoInfo[VFO]; + vfo_info_t *pRadio = &g_eeprom.vfo_info[VFO]; - if (!gSetting_350EN) + if (!g_setting_350_enable) { if (g_eeprom.freq_channel[VFO] == (FREQ_CHANNEL_LAST - 2)) g_eeprom.freq_channel[VFO] = FREQ_CHANNEL_LAST - 1; @@ -171,7 +171,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; - gUpdateStatus = true; + g_update_status = true; return; } #endif @@ -181,20 +181,20 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Channel = RADIO_FindNextChannel(Channel, RADIO_CHANNEL_UP, false, VFO); if (Channel == 0xFF) { - Channel = g_eeprom.freq_channel[VFO]; + Channel = g_eeprom.freq_channel[VFO]; g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO]; } else { g_eeprom.screen_channel[VFO] = Channel; - g_eeprom.user_channel[VFO] = Channel; + g_eeprom.user_channel[VFO] = Channel; } } } else Channel = FREQ_CHANNEL_LAST - 1; - Attributes = gUSER_ChannelAttributes[Channel]; + Attributes = g_user_channel_attributes[Channel]; if (Attributes == 0xFF) { // invalid/unused channel @@ -202,13 +202,13 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (Channel <= USER_CHANNEL_LAST) { - Channel = g_eeprom.freq_channel[VFO]; + Channel = g_eeprom.freq_channel[VFO]; g_eeprom.screen_channel[VFO] = g_eeprom.freq_channel[VFO]; } Index = Channel - FREQ_CHANNEL_FIRST; - RADIO_InitInfo(pRadio, Channel, frequencyBandTable[Index].lower); + RADIO_InitInfo(pRadio, Channel, FREQ_BAND_TABLE[Index].lower); return; } @@ -220,20 +220,20 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (Channel <= USER_CHANNEL_LAST) { - g_eeprom.VfoInfo[VFO].band = Band; - g_eeprom.VfoInfo[VFO].scanlist_1_participation = !!(Attributes & USER_CH_SCANLIST1); - bParticipation2 = !!(Attributes & USER_CH_SCANLIST2); + g_eeprom.vfo_info[VFO].band = Band; + g_eeprom.vfo_info[VFO].scanlist_1_participation = (Attributes & USER_CH_SCANLIST1) ? true : false; + bParticipation2 = (Attributes & USER_CH_SCANLIST2) ? true : false; } else { - Band = Channel - FREQ_CHANNEL_FIRST; - g_eeprom.VfoInfo[VFO].band = Band; - bParticipation2 = true; - g_eeprom.VfoInfo[VFO].scanlist_1_participation = true; + Band = Channel - FREQ_CHANNEL_FIRST; + g_eeprom.vfo_info[VFO].band = Band; + bParticipation2 = true; + g_eeprom.vfo_info[VFO].scanlist_1_participation = true; } - g_eeprom.VfoInfo[VFO].scanlist_2_participation = bParticipation2; - g_eeprom.VfoInfo[VFO].channel_save = Channel; + g_eeprom.vfo_info[VFO].scanlist_2_participation = bParticipation2; + g_eeprom.vfo_info[VFO].channel_save = Channel; if (Channel <= USER_CHANNEL_LAST) Base = Channel * 16; @@ -252,92 +252,92 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Tmp = Data[3] & 0x0F; if (Tmp > TX_OFFSET_FREQ_DIR_SUB) Tmp = 0; - g_eeprom.VfoInfo[VFO].tx_offset_freq_dir = Tmp; - g_eeprom.VfoInfo[VFO].am_mode = (Data[3] >> 4) & 1u; + g_eeprom.vfo_info[VFO].tx_offset_freq_dir = Tmp; + g_eeprom.vfo_info[VFO].am_mode = (Data[3] >> 4) & 1u; Tmp = Data[6]; - if (Tmp >= ARRAY_SIZE(StepFrequencyTable)) + if (Tmp >= ARRAY_SIZE(STEP_FREQ_TABLE)) Tmp = STEP_12_5kHz; - g_eeprom.VfoInfo[VFO].step_setting = Tmp; - g_eeprom.VfoInfo[VFO].step_freq = StepFrequencyTable[Tmp]; + g_eeprom.vfo_info[VFO].step_setting = Tmp; + g_eeprom.vfo_info[VFO].step_freq = STEP_FREQ_TABLE[Tmp]; Tmp = Data[7]; - if (Tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1)) + if (Tmp > (ARRAY_SIZE(g_sub_menu_SCRAMBLER) - 1)) Tmp = 0; - g_eeprom.VfoInfo[VFO].scrambling_type = Tmp; + g_eeprom.vfo_info[VFO].scrambling_type = Tmp; - 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; + g_eeprom.vfo_info[VFO].freq_config_rx.code_type = (Data[2] >> 0) & 0x0F; + g_eeprom.vfo_info[VFO].freq_config_tx.code_type = (Data[2] >> 4) & 0x0F; Tmp = Data[0]; - switch (g_eeprom.VfoInfo[VFO].freq_config_rx.code_type) + switch (g_eeprom.vfo_info[VFO].freq_config_rx.code_type) { default: case CODE_TYPE_OFF: - g_eeprom.VfoInfo[VFO].freq_config_rx.code_type = CODE_TYPE_OFF; + g_eeprom.vfo_info[VFO].freq_config_rx.code_type = CODE_TYPE_OFF; Tmp = 0; break; case CODE_TYPE_CONTINUOUS_TONE: - if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1)) + if (Tmp > (ARRAY_SIZE(CTCSS_OPTIONS) - 1)) Tmp = 0; break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (Tmp > (ARRAY_SIZE(DCS_Options) - 1)) + if (Tmp > (ARRAY_SIZE(DCS_OPTIONS) - 1)) Tmp = 0; break; } - g_eeprom.VfoInfo[VFO].freq_config_rx.code = Tmp; + g_eeprom.vfo_info[VFO].freq_config_rx.code = Tmp; Tmp = Data[1]; - switch (g_eeprom.VfoInfo[VFO].freq_config_tx.code_type) + switch (g_eeprom.vfo_info[VFO].freq_config_tx.code_type) { default: case CODE_TYPE_OFF: - g_eeprom.VfoInfo[VFO].freq_config_tx.code_type = CODE_TYPE_OFF; + g_eeprom.vfo_info[VFO].freq_config_tx.code_type = CODE_TYPE_OFF; Tmp = 0; break; case CODE_TYPE_CONTINUOUS_TONE: - if (Tmp > (ARRAY_SIZE(CTCSS_Options) - 1)) + if (Tmp > (ARRAY_SIZE(CTCSS_OPTIONS) - 1)) Tmp = 0; break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (Tmp > (ARRAY_SIZE(DCS_Options) - 1)) + if (Tmp > (ARRAY_SIZE(DCS_OPTIONS) - 1)) Tmp = 0; break; } - g_eeprom.VfoInfo[VFO].freq_config_tx.code = Tmp; + g_eeprom.vfo_info[VFO].freq_config_tx.code = Tmp; if (Data[4] == 0xFF) { - 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; + g_eeprom.vfo_info[VFO].frequency_reverse = false; + g_eeprom.vfo_info[VFO].channel_bandwidth = BK4819_FILTER_BW_WIDE; + g_eeprom.vfo_info[VFO].output_power = OUTPUT_POWER_LOW; + g_eeprom.vfo_info[VFO].busy_channel_lock = false; } else { const uint8_t d4 = Data[4]; - 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); + g_eeprom.vfo_info[VFO].frequency_reverse = ((d4 >> 0) & 1u) ? true : false; + g_eeprom.vfo_info[VFO].channel_bandwidth = ((d4 >> 1) & 1u) ? true : false; + g_eeprom.vfo_info[VFO].output_power = ((d4 >> 2) & 3u) ? true : false; + g_eeprom.vfo_info[VFO].busy_channel_lock = ((d4 >> 4) & 1u) ? true : false; } if (Data[5] == 0xFF) { - g_eeprom.VfoInfo[VFO].DTMF_decoding_enable = false; - g_eeprom.VfoInfo[VFO].DTMF_ptt_id_tx_mode = PTT_ID_OFF; + g_eeprom.vfo_info[VFO].dtmf_decoding_enable = false; + g_eeprom.vfo_info[VFO].dtmf_ptt_id_tx_mode = PTT_ID_OFF; } else { - 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); + g_eeprom.vfo_info[VFO].dtmf_decoding_enable = ((Data[5] >> 0) & 1u) ? true : false; + g_eeprom.vfo_info[VFO].dtmf_ptt_id_tx_mode = ((Data[5] >> 1) & 7u); } // *************** @@ -354,7 +354,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (info.offset >= 100000000) info.offset = 1000000; - g_eeprom.VfoInfo[VFO].tx_offset_freq = info.offset; + g_eeprom.vfo_info[VFO].tx_offset_freq = info.offset; // *************** } @@ -366,64 +366,64 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure Band = FREQUENCY_GetBand(Frequency); #endif - if (Frequency < frequencyBandTable[Band].lower) - Frequency = frequencyBandTable[Band].lower; + if (Frequency < FREQ_BAND_TABLE[Band].lower) + Frequency = FREQ_BAND_TABLE[Band].lower; else - if (Frequency > frequencyBandTable[Band].upper) - Frequency = frequencyBandTable[Band].upper; + if (Frequency > FREQ_BAND_TABLE[Band].upper) + Frequency = FREQ_BAND_TABLE[Band].upper; else if (Channel >= FREQ_CHANNEL_FIRST) - Frequency = FREQUENCY_FloorToStep(Frequency, g_eeprom.VfoInfo[VFO].step_freq, frequencyBandTable[Band].lower); + Frequency = FREQUENCY_FloorToStep(Frequency, g_eeprom.vfo_info[VFO].step_freq, FREQ_BAND_TABLE[Band].lower); pRadio->freq_config_rx.frequency = Frequency; if (Frequency >= 10800000 && Frequency < 13600000) - g_eeprom.VfoInfo[VFO].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; + g_eeprom.vfo_info[VFO].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; else 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); + g_eeprom.vfo_info[VFO].tx_offset_freq = FREQUENCY_FloorToStep(g_eeprom.vfo_info[VFO].tx_offset_freq, g_eeprom.vfo_info[VFO].step_freq, 0); RADIO_ApplyOffset(pRadio); - memset(g_eeprom.VfoInfo[VFO].name, 0, sizeof(g_eeprom.VfoInfo[VFO].name)); + memset(g_eeprom.vfo_info[VFO].name, 0, sizeof(g_eeprom.vfo_info[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), g_eeprom.VfoInfo[VFO].name + 0, 8); - EEPROM_ReadBuffer(0x0F58 + (Channel * 16), g_eeprom.VfoInfo[VFO].name + 8, 2); + EEPROM_ReadBuffer(0x0F50 + (Channel * 16), g_eeprom.vfo_info[VFO].name + 0, 8); + EEPROM_ReadBuffer(0x0F58 + (Channel * 16), g_eeprom.vfo_info[VFO].name + 8, 2); } - if (!g_eeprom.VfoInfo[VFO].frequency_reverse) + if (!g_eeprom.vfo_info[VFO].frequency_reverse) { - g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_rx; - g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_tx; + g_eeprom.vfo_info[VFO].pRX = &g_eeprom.vfo_info[VFO].freq_config_rx; + g_eeprom.vfo_info[VFO].pTX = &g_eeprom.vfo_info[VFO].freq_config_tx; } else { - g_eeprom.VfoInfo[VFO].pRX = &g_eeprom.VfoInfo[VFO].freq_config_tx; - g_eeprom.VfoInfo[VFO].pTX = &g_eeprom.VfoInfo[VFO].freq_config_rx; + g_eeprom.vfo_info[VFO].pRX = &g_eeprom.vfo_info[VFO].freq_config_tx; + g_eeprom.vfo_info[VFO].pTX = &g_eeprom.vfo_info[VFO].freq_config_rx; } - if (!gSetting_350EN) + if (!g_setting_350_enable) { - FREQ_Config_t *pConfig = g_eeprom.VfoInfo[VFO].pRX; - if (pConfig->frequency >= 35000000 && pConfig->frequency < 40000000) - pConfig->frequency = 43300000; + freq_config_t *pConfig = g_eeprom.vfo_info[VFO].pRX; + if (pConfig->frequency >= 35000000 && pConfig->frequency < 40000000) // not allowed in this range + pConfig->frequency = 43300000; // hop onto the ham band } - if (g_eeprom.VfoInfo[VFO].am_mode) + if (g_eeprom.vfo_info[VFO].am_mode) { // freq/chan is in AM mode - 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; + g_eeprom.vfo_info[VFO].scrambling_type = 0; +// g_eeprom.vfo_info[VFO].dtmf_decoding_enable = false; // no reason to disable DTMF decoding, aircraft use it on SSB + g_eeprom.vfo_info[VFO].freq_config_rx.code_type = CODE_TYPE_OFF; + g_eeprom.vfo_info[VFO].freq_config_tx.code_type = CODE_TYPE_OFF; } - g_eeprom.VfoInfo[VFO].compander = (Attributes & USER_CH_COMPAND) >> 4; + g_eeprom.vfo_info[VFO].compander = (Attributes & USER_CH_COMPAND) >> 4; RADIO_ConfigureSquelchAndOutputPower(pRadio); } -void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) +void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *pInfo) { uint8_t TX_power[3]; FREQUENCY_Band_t Band; @@ -436,11 +436,11 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) if (g_eeprom.squelch_level == 0) { // squelch == 0 (off) - pInfo->squelch_open_RSSI_thresh = 0; // 0 ~ 255 + 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->squelch_close_RSSI_thresh = 0; // 0 ~ 255 + pInfo->squelch_close_rssi_thresh = 0; // 0 ~ 255 pInfo->squelch_close_noise_thresh = 127; // 127 ~ 0 pInfo->squelch_open_glitch_thresh = 255; // 255 ~ 0 } @@ -448,8 +448,8 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) { // squelch >= 1 Base += g_eeprom.squelch_level; // my eeprom squelch-1 // VHF UHF - 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 + 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->squelch_open_noise_thresh, 1); // 65 90 EEPROM_ReadBuffer(Base + 0x30, &pInfo->squelch_close_noise_thresh, 1); // 70 100 @@ -457,8 +457,8 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) 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->squelch_open_RSSI_thresh; - uint16_t rssi_close = pInfo->squelch_close_RSSI_thresh; + 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; @@ -501,8 +501,8 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) if (glitch_close == glitch_open && glitch_close <= 253) glitch_close += 2; - 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_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; @@ -530,15 +530,15 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) TX_power[0], TX_power[1], TX_power[2], - frequencyBandTable[Band].lower, - (frequencyBandTable[Band].lower + frequencyBandTable[Band].upper) / 2, - frequencyBandTable[Band].upper, + FREQ_BAND_TABLE[Band].lower, + (FREQ_BAND_TABLE[Band].lower + FREQ_BAND_TABLE[Band].upper) / 2, + FREQ_BAND_TABLE[Band].upper, pInfo->pTX->frequency); // ******************************* } -void RADIO_ApplyOffset(VFO_Info_t *pInfo) +void RADIO_ApplyOffset(vfo_info_t *pInfo) { uint32_t Frequency = pInfo->freq_config_rx.frequency; @@ -554,40 +554,40 @@ void RADIO_ApplyOffset(VFO_Info_t *pInfo) break; } - if (Frequency < frequencyBandTable[0].lower) - Frequency = frequencyBandTable[0].lower; + if (Frequency < FREQ_BAND_TABLE[0].lower) + Frequency = FREQ_BAND_TABLE[0].lower; else - if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper) - Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper; + if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper) + Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper; pInfo->freq_config_tx.frequency = Frequency; } static void RADIO_SelectCurrentVfo(void) { - gCurrentVfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? gRxVfo : &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; + g_current_vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_rx_vfo : &g_eeprom.vfo_info[g_eeprom.tx_vfo]; } void RADIO_SelectVfos(void) { - g_eeprom.tx_vfo = get_tx_VFO(); + 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 = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; - gRxVfo = &g_eeprom.VfoInfo[g_eeprom.rx_vfo]; + g_tx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo]; + g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.rx_vfo]; RADIO_SelectCurrentVfo(); } void RADIO_SetupRegisters(bool bSwitchToFunction0) { - BK4819_FilterBandwidth_t Bandwidth = gRxVfo->channel_bandwidth; + BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel_bandwidth; uint16_t InterruptMask; uint32_t Frequency; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); @@ -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, g_rx_vfo->am_mode && g_setting_am_fix); BK4819_SetFilterBandwidth(Bandwidth, true); #else BK4819_SetFilterBandwidth(Bandwidth, false); @@ -632,19 +632,19 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) 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(g_rx_vfo->channel_save) || !g_is_noaa_mode) + Frequency = g_rx_vfo->pRX->frequency; else - Frequency = NoaaFrequencyTable[gNoaaChannel]; + Frequency = NoaaFrequencyTable[g_noaa_channel]; #else - Frequency = gRxVfo->pRX->frequency; + Frequency = g_rx_vfo->pRX->frequency; #endif BK4819_SetFrequency(Frequency); BK4819_SetupSquelch( - 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); + g_rx_vfo->squelch_open_rssi_thresh, g_rx_vfo->squelch_close_rssi_thresh, + g_rx_vfo->squelch_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh, + g_rx_vfo->squelch_close_glitch_thresh, g_rx_vfo->squelch_open_glitch_thresh); BK4819_PickRXFilterPathBasedOnFrequency(Frequency); @@ -657,17 +657,17 @@ 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(g_rx_vfo->channel_save)) #endif { - if (gRxVfo->am_mode == 0) + if (g_rx_vfo->am_mode == 0) { // FM - uint8_t code_type = gSelectedcode_type; - uint8_t Code = gSelectedCode; - if (gCssScanMode == CSS_SCAN_MODE_OFF) + uint8_t code_type = g_selected_code_type; + uint8_t Code = g_selected_code; + if (g_css_scan_mode == CSS_SCAN_MODE_OFF) { - code_type = gRxVfo->pRX->code_type; - Code = gRxVfo->pRX->code; + code_type = g_rx_vfo->pRX->code_type; + Code = g_rx_vfo->pRX->code; } switch (code_type) @@ -686,12 +686,12 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) break; case CODE_TYPE_CONTINUOUS_TONE: - BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); + BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]); //#ifndef ENABLE_CTCSS_TAIL_PHASE_SHIFT BK4819_SetTailDetection(550); // QS's 55Hz tone method //#else - // BK4819_SetTailDetection(CTCSS_Options[Code]); + // BK4819_SetTailDetection(CTCSS_OPTIONS[Code]); //#endif InterruptMask = 0 @@ -715,8 +715,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) break; } - if (gRxVfo->scrambling_type > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gRxVfo->scrambling_type - 1); + if (g_rx_vfo->scrambling_type > 0 && g_setting_scramble_enable) + BK4819_EnableScramble(g_rx_vfo->scrambling_type - 1); else BK4819_DisableScramble(); } @@ -736,15 +736,15 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #ifdef ENABLE_VOX #ifdef ENABLE_NOAA #ifdef ENABLE_FMRADIO - if (g_eeprom.vox_switch && !gFmRadioMode && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0) + if (g_eeprom.vox_switch && !g_fm_radio_mode && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && g_current_vfo->am_mode == 0) #else - if (g_eeprom.vox_switch && IS_NOT_NOAA_CHANNEL(gCurrentVfo->channel_save) && gCurrentVfo->am_mode == 0) + if (g_eeprom.vox_switch && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && g_current_vfo->am_mode == 0) #endif #else #ifdef ENABLE_FMRADIO - if (g_eeprom.vox_switch && !gFmRadioMode && gCurrentVfo->am_mode == 0) + if (g_eeprom.vox_switch && !g_fm_radio_mode && g_current_vfo->am_mode == 0) #else - if (g_eeprom.vox_switch && gCurrentVfo->am_mode == 0) + if (g_eeprom.vox_switch && g_current_vfo->am_mode == 0) #endif #endif { @@ -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((g_rx_vfo->am_mode == 0 && g_rx_vfo->compander >= 2) ? g_rx_vfo->compander : 0); #if 0 - if (!gRxVfo->DTMF_decoding_enable && !gSetting_KILLED) + if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_killed) { BK4819_DisableDTMF(); } @@ -769,7 +769,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; } #else - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) { BK4819_DisableDTMF(); BK4819_EnableDTMF(); @@ -795,9 +795,9 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) { uint8_t ChanAB; - gUpdateStatus = true; + g_update_status = true; - if (g_eeprom.NOAA_auto_scan) + if (g_eeprom.noaa_auto_scan) { if (g_eeprom.dual_watch != DUAL_WATCH_OFF) { @@ -805,7 +805,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) { if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) { - gIsNoaaMode = false; + g_is_noaa_mode = false; return; } ChanAB = 1; @@ -813,35 +813,35 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) else ChanAB = 0; - if (!gIsNoaaMode) - gNoaaChannel = g_eeprom.VfoInfo[ChanAB].channel_save - NOAA_CHANNEL_FIRST; + if (!g_is_noaa_mode) + g_noaa_channel = g_eeprom.vfo_info[ChanAB].channel_save - NOAA_CHANNEL_FIRST; - gIsNoaaMode = true; + g_is_noaa_mode = true; return; } - if (gRxVfo->channel_save >= NOAA_CHANNEL_FIRST) + if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST) { - gIsNoaaMode = true; - gNoaaChannel = gRxVfo->channel_save - NOAA_CHANNEL_FIRST; - gNOAA_Countdown_10ms = NOAA_countdown_2_10ms; - gScheduleNOAA = false; + g_is_noaa_mode = true; + g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST; + g_noaa_count_down_10ms = noaa_count_down_2_10ms; + g_schedule_noaa = false; } else - gIsNoaaMode = false; + g_is_noaa_mode = false; } else - gIsNoaaMode = false; + g_is_noaa_mode = false; } #endif void RADIO_SetTxParameters(void) { - BK4819_FilterBandwidth_t Bandwidth = gCurrentVfo->channel_bandwidth; + BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel_bandwidth; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = false; + g_enable_speaker = false; BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); @@ -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, g_current_vfo->am_mode && g_setting_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(g_current_vfo->pTX->frequency); // TX compressor - BK4819_SetCompander((gRxVfo->am_mode == 0 && (gRxVfo->compander == 1 || gRxVfo->compander >= 3)) ? gRxVfo->compander : 0); + BK4819_SetCompander((g_rx_vfo->am_mode == 0 && (g_rx_vfo->compander == 1 || g_rx_vfo->compander >= 3)) ? g_rx_vfo->compander : 0); BK4819_PrepareTransmit(); SYSTEM_DelayMs(10); - BK4819_PickRXFilterPathBasedOnFrequency(gCurrentVfo->pTX->frequency); + BK4819_PickRXFilterPathBasedOnFrequency(g_current_vfo->pTX->frequency); BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, true); SYSTEM_DelayMs(5); - BK4819_SetupPowerAmplifier(gCurrentVfo->txp_calculated_setting, gCurrentVfo->pTX->frequency); + BK4819_SetupPowerAmplifier(g_current_vfo->txp_calculated_setting, g_current_vfo->pTX->frequency); SYSTEM_DelayMs(10); - switch (gCurrentVfo->pTX->code_type) + switch (g_current_vfo->pTX->code_type) { default: case CODE_TYPE_OFF: @@ -892,104 +892,104 @@ void RADIO_SetTxParameters(void) break; case CODE_TYPE_CONTINUOUS_TONE: - BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->code]); + BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[g_current_vfo->pTX->code]); break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(gCurrentVfo->pTX->code_type, gCurrentVfo->pTX->code)); + BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(g_current_vfo->pTX->code_type, g_current_vfo->pTX->code)); break; } } -void RADIO_SetVfoState(VfoState_t State) +void RADIO_Setg_vfo_state(vfo_state_t State) { if (State == VFO_STATE_NORMAL) { - VfoState[0] = VFO_STATE_NORMAL; - VfoState[1] = VFO_STATE_NORMAL; + g_vfo_state[0] = VFO_STATE_NORMAL; + g_vfo_state[1] = VFO_STATE_NORMAL; #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown_500ms = 0; + g_fm_resume_count_down_500ms = 0; #endif } else { if (State == VFO_STATE_VOLTAGE_HIGH) { - VfoState[0] = VFO_STATE_VOLTAGE_HIGH; - VfoState[1] = VFO_STATE_TX_DISABLE; + g_vfo_state[0] = VFO_STATE_VOLTAGE_HIGH; + g_vfo_state[1] = VFO_STATE_TX_DISABLE; } else { // 1of11 const unsigned int vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo; - VfoState[vfo] = State; + g_vfo_state[vfo] = State; } #ifdef ENABLE_FMRADIO - gFM_ResumeCountdown_500ms = fm_resume_countdown_500ms; + g_fm_resume_count_down_500ms = fm_resume_countdown_500ms; #endif } - gUpdateDisplay = true; + g_update_display = true; } void RADIO_PrepareTX(void) { - VfoState_t State = VFO_STATE_NORMAL; // default to OK to TX + vfo_state_t State = VFO_STATE_NORMAL; // default to OK to TX if (g_eeprom.dual_watch != DUAL_WATCH_OFF) { // dual-RX is enabled - gDualWatchCountdown_10ms = dual_watch_count_after_tx_10ms; - gScheduleDualWatch = false; + g_dual_watch_count_down_10ms = dual_watch_count_after_tx_10ms; + g_schedule_dual_watch = false; #if 0 - if (gRxVfoIsActive) + if (g_rx_vfo_is_active) { // use the TX vfo g_eeprom.rx_vfo = g_eeprom.tx_vfo; - gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; - gRxVfoIsActive = false; + g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo]; + g_rx_vfo_is_active = false; } - gCurrentVfo = gRxVfo; + g_current_vfo = g_rx_vfo; #else - if (!gRxVfoIsActive) + if (!g_rx_vfo_is_active) { // use the current RX vfo g_eeprom.rx_vfo = g_eeprom.tx_vfo; - gRxVfo = &g_eeprom.VfoInfo[g_eeprom.tx_vfo]; - gRxVfoIsActive = true; + g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo]; + g_rx_vfo_is_active = true; } - gCurrentVfo = gRxVfo; + g_current_vfo = g_rx_vfo; #endif // let the user see that DW is not active '><' symbol - gDualWatchActive = false; - gUpdateStatus = true; + g_dual_watch_active = false; + g_update_status = true; } RADIO_SelectCurrentVfo(); #ifndef ENABLE_TX_WHEN_AM - if (gCurrentVfo->am_mode) + if (g_current_vfo->am_mode) { // not allowed to TX if in AM mode State = VFO_STATE_TX_DISABLE; } else #endif - if (!gSetting_TX_EN || gSerialConfigCountDown_500ms > 0) + if (!g_Setting_tx_enable || g_serial_config_count_down_500ms > 0) { // TX is disabled or config upload/download in progress State = VFO_STATE_TX_DISABLE; } else - if (TX_freq_check(gCurrentVfo->pTX->frequency) == 0) + if (TX_freq_check(g_current_vfo->pTX->frequency) == 0) { // TX frequency is allowed - if (gCurrentVfo->busy_channel_lock && gCurrentFunction == FUNCTION_RECEIVE) + if (g_current_vfo->busy_channel_lock && g_current_function == FUNCTION_RECEIVE) State = VFO_STATE_BUSY; // busy RX'ing a station else - if (gBatteryDisplayLevel == 0) + if (g_battery_display_level == 0) State = VFO_STATE_BAT_LOW; // charge your battery ! else - if (gBatteryDisplayLevel >= 6) + if (g_battery_display_level >= 6) State = VFO_STATE_VOLTAGE_HIGH; // over voltage (no doubt to protect the PA) .. this is being a pain } else @@ -998,13 +998,13 @@ void RADIO_PrepareTX(void) if (State != VFO_STATE_NORMAL) { // TX not allowed - RADIO_SetVfoState(State); + RADIO_Setg_vfo_state(State); #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - gAlarmState = ALARM_STATE_OFF; + g_alarm_state = ALARM_STATE_OFF; #endif - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_dtmf_reply_state = DTMF_REPLY_NONE; AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); return; @@ -1012,47 +1012,47 @@ void RADIO_PrepareTX(void) // TX is allowed - if (gDTMF_ReplyState == DTMF_REPLY_ANI) + if (g_dtmf_reply_state == DTMF_REPLY_ANI) { - if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) + if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF) { - gDTMF_IsTx = true; - gDTMF_CallState = DTMF_CALL_STATE_NONE; - gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms; + g_dtmf_is_tx = true; + g_dtmf_call_state = DTMF_CALL_STATE_NONE; + g_dtmf_tx_stop_count_down_500ms = dtmf_txstop_countdown_500ms; } else { - gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT; - gDTMF_IsTx = false; + g_dtmf_call_state = DTMF_CALL_STATE_CALL_OUT; + g_dtmf_is_tx = false; } } FUNCTION_Select(FUNCTION_TRANSMIT); - gTxTimerCountdown_500ms = 0; // no timeout + g_tx_timer_count_down_500ms = 0; // no timeout #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF) + if (g_alarm_state == ALARM_STATE_OFF) #endif { if (g_eeprom.tx_timeout_timer == 0) - gTxTimerCountdown_500ms = 60; // 30 sec + g_tx_timer_count_down_500ms = 60; // 30 sec else - if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1)) - gTxTimerCountdown_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes + if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(g_sub_menu_TOT) - 1)) + g_tx_timer_count_down_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes else - gTxTimerCountdown_500ms = 120 * 15; // 15 minutes + g_tx_timer_count_down_500ms = 120 * 15; // 15 minutes } - gTxTimeoutReached = false; + g_tx_timeout_reached = false; - gFlagEndTransmission = false; - gRTTECountdown = 0; - gDTMF_ReplyState = DTMF_REPLY_NONE; + g_flag_end_tx = false; + g_rtte_count_down = 0; + g_dtmf_reply_state = DTMF_REPLY_NONE; } void RADIO_EnableCxCSS(void) { - switch (gCurrentVfo->pTX->code_type) + switch (g_current_vfo->pTX->code_type) { default: case CODE_TYPE_OFF: @@ -1089,31 +1089,31 @@ void RADIO_SendEndOfTransmission(void) 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, g_eeprom.DTMF_side_tone); + if (g_current_vfo->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)) + if (g_dtmf_call_state == DTMF_CALL_STATE_NONE && + (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_TX_DOWN || g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_BOTH)) { // end-of-tx - if (g_eeprom.DTMF_side_tone) + if (g_eeprom.dtmf_side_tone) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; + g_enable_speaker = true; SYSTEM_DelayMs(60); } - BK4819_EnterDTMF_TX(g_eeprom.DTMF_side_tone); + BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone); BK4819_PlayDTMFString( - g_eeprom.DTMF_down_code, + g_eeprom.dtmf_down_code, 0, - 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); + 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; + g_enable_speaker = false; } BK4819_ExitDTMF_TX(true); diff --git a/radio.h b/radio.h index 91c4b0ac..874e2c6c 100644 --- a/radio.h +++ b/radio.h @@ -40,16 +40,16 @@ enum { BANDWIDTH_NARROW }; -enum PTT_ID_t { +enum ptt_id_e { PTT_ID_OFF = 0, // OFF PTT_ID_TX_UP, // BEGIN OF TX PTT_ID_TX_DOWN, // END OF TX PTT_ID_BOTH, // BOTH PTT_ID_APOLLO // Apolo quindar tones }; -typedef enum PTT_ID_t PTT_ID_t; +typedef enum ptt_id_e ptt_id_t; -enum VfoState_t +enum vfo_state_e { VFO_STATE_NORMAL = 0, VFO_STATE_BUSY, @@ -59,7 +59,7 @@ enum VfoState_t VFO_STATE_ALARM, VFO_STATE_VOLTAGE_HIGH }; -typedef enum VfoState_t VfoState_t; +typedef enum vfo_state_e vfo_state_t; typedef struct { @@ -67,14 +67,14 @@ typedef struct dcs_code_type_t code_type; uint8_t code; uint8_t padding[2]; -} FREQ_Config_t; +} freq_config_t; -typedef struct VFO_Info_t +typedef struct vfo_info_t { - FREQ_Config_t freq_config_rx; - FREQ_Config_t freq_config_tx; - FREQ_Config_t *pRX; - FREQ_Config_t *pTX; + freq_config_t freq_config_rx; + freq_config_t freq_config_tx; + freq_config_t *pRX; + freq_config_t *pTX; uint32_t tx_offset_freq; uint16_t step_freq; @@ -83,10 +83,10 @@ typedef struct VFO_Info_t uint8_t tx_offset_freq_dir; - uint8_t squelch_open_RSSI_thresh; + 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_rssi_thresh; uint8_t squelch_close_noise_thresh; uint8_t squelch_open_glitch_thresh; @@ -103,8 +103,8 @@ typedef struct VFO_Info_t 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; @@ -113,26 +113,26 @@ typedef struct VFO_Info_t uint8_t compander; char name[16]; -} VFO_Info_t; +} vfo_info_t; -extern VFO_Info_t *gTxVfo; -extern VFO_Info_t *gRxVfo; -extern VFO_Info_t *gCurrentVfo; +extern vfo_info_t *g_tx_vfo; +extern vfo_info_t *g_rx_vfo; +extern vfo_info_t *g_current_vfo; -extern dcs_code_type_t gSelectedcode_type; -extern dcs_code_type_t gCurrentcode_type; -extern uint8_t gSelectedCode; +extern dcs_code_type_t g_selected_code_type; +extern dcs_code_type_t g_current_code_type; +extern uint8_t g_selected_code; -extern step_setting_t gStepSetting; +extern step_setting_t g_step_setting; -extern VfoState_t VfoState[2]; +extern vfo_state_t g_vfo_state[2]; bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum); uint8_t RADIO_FindNextChannel(uint8_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum); -void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency); +void RADIO_InitInfo(vfo_info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency); void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure); -void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo); -void RADIO_ApplyOffset(VFO_Info_t *pInfo); +void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *pInfo); +void RADIO_ApplyOffset(vfo_info_t *pInfo); void RADIO_SelectVfos(void); void RADIO_SetupRegisters(bool bSwitchToFunction0); #ifdef ENABLE_NOAA @@ -140,7 +140,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0); #endif void RADIO_SetTxParameters(void); -void RADIO_SetVfoState(VfoState_t State); +void RADIO_Setg_vfo_state(vfo_state_t State); void RADIO_PrepareTX(void); void RADIO_EnableCxCSS(void); void RADIO_PrepareCssTX(void); diff --git a/scheduler.c b/scheduler.c index 1a6f3cc6..2ff29e8a 100644 --- a/scheduler.c +++ b/scheduler.c @@ -41,73 +41,73 @@ flag = true; \ } while (0) -static volatile uint32_t gGlobalSysTickCounter; +static volatile uint32_t g_global_sys_tick_counter; void SystickHandler(void); // we come here every 10ms void SystickHandler(void) { - gGlobalSysTickCounter++; + g_global_sys_tick_counter++; - gNextTimeslice = true; + g_next_time_slice = true; - if ((gGlobalSysTickCounter % 50) == 0) + if ((g_global_sys_tick_counter % 50) == 0) { // 500ms tick - gNextTimeslice_500ms = true; + g_next_time_slice_500ms = true; - DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached); - DECREMENT(gSerialConfigCountDown_500ms); + DECREMENT_AND_TRIGGER(g_tx_timer_count_down_500ms, g_tx_timeout_reached); + DECREMENT(g_serial_config_count_down_500ms); } - if ((gGlobalSysTickCounter & 3) == 0) - gNextTimeslice40ms = true; + if ((g_global_sys_tick_counter & 3) == 0) + g_next_time_slice_40ms = true; #ifdef ENABLE_NOAA - DECREMENT(gNOAACountdown_10ms); + DECREMENT(g_noaa_count_down_10ms); #endif - DECREMENT(gFoundCDCSSCountdown_10ms); + DECREMENT(g_found_CDCSS_count_down_10ms); - DECREMENT(gFoundCTCSSCountdown_10ms); + DECREMENT(g_found_CTCSS_count_down_10ms); - if (gCurrentFunction == FUNCTION_FOREGROUND) - DECREMENT_AND_TRIGGER(gBatterySaveCountdown_10ms, gSchedulePowerSave); + if (g_current_function == FUNCTION_FOREGROUND) + DECREMENT_AND_TRIGGER(g_battery_save_count_down_10ms, g_schedule_power_save); - if (gCurrentFunction == FUNCTION_POWER_SAVE) - DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired); + if (g_current_function == FUNCTION_POWER_SAVE) + DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_count_down_expired); - 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); + if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF) + if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) + DECREMENT_AND_TRIGGER(g_dual_watch_count_down_10ms, g_schedule_dual_watch); #ifdef ENABLE_NOAA - 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); + if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch == DUAL_WATCH_OFF) + if (g_is_noaa_mode && g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_RECEIVE) + DECREMENT_AND_TRIGGER(g_noaa_count_down_10ms, g_schedule_noaa); #endif - if (gScanStateDir != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING) - if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) - DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen); + if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode == CSS_SCAN_MODE_SCANNING) + if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT) + DECREMENT_AND_TRIGGER(g_scan_pause_delay_in_10ms, g_schedule_scan_listen); - DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete); + DECREMENT_AND_TRIGGER(g_tail_tone_elimination_count_down_10ms, g_flag_tail_tone_elimination_complete); #ifdef ENABLE_VOICE DECREMENT_AND_TRIGGER(g_count_down_to_play_next_voice_10ms, g_flag_play_queued_voice); #endif #ifdef ENABLE_FMRADIO - if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR) - if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) - DECREMENT_AND_TRIGGER(gFmPlayCountdown_10ms, gScheduleFM); + if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR) + if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) + DECREMENT_AND_TRIGGER(g_fm_play_count_down_10ms, g_schedule_fm); #endif #ifdef ENABLE_VOX - DECREMENT(gVoxStopCountdown_10ms); + DECREMENT(g_vox_stop_count_down_10ms); #endif - DECREMENT(boot_counter_10ms); + DECREMENT(g_boot_counter_10ms); } diff --git a/settings.c b/settings.c index 5bb200a1..857ee978 100644 --- a/settings.c +++ b/settings.c @@ -24,7 +24,7 @@ #include "misc.h" #include "settings.h" -EEPROM_Config_t g_eeprom; +eeprom_config_t g_eeprom; #ifdef ENABLE_FMRADIO void SETTINGS_SaveFM(void) @@ -47,7 +47,7 @@ EEPROM_Config_t g_eeprom; EEPROM_WriteBuffer(0x0E88, &state); for (i = 0; i < 5; i++) - EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]); + EEPROM_WriteBuffer(0x0E40 + (i * 8), &g_fm_channels[i * 4]); } #endif @@ -81,7 +81,7 @@ void SETTINGS_SaveSettings(void) State[1] = g_eeprom.squelch_level; State[2] = g_eeprom.tx_timeout_timer; #ifdef ENABLE_NOAA - State[3] = g_eeprom.NOAA_auto_scan; + State[3] = g_eeprom.noaa_auto_scan; #else State[3] = false; #endif @@ -146,19 +146,19 @@ void SETTINGS_SaveSettings(void) State[3] = g_eeprom.tx_vfo; EEPROM_WriteBuffer(0x0EA8, State); - 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; + 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] = g_eeprom.DTMF_code_persist_time / 10U; - State[1] = g_eeprom.DTMF_code_interval_time / 10U; + 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); @@ -173,28 +173,28 @@ void SETTINGS_SaveSettings(void) EEPROM_WriteBuffer(0x0F18, State); memset(State, 0xFF, sizeof(State)); - State[0] = gSetting_F_LOCK; - State[1] = gSetting_350TX; - State[2] = gSetting_KILLED; - State[3] = gSetting_200TX; - State[4] = gSetting_500TX; - State[5] = gSetting_350EN; - State[6] = gSetting_ScrambleEnable; - if (!gSetting_TX_EN) State[7] &= ~(1u << 0); - if (!gSetting_live_DTMF_decoder) State[7] &= ~(1u << 1); - State[7] = (State[7] & ~(3u << 2)) | ((gSetting_battery_text & 3u) << 2); + State[0] = g_setting_f_lock; + State[1] = g_setting_350_tx_enable; + State[2] = g_setting_killed; + State[3] = g_setting_200_tx_enable; + State[4] = g_setting_500_tx_enable; + State[5] = g_setting_350_enable; + State[6] = g_setting_scramble_enable; + if (!g_Setting_tx_enable) State[7] &= ~(1u << 0); + if (!g_setting_live_dtmf_decoder) State[7] &= ~(1u << 1); + State[7] = (State[7] & ~(3u << 2)) | ((g_setting_battery_text & 3u) << 2); #ifdef ENABLE_AUDIO_BAR - if (!gSetting_mic_bar) State[7] &= ~(1u << 4); + if (!g_setting_mic_bar) State[7] &= ~(1u << 4); #endif #ifdef ENABLE_AM_FIX - if (!gSetting_AM_fix) State[7] &= ~(1u << 5); + if (!g_setting_am_fix) State[7] &= ~(1u << 5); #endif - State[7] = (State[7] & ~(3u << 6)) | ((gSetting_backlight_on_tx_rx & 3u) << 6); + State[7] = (State[7] & ~(3u << 6)) | ((g_setting_backlight_on_tx_rx & 3u) << 6); EEPROM_WriteBuffer(0x0F40, State); } -void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) +void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode) { #ifdef ENABLE_NOAA if (IS_NOT_NOAA_CHANNEL(Channel)) @@ -227,7 +227,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, | (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[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); @@ -259,7 +259,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, } } -void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) +void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep) { #ifdef ENABLE_NOAA if (IS_NOT_NOAA_CHANNEL(Channel)) @@ -284,7 +284,7 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) EEPROM_WriteBuffer(Offset, State); - gUSER_ChannelAttributes[Channel] = Attributes; + g_user_channel_attributes[Channel] = Attributes; // #ifndef ENABLE_KEEP_MEM_NAME if (Channel <= USER_CHANNEL_LAST) diff --git a/settings.h b/settings.h index 6ee168c5..03e1efb8 100644 --- a/settings.h +++ b/settings.h @@ -94,7 +94,7 @@ enum { #endif enum alarm_mode_e { - alarm_mode_SITE = 0, + ALARM_MODE_SITE = 0, ALARM_MODE_TONE }; typedef enum alarm_mode_e alarm_mode_t; @@ -179,11 +179,11 @@ typedef struct { uint8_t mic_sensitivity; uint8_t mic_sensitivity_tuning; uint8_t chan_1_call; - char ani_DTMF_id[8]; + char ani_dtmf_id[8]; char kill_code[8]; char revive_code[8]; - char DTMF_up_code[16]; - char DTMF_down_code[16]; + char dtmf_up_code[16]; + char dtmf_down_code[16]; uint8_t field57_0x6c; uint8_t field58_0x6d; @@ -191,24 +191,24 @@ typedef struct { uint8_t field60_0x7e; uint8_t field61_0x7f; - 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; + 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; #ifdef ENABLE_NOAA - bool NOAA_auto_scan; + bool noaa_auto_scan; #endif uint8_t volume_gain; uint8_t dac_gain; - VFO_Info_t VfoInfo[2]; + vfo_info_t vfo_info[2]; uint32_t power_on_password; uint16_t vox1_threshold; uint16_t vox0_threshold; @@ -218,16 +218,16 @@ typedef struct { uint8_t field79_0x97; uint8_t _pad[1]; -} EEPROM_Config_t; +} eeprom_config_t; -extern EEPROM_Config_t g_eeprom; +extern eeprom_config_t g_eeprom; #ifdef ENABLE_FMRADIO void SETTINGS_SaveFM(void); #endif void SETTINGS_SaveVfoIndices(void); void SETTINGS_SaveSettings(void); -void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); -void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep); +void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode); +void SETTINGS_UpdateChannel(uint8_t Channel, const vfo_info_t *pVFO, bool keep); #endif diff --git a/ui/aircopy.c b/ui/aircopy.c index 4dfa6d9c..1c43242f 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -31,32 +31,32 @@ void UI_DisplayAircopy(void) { char String[16]; - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); - if (gAircopyState == AIRCOPY_READY) + if (g_aircopy_state == AIRCOPY_READY) strcpy(String, "AIR COPY(RDY)"); else - if (gAircopyState == AIRCOPY_TRANSFER) + if (g_aircopy_state == AIRCOPY_TRANSFER) strcpy(String, "AIR COPY"); else strcpy(String, "AIR COPY(CMP)"); UI_PrintString(String, 2, 127, 0, 8); - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { - NUMBER_ToDigits(gRxVfo->freq_config_rx.frequency, String); + NUMBER_ToDigits(g_rx_vfo->freq_config_rx.frequency, String); UI_DisplayFrequency(String, 16, 2, 0, 0); - UI_DisplaySmallDigits(2, String + 6, 97, 3, true); + UI_Displaysmall_digits(2, String + 6, 97, 3, true); } else - UI_DisplayFrequency(gInputBox, 16, 2, 1, 0); + UI_DisplayFrequency(g_input_box, 16, 2, 1, 0); memset(String, 0, sizeof(String)); - if (gAirCopyIsSendMode == 0) - sprintf(String, "RCV:%u E:%u", gAirCopyBlockNumber, gErrorsDuringAirCopy); + if (g_air_copy_is_send_mode == 0) + sprintf(String, "RCV:%u E:%u", g_air_copy_block_number, g_errors_during_air_copyy); else - if (gAirCopyIsSendMode == 1) - sprintf(String, "SND:%u", gAirCopyBlockNumber); + if (g_air_copy_is_send_mode == 1) + sprintf(String, "SND:%u", g_air_copy_block_number); UI_PrintString(String, 2, 127, 4, 8); ST7565_BlitFullScreen(); diff --git a/ui/fmradio.c b/ui/fmradio.c index 39468c61..df8e5f55 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -33,31 +33,31 @@ void UI_DisplayFM(void) unsigned int i; char String[16]; - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); memset(String, 0, sizeof(String)); strcpy(String, "FM"); UI_PrintString(String, 0, 127, 0, 12); memset(String, 0, sizeof(String)); - if (gAskToSave) + if (g_ask_to_save) { strcpy(String, "SAVE?"); } else - if (gAskToDelete) + if (g_ask_to_delete) { strcpy(String, "DEL?"); } else { - if (gFM_ScanState == FM_SCAN_OFF) + if (g_fm_scan_state == FM_SCAN_OFF) { if (!g_eeprom.fm_is_channel_mode) { for (i = 0; i < 20; i++) { - if (g_eeprom.fm_frequency_playing == gFM_Channels[i]) + if (g_eeprom.fm_frequency_playing == g_fm_channels[i]) { sprintf(String, "VFO(CH%02u)", i + 1); break; @@ -72,29 +72,29 @@ void UI_DisplayFM(void) } else { - if (!gFM_AutoScan) + if (!g_fm_auto_scan) strcpy(String, "M-SCAN"); else - sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1); + sprintf(String, "A-SCAN(%u)", g_fm_channel_position + 1); } } UI_PrintString(String, 0, 127, 2, 10); memset(String, 0, sizeof(String)); - if (gAskToSave || (g_eeprom.fm_is_channel_mode && gInputBoxIndex > 0)) + if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0)) { - UI_GenerateChannelString(String, gFM_ChannelPosition); + UI_GenerateChannelString(String, g_fm_channel_position); } else - if (!gAskToDelete) + if (!g_ask_to_delete) { - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { NUMBER_ToDigits(g_eeprom.fm_frequency_playing * 10000, String); UI_DisplayFrequency(String, 23, 4, false, true); } else - UI_DisplayFrequency(gInputBox, 23, 4, true, false); + UI_DisplayFrequency(g_input_box, 23, 4, true, false); ST7565_BlitFullScreen(); return; diff --git a/ui/helper.c b/ui/helper.c index 11b3545d..ff7ea4b5 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -30,7 +30,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel) { unsigned int i; - if (gInputBoxIndex == 0) + if (g_input_box_index == 0) { sprintf(pString, "CH-%02u", Channel + 1); return; @@ -40,16 +40,16 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel) pString[1] = 'H'; pString[2] = '-'; for (i = 0; i < 2; i++) - pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + pString[i + 3] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; } void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber) { - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { unsigned int i; for (i = 0; i < 3; i++) - pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + pString[i] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; return; } @@ -76,8 +76,8 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin { const unsigned int index = pString[i] - ' '; const unsigned int ofs = (unsigned int)Start + (i * Width); - memmove(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 8); - memmove(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][8], 7); + memmove(g_frame_buffer[Line + 0] + ofs, &g_font_big[index][0], 8); + memmove(g_frame_buffer[Line + 1] + ofs, &g_font_big[index][8], 7); } } } @@ -90,16 +90,16 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ if (End > Start) Start += (((End - Start) - (Length * 8)) + 1) / 2; - const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); + const unsigned int char_width = ARRAY_SIZE(g_font_small[0]); const unsigned int char_spacing = char_width + 1; - uint8_t *pFb = gFrameBuffer[Line] + Start; + uint8_t *pFb = g_frame_buffer[Line] + Start; for (i = 0; i < Length; i++) { if (pString[i] >= 32) { const unsigned int index = (unsigned int)pString[i] - 32; - if (index < ARRAY_SIZE(gFontSmall)) - memmove(pFb + (i * char_spacing) + 1, &gFontSmall[index], char_width); + if (index < ARRAY_SIZE(g_font_small)) + memmove(pFb + (i * char_spacing) + 1, &g_font_small[index], char_width); } } } @@ -113,16 +113,16 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ if (End > Start) Start += (((End - Start) - (Length * 8)) + 1) / 2; - const unsigned int char_width = ARRAY_SIZE(gFontSmallBold[0]); + const unsigned int char_width = ARRAY_SIZE(g_font_small_bold[0]); const unsigned int char_spacing = char_width + 1; - uint8_t *pFb = gFrameBuffer[Line] + Start; + uint8_t *pFb = g_frame_buffer[Line] + Start; for (i = 0; i < Length; i++) { if (pString[i] >= 32) { const unsigned int index = (unsigned int)pString[i] - 32; - if (index < ARRAY_SIZE(gFontSmallBold)) - memmove(pFb + (i * char_spacing) + 1, &gFontSmallBold[index], char_width); + if (index < ARRAY_SIZE(g_font_small_bold)) + memmove(pFb + (i * char_spacing) + 1, &g_font_small_bold[index], char_width); } } } @@ -131,23 +131,23 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer) { size_t i; - const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); + const unsigned int char_width = ARRAY_SIZE(g_font_small[0]); const unsigned int char_spacing = char_width + 1; for (i = 0; i < strlen(pString); i++) { if (pString[i] >= 32) { const unsigned int index = (unsigned int)pString[i] - 32; - if (index < ARRAY_SIZE(gFontSmall)) - memmove(buffer + (i * char_spacing) + 1, &gFontSmall[index], char_width); + if (index < ARRAY_SIZE(g_font_small)) + memmove(buffer + (i * char_spacing) + 1, &g_font_small[index], char_width); } } } -void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag) +void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool flag) { const unsigned int char_width = 13; - uint8_t *pFb0 = gFrameBuffer[Y] + X; + uint8_t *pFb0 = g_frame_buffer[Y] + X; uint8_t *pFb1 = pFb0 + 128; bool bCanDisplay = false; unsigned int i = 0; @@ -159,11 +159,11 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla if (bDisplayLeadingZero || bCanDisplay || Digit > 0) { bCanDisplay = true; - memmove(pFb0, gFontBigDigits[Digit], char_width); - memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width); + memmove(pFb0, g_font_big_digits[Digit], char_width); + memmove(pFb1, g_font_big_digits[Digit] + char_width, char_width); } else - if (bFlag) + if (flag) { pFb0 -= 6; pFb1 -= 6; @@ -181,8 +181,8 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla while (i < 6) { const unsigned int Digit = pDigits[i++]; - memmove(pFb0, gFontBigDigits[Digit], char_width); - memmove(pFb1, gFontBigDigits[Digit] + char_width, char_width); + memmove(pFb0, g_font_big_digits[Digit], char_width); + memmove(pFb1, g_font_big_digits[Digit] + char_width, char_width); pFb0 += char_width; pFb1 += char_width; } @@ -190,9 +190,9 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero) { - const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); + const unsigned int char_width = ARRAY_SIZE(g_font_small[0]); const unsigned int spacing = 1 + char_width; - uint8_t *pFb = gFrameBuffer[Y] + X; + uint8_t *pFb = g_frame_buffer[Y] + X; bool bCanDisplay = false; unsigned int i = 0; @@ -203,10 +203,10 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD if (bDisplayLeadingZero || bCanDisplay || c > 0) { #if 0 - memmove(pFb + 1, gFontSmallDigits[c], char_width); + memmove(pFb + 1, g_font_small_digits[c], char_width); #else const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; - memmove(pFb + 1, gFontSmall[index], char_width); + memmove(pFb + 1, g_font_small[index], char_width); #endif pFb += spacing; bCanDisplay = true; @@ -225,18 +225,18 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD { const unsigned int c = pDigits[i++]; #if 0 - memmove(pFb + 1, gFontSmallDigits[c], char_width); + memmove(pFb + 1, g_font_small_digits[c], char_width); #else const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; - memmove(pFb + 1, gFontSmall[index], char_width); + memmove(pFb + 1, g_font_small[index], char_width); #endif pFb += spacing; } } -void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros) +void UI_Displaysmall_digits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros) { - const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); + const unsigned int char_width = ARRAY_SIZE(g_font_small[0]); const unsigned int spacing = 1 + char_width; bool display = display_leading_zeros; unsigned int xx; @@ -249,10 +249,10 @@ void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, if (display && c < 11) { #if 0 - memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); + memmove(g_frame_buffer[y] + xx, g_font_small_digits[c], char_width); #else const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; - memmove(gFrameBuffer[y] + xx + 1, gFontSmall[index], char_width); + memmove(g_frame_buffer[y] + xx + 1, g_font_small[index], char_width); #endif xx += spacing; } diff --git a/ui/helper.h b/ui/helper.h index 87eb6860..6e9184e2 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -28,9 +28,9 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); #endif void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer); -void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag); +void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool flag); void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero); -void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros); +void UI_Displaysmall_digits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros); #endif diff --git a/ui/inputbox.c b/ui/inputbox.c index 0900990b..d002c60b 100644 --- a/ui/inputbox.c +++ b/ui/inputbox.c @@ -18,18 +18,18 @@ #include "ui/inputbox.h" -char gInputBox[8]; -uint8_t gInputBoxIndex; +char g_input_box[8]; +uint8_t g_input_box_index; void INPUTBOX_Append(const key_code_t Digit) { - if (gInputBoxIndex >= sizeof(gInputBox)) + if (g_input_box_index >= sizeof(g_input_box)) return; - if (gInputBoxIndex == 0) - memset(gInputBox, 10, sizeof(gInputBox)); + if (g_input_box_index == 0) + memset(g_input_box, 10, sizeof(g_input_box)); if (Digit >= KEY_0 && Digit != KEY_INVALID) - gInputBox[gInputBoxIndex++] = (char)(Digit - KEY_0); + g_input_box[g_input_box_index++] = (char)(Digit - KEY_0); } diff --git a/ui/inputbox.h b/ui/inputbox.h index 419f2a60..5ca93d78 100644 --- a/ui/inputbox.h +++ b/ui/inputbox.h @@ -21,8 +21,8 @@ #include "driver/keyboard.h" -extern char gInputBox[8]; -extern uint8_t gInputBoxIndex; +extern char g_input_box[8]; +extern uint8_t g_input_box_index; void INPUTBOX_Append(const key_code_t Digit); diff --git a/ui/lock.c b/ui/lock.c index 3d32ba0f..6535c498 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -34,13 +34,13 @@ static void Render(void) unsigned int i; char String[7]; - memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_status_line, 0, sizeof(g_status_line)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); strcpy(String, "LOCK"); UI_PrintString(String, 0, 127, 1, 10); for (i = 0; i < 6; i++) - String[i] = (gInputBox[i] == 10) ? '-' : '*'; + String[i] = (g_input_box[i] == 10) ? '-' : '*'; String[6] = 0; UI_PrintString(String, 0, 127, 3, 12); @@ -51,19 +51,19 @@ static void Render(void) void UI_DisplayLock(void) { key_code_t Key; - BEEP_Type_t Beep; + beep_type_t Beep; - gUpdateDisplay = true; + g_update_display = true; - memset(gInputBox, 10, sizeof(gInputBox)); + memset(g_input_box, 10, sizeof(g_input_box)); while (1) { - while (!gNextTimeslice) {} + while (!g_next_time_slice) {} // TODO: Original code doesn't do the below, but is needed for proper key debounce - gNextTimeslice = false; + g_next_time_slice = false; Key = KEYBOARD_Poll(); @@ -93,7 +93,7 @@ void UI_DisplayLock(void) case KEY_9: INPUTBOX_Append(Key - KEY_0); - if (gInputBoxIndex < 6) // 6 frequency digits + if (g_input_box_index < 6) // 6 frequency digits { Beep = BEEP_1KHZ_60MS_OPTIONAL; } @@ -101,9 +101,9 @@ void UI_DisplayLock(void) { uint32_t Password; - gInputBoxIndex = 0; + g_input_box_index = 0; - NUMBER_Get(gInputBox, &Password); + NUMBER_Get(g_input_box, &Password); if ((g_eeprom.power_on_password * 100) == Password) { @@ -111,21 +111,21 @@ void UI_DisplayLock(void) return; } - memset(gInputBox, 10, sizeof(gInputBox)); + memset(g_input_box, 10, sizeof(g_input_box)); Beep = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } AUDIO_PlayBeep(Beep); - gUpdateDisplay = true; + g_update_display = true; break; case KEY_EXIT: - if (gInputBoxIndex > 0) + if (g_input_box_index > 0) { - gInputBox[--gInputBoxIndex] = 10; - gUpdateDisplay = true; + g_input_box[--g_input_box_index] = 10; + g_update_display = true; } AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); @@ -135,7 +135,7 @@ void UI_DisplayLock(void) } } - gKeyBeingHeld = false; + g_key_being_held = false; } } else @@ -151,10 +151,10 @@ void UI_DisplayLock(void) __enable_irq(); } - if (gUpdateDisplay) + if (g_update_display) { Render(); - gUpdateDisplay = false; + g_update_display = false; } } } diff --git a/ui/main.c b/ui/main.c index 998c39fd..4ca77d37 100644 --- a/ui/main.c +++ b/ui/main.c @@ -50,7 +50,7 @@ center_line_t center_line = CENTER_LINE_NONE; { unsigned int timeout_secs = 0; - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (g_current_function != FUNCTION_TRANSMIT) return false; if (center_line != CENTER_LINE_NONE && center_line != CENTER_LINE_TX_TIMEOUT) @@ -59,12 +59,12 @@ center_line_t center_line = CENTER_LINE_NONE; if (g_eeprom.tx_timeout_timer == 0) timeout_secs = 30; // 30 sec else - if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(gSubMenu_TOT) - 1)) + if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(g_sub_menu_TOT) - 1)) timeout_secs = 60 * g_eeprom.tx_timeout_timer; // minutes else timeout_secs = 60 * 15; // 15 minutes - if (timeout_secs == 0 || gTxTimerCountdown_500ms == 0) + if (timeout_secs == 0 || g_tx_timer_count_down_500ms == 0) return false; { @@ -72,11 +72,11 @@ center_line_t center_line = CENTER_LINE_NONE; const unsigned int txt_width = 7 * 6; // 6 text chars const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph const unsigned int bar_width = LCD_WIDTH - 1 - bar_x; - const unsigned int secs = gTxTimerCountdown_500ms / 2; + const unsigned int secs = g_tx_timer_count_down_500ms / 2; const unsigned int level = ((secs * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding // const unsigned int level = (((timeout_secs - secs) * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding const unsigned int len = (level <= bar_width) ? level : bar_width; - uint8_t *p_line = gFrameBuffer[line]; + uint8_t *p_line = g_frame_buffer[line]; unsigned int i; char s[16]; @@ -112,13 +112,13 @@ void UI_drawBars(uint8_t *p, const unsigned int level) switch (level) { default: - case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6)); - case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5)); - case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4)); - case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); - case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); - case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); - case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); + case 7: memmove(p + 20, BITMAP_ANTENNA_LEVEL6, sizeof(BITMAP_ANTENNA_LEVEL6)); + case 6: memmove(p + 17, BITMAP_ANTENNA_LEVEL5, sizeof(BITMAP_ANTENNA_LEVEL5)); + case 5: memmove(p + 14, BITMAP_ANTENNA_LEVEL4, sizeof(BITMAP_ANTENNA_LEVEL4)); + case 4: memmove(p + 11, BITMAP_ANTENNA_LEVEL3, sizeof(BITMAP_ANTENNA_LEVEL3)); + case 3: memmove(p + 8, BITMAP_ANTENNA_LEVEL2, sizeof(BITMAP_ANTENNA_LEVEL2)); + case 2: memmove(p + 5, BITMAP_ANTENNA_LEVEL1, sizeof(BITMAP_ANTENNA_LEVEL1)); + case 1: memmove(p + 0, BITMAP_ANTENNA, sizeof(BITMAP_ANTENNA)); case 0: break; } @@ -147,22 +147,22 @@ void UI_drawBars(uint8_t *p, const unsigned int level) void UI_DisplayAudioBar(void) { - if (gSetting_mic_bar) + if (g_setting_mic_bar) { const unsigned int line = 3; const unsigned int bar_x = 2; const unsigned int bar_width = LCD_WIDTH - 2 - bar_x; unsigned int i; - if (gCurrentFunction != FUNCTION_TRANSMIT || - gScreenToDisplay != DISPLAY_MAIN || - gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_current_function != FUNCTION_TRANSMIT || + g_screen_to_display != DISPLAY_MAIN || + g_dtmf_call_state != DTMF_CALL_STATE_NONE) { return; // screen is in use } #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - if (gAlarmState != ALARM_STATE_OFF) + if (g_alarm_state != ALARM_STATE_OFF) return; #endif @@ -191,7 +191,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level) #endif - uint8_t *p_line = gFrameBuffer[line]; + uint8_t *p_line = g_frame_buffer[line]; memset(p_line, 0, LCD_WIDTH); @@ -205,7 +205,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level) p_line[bar_x + i] = (i <= len) ? 0x7f : 0x41; #endif - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) ST7565_BlitFullScreen(); } } @@ -235,17 +235,17 @@ void UI_drawBars(uint8_t *p, const unsigned int level) const unsigned int len = ((clamped_dBm - bar_min_dBm) * bar_width) / bar_range_dB; const unsigned int line = 3; - uint8_t *p_line = gFrameBuffer[line]; + uint8_t *p_line = g_frame_buffer[line]; char s[16]; unsigned int i; - if (g_eeprom.key_lock && gKeypadLocked > 0) + if (g_eeprom.key_lock && g_keypad_locked > 0) return; // display is in use - if (gCurrentFunction == FUNCTION_TRANSMIT || - gScreenToDisplay != DISPLAY_MAIN || - gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_current_function == FUNCTION_TRANSMIT || + g_screen_to_display != DISPLAY_MAIN || + g_dtmf_call_state != DTMF_CALL_STATE_NONE) return; // display is in use if (now) @@ -290,9 +290,9 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) if (center_line != CENTER_LINE_RSSI) return; - if (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) + if (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) { UI_DisplayRSSIBar(rssi, true); } @@ -303,7 +303,7 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) // const int16_t dBm = (rssi / 2) - 160; const uint8_t Line = (vfo == 0) ? 3 : 7; - uint8_t *p_line = gFrameBuffer[Line - 1]; + uint8_t *p_line = g_frame_buffer[Line - 1]; // TODO: sort out all 8 values from the eeprom @@ -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 = 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]; + 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 @@ -327,7 +327,7 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) const int16_t level12 = (level1 + level2) / 2; const int16_t level23 = (level2 + level3) / 2; - gVFO_RSSI[vfo] = rssi; + g_vfo_rssi[vfo] = rssi; uint8_t rssi_level = 0; @@ -345,20 +345,20 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo) else if (rssi >= level0) rssi_level = 1; - if (gVFO_RSSI_bar_level[vfo] == rssi_level) + if (g_vfo_rssi_bar_level[vfo] == rssi_level) return; - gVFO_RSSI_bar_level[vfo] = rssi_level; + g_vfo_rssi_bar_level[vfo] = rssi_level; // ********************************************************** - if (g_eeprom.key_lock && gKeypadLocked > 0) + if (g_eeprom.key_lock && g_keypad_locked > 0) return; // display is in use - if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) + if (g_current_function == FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN) return; // display is in use - p_line = gFrameBuffer[Line - 1]; + p_line = g_frame_buffer[Line - 1]; memset(p_line, 0, 23); @@ -391,9 +391,9 @@ void UI_DisplayMain(void) // #endif // clear the screen - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); - if (g_eeprom.key_lock && gKeypadLocked > 0) + if (g_eeprom.key_lock && g_keypad_locked > 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); @@ -407,8 +407,8 @@ void UI_DisplayMain(void) 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]; + uint8_t *p_line0 = g_frame_buffer[line + 0]; + uint8_t *p_line1 = g_frame_buffer[line + 1]; unsigned int mode = 0; unsigned int state; @@ -421,46 +421,46 @@ void UI_DisplayMain(void) } - if (g_eeprom.dual_watch != DUAL_WATCH_OFF && gRxVfoIsActive) + if (g_eeprom.dual_watch != DUAL_WATCH_OFF && g_rx_vfo_is_active) channel = g_eeprom.rx_vfo; // we're currently monitoring the other VFO if (channel != vfo_num) { - if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) + if (g_dtmf_call_state != DTMF_CALL_STATE_NONE || g_dtmf_is_tx || g_dtmf_input_mode) { // show DTMF stuff char Contact[16]; - if (!gDTMF_InputMode) + if (!g_dtmf_input_mode) { memset(Contact, 0, sizeof(Contact)); - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) - strcpy(String, (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT"); + if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) + strcpy(String, (g_dtmf_state == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT"); else - if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) - sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller); + if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY) + sprintf(String, "CALL FRM:%s", (DTMF_FindContact(g_dtmf_caller, Contact)) ? Contact : g_dtmf_caller); else - if (gDTMF_IsTx) - strcpy(String, (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX"); + if (g_dtmf_is_tx) + strcpy(String, (g_dtmf_state == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX"); } else { - sprintf(String, ">%s", gDTMF_InputBox); + sprintf(String, ">%s", g_dtmf_input_box); } UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8); memset(String, 0, sizeof(String)); - if (!gDTMF_InputMode) + if (!g_dtmf_input_mode) { memset(Contact, 0, sizeof(Contact)); - if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) - sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String); + if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) + sprintf(String, ">%s", (DTMF_FindContact(g_dtmf_string, Contact)) ? Contact : g_dtmf_string); else - if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) - sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee); + if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY) + sprintf(String, ">%s", (DTMF_FindContact(g_dtmf_callee, Contact)) ? Contact : g_dtmf_callee); else - if (gDTMF_IsTx) - sprintf(String, ">%s", gDTMF_String); + if (g_dtmf_is_tx) + sprintf(String, ">%s", g_dtmf_string); } UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8); @@ -470,26 +470,26 @@ void UI_DisplayMain(void) // highlight the selected/used VFO with a marker if (!single_vfo && same_vfo) - memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memmove(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT)); else if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF) - memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + memmove(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT)); } else if (!single_vfo) { // highlight the selected/used VFO with a marker if (same_vfo) - memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memmove(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT)); else //if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF) - memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + memmove(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT)); } - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { // transmitting #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_ALARM) + if (g_alarm_state == ALARM_STATE_ALARM) mode = 2; else #endif @@ -509,9 +509,9 @@ void UI_DisplayMain(void) else { // receiving .. show the RX symbol mode = 2; - if ((gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) && + if ((g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) && g_eeprom.rx_vfo == vfo_num) { #ifdef ENABLE_SMALL_BOLD @@ -525,13 +525,13 @@ void UI_DisplayMain(void) if (g_eeprom.screen_channel[vfo_num] <= USER_CHANNEL_LAST) { // channel mode const unsigned int x = 2; - const bool inputting = (gInputBoxIndex == 0 || g_eeprom.tx_vfo != vfo_num) ? false : true; + const bool inputting = (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num) ? false : true; if (!inputting) 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 + memmove(String + 5, g_input_box, 3); // show the input text UI_PrintStringSmall("M", x, 0, line + 1); - UI_DisplaySmallDigits(3, String + 5, x + 7, line + 1, inputting); + UI_Displaysmall_digits(3, String + 5, x + 7, line + 1, inputting); } else if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num])) @@ -545,13 +545,13 @@ void UI_DisplayMain(void) #ifdef ENABLE_NOAA else { - if (gInputBoxIndex == 0 || g_eeprom.tx_vfo != vfo_num) + if (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num) { // channel number sprintf(String, "N%u", 1 + g_eeprom.screen_channel[vfo_num] - NOAA_CHANNEL_FIRST); } else { // user entering channel number - sprintf(String, "N%u%u", '0' + gInputBox[0], '0' + gInputBox[1]); + sprintf(String, "N%u%u", '0' + g_input_box[0], '0' + g_input_box[1]); } UI_PrintStringSmall(String, 7, 0, line + 1); } @@ -559,10 +559,10 @@ void UI_DisplayMain(void) // ************ - state = VfoState[vfo_num]; + state = g_vfo_state[vfo_num]; #ifdef ENABLE_ALARM - if (gCurrentFunction == FUNCTION_TRANSMIT && gAlarmState == ALARM_STATE_ALARM) + if (g_current_function == FUNCTION_TRANSMIT && g_alarm_state == ALARM_STATE_ALARM) { channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo; if (channel == vfo_num) @@ -577,34 +577,34 @@ void UI_DisplayMain(void) UI_PrintString(state_list[state], 31, 0, line, 8); } else - if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]) && g_eeprom.tx_vfo == vfo_num) + if (g_input_box_index > 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); + UI_DisplayFrequency(g_input_box, 32, line, true, false); // center_line = CENTER_LINE_IN_USE; } else { - uint32_t frequency = g_eeprom.VfoInfo[vfo_num].pRX->frequency; - if (gCurrentFunction == FUNCTION_TRANSMIT) + uint32_t frequency = g_eeprom.vfo_info[vfo_num].pRX->frequency; + if (g_current_function == FUNCTION_TRANSMIT) { // transmitting channel = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.rx_vfo : g_eeprom.tx_vfo; if (channel == vfo_num) - frequency = g_eeprom.VfoInfo[vfo_num].pTX->frequency; + frequency = g_eeprom.vfo_info[vfo_num].pTX->frequency; } if (g_eeprom.screen_channel[vfo_num] <= USER_CHANNEL_LAST) { // it's a channel // show the channel symbols - const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]]; + const uint8_t attributes = g_user_channel_attributes[g_eeprom.screen_channel[vfo_num]]; if (attributes & USER_CH_SCANLIST1) - memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + memmove(p_line0 + 113, BITMAP_SCANLIST1, sizeof(BITMAP_SCANLIST1)); if (attributes & USER_CH_SCANLIST2) - memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + memmove(p_line0 + 120, BITMAP_SCANLIST2, sizeof(BITMAP_SCANLIST2)); #ifndef ENABLE_BIG_FREQ if ((attributes & USER_CH_COMPAND) > 0) - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_COMPAND, sizeof(BITMAP_COMPAND)); #else // TODO: // find somewhere else to put the symbol @@ -622,7 +622,7 @@ void UI_DisplayMain(void) // show the main large frequency digits UI_DisplayFrequency(String, 32, line, false, false); // show the remaining 2 small frequency digits - UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true); + UI_Displaysmall_digits(2, String + 6, 113, line + 1, true); #else // show the frequency in the main font sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); @@ -673,7 +673,7 @@ void UI_DisplayMain(void) // show the main large frequency digits UI_DisplayFrequency(String, 32, line, false, false); // show the remaining 2 small frequency digits - UI_DisplaySmallDigits(2, String + 6, 113, line + 1, true); + UI_Displaysmall_digits(2, String + 6, 113, line + 1, true); #else // show the frequency in the main font sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); @@ -681,12 +681,12 @@ void UI_DisplayMain(void) #endif // show the channel symbols - const uint8_t attributes = gUSER_ChannelAttributes[g_eeprom.screen_channel[vfo_num]]; + const uint8_t attributes = g_user_channel_attributes[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)); + memmove(p_line0 + 120, BITMAP_COMPAND, sizeof(BITMAP_COMPAND)); #else - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_COMPAND, sizeof(BITMAP_COMPAND)); #endif } } @@ -698,7 +698,7 @@ void UI_DisplayMain(void) if (mode == 1) { // TX power level - switch (gRxVfo->output_power) + switch (g_rx_vfo->output_power) { case OUTPUT_POWER_LOW: Level = 2; break; case OUTPUT_POWER_MID: Level = 4; break; @@ -710,8 +710,8 @@ void UI_DisplayMain(void) { // RX signal level #ifndef ENABLE_RSSI_BAR // bar graph - if (gVFO_RSSI_bar_level[vfo_num] > 0) - Level = gVFO_RSSI_bar_level[vfo_num]; + if (g_vfo_rssi_bar_level[vfo_num] > 0) + Level = g_vfo_rssi_bar_level[vfo_num]; #endif } @@ -721,13 +721,13 @@ void UI_DisplayMain(void) // ************ String[0] = '\0'; - if (g_eeprom.VfoInfo[vfo_num].am_mode) + if (g_eeprom.vfo_info[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) ? g_eeprom.VfoInfo[vfo_num].pTX : g_eeprom.VfoInfo[vfo_num].pRX; + const freq_config_t *pConfig = (mode == 1) ? g_eeprom.vfo_info[vfo_num].pTX : g_eeprom.vfo_info[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)) @@ -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 = g_eeprom.VfoInfo[vfo_num].output_power; + const unsigned int i = g_eeprom.vfo_info[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 (g_eeprom.VfoInfo[vfo_num].freq_config_rx.frequency != g_eeprom.VfoInfo[vfo_num].freq_config_tx.frequency) + if (g_eeprom.vfo_info[vfo_num].freq_config_rx.frequency != g_eeprom.vfo_info[vfo_num].freq_config_tx.frequency) { // show the TX offset symbol const char dir_list[] = "\0+-"; - const unsigned int i = g_eeprom.VfoInfo[vfo_num].tx_offset_freq_dir; + const unsigned int i = g_eeprom.vfo_info[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 (g_eeprom.VfoInfo[vfo_num].frequency_reverse) + if (g_eeprom.vfo_info[vfo_num].frequency_reverse) UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1); { // show the narrow band symbol String[0] = '\0'; - if (g_eeprom.VfoInfo[vfo_num].channel_bandwidth == BANDWIDTH_NARROW) + if (g_eeprom.vfo_info[vfo_num].channel_bandwidth == BANDWIDTH_NARROW) { String[0] = 'N'; String[1] = '\0'; @@ -768,20 +768,20 @@ void UI_DisplayMain(void) } // show the DTMF decoding symbol - if (g_eeprom.VfoInfo[vfo_num].DTMF_decoding_enable || gSetting_KILLED) + if (g_eeprom.vfo_info[vfo_num].dtmf_decoding_enable || g_setting_killed) UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, line + 1); // show the audio scramble symbol - if (g_eeprom.VfoInfo[vfo_num].scrambling_type > 0 && gSetting_ScrambleEnable) + if (g_eeprom.vfo_info[vfo_num].scrambling_type > 0 && g_setting_scramble_enable) UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1); } if (center_line == CENTER_LINE_NONE) { // we're free to use the middle line - const bool rx = (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING); + const bool rx = (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING); #ifdef ENABLE_SHOW_TX_TIMEOUT // show the TX timeout count down @@ -794,7 +794,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_AUDIO_BAR // show the TX audio level - if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) + if (g_setting_mic_bar && g_current_function == FUNCTION_TRANSMIT) { center_line = CENTER_LINE_AUDIO_BAR; UI_DisplayAudioBar(); @@ -804,9 +804,9 @@ void UI_DisplayMain(void) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) // show the AM-FIX debug data - if (rx && g_eeprom.VfoInfo[g_eeprom.rx_vfo].am_mode && gSetting_AM_fix) + if (rx && g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix) { - if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) return; center_line = CENTER_LINE_AM_FIX_DATA; @@ -821,57 +821,57 @@ void UI_DisplayMain(void) if (rx) { center_line = CENTER_LINE_RSSI; - UI_DisplayRSSIBar(gCurrentRSSI[g_eeprom.rx_vfo], false); + UI_DisplayRSSIBar(g_current_rssi[g_eeprom.rx_vfo], false); } else #endif - if (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE) + if (rx || g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE) { #if 1 - if (gSetting_live_DTMF_decoder && gDTMF_RX_live[0] != 0) + if (g_setting_live_dtmf_decoder && g_dtmf_rx_live[0] != 0) { // show live DTMF decode - const unsigned int len = strlen(gDTMF_RX_live); + const unsigned int len = strlen(g_dtmf_rx_live); const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars - if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) return; center_line = CENTER_LINE_DTMF_DEC; strcpy(String, "DTMF "); - strcat(String, gDTMF_RX_live + idx); + strcat(String, g_dtmf_rx_live + idx); UI_PrintStringSmall(String, 2, 0, 3); } #else - if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0) + if (g_setting_live_dtmf_decoder && g_dtmf_rx_index > 0) { // show live DTMF decode - const unsigned int len = gDTMF_RX_index; + const unsigned int len = g_dtmf_rx_index; const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars - if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) return; center_line = CENTER_LINE_DTMF_DEC; strcpy(String, "DTMF "); - strcat(String, gDTMF_RX + idx); + strcat(String, g_dtmf_rx + idx); UI_PrintStringSmall(String, 2, 0, 3); } #endif #ifdef ENABLE_SHOW_CHARGE_LEVEL else - if (gChargingWithTypeC) + if (g_charging_with_type_c) { // show the battery charge state - if (gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) return; center_line = CENTER_LINE_CHARGE_DATA; sprintf(String, "Charge %u.%02uV %u%%", - gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage)); + g_battery_voltage_average / 100, g_battery_voltage_average % 100, + BATTERY_VoltsToPercent(g_battery_voltage_average)); UI_PrintStringSmall(String, 2, 0, 3); } #endif diff --git a/ui/main.h b/ui/main.h index 8f3bbad6..b3e756ff 100644 --- a/ui/main.h +++ b/ui/main.h @@ -17,7 +17,7 @@ #ifndef UI_MAIN_H #define UI_MAIN_H -enum center_line_t { +enum center_line_e { CENTER_LINE_NONE = 0, CENTER_LINE_IN_USE, CENTER_LINE_TX_TIMEOUT, @@ -27,7 +27,7 @@ enum center_line_t { CENTER_LINE_DTMF_DEC, CENTER_LINE_CHARGE_DATA }; -typedef enum center_line_t center_line_t; +typedef enum center_line_e center_line_t; extern center_line_t center_line; diff --git a/ui/menu.c b/ui/menu.c index b4b84b2e..564145b3 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -41,7 +41,7 @@ // // the order of entries in this list below is no longer important, no longer has to match the enum list -const t_menu_item MenuList[] = +const t_menu_item g_menu_list[] = { // text, voice ID, menu ID @@ -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_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 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" @@ -140,37 +140,37 @@ const t_menu_item MenuList[] = }; // number of hidden menu items at the end of the list - KEEP THIS UP-TO-DATE -const unsigned int gHidden_menu_count = 9; +const unsigned int g_hidden_menu_count = 9; // *************************************************************************************** -const char gSubMenu_TXP[3][5] = +const char g_sub_menu_txp[3][5] = { "LOW", "MID", "HIGH" }; -const char gSubMenu_SFT_D[3][4] = +const char g_sub_menu_shift_dir[3][4] = { "OFF", "+", "-" }; -const char gSubMenu_W_N[2][7] = +const char g_sub_menu_w_n[2][7] = { "WIDE", "NARROW" }; -const char gSubMenu_OFF_ON[2][4] = +const char g_sub_menu_off_on[2][4] = { "OFF", "ON" }; -const char gSubMenu_SAVE[5][4] = +const char g_sub_menu_SAVE[5][4] = { "OFF", "1:1", @@ -179,7 +179,7 @@ const char gSubMenu_SAVE[5][4] = "1:4" }; -const char gSubMenu_TOT[11][7] = +const char g_sub_menu_TOT[11][7] = { "30 sec", "1 min", @@ -194,14 +194,14 @@ const char gSubMenu_TOT[11][7] = "15 min" }; -const char gSubMenu_TDR[3][10] = +const char g_sub_menu_tdr[3][10] = { "OFF", "LOWER\nVFO", "UPPER\nVFO", }; -const char gSubMenu_XB[3][10] = +const char g_sub_menu_xb[3][10] = { "RX\nVFO", "UPPER\nVFO", @@ -209,7 +209,7 @@ const char gSubMenu_XB[3][10] = }; #ifdef ENABLE_VOICE - const char gSubMenu_VOICE[3][4] = + const char g_sub_menu_voice[3][4] = { "OFF", "CHI", @@ -217,14 +217,14 @@ const char gSubMenu_XB[3][10] = }; #endif -const char gSubMenu_SC_REV[3][13] = +const char g_sub_menu_sc_rev[3][13] = { "TIME", "CARRIER", "SEARCH" }; -const char gSubMenu_MDF[4][15] = +const char g_sub_menu_mdf[4][15] = { "FREQ", "CHANNEL\nNUMBER", @@ -233,14 +233,14 @@ const char gSubMenu_MDF[4][15] = }; #ifdef ENABLE_ALARM - const char gSubMenu_AL_MOD[2][5] = + const char g_sub_menu_AL_MOD[2][5] = { "SITE", "TONE" }; #endif -const char gSubMenu_D_RSP[4][11] = +const char g_sub_menu_D_RSP[4][11] = { "DO\nNOTHING", "RING", @@ -248,7 +248,7 @@ const char gSubMenu_D_RSP[4][11] = "BOTH" }; -const char gSubMenu_PTT_ID[5][15] = +const char g_sub_menu_PTT_ID[5][15] = { "OFF", "KEY\nUP", @@ -257,7 +257,7 @@ const char gSubMenu_PTT_ID[5][15] = "APOLLO\nQUINDAR" }; -const char gSubMenu_PONMSG[4][8] = +const char g_sub_menu_pwr_on_msg[4][8] = { "FULL", "MESSAGE", @@ -265,20 +265,20 @@ const char gSubMenu_PONMSG[4][8] = "NONE" }; -const char gSubMenu_ROGER[3][9] = +const char g_sub_menu_roger_mode[3][9] = { "OFF", "ROGER", "MDC\n1200" }; -const char gSubMenu_RESET[2][4] = +const char g_sub_menu_RESET[2][4] = { "VFO", "ALL" }; -const char gSubMenu_F_LOCK[6][4] = +const char g_sub_menu_f_lock[6][4] = { "OFF", "FCC", @@ -288,7 +288,7 @@ const char gSubMenu_F_LOCK[6][4] = "438" }; -const char gSubMenu_backlight[8][7] = +const char g_sub_menu_backlight[8][7] = { "OFF", "5 sec", @@ -300,7 +300,7 @@ const char gSubMenu_backlight[8][7] = "ON" }; -const char gSubMenu_RX_TX[4][6] = +const char g_sub_menu_rx_tx[4][6] = { "OFF", "TX", @@ -309,7 +309,7 @@ const char gSubMenu_RX_TX[4][6] = }; #ifdef ENABLE_AM_FIX_TEST1 - const char gSubMenu_AM_fix_test1[4][8] = + const char g_sub_menu_AM_fix_test1[4][8] = { "LNA-S 0", "LNA-S 1", @@ -318,14 +318,14 @@ const char gSubMenu_RX_TX[4][6] = }; #endif -const char gSubMenu_BAT_TXT[3][8] = +const char g_sub_menu_BAT_TXT[3][8] = { "NONE", "VOLTAGE", "PERCENT" }; -const char gSubMenu_SCRAMBLER[11][7] = +const char g_sub_menu_SCRAMBLER[11][7] = { "OFF", "2600Hz", @@ -340,8 +340,8 @@ const char gSubMenu_SCRAMBLER[11][7] = "3500Hz" }; -const char gSubMenu_SIDE_BUTT[9][16] = -//const char gSubMenu_SIDE_BUTT[10][16] = +const char g_sub_menu_SIDE_BUTT[9][16] = +//const char g_sub_menu_SIDE_BUTT[10][16] = { "NONE", "FLASH\nLIGHT", @@ -357,17 +357,17 @@ const char gSubMenu_SIDE_BUTT[9][16] = // *************************************************************************************** -uint8_t MenuList_sorted[ARRAY_SIZE(MenuList)]; +uint8_t g_menu_list_sorted[ARRAY_SIZE(g_menu_list)]; -bool gIsInSubMenu; -uint8_t gMenuCursor; -int8_t gMenuScrollDirection; -int32_t gSubMenuSelection; +bool g_is_in_sub_menu; +uint8_t g_menu_cursor; +int8_t g_menu_scroll_direction; +int32_t g_sub_menu_selection; // edit box -char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/differences -char edit[17]; -int edit_index; +char g_edit_original[17]; // a copy of the text before editing so that we can easily test for changes/differences +char g_edit[17]; +int g_edit_index; // *************************************************************************************** @@ -377,42 +377,42 @@ void UI_SortMenu(const bool hide_hidden) // // this means the menu order is entirely determined by the enum list (found in id/menu.h) // it now no longer depends on the order of entries in the above const list (they can be any order) - + unsigned int i; - unsigned int hidden_menu_count = gHidden_menu_count; + unsigned int hidden_menu_count = g_hidden_menu_count; #ifndef ENABLE_F_CAL_MENU hidden_menu_count--; #endif - gMenuListCount = ARRAY_SIZE(MenuList_sorted); + g_menu_list_count = ARRAY_SIZE(g_menu_list_sorted); - for (i = 0; i < gMenuListCount; i++) - MenuList_sorted[i] = MenuList[i].menu_id; + for (i = 0; i < g_menu_list_count; i++) + g_menu_list_sorted[i] = g_menu_list[i].menu_id; // don't sort the hidden entries at the end, keep them at the end of the list - for (i = 0; i < (gMenuListCount - hidden_menu_count - 1); i++) + for (i = 0; i < (g_menu_list_count - hidden_menu_count - 1); i++) { unsigned int k; - unsigned int menu_id1 = MenuList_sorted[i]; - for (k = i + 1; k < (gMenuListCount - hidden_menu_count); k++) + unsigned int menu_id1 = g_menu_list_sorted[i]; + for (k = i + 1; k < (g_menu_list_count - hidden_menu_count); k++) { - unsigned int menu_id2 = MenuList_sorted[k]; + unsigned int menu_id2 = g_menu_list_sorted[k]; if (menu_id2 < menu_id1) { // swap const unsigned int id = menu_id1; menu_id1 = menu_id2; menu_id2 = id; - MenuList_sorted[i] = menu_id1; - MenuList_sorted[k] = menu_id2; + g_menu_list_sorted[i] = menu_id1; + g_menu_list_sorted[k] = menu_id2; } } } if (hide_hidden) - gMenuListCount -= hidden_menu_count; // hide the hidden menu items + g_menu_list_count -= hidden_menu_count; // hide the hidden menu items } void UI_DisplayMenu(void) @@ -425,78 +425,78 @@ void UI_DisplayMenu(void) char Contact[16]; // clear the screen buffer - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); #if 0 // original menu layout for (i = 0; i < 3; i++) - if (gMenuCursor > 0 || i > 0) - if ((gMenuListCount - 1) != gMenuCursor || i != 2) - UI_PrintString(MenuList[MenuList_sorted[gMenuCursor + i - 1]].name, 0, 0, i * 2, 8); + if (g_menu_cursor > 0 || i > 0) + if ((g_menu_list_count - 1) != g_menu_cursor || i != 2) + UI_PrintString(g_menu_list[g_menu_list_sorted[g_menu_cursor + i - 1]].name, 0, 0, i * 2, 8); // invert the current menu list item pixels for (i = 0; i < (8 * menu_list_width); i++) { - gFrameBuffer[2][i] ^= 0xFF; - gFrameBuffer[3][i] ^= 0xFF; + g_frame_buffer[2][i] ^= 0xFF; + g_frame_buffer[3][i] ^= 0xFF; } // draw vertical separating dotted line for (i = 0; i < 7; i++) - gFrameBuffer[i][(8 * menu_list_width) + 1] = 0xAA; + g_frame_buffer[i][(8 * menu_list_width) + 1] = 0xAA; // draw the little sub-menu triangle marker - if (gIsInSubMenu) - memmove(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); + if (g_is_in_sub_menu) + memmove(g_frame_buffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); // draw the menu index number/count - sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); + sprintf(String, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count); UI_PrintStringSmall(String, 2, 0, 6); #else { // new menu layout .. experimental & unfinished - const int menu_index = gMenuCursor; // current selected menu item + const int menu_index = g_menu_cursor; // current selected menu item i = 1; - if (!gIsInSubMenu) + if (!g_is_in_sub_menu) { while (i < 2) { // leading menu items - small text const int k = menu_index + i - 2; if (k < 0) - UI_PrintStringSmall(MenuList[MenuList_sorted[gMenuListCount + k]].name, 0, 0, i); // wrap-a-round + UI_PrintStringSmall(g_menu_list[g_menu_list_sorted[g_menu_list_count + k]].name, 0, 0, i); // wrap-a-round else - if (k >= 0 && k < (int)gMenuListCount) - UI_PrintStringSmall(MenuList[MenuList_sorted[k]].name, 0, 0, i); + if (k >= 0 && k < (int)g_menu_list_count) + UI_PrintStringSmall(g_menu_list[g_menu_list_sorted[k]].name, 0, 0, i); i++; } // current menu item - keep big n fat - if (menu_index >= 0 && menu_index < (int)gMenuListCount) - UI_PrintString(MenuList[MenuList_sorted[menu_index]].name, 0, 0, 2, 8); + if (menu_index >= 0 && menu_index < (int)g_menu_list_count) + UI_PrintString(g_menu_list[g_menu_list_sorted[menu_index]].name, 0, 0, 2, 8); i++; while (i < 4) { // trailing menu item - small text const int k = menu_index + i - 2; - if (k >= 0 && k < (int)gMenuListCount) - UI_PrintStringSmall(MenuList[MenuList_sorted[k]].name, 0, 0, 1 + i); + if (k >= 0 && k < (int)g_menu_list_count) + UI_PrintStringSmall(g_menu_list[g_menu_list_sorted[k]].name, 0, 0, 1 + i); else - if (k >= (int)gMenuListCount) - UI_PrintStringSmall(MenuList[MenuList_sorted[gMenuListCount - k]].name, 0, 0, 1 + i); // wrap-a-round + if (k >= (int)g_menu_list_count) + UI_PrintStringSmall(g_menu_list[g_menu_list_sorted[g_menu_list_count - k]].name, 0, 0, 1 + i); // wrap-a-round i++; } // draw the menu index number/count - sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); + sprintf(String, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count); UI_PrintStringSmall(String, 2, 0, 6); } else - if (menu_index >= 0 && menu_index < (int)gMenuListCount) + if (menu_index >= 0 && menu_index < (int)g_menu_list_count) { // current menu item - strcpy(String, MenuList[MenuList_sorted[menu_index]].name); + strcpy(String, g_menu_list[g_menu_list_sorted[menu_index]].name); // strcat(String, ":"); UI_PrintString(String, 0, 0, 0, 8); // UI_PrintStringSmall(String, 0, 0, 0); @@ -513,42 +513,42 @@ void UI_DisplayMenu(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" - switch (gMenuCursor) + switch (g_menu_cursor) { case MENU_SQL: - sprintf(String, "%d", gSubMenuSelection); + sprintf(String, "%d", g_sub_menu_selection); break; case MENU_MIC: { // display the mic gain in actual dB rather than just an index number - const uint8_t mic = gMicGain_dB2[gSubMenuSelection]; + const uint8_t mic = g_mic_gain_dB_2[g_sub_menu_selection]; sprintf(String, "+%u.%01udB", mic / 2, mic % 2); } break; #ifdef ENABLE_AUDIO_BAR case MENU_MIC_BAR: - strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); + strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]); break; #endif case MENU_STEP: - sprintf(String, "%d.%02ukHz", StepFrequencyTable[gSubMenuSelection] / 100, abs(StepFrequencyTable[gSubMenuSelection]) % 100); + sprintf(String, "%d.%02ukHz", STEP_FREQ_TABLE[g_sub_menu_selection] / 100, abs(STEP_FREQ_TABLE[g_sub_menu_selection]) % 100); break; case MENU_TXP: - strcpy(String, gSubMenu_TXP[gSubMenuSelection]); + strcpy(String, g_sub_menu_txp[g_sub_menu_selection]); break; case MENU_R_DCS: case MENU_T_DCS: - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) strcpy(String, "OFF"); else - if (gSubMenuSelection < 105) - sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]); + if (g_sub_menu_selection < 105) + sprintf(String, "D%03oN", DCS_OPTIONS[g_sub_menu_selection - 1]); else - sprintf(String, "D%03oI", DCS_Options[gSubMenuSelection - 105]); + sprintf(String, "D%03oI", DCS_OPTIONS[g_sub_menu_selection - 105]); break; case MENU_R_CTCS: @@ -556,8 +556,8 @@ 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; - if (gSubMenuSelection == 0) + freq_config_t *pConfig = (g_menu_cursor == MENU_R_CTCS) ? &g_tx_vfo->freq_config_rx : &g_tx_vfo->freq_config_tx; + if (g_sub_menu_selection == 0) { strcpy(String, "OFF"); @@ -571,41 +571,41 @@ void UI_DisplayMenu(void) } else { - sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); + sprintf(String, "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10); pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE; - Code = gSubMenuSelection - 1; + Code = g_sub_menu_selection - 1; pConfig->code = Code; - BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); + BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]); } #else - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) strcpy(String, "OFF"); else - sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); + sprintf(String, "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10); #endif break; } case MENU_SFT_D: - strcpy(String, gSubMenu_SFT_D[gSubMenuSelection]); + strcpy(String, g_sub_menu_shift_dir[g_sub_menu_selection]); break; case MENU_OFFSET: - if (!gIsInSubMenu || gInputBoxIndex == 0) + if (!g_is_in_sub_menu || g_input_box_index == 0) { - sprintf(String, "%d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000); + sprintf(String, "%d.%05u", g_sub_menu_selection / 100000, abs(g_sub_menu_selection) % 100000); UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8); } else { for (i = 0; i < 3; i++) - String[i ] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + String[i ] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; String[3] = '.'; for (i = 3; i < 6; i++) - String[i + 1] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; + String[i + 1] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; String[ 7] = '-'; String[ 8] = '-'; String[ 9] = 0; @@ -620,14 +620,14 @@ void UI_DisplayMenu(void) break; case MENU_W_N: - strcpy(String, gSubMenu_W_N[gSubMenuSelection]); + strcpy(String, g_sub_menu_w_n[g_sub_menu_selection]); break; case MENU_SCR: - strcpy(String, gSubMenu_SCRAMBLER[gSubMenuSelection]); + strcpy(String, g_sub_menu_SCRAMBLER[g_sub_menu_selection]); #if 1 - if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gSubMenuSelection - 1); + if (g_sub_menu_selection > 0 && g_setting_scramble_enable) + BK4819_EnableScramble(g_sub_menu_selection - 1); else BK4819_DisableScramble(); #endif @@ -635,35 +635,35 @@ void UI_DisplayMenu(void) #ifdef ENABLE_VOX case MENU_VOX: - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) strcpy(String, "OFF"); else - sprintf(String, "%d", gSubMenuSelection); + sprintf(String, "%d", g_sub_menu_selection); break; #endif case MENU_ABR: - strcpy(String, gSubMenu_backlight[gSubMenuSelection]); + strcpy(String, g_sub_menu_backlight[g_sub_menu_selection]); break; case MENU_AM: - strcpy(String, (gSubMenuSelection == 0) ? "FM" : "AM"); + strcpy(String, (g_sub_menu_selection == 0) ? "FM" : "AM"); break; #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: - strcpy(String, gSubMenu_AM_fix_test1[gSubMenuSelection]); -// gSetting_AM_fix = gSubMenuSelection; + strcpy(String, g_sub_menu_AM_fix_test1[g_sub_menu_selection]); +// g_setting_am_fix = g_sub_menu_selection; break; #endif case MENU_AUTOLK: - strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO"); + strcpy(String, (g_sub_menu_selection == 0) ? "OFF" : "AUTO"); break; case MENU_COMPAND: case MENU_ABR_ON_TX_RX: - strcpy(String, gSubMenu_RX_TX[gSubMenuSelection]); + strcpy(String, g_sub_menu_rx_tx[g_sub_menu_selection]); break; #ifdef ENABLE_AM_FIX @@ -686,21 +686,21 @@ void UI_DisplayMenu(void) case MENU_350EN: case MENU_SCREN: case MENU_TX_EN: - strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); + strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]); break; case MENU_MEM_CH: case MENU_1_CALL: case MENU_DEL_CH: { - const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0); + const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0); - UI_GenerateChannelStringEx(String, valid, gSubMenuSelection); + UI_GenerateChannelStringEx(String, valid, g_sub_menu_selection); UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); - if (valid && !gAskForConfirmation) + if (valid && !g_ask_for_confirmation) { // show the frequency so that the user knows the channels frequency - const uint32_t frequency = BOARD_fetchChannelFrequency(gSubMenuSelection); + const uint32_t frequency = BOARD_fetchChannelFrequency(g_sub_menu_selection); sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); } @@ -711,33 +711,33 @@ void UI_DisplayMenu(void) case MENU_MEM_NAME: { - const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0); + const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0); - UI_GenerateChannelStringEx(String, valid, gSubMenuSelection); + UI_GenerateChannelStringEx(String, valid, g_sub_menu_selection); UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); if (valid) { - const uint32_t frequency = BOARD_fetchChannelFrequency(gSubMenuSelection); + const uint32_t frequency = BOARD_fetchChannelFrequency(g_sub_menu_selection); - if (!gIsInSubMenu || edit_index < 0) + if (!g_is_in_sub_menu || g_edit_index < 0) { // show the channel name - BOARD_fetchChannelName(String, gSubMenuSelection); + BOARD_fetchChannelName(String, g_sub_menu_selection); if (String[0] == 0) strcpy(String, "--"); UI_PrintString(String, menu_item_x1, menu_item_x2, 2, 8); } else { // show the channel name being edited - UI_PrintString(edit, menu_item_x1, 0, 2, 8); - if (edit_index < 10) - UI_PrintString( "^", menu_item_x1 + (8 * edit_index), 0, 4, 8); // show the cursor + UI_PrintString(g_edit, menu_item_x1, 0, 2, 8); + if (g_edit_index < 10) + UI_PrintString("^", menu_item_x1 + (8 * g_edit_index), 0, 4, 8); // show the cursor } - if (!gAskForConfirmation) + if (!g_ask_for_confirmation) { // show the frequency so that the user knows the channels frequency sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); - if (!gIsInSubMenu || edit_index < 0) + if (!g_is_in_sub_menu || g_edit_index < 0) UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); else UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8); @@ -749,158 +749,158 @@ void UI_DisplayMenu(void) } case MENU_SAVE: - strcpy(String, gSubMenu_SAVE[gSubMenuSelection]); + strcpy(String, g_sub_menu_SAVE[g_sub_menu_selection]); break; case MENU_TDR: -// strcpy(String, gSubMenu_TDR[gSubMenuSelection]); - strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); +// strcpy(String, g_sub_menu_tdr[g_sub_menu_selection]); + strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]); break; case MENU_XB: - strcpy(String, gSubMenu_XB[gSubMenuSelection]); + strcpy(String, g_sub_menu_xb[g_sub_menu_selection]); break; case MENU_TOT: - strcpy(String, gSubMenu_TOT[gSubMenuSelection]); + strcpy(String, g_sub_menu_TOT[g_sub_menu_selection]); break; #ifdef ENABLE_VOICE case MENU_VOICE: - strcpy(String, gSubMenu_VOICE[gSubMenuSelection]); + strcpy(String, g_sub_menu_voice[g_sub_menu_selection]); break; #endif case MENU_SC_REV: - strcpy(String, gSubMenu_SC_REV[gSubMenuSelection]); + strcpy(String, g_sub_menu_sc_rev[g_sub_menu_selection]); break; case MENU_MDF: - strcpy(String, gSubMenu_MDF[gSubMenuSelection]); + strcpy(String, g_sub_menu_mdf[g_sub_menu_selection]); break; case MENU_RP_STE: - if (gSubMenuSelection == 0) + if (g_sub_menu_selection == 0) strcpy(String, "OFF"); else - sprintf(String, "%d*100ms", gSubMenuSelection); + sprintf(String, "%d*100ms", g_sub_menu_selection); break; case MENU_S_LIST: - if (gSubMenuSelection < 2) - sprintf(String, "LIST%u", 1 + gSubMenuSelection); + if (g_sub_menu_selection < 2) + sprintf(String, "LIST%u", 1 + g_sub_menu_selection); else strcpy(String, "ALL"); break; #ifdef ENABLE_ALARM case MENU_AL_MOD: - sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]); + sprintf(String, g_sub_menu_AL_MOD[g_sub_menu_selection]); break; #endif case MENU_ANI_ID: - strcpy(String, g_eeprom.ani_DTMF_id); + strcpy(String, g_eeprom.ani_dtmf_id); break; case MENU_UPCODE: - strcpy(String, g_eeprom.DTMF_up_code); + strcpy(String, g_eeprom.dtmf_up_code); break; case MENU_DWCODE: - strcpy(String, g_eeprom.DTMF_down_code); + strcpy(String, g_eeprom.dtmf_down_code); break; case MENU_D_RSP: - strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]); + strcpy(String, g_sub_menu_D_RSP[g_sub_menu_selection]); break; case MENU_D_HOLD: // only allow 5, 10, 20, 30, 40, 50 or "STAY ON SCREEN" (60) - switch (gSubMenuSelection) + switch (g_sub_menu_selection) { - case 4: gSubMenuSelection = 60; break; - case 6: gSubMenuSelection = 10; break; - case 9: gSubMenuSelection = 5; break; - case 11: gSubMenuSelection = 20; break; - case 19: gSubMenuSelection = 10; break; - case 21: gSubMenuSelection = 30; break; - case 29: gSubMenuSelection = 20; break; - case 31: gSubMenuSelection = 40; break; - case 39: gSubMenuSelection = 30; break; - case 41: gSubMenuSelection = 50; break; - case 49: gSubMenuSelection = 40; break; - case 51: gSubMenuSelection = 60; break; - case 59: gSubMenuSelection = 50; break; - case 61: gSubMenuSelection = 5; break; + case 4: g_sub_menu_selection = 60; break; + case 6: g_sub_menu_selection = 10; break; + case 9: g_sub_menu_selection = 5; break; + case 11: g_sub_menu_selection = 20; break; + case 19: g_sub_menu_selection = 10; break; + case 21: g_sub_menu_selection = 30; break; + case 29: g_sub_menu_selection = 20; break; + case 31: g_sub_menu_selection = 40; break; + case 39: g_sub_menu_selection = 30; break; + case 41: g_sub_menu_selection = 50; break; + case 49: g_sub_menu_selection = 40; break; + case 51: g_sub_menu_selection = 60; break; + case 59: g_sub_menu_selection = 50; break; + case 61: g_sub_menu_selection = 5; break; } - - if (gSubMenuSelection < DTMF_HOLD_MAX) - sprintf(String, "%d sec", gSubMenuSelection); + + if (g_sub_menu_selection < DTMF_HOLD_MAX) + sprintf(String, "%d sec", g_sub_menu_selection); else strcpy(String, "STAY ON\nSCREEN"); // 60 break; case MENU_D_PRE: - sprintf(String, "%d*10ms", gSubMenuSelection); + sprintf(String, "%d*10ms", g_sub_menu_selection); break; case MENU_PTT_ID: - strcpy(String, gSubMenu_PTT_ID[gSubMenuSelection]); + strcpy(String, g_sub_menu_PTT_ID[g_sub_menu_selection]); break; case MENU_BAT_TXT: - strcpy(String, gSubMenu_BAT_TXT[gSubMenuSelection]); + strcpy(String, g_sub_menu_BAT_TXT[g_sub_menu_selection]); break; case MENU_D_LIST: - gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); - if (!gIsDtmfContactValid) + g_dtmf_is_contact_valid = DTMF_GetContact((int)g_sub_menu_selection - 1, Contact); + if (!g_dtmf_is_contact_valid) strcpy(String, "NULL"); else memmove(String, Contact, 8); break; case MENU_PONMSG: - strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]); + strcpy(String, g_sub_menu_pwr_on_msg[g_sub_menu_selection]); break; case MENU_ROGER: - strcpy(String, gSubMenu_ROGER[gSubMenuSelection]); + strcpy(String, g_sub_menu_roger_mode[g_sub_menu_selection]); break; case MENU_VOL: sprintf(String, "%u.%02uV\n%u%%", - gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage)); + g_battery_voltage_average / 100, g_battery_voltage_average % 100, + BATTERY_VoltsToPercent(g_battery_voltage_average)); break; case MENU_SIDE1_SHORT: case MENU_SIDE1_LONG: case MENU_SIDE2_SHORT: case MENU_SIDE2_LONG: - strcpy(String, gSubMenu_SIDE_BUTT[gSubMenuSelection]); + strcpy(String, g_sub_menu_SIDE_BUTT[g_sub_menu_selection]); break; case MENU_RESET: - strcpy(String, gSubMenu_RESET[gSubMenuSelection]); + strcpy(String, g_sub_menu_RESET[g_sub_menu_selection]); break; case MENU_F_LOCK: - strcpy(String, gSubMenu_F_LOCK[gSubMenuSelection]); + strcpy(String, g_sub_menu_f_lock[g_sub_menu_selection]); break; #ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: { - const uint32_t value = 22656 + gSubMenuSelection; + const uint32_t value = 22656 + g_sub_menu_selection; const uint32_t xtal_Hz = (0x4f0000u + value) * 5; - writeXtalFreqCal(gSubMenuSelection, false); + writeXtalFreqCal(g_sub_menu_selection, false); sprintf(String, "%d\n%u.%06u\nMHz", - gSubMenuSelection, + g_sub_menu_selection, xtal_Hz / 1000000, xtal_Hz % 1000000); } break; @@ -908,8 +908,8 @@ void UI_DisplayMenu(void) case MENU_BATCAL: { - const uint16_t vol = (uint32_t)gBatteryVoltageAverage * gBatteryCalibration[3] / gSubMenuSelection; - sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); + const uint16_t vol = (uint32_t)g_battery_voltage_average * g_battery_calibration[3] / g_sub_menu_selection; + sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, g_sub_menu_selection); break; } } @@ -970,24 +970,24 @@ void UI_DisplayMenu(void) } } - if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2) + if (g_menu_cursor == MENU_SLIST1 || g_menu_cursor == MENU_SLIST2) { - i = (gMenuCursor == MENU_SLIST1) ? 0 : 1; + i = (g_menu_cursor == MENU_SLIST1) ? 0 : 1; -// if (gSubMenuSelection == 0xFF) - if (gSubMenuSelection < 0) +// if (g_sub_menu_selection == 0xFF) + if (g_sub_menu_selection < 0) strcpy(String, "NULL"); else - UI_GenerateChannelStringEx(String, true, gSubMenuSelection); + UI_GenerateChannelStringEx(String, true, g_sub_menu_selection); -// if (gSubMenuSelection == 0xFF || !g_eeprom.scan_list_enabled[i]) - if (gSubMenuSelection < 0 || !g_eeprom.scan_list_enabled[i]) +// if (g_sub_menu_selection == 0xFF || !g_eeprom.scan_list_enabled[i]) + if (g_sub_menu_selection < 0 || !g_eeprom.scan_list_enabled[i]) { // channel number UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); // channel name - BOARD_fetchChannelName(String, gSubMenuSelection); + BOARD_fetchChannelName(String, g_sub_menu_selection); if (String[0] == 0) strcpy(String, "--"); UI_PrintString(String, menu_item_x1, menu_item_x2, 2, 8); @@ -998,7 +998,7 @@ void UI_DisplayMenu(void) UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); // channel name - BOARD_fetchChannelName(String, gSubMenuSelection); + BOARD_fetchChannelName(String, g_sub_menu_selection); if (String[0] == 0) strcpy(String, "--"); UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 2); @@ -1017,54 +1017,54 @@ void UI_DisplayMenu(void) } } - if (gMenuCursor == MENU_MEM_CH || - gMenuCursor == MENU_DEL_CH || - gMenuCursor == MENU_1_CALL) + if (g_menu_cursor == MENU_MEM_CH || + g_menu_cursor == MENU_DEL_CH || + g_menu_cursor == MENU_1_CALL) { // display the channel name char s[11]; - BOARD_fetchChannelName(s, gSubMenuSelection); + BOARD_fetchChannelName(s, g_sub_menu_selection); if (s[0] == 0) strcpy(s, "--"); UI_PrintString(s, menu_item_x1, menu_item_x2, 2, 8); } - if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF) + if ((g_menu_cursor == MENU_R_CTCS || g_menu_cursor == MENU_R_DCS) && g_css_scan_mode != CSS_SCAN_MODE_OFF) UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8); - if (gMenuCursor == MENU_UPCODE) - 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 (g_menu_cursor == MENU_UPCODE) + 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(g_eeprom.DTMF_down_code) > 8) - UI_PrintString(g_eeprom.DTMF_down_code + 8, menu_item_x1, menu_item_x2, 4, 8); + if (g_menu_cursor == MENU_DWCODE) + 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) + if (g_menu_cursor == MENU_D_LIST && g_dtmf_is_contact_valid) { Contact[11] = 0; - memmove(&gDTMF_ID, Contact + 8, 4); + memmove(&g_dtmf_id, Contact + 8, 4); sprintf(String, "ID:%s", Contact + 8); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); } - if (gMenuCursor == MENU_R_CTCS || - gMenuCursor == MENU_T_CTCS || - gMenuCursor == MENU_R_DCS || - gMenuCursor == MENU_T_DCS || - gMenuCursor == MENU_D_LIST) + if (g_menu_cursor == MENU_R_CTCS || + g_menu_cursor == MENU_T_CTCS || + g_menu_cursor == MENU_R_DCS || + g_menu_cursor == MENU_T_DCS || + g_menu_cursor == MENU_D_LIST) { unsigned int Offset; - NUMBER_ToDigits(gSubMenuSelection, String); - Offset = (gMenuCursor == MENU_D_LIST) ? 2 : 3; - UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false); + NUMBER_ToDigits(g_sub_menu_selection, String); + Offset = (g_menu_cursor == MENU_D_LIST) ? 2 : 3; + UI_Displaysmall_digits(Offset, String + (8 - Offset), 105, 0, false); } - if ((gMenuCursor == MENU_RESET || - gMenuCursor == MENU_MEM_CH || - gMenuCursor == MENU_MEM_NAME || - gMenuCursor == MENU_DEL_CH) && gAskForConfirmation) + if ((g_menu_cursor == MENU_RESET || + g_menu_cursor == MENU_MEM_CH || + g_menu_cursor == MENU_MEM_NAME || + g_menu_cursor == MENU_DEL_CH) && g_ask_for_confirmation) { // display confirmation - strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"); + strcpy(String, (g_ask_for_confirmation == 1) ? "SURE?" : "WAIT!"); UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8); } diff --git a/ui/menu.h b/ui/menu.h index 4bbf2b8d..bf7e86d3 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -23,13 +23,13 @@ #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; - uint8_t menu_id; + const char name[7]; // menu display area only has room for 6 characters + voice_id_t voice_id; + uint8_t menu_id; } t_menu_item; // currently this list MUST be in exactly the same order -// as the other menu list "MenuList[]" in "ui/menu.c", otherwise +// as the other menu list "g_menu_list[]" in "ui/menu.c", otherwise // you'll have big problems // // I'm going to fix that so that you can reorder the menu items @@ -137,53 +137,53 @@ enum // ************************************ }; -extern const unsigned int gHidden_menu_count; +extern const unsigned int g_hidden_menu_count; -extern const t_menu_item MenuList[]; -extern uint8_t MenuList_sorted[]; +extern const t_menu_item g_menu_list[]; +extern uint8_t g_menu_list_sorted[]; -extern const char gSubMenu_TXP[3][5]; -extern const char gSubMenu_SFT_D[3][4]; -extern const char gSubMenu_W_N[2][7]; -extern const char gSubMenu_OFF_ON[2][4]; -extern const char gSubMenu_SAVE[5][4]; -extern const char gSubMenu_TOT[11][7]; -extern const char gSubMenu_TDR[3][10]; -extern const char gSubMenu_XB[3][10]; +extern const char g_sub_menu_txp[3][5]; +extern const char g_sub_menu_shift_dir[3][4]; +extern const char g_sub_menu_w_n[2][7]; +extern const char g_sub_menu_off_on[2][4]; +extern const char g_sub_menu_SAVE[5][4]; +extern const char g_sub_menu_TOT[11][7]; +extern const char g_sub_menu_tdr[3][10]; +extern const char g_sub_menu_xb[3][10]; #ifdef ENABLE_VOICE - extern const char gSubMenu_VOICE[3][4]; + extern const char g_sub_menu_voice[3][4]; #endif -extern const char gSubMenu_SC_REV[3][13]; -extern const char gSubMenu_MDF[4][15]; +extern const char g_sub_menu_sc_rev[3][13]; +extern const char g_sub_menu_mdf[4][15]; #ifdef ENABLE_ALARM - extern const char gSubMenu_AL_MOD[2][5]; + extern const char g_sub_menu_AL_MOD[2][5]; #endif -extern const char gSubMenu_D_RSP[4][11]; -extern const char gSubMenu_PTT_ID[5][15]; -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_RX_TX[4][6]; +extern const char g_sub_menu_D_RSP[4][11]; +extern const char g_sub_menu_PTT_ID[5][15]; +extern const char g_sub_menu_pwr_on_msg[4][8]; +extern const char g_sub_menu_roger_mode[3][9]; +extern const char g_sub_menu_RESET[2][4]; +extern const char g_sub_menu_f_lock[6][4]; +extern const char g_sub_menu_backlight[8][7]; +extern const char g_sub_menu_rx_tx[4][6]; #ifdef ENABLE_AM_FIX_TEST1 - extern const char gSubMenu_AM_fix_test1[4][8]; + extern const char g_sub_menu_AM_fix_test1[4][8]; #endif -extern const char gSubMenu_BAT_TXT[3][8]; +extern const char g_sub_menu_BAT_TXT[3][8]; -extern const char gSubMenu_SCRAMBLER[11][7]; +extern const char g_sub_menu_SCRAMBLER[11][7]; -extern const char gSubMenu_SIDE_BUTT[9][16]; +extern const char g_sub_menu_SIDE_BUTT[9][16]; -extern bool gIsInSubMenu; +extern bool g_is_in_sub_menu; -extern uint8_t gMenuCursor; -extern int8_t gMenuScrollDirection; -extern int32_t gSubMenuSelection; +extern uint8_t g_menu_cursor; +extern int8_t g_menu_scroll_direction; +extern int32_t g_sub_menu_selection; -extern char edit_original[17]; -extern char edit[17]; -extern int edit_index; +extern char g_edit_original[17]; +extern char g_edit[17]; +extern int g_edit_index; void UI_SortMenu(const bool hide_hidden); void UI_DisplayMenu(void); diff --git a/ui/scanner.c b/ui/scanner.c index bca399b4..cbaf9981 100644 --- a/ui/scanner.c +++ b/ui/scanner.c @@ -32,10 +32,10 @@ void UI_DisplayScanner(void) char String[16]; bool text_centered = false; - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); memset(String, 0, sizeof(String)); - if (gScanSingleFrequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED)) + if (g_scan_single_frequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED)) { const uint32_t freq = gScanFrequency; sprintf(String, "FREQ %u.%05u", freq / 100000, freq % 100000); @@ -51,9 +51,9 @@ void UI_DisplayScanner(void) strcpy(String, "CODE scanning"); else if (gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) - sprintf(String, " CTC %u.%uHz", CTCSS_Options[gScanCssResultCode] / 10, CTCSS_Options[gScanCssResultCode] % 10); + sprintf(String, " CTC %u.%uHz", CTCSS_OPTIONS[gScanCssResultCode] / 10, CTCSS_OPTIONS[gScanCssResultCode] % 10); else - sprintf(String, " DCS D%03oN", DCS_Options[gScanCssResultCode]); + sprintf(String, " DCS D%03oN", DCS_OPTIONS[gScanCssResultCode]); UI_PrintString(String, 2, 0, 3, 8); memset(String, 0, sizeof(String)); @@ -81,7 +81,7 @@ void UI_DisplayScanner(void) case SCAN_EDIT_STATE_BUSY: strcpy(String, "SAVE "); - UI_GenerateChannelStringEx(String + 5, gShowChPrefix, gScanChannel); + UI_GenerateChannelStringEx(String + 5, g_show_chan_prefix, gScanChannel); break; case SCAN_EDIT_STATE_DONE: diff --git a/ui/status.c b/ui/status.c index 33ff0f2c..f32c9f27 100644 --- a/ui/status.c +++ b/ui/status.c @@ -34,32 +34,32 @@ void UI_DisplayStatus(const bool test_display) { - uint8_t *line = gStatusLine; + uint8_t *line = g_status_line; unsigned int x = 0; unsigned int x1 = 0; - gUpdateStatus = false; + g_update_status = false; - memset(gStatusLine, 0, sizeof(gStatusLine)); + memset(g_status_line, 0, sizeof(g_status_line)); // ************** // POWER-SAVE indicator - if (gCurrentFunction == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT) { memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX)); x1 = x + sizeof(BITMAP_TX); } else - if (gCurrentFunction == FUNCTION_RECEIVE || - gCurrentFunction == FUNCTION_MONITOR || - gCurrentFunction == FUNCTION_INCOMING) + if (g_current_function == FUNCTION_RECEIVE || + g_current_function == FUNCTION_MONITOR || + g_current_function == FUNCTION_INCOMING) { memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); x1 = x + sizeof(BITMAP_RX); } else - if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display) + if (g_current_function == FUNCTION_POWER_SAVE || test_display) { memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); x1 = x + sizeof(BITMAP_POWERSAVE); @@ -68,7 +68,7 @@ void UI_DisplayStatus(const bool test_display) #ifdef ENABLE_NOAA // NOASS SCAN indicator - if (gIsNoaaMode || test_display) + if (g_is_noaa_mode || test_display) { memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA)); x1 = x + sizeof(BITMAP_NOAA); @@ -78,7 +78,7 @@ void UI_DisplayStatus(const bool test_display) // hmmm, what to put in it's place #endif - if (gSetting_KILLED) + if (g_setting_killed) { memset(line + x, 0xFF, 10); x1 = x + 10; @@ -86,7 +86,7 @@ void UI_DisplayStatus(const bool test_display) else #ifdef ENABLE_FMRADIO // FM indicator - if (gFmRadioMode || test_display) + if (g_fm_radio_mode || test_display) { memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM)); x1 = x + sizeof(BITMAP_FM); @@ -94,9 +94,9 @@ void UI_DisplayStatus(const bool test_display) else #endif // SCAN indicator - if (gScanStateDir != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display) + if (g_scan_state_dir != SCAN_OFF || g_screen_to_display == DISPLAY_SCANNER || test_display) { - if (gNextChannel <= USER_CHANNEL_LAST) + if (g_next_channel <= USER_CHANNEL_LAST) { // channel mode if (g_eeprom.scan_list_default == 0) UI_PrintStringSmallBuffer("1", line + x); @@ -119,10 +119,10 @@ void UI_DisplayStatus(const bool test_display) // VOICE indicator if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF || test_display) { - memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); - x1 = x + sizeof(BITMAP_VoicePrompt); + memmove(line + x, BITMAP_VOICE_PROMPT, sizeof(BITMAP_VOICE_PROMPT)); + x1 = x + sizeof(BITMAP_VOICE_PROMPT); } - x += sizeof(BITMAP_VoicePrompt); + x += sizeof(BITMAP_VOICE_PROMPT); #else // hmmm, what to put in it's place #endif @@ -130,7 +130,7 @@ void UI_DisplayStatus(const bool test_display) // DUAL-WATCH indicator if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display) { - if (gDualWatchActive || test_display) + if (g_dual_watch_active || test_display) memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1)); else memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2)); @@ -158,15 +158,15 @@ void UI_DisplayStatus(const bool test_display) // KEY-LOCK indicator if (g_eeprom.key_lock || test_display) { - memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); - x += sizeof(BITMAP_KeyLock); + memmove(line + x, BITMAP_KEYLOCK, sizeof(BITMAP_KEYLOCK)); + x += sizeof(BITMAP_KEYLOCK); x1 = x; } else - if (g_was_f_key_pressed) + if (g_f_key_was_pressed) { - memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key)); - x += sizeof(BITMAP_F_Key); + memmove(line + x, BITMAP_F_KEY, sizeof(BITMAP_F_KEY)); + x += sizeof(BITMAP_F_KEY); x1 = x; } @@ -176,10 +176,10 @@ void UI_DisplayStatus(const bool test_display) unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - 3; - if (gChargingWithTypeC) + if (g_charging_with_type_c) x2 -= sizeof(BITMAP_USB_C); // the radio is on charge - switch (gSetting_battery_text) + switch (g_setting_battery_text) { default: case 0: @@ -187,7 +187,7 @@ void UI_DisplayStatus(const bool test_display) case 1: // voltage { - const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V + const uint16_t voltage = (g_battery_voltage_average <= 999) ? g_battery_voltage_average : 999; // limit to 9.99V sprintf(s, "%u.%02uV", voltage / 100, voltage % 100); space_needed = (7 * strlen(s)); if (x2 >= (x1 + space_needed)) @@ -199,7 +199,7 @@ void UI_DisplayStatus(const bool test_display) case 2: // percentage { - sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage)); + sprintf(s, "%u%%", BATTERY_VoltsToPercent(g_battery_voltage_average)); space_needed = (7 * strlen(s)); if (x2 >= (x1 + space_needed)) UI_PrintStringSmallBuffer(s, line + x2 - space_needed); @@ -212,13 +212,13 @@ void UI_DisplayStatus(const bool test_display) x = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - sizeof(BITMAP_USB_C); // USB-C charge indicator - if (gChargingWithTypeC || test_display) + if (g_charging_with_type_c || test_display) memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C)); x += sizeof(BITMAP_USB_C); { // BATTERY LEVEL indicator uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)]; - unsigned int i = gBatteryDisplayLevel; + unsigned int i = g_battery_display_level; memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL)); @@ -237,7 +237,7 @@ void UI_DisplayStatus(const bool test_display) } } else - if (gLowBattery) + if (g_low_battery) memset(bitmap, 0, sizeof(bitmap)); memmove(line + x, bitmap, sizeof(bitmap)); diff --git a/ui/ui.c b/ui/ui.c index 893a9855..67e11fd5 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -35,16 +35,15 @@ #include "ui/scanner.h" #include "ui/ui.h" -GUI_DisplayType_t gScreenToDisplay; -GUI_DisplayType_t gRequestDisplayScreen = DISPLAY_INVALID; - -uint8_t gAskForConfirmation; -bool gAskToSave; -bool gAskToDelete; +gui_display_type_t g_screen_to_display; +gui_display_type_t g_request_display_screen = DISPLAY_INVALID; +uint8_t g_ask_for_confirmation; +bool g_ask_to_save; +bool g_ask_to_delete; void GUI_DisplayScreen(void) { - switch (gScreenToDisplay) + switch (g_screen_to_display) { case DISPLAY_MAIN: UI_DisplayMain(); @@ -75,30 +74,30 @@ void GUI_DisplayScreen(void) } } -void GUI_SelectNextDisplay(GUI_DisplayType_t Display) +void GUI_SelectNextDisplay(gui_display_type_t Display) { if (Display == DISPLAY_INVALID) return; - if (gScreenToDisplay != Display) + if (g_screen_to_display != Display) { DTMF_clear_input_box(); - gInputBoxIndex = 0; - gIsInSubMenu = false; - gCssScanMode = CSS_SCAN_MODE_OFF; - gScanStateDir = SCAN_OFF; + g_input_box_index = 0; + g_is_in_sub_menu = false; + g_css_scan_mode = CSS_SCAN_MODE_OFF; + g_scan_state_dir = SCAN_OFF; #ifdef ENABLE_FMRADIO - gFM_ScanState = FM_SCAN_OFF; + g_fm_scan_state = FM_SCAN_OFF; #endif - gAskForConfirmation = 0; - gAskToSave = false; - gAskToDelete = false; - g_was_f_key_pressed = false; + g_ask_for_confirmation = 0; + g_ask_to_save = false; + g_ask_to_delete = false; + g_f_key_was_pressed = false; - gUpdateStatus = true; + g_update_status = true; } - gScreenToDisplay = Display; - gUpdateDisplay = true; + g_screen_to_display = Display; + g_update_display = true; } diff --git a/ui/ui.h b/ui/ui.h index 8a107d9f..664bb136 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -20,27 +20,25 @@ #include #include -enum GUI_DisplayType_t +enum gui_display_type_e { DISPLAY_MAIN = 0, DISPLAY_FM, DISPLAY_MENU, DISPLAY_SCANNER, DISPLAY_AIRCOPY, - DISPLAY_INVALID = 0xFFu + DISPLAY_INVALID // 0xff }; +typedef enum gui_display_type_e gui_display_type_t; -typedef enum GUI_DisplayType_t GUI_DisplayType_t; - -extern GUI_DisplayType_t gScreenToDisplay; -extern GUI_DisplayType_t gRequestDisplayScreen; - -extern uint8_t gAskForConfirmation; -extern bool gAskToSave; -extern bool gAskToDelete; +extern gui_display_type_t g_screen_to_display; +extern gui_display_type_t g_request_display_screen; +extern uint8_t g_ask_for_confirmation; +extern bool g_ask_to_save; +extern bool g_ask_to_delete; void GUI_DisplayScreen(void); -void GUI_SelectNextDisplay(GUI_DisplayType_t Display); +void GUI_SelectNextDisplay(gui_display_type_t Display); #endif diff --git a/ui/welcome.c b/ui/welcome.c index 5368fb33..90c5083f 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -29,8 +29,8 @@ void UI_DisplayReleaseKeys(void) { - memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_status_line, 0, sizeof(g_status_line)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); UI_PrintString("RELEASE", 0, 127, 1, 10); UI_PrintString("ALL KEYS", 0, 127, 3, 10); @@ -45,8 +45,8 @@ void UI_DisplayWelcome(void) char WelcomeString1[16]; char WelcomeString2[16]; - memset(gStatusLine, 0, sizeof(gStatusLine)); - memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); + memset(g_status_line, 0, sizeof(g_status_line)); + memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_NONE) { @@ -67,12 +67,12 @@ void UI_DisplayWelcome(void) { strcpy(WelcomeString0, "VOLTAGE"); sprintf(WelcomeString1, "%u.%02uV %u%%", - gBatteryVoltageAverage / 100, - gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage)); + g_battery_voltage_average / 100, + g_battery_voltage_average % 100, + BATTERY_VoltsToPercent(g_battery_voltage_average)); #if 0 - sprintf(WelcomeString2, "Current %u", gBatteryCurrent); // needs scaling into mA + sprintf(WelcomeString2, "Current %u", g_battery_current); // needs scaling into mA #endif } else