0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 14:48:03 +03:00

lots more step sizes added, though the QS config software will only use the original 7 step sizes.

This commit is contained in:
OneOfEleven
2023-10-18 16:17:41 +01:00
parent 2e880a61e1
commit ce4528b4ee
12 changed files with 160 additions and 171 deletions

View File

@ -340,8 +340,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
return;
}
if (key_pressed)
{ // key is pressed
if (key_pressed && !key_held)
{ // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return; // don't use the key till it's released
}
@ -519,8 +519,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
void MAIN_Key_EXIT(bool key_pressed, bool key_held)
{
if (!key_held && key_pressed)
{ // exit key pressed
if (key_pressed && !key_held)
{ // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
@ -586,9 +586,10 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
{
if (key_pressed && !key_held)
// menu key pressed
{ // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
}
if (key_held)
{ // menu key held down (long press)
@ -685,10 +686,8 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
{
if (g_input_box_index > 0)
{ // entering a channel, frequency or DTMF string
if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
@ -763,6 +762,11 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
if (key_pressed && !key_held)
{ // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
}
if (!key_pressed &&
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
IS_NOT_NOAA_CHANNEL(Channel) &&
@ -831,7 +835,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency);
const uint32_t frequency = APP_set_frequency_by_step(g_tx_vfo, Direction);
if (RX_freq_check(frequency) < 0)
if (FREQUENCY_rx_freq_check(frequency) < 0)
{ // frequency not allowed
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;

View File

@ -393,7 +393,7 @@ void MENU_AcceptSetting(void)
break;
case MENU_STEP:
g_tx_vfo->step_setting = g_sub_menu_selection;
g_tx_vfo->step_setting = step_freq_table_sorted[g_sub_menu_selection];
if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
{
g_request_save_channel = 1;
@ -935,9 +935,9 @@ void MENU_ShowCurrentSetting(void)
break;
case MENU_STEP:
g_sub_menu_selection = g_tx_vfo->step_setting;
g_sub_menu_selection = FREQUENCY_get_step_index(STEP_FREQ_TABLE[g_tx_vfo->step_setting]);
break;
case MENU_TX_POWER:
g_sub_menu_selection = g_tx_vfo->output_power;
break;

View File

@ -180,95 +180,14 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
if (!g_search_single_frequency)
{
#if 0
uint32_t Freq250 = FREQUENCY_FloorToStep(g_search_frequency, 250, 0);
uint32_t Freq625 = FREQUENCY_FloorToStep(g_search_frequency, 625, 0);
int16_t Delta250 = (int16_t)g_search_frequency - (int16_t)Freq250;
int16_t Delta625;
if (125 < Delta250)
{
Delta250 = 250 - Delta250;
Freq250 += 250;
}
Delta625 = (int16_t)g_search_frequency - (int16_t)Freq625;
if (312 < Delta625)
{
Delta625 = 625 - Delta625;
Freq625 += 625;
}
if (Delta625 < Delta250)
{
g_search_step_setting = STEP_6_25kHz;
g_search_frequency = Freq625;
}
else
{
g_search_step_setting = STEP_2_5kHz;
g_search_frequency = Freq250;
}
#elif 0
#ifdef ENABLE_1250HZ_STEP
const step_setting_t small_step = STEP_1_25kHz;
const step_setting_t big_step = STEP_6_25kHz;
#else
const step_setting_t small_step = STEP_2_5kHz;
const step_setting_t big_step = STEP_6_25kHz;
#endif
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(g_search_frequency, small_step_freq, 0);
uint32_t freq_big_step = FREQUENCY_FloorToStep(g_search_frequency, big_step_freq, 0);
int32_t delta_small_step = (int32_t)g_search_frequency - freq_small_step;
int32_t delta_big_step = (int32_t)g_search_frequency - freq_big_step;
if (delta_small_step > 125)
{
delta_small_step = STEP_FREQ_TABLE[small_step] - delta_small_step;
freq_big_step += small_step_freq;
}
delta_big_step = (int32_t)g_search_frequency - freq_big_step;
if (delta_big_step > 312)
{
delta_big_step = big_step_freq - delta_big_step;
freq_big_step += big_step_freq;
}
if (delta_small_step >= delta_big_step)
{
g_search_step_setting = small_step;
g_search_frequency = freq_small_step;
}
else
{
g_search_step_setting = big_step;
g_search_frequency = freq_big_step;
}
#else
// determine what the current step size is for the detected frequency
// use the 7 VFO channels/bands to determine it
const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
{ // round to nearest step size
const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
}
#endif
// determine what the current step size is for the detected frequency
// use the 7 VFO channels/bands to determine it
const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
{ // round to nearest step size
const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
}
}
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)