0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-08-04 01:46:33 +03:00

Renamed lots more

This commit is contained in:
OneOfEleven
2023-10-08 20:23:37 +01:00
parent 1ab74dcba1
commit 0bb34d230c
68 changed files with 3748 additions and 3765 deletions

View File

@@ -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;
}

View File

@@ -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;
gAirCopyBlockNumber++;
if (Offset == 0x1E00)
g_aircopy_state = AIRCOPY_COMPLETE;
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;

1327
app/app.c

File diff suppressed because it is too large Load Diff

View File

@@ -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);

View File

@@ -33,42 +33,42 @@
#include "settings.h"
#include "ui/ui.h"
char gDTMF_String[15];
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;
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;
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);
}

View File

@@ -22,88 +22,85 @@
#define MAX_DTMF_CONTACTS 16
enum DTMF_State_t {
DTMF_STATE_0 = 0,
DTMF_STATE_TX_SUCC,
DTMF_STATE_CALL_OUT_RSP
};
typedef enum DTMF_State_t DTMF_State_t;
enum DTMF_CallState_t {
DTMF_CALL_STATE_NONE = 0,
DTMF_CALL_STATE_CALL_OUT,
DTMF_CALL_STATE_RECEIVED,
DTMF_CALL_STATE_RECEIVED_STAY
};
enum DTMF_DecodeResponse_t {
DTMF_DEC_RESPONSE_NONE = 0,
DTMF_DEC_RESPONSE_RING,
DTMF_DEC_RESPONSE_REPLY,
DTMF_DEC_RESPONSE_BOTH
};
typedef enum DTMF_CallState_t DTMF_CallState_t;
enum DTMF_ReplyState_t {
DTMF_REPLY_NONE = 0,
DTMF_REPLY_ANI,
DTMF_REPLY_AB,
DTMF_REPLY_AAAAA
};
typedef enum DTMF_ReplyState_t DTMF_ReplyState_t;
enum DTMF_CallMode_t {
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;
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;
extern char gDTMF_String[15];
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;
extern char gDTMF_InputBox[15];
extern uint8_t gDTMF_InputBox_Index;
extern bool gDTMF_InputMode;
extern uint8_t gDTMF_PreviousIndex;
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;
extern char gDTMF_RX[17];
extern uint8_t gDTMF_RX_index;
extern uint8_t gDTMF_RX_timeout;
extern bool gDTMF_RX_pending;
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;
extern char gDTMF_RX_live[20];
extern uint8_t gDTMF_RX_live_timeout;
enum dtmf_call_mode_e {
DTMF_CALL_MODE_NOT_GROUP = 0,
DTMF_CALL_MODE_GROUP,
DTMF_CALL_MODE_DTMF
};
typedef enum dtmf_call_mode_e dtmf_call_mode_t;
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;
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);

310
app/fm.c
View File

@@ -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 @@ Bail:
return ret;
}
static void FM_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
static void FM_Key_DIGITS(key_code_t Key, bool 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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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];

View File

@@ -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;