0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 22:01:26 +03:00
This commit is contained in:
OneOfEleven 2023-11-10 07:31:50 +00:00
parent a48b3bc475
commit aebd397221
11 changed files with 85 additions and 79 deletions

View File

@ -82,7 +82,7 @@ ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the sta
ENABLE_FREQ_SEARCH_LNA := 0 keep this disabled
ENABLE_FREQ_SEARCH_TIMEOUT := 0 timeout if FREQ not found when using F+4 search function
ENABLE_CODE_SEARCH_TIMEOUT := 0 timeout if CTCSS/CDCSS not found when using F+* search function
ENABLE_SCAN_IGNORE_LIST := 1 ignore selected frequencies when scanning - add freqs to list with short */scan button when scanning, remove freq from list with long press MENU when not scanning
ENABLE_SCAN_IGNORE_LIST := 1 ignore selected frequencies when scanning - add freqs to list with short */scan button when freq scanning, remove freq from list with long press MENU when not scanning
ENABLE_SCAN_RANGES := 0 adds menu option to auto select frequency scan range/step depending on your initial frequency
ENABLE_KILL_REVIVE := 0 include kill and revive code
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to help prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
@ -101,13 +101,17 @@ ENABLE_KEYLOCK := 1 enable keylock menu option + keylock
# New/modified function keys
* Long-press 'M' .. Copy selected channel into same VFO, then switch VFO to frequency mode
* Long-press 'M' ... Remove current frequency from ignore list (only if it's in the ignore frequency list)
* Long-press 'M' ... Copy current frequency into a channel (takes you into the channel save menu)
* Long-press 'M' ... Copy current channel into the same VFO, then switch the VFO to frequency mode
*
* Long-press '7' .. Toggle selected channel scanlist setting .. if VOX is disabled in Makefile
* Long-press '5' ... Toggle selected channel scanlist setting (if NOAA is disabled in Makefile)
* or
* Long-press '5' .. Toggle selected channel scanlist setting .. if NOAA is disabled in Makefile
* Long-press '7' ... Toggle selected channel scanlist setting (if VOX is disabled in Makefile)
*
* Long-press '*' .. Start scanning, then toggles the scanning between scanlists 1, 2 or ALL channels
* Long-press '*' ... Start scanning, then toggles the scanning between scanlists 1, 2 or ALL channels
*
* Short-press '*' .. Add current frequency to the frequency ignore list (only if in frequency scan mode)
# Edit channel/memory name
@ -123,7 +127,7 @@ ENABLE_KEYLOCK := 1 enable keylock menu option + keylock
Press the Exit button at any time to cancel the edit and return to the main menu.
Sounds a lot/complicated but once you done it a couple of times you'll be fine (hopefully).
Sounds complicated but once you done it a couple of times you'll be fine.
When you're editing the name, you can enter digits (0 ~ 9) directly without having to use the up/down buttons to find them.

View File

@ -625,7 +625,7 @@ void APP_stop_scan(void)
// find the first channel that contains this frequency
g_rx_vfo->freq_in_channel = SETTINGS_find_channel(g_rx_vfo->freq_config_rx.frequency);
RADIO_ApplyOffset(g_rx_vfo, false);
RADIO_apply_offset(g_rx_vfo, false);
RADIO_ConfigureSquelch(g_rx_vfo);
RADIO_setup_registers(true);
}
@ -637,7 +637,7 @@ void APP_stop_scan(void)
if (g_rx_vfo->channel_save > USER_CHANNEL_LAST)
{ // frequency mode
RADIO_ApplyOffset(g_rx_vfo, false);
RADIO_apply_offset(g_rx_vfo, false);
RADIO_ConfigureSquelch(g_rx_vfo);
SETTINGS_save_channel(g_rx_vfo->channel_save, g_rx_vfo_num, g_rx_vfo, 1);
return;
@ -692,8 +692,7 @@ static void APP_next_freq(void)
#if 0
// original slower method
RADIO_ApplyOffset(g_tx_vfo, false);
// RADIO_ConfigureSquelch(g_tx_vfo);
RADIO_apply_offset(g_tx_vfo, false);
RADIO_setup_registers(true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
@ -708,12 +707,11 @@ static void APP_next_freq(void)
BK4819_set_rf_frequency(g_tx_vfo->freq_config_rx.frequency, true);
BK4819_set_rf_filter_path(g_tx_vfo->freq_config_rx.frequency);
RADIO_ApplyOffset(g_tx_vfo, false);
// RADIO_ConfigureSquelch(g_tx_vfo);
RADIO_apply_offset(g_tx_vfo, false);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
//g_scan_tick_10ms = 10; // 100ms
g_scan_tick_10ms = 7; // 70ms
g_scan_tick_10ms = 6; // 60ms
#else
g_scan_tick_10ms = scan_pause_freq_10ms;
#endif
@ -2163,8 +2161,8 @@ void APP_time_slice_500ms(void)
}
}
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
APP_update_rssi(g_rx_vfo_num, false);
// if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
// APP_update_rssi(g_rx_vfo_num, false);
if (g_low_battery)
{
@ -2321,10 +2319,6 @@ void APP_time_slice_10ms(void)
g_request_display_screen = DISPLAY_INVALID;
}
// 1of11
if (g_update_rssi)
APP_update_rssi(g_rx_vfo_num, false);
if (g_update_display)
GUI_DisplayScreen();
@ -2419,11 +2413,19 @@ void APP_time_slice_10ms(void)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
// 1of11
// if (g_update_rssi)
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
if (!g_flag_save_channel)
APP_update_rssi(g_rx_vfo_num, false);
if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode)
APP_process_radio_interrupts();
APP_process_functions();
APP_process_flash_light_10ms();
if (g_current_function == FUNCTION_TRANSMIT)
{ // transmitting
#ifdef ENABLE_TX_AUDIO_BAR
@ -2440,8 +2442,6 @@ void APP_time_slice_10ms(void)
}
#endif
APP_process_flash_light_10ms();
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_radio_tick_500ms > 0)
return;
@ -2461,6 +2461,15 @@ void APP_time_slice_10ms(void)
APP_process_transmit();
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_restore_tick_10ms > 0)
{
if (--g_fm_restore_tick_10ms == 0)
{ // switch back to FM radio mode
FM_turn_on();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
if (g_fm_schedule &&
g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF &&
!g_monitor_enabled &&
@ -2474,17 +2483,6 @@ void APP_time_slice_10ms(void)
APP_process_power_save();
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_restore_tick_10ms > 0)
{
if (--g_fm_restore_tick_10ms == 0)
{ // switch back to FM radio mode
FM_turn_on();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
#endif
APP_process_scan();
APP_process_search();
@ -2820,7 +2818,7 @@ Skip:
MENU_AcceptSetting();
g_flag_refresh_menu = true;
g_update_menu = true;
g_flag_accept_setting = false;
}
@ -2930,9 +2928,9 @@ Skip:
g_flag_reconfigure_vfos = false;
}
if (g_flag_refresh_menu)
if (g_update_menu)
{
g_flag_refresh_menu = false;
g_update_menu = false;
g_menu_tick_10ms = menu_timeout_500ms;
MENU_ShowCurrentSetting();

View File

@ -141,7 +141,7 @@ void toggle_chan_scanlist(void)
g_eeprom.config.setting.tx_vfo_num = vfo;
RADIO_select_vfos();
RADIO_ApplyOffset(g_tx_vfo, false);
RADIO_apply_offset(g_tx_vfo, false);
RADIO_ConfigureSquelch(g_tx_vfo);
// RADIO_ConfigureTXPower(g_tx_vfo);
RADIO_setup_registers(true);
@ -186,7 +186,7 @@ void toggle_chan_scanlist(void)
#endif
g_sub_menu_selection = chan;
g_flag_refresh_menu = false;
g_update_menu = false;
g_current_display_screen = DISPLAY_MENU;
g_update_display = false;
UI_DisplayMenu();
@ -820,7 +820,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
if (flag)
{
g_flag_refresh_menu = true;
g_update_menu = true;
g_request_display_screen = DISPLAY_MENU;
#ifdef ENABLE_VOICE
@ -962,7 +962,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t directio
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.config.setting.tx_vfo_num, g_tx_vfo, 1);
RADIO_ApplyOffset(g_tx_vfo, true);
RADIO_apply_offset(g_tx_vfo, true);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("save chan %u\r\n", g_rx_vfo->channel_save);
@ -1065,7 +1065,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t directio
g_tx_vfo->freq_in_channel = 0xff;
#if 0
RADIO_ApplyOffset(g_tx_vfo, false);
RADIO_apply_offset(g_tx_vfo, false);
RADIO_ConfigureSquelch(g_tx_vfo);
// RADIO_ConfigureTXPower(g_tx_vfo);
@ -1091,7 +1091,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t directio
BK4819_set_rf_frequency(freq, true); // set the VCO/PLL
BK4819_set_rf_filter_path(freq); // set the proper LNA/PA filter path
RADIO_ApplyOffset(g_tx_vfo, false);
RADIO_apply_offset(g_tx_vfo, false);
RADIO_ConfigureSquelch(g_tx_vfo);
// RADIO_ConfigureTXPower(g_tx_vfo);
#endif

View File

@ -1404,7 +1404,7 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
if (value > 0 && value <= g_menu_list_count)
{
g_menu_cursor = value - 1;
g_flag_refresh_menu = true;
g_update_menu = true;
return;
}
@ -1421,7 +1421,7 @@ static void MENU_Key_0_to_9(key_code_t Key, bool key_pressed, bool key_held)
if (value > 0 && value <= g_menu_list_count)
{
g_menu_cursor = value - 1;
g_flag_refresh_menu = true;
g_update_menu = true;
return;
}
break;
@ -1581,7 +1581,7 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
g_ask_for_confirmation = 0;
g_in_sub_menu = false;
g_input_box_index = 0;
g_flag_refresh_menu = true;
g_update_menu = true;
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_CANCEL;
@ -1884,7 +1884,7 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
{
g_menu_cursor = NUMBER_AddWithWraparound(g_menu_cursor, -Direction, 0, g_menu_list_count - 1);
g_flag_refresh_menu = true;
g_update_menu = true;
g_request_display_screen = DISPLAY_MENU;

View File

@ -306,9 +306,9 @@ void BK4819_DisableAGC(void)
BK4819_write_reg(0x10, 0x007A); // 000000 00 011 11 010
BK4819_write_reg(0x14, 0x0019); // 000000 00 000 11 001
// ???
BK4819_write_reg(0x49, 0x2A38);
BK4819_write_reg(0x7B, 0x8420);
BK4819_write_reg(0x49, (0u << 14) | (84u << 7) | (56u << 0)); // 0x2A38 AGC thresholds
BK4819_write_reg(0x7B, 0x8420); // RSSI table
}
void BK4819_EnableAGC(void)
@ -355,8 +355,9 @@ void BK4819_EnableAGC(void)
//BK4819_write_reg(0x10, 0x007A); // 000000 00 011 11 010
//BK4819_write_reg(0x14, 0x0019); // 000000 00 000 11 001
BK4819_write_reg(0x49, 0x2A38);
BK4819_write_reg(0x7B, 0x8420);
BK4819_write_reg(0x49, (0u << 14) | (84u << 7) | (56u << 0)); // 0x2A38 AGC thresholds
BK4819_write_reg(0x7B, 0x8420); // RSSI table
for (unsigned int i = 0; i < 8; i++)
BK4819_write_reg(0x06, ((i & 7u) << 13) | (0x4A << 7) | (0x36 << 0));

Binary file not shown.

Binary file not shown.

53
misc.c
View File

@ -85,6 +85,8 @@ const uint32_t g_default_aes_key[4] = {0x4AA5CC60, 0x0312CC5F
const uint8_t g_mic_gain_dB_2[5] = {3, 8, 16, 24, 31};
uint8_t g_mic_sensitivity_tuning;
bool g_monitor_enabled;
bool g_has_aes_key;
@ -118,10 +120,17 @@ uint8_t g_key_input_count_down;
uint8_t g_key_lock_tick_500ms;
#endif
uint8_t g_rtte_count_down;
bool g_password_locked;
uint8_t g_update_status;
bool g_update_display;
bool g_update_rssi;
bool g_update_menu;
bool g_password_locked;
uint8_t g_found_ctcss;
uint8_t g_found_cdcss;
bool g_end_of_rx_detected_maybe;
int16_t g_vfo_rssi[2];
@ -129,8 +138,6 @@ uint8_t g_vfo_rssi_bar_level[2];
uint8_t g_reduced_service;
uint8_t g_battery_voltage_index;
css_scan_mode_t g_css_scan_mode;
bool g_update_rssi;
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
alarm_state_t g_alarm_state;
#endif
@ -143,18 +150,18 @@ uint8_t g_request_save_channel;
bool g_request_save_settings;
#ifdef ENABLE_FMRADIO
bool g_request_save_fm;
bool g_flag_save_fm;
#endif
bool g_flag_prepare_tx;
bool g_flag_accept_setting;
bool g_flag_refresh_menu;
bool g_flag_save_vfo;
bool g_flag_save_settings;
bool g_flag_save_channel;
#ifdef ENABLE_FMRADIO
bool g_flag_save_fm;
#endif
css_scan_mode_t g_css_scan_mode;
bool g_cdcss_lost;
uint8_t g_cdcss_code_type;
@ -162,23 +169,23 @@ bool g_ctcss_lost;
bool g_cxcss_tail_found;
uint8_t g_ctcss_tail_phase_shift_rx;
#ifdef ENABLE_VOX
bool g_vox_lost;
bool g_vox_audio_detected;
uint16_t g_vox_resume_tick_10ms;
uint16_t g_vox_pause_tick_10ms;
volatile uint16_t g_vox_stop_tick_10ms;
#endif
bool g_squelch_open;
reception_mode_t g_rx_reception_mode;
uint8_t g_flash_light_state;
uint16_t g_flash_light_blink_tick_10ms;
bool g_flag_end_tx;
uint16_t g_low_battery_tick_10ms;
reception_mode_t g_rx_reception_mode;
uint16_t g_low_battery_tick_10ms;
uint32_t g_scan_initial_lower;
uint32_t g_scan_initial_upper;
@ -198,6 +205,7 @@ bool g_rx_vfo_is_active;
uint16_t g_alarm_tone_counter_10ms;
uint16_t g_alarm_running_counter_10ms;
#endif
uint8_t g_menu_list_count;
uint8_t g_backup_cross_vfo;
@ -205,32 +213,27 @@ uint8_t g_backup_cross_vfo;
#ifdef ENABLE_NOAA
bool g_noaa_mode;
uint8_t g_noaa_channel;
volatile uint16_t g_noaa_tick_10ms;
volatile bool g_schedule_noaa = true;
#endif
bool g_update_display;
bool g_unhide_hidden = false;
bool g_unhide_hidden;
volatile bool g_next_time_slice;
volatile bool g_next_time_slice_40ms;
volatile uint8_t g_found_cdcss_tick_10ms;
volatile uint8_t g_found_ctcss_tick_10ms;
#ifdef ENABLE_VOX
volatile uint16_t g_vox_stop_tick_10ms;
#endif
volatile bool g_next_time_slice_40ms;
#ifdef ENABLE_NOAA
volatile uint16_t g_noaa_tick_10ms = 0;
volatile bool g_schedule_noaa = true;
#endif
volatile bool g_flag_tail_tone_elimination_complete;
volatile uint16_t g_boot_tick_10ms = 4000 / 10; // 4 seconds
int16_t g_current_rssi[2] = {0, 0};
uint16_t g_current_glitch[2] = {0, 0};
uint16_t g_current_noise[2] = {0, 0};
int16_t g_current_rssi[2];
uint16_t g_current_glitch[2];
uint16_t g_current_noise[2];
uint8_t g_mic_sensitivity_tuning;
// ***************************
unsigned int get_RX_VFO(void)
{

2
misc.h
View File

@ -243,7 +243,7 @@ extern bool g_request_save_settings;
extern bool g_flag_prepare_tx;
extern bool g_flag_accept_setting; // accept menu setting
extern bool g_flag_refresh_menu; // refresh menu display
extern bool g_update_menu; // refresh menu display
extern bool g_flag_save_vfo;
extern bool g_flag_save_settings;

View File

@ -331,7 +331,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
p_vfo->channel.tx_offset = FREQUENCY_floor_to_step(p_vfo->channel.tx_offset + (p_vfo->step_freq / 2), p_vfo->step_freq, 0, p_vfo->channel.tx_offset + p_vfo->step_freq);
}
RADIO_ApplyOffset(p_vfo, true);
RADIO_apply_offset(p_vfo, true);
// channel name
memset(&p_vfo->channel_name, 0, sizeof(p_vfo->channel_name));
@ -575,7 +575,7 @@ void RADIO_ConfigureTXPower(vfo_info_t *p_vfo)
p_vfo->p_tx->frequency);
}
void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees)
void RADIO_apply_offset(vfo_info_t *p_vfo, const bool set_pees)
{
uint32_t Frequency = p_vfo->freq_config_rx.frequency;

View File

@ -44,7 +44,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int conf
#endif
void RADIO_ConfigureSquelch(vfo_info_t *p_vfo);
void RADIO_ConfigureTXPower(vfo_info_t *p_vfo);
void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees);
void RADIO_apply_offset(vfo_info_t *p_vfo, const bool set_pees);
void RADIO_select_vfos(void);
void RADIO_setup_registers(bool switch_to_function_foreground);
#ifdef ENABLE_NOAA