mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 06:11:24 +03:00
fix bug in ignore freq add
This commit is contained in:
parent
521793ba6f
commit
1ee2662f78
28
app/app.c
28
app/app.c
@ -1951,6 +1951,20 @@ void APP_time_slice_500ms(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_current_function == FUNCTION_TRANSMIT)
|
||||||
|
{
|
||||||
|
if (g_tx_timer_tick_500ms < 6)
|
||||||
|
{ // <= 3 seconds left
|
||||||
|
if (g_tx_timer_tick_500ms & 1u)
|
||||||
|
BK4819_start_tone(880, 10, true, true);
|
||||||
|
else
|
||||||
|
BK4819_stop_tones(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_tx_timer_tick_500ms & 1u)
|
||||||
|
g_update_display = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_update_screen_tick_500ms > 0)
|
if (g_update_screen_tick_500ms > 0)
|
||||||
{ // update display once every 500ms
|
{ // update display once every 500ms
|
||||||
if (--g_update_screen_tick_500ms == 0)
|
if (--g_update_screen_tick_500ms == 0)
|
||||||
@ -1994,20 +2008,6 @@ void APP_time_slice_500ms(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_current_function == FUNCTION_TRANSMIT)
|
|
||||||
{
|
|
||||||
if (g_tx_timer_tick_500ms < 6)
|
|
||||||
{ // <= 3 seconds left
|
|
||||||
if (g_tx_timer_tick_500ms & 1u)
|
|
||||||
BK4819_start_tone(880, 10, true, false);
|
|
||||||
else
|
|
||||||
BK4819_stop_tones(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_tx_timer_tick_500ms & 1u)
|
|
||||||
g_update_display = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_menu_tick_10ms > 0)
|
if (g_menu_tick_10ms > 0)
|
||||||
if (--g_menu_tick_10ms == 0)
|
if (--g_menu_tick_10ms == 0)
|
||||||
exit_menu = (g_current_display_screen == DISPLAY_MENU); // exit menu mode
|
exit_menu = (g_current_display_screen == DISPLAY_MENU); // exit menu mode
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -12,6 +12,10 @@ int ignore_frequencies_count = 0;
|
|||||||
void FI_clear_freq_ignored(void)
|
void FI_clear_freq_ignored(void)
|
||||||
{ // clear the ignore list
|
{ // clear the ignore list
|
||||||
ignore_frequencies_count = 0;
|
ignore_frequencies_count = 0;
|
||||||
|
|
||||||
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
|
UART_SendText("ignore cleared\r\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int FI_freq_ignored(const uint32_t frequency)
|
int FI_freq_ignored(const uint32_t frequency)
|
||||||
@ -20,8 +24,8 @@ int FI_freq_ignored(const uint32_t frequency)
|
|||||||
if (frequency == 0 || frequency == 0xffffffff || ignore_frequencies_count <= 0)
|
if (frequency == 0 || frequency == 0xffffffff || ignore_frequencies_count <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ignore_frequencies_count > 4)
|
if (ignore_frequencies_count >= 8)
|
||||||
{ // binary search .. becomes much faster than sequencial as the list grows
|
{ // binary search .. becomes much faster than sequencial search when the list is bigger
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = ignore_frequencies_count;
|
int high = ignore_frequencies_count;
|
||||||
while (low < high)
|
while (low < high)
|
||||||
@ -34,7 +38,12 @@ int FI_freq_ignored(const uint32_t frequency)
|
|||||||
if (freq < frequency)
|
if (freq < frequency)
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
|
UART_printf("ignored bin %u %u\r\n", frequency, mid);
|
||||||
|
#endif
|
||||||
return mid;
|
return mid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -44,7 +53,12 @@ int FI_freq_ignored(const uint32_t frequency)
|
|||||||
{
|
{
|
||||||
register uint32_t freq = ignore_frequencies[i];
|
register uint32_t freq = ignore_frequencies[i];
|
||||||
if (frequency == freq)
|
if (frequency == freq)
|
||||||
return i; // found it
|
{ // found it
|
||||||
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
|
UART_printf("ignored seq %u %u\r\n", frequency, i);
|
||||||
|
#endif
|
||||||
|
return i;
|
||||||
|
}
|
||||||
if (frequency < freq)
|
if (frequency < freq)
|
||||||
return -1; // can exit loop early as the list is sorted by frequency
|
return -1; // can exit loop early as the list is sorted by frequency
|
||||||
}
|
}
|
||||||
@ -59,13 +73,16 @@ void FI_add_freq_ignored(const uint32_t frequency)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
UART_printf("ignore %u\r\n", frequency);
|
UART_printf("ignore add %u\r\n", frequency);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (frequency == 0 || frequency == 0xffffffff)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ignore_frequencies_count >= (int)ARRAY_SIZE(ignore_frequencies))
|
if (ignore_frequencies_count >= (int)ARRAY_SIZE(ignore_frequencies))
|
||||||
{ // the list is full
|
{ // the list is full
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
UART_SendText("ignore full\r\n");
|
UART_SendText("ignore add full\r\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -77,7 +94,7 @@ void FI_add_freq_ignored(const uint32_t frequency)
|
|||||||
if (frequency == freq)
|
if (frequency == freq)
|
||||||
{ // already in the list
|
{ // already in the list
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
UART_SendText("ignore already\r\n");
|
UART_SendText("ignore add already\r\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -88,13 +105,9 @@ void FI_add_freq_ignored(const uint32_t frequency)
|
|||||||
|
|
||||||
// found the location to store the new frequency - the list is kept sorted by frequency
|
// found the location to store the new frequency - the list is kept sorted by frequency
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
|
||||||
UART_SendText("ignore adding ..\r\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// make room for the new frequency
|
// make room for the new frequency
|
||||||
if (i < ignore_frequencies_count)
|
if (i < ignore_frequencies_count)
|
||||||
memmove(&ignore_frequencies[i + 1], &ignore_frequencies[i], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - i - 1));
|
memmove(&ignore_frequencies[i + 1], &ignore_frequencies[i], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - i));
|
||||||
|
|
||||||
// add the frequency to the list
|
// add the frequency to the list
|
||||||
ignore_frequencies[i] = frequency;
|
ignore_frequencies[i] = frequency;
|
||||||
@ -109,17 +122,23 @@ void FI_add_freq_ignored(const uint32_t frequency)
|
|||||||
void FI_sub_freq_ignored(const uint32_t frequency)
|
void FI_sub_freq_ignored(const uint32_t frequency)
|
||||||
{ // remove a frequency from the ignore list
|
{ // remove a frequency from the ignore list
|
||||||
|
|
||||||
int index = FI_freq_ignored(frequency);
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
if (index >= 0)
|
UART_printf("ignore sub %u\r\n", frequency);
|
||||||
{
|
#endif
|
||||||
if (index < (ignore_frequencies_count - 1))
|
|
||||||
memmove(&ignore_frequencies[index], &ignore_frequencies[index + 1], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - 1));
|
|
||||||
ignore_frequencies_count--;
|
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
if (frequency == 0 || frequency == 0xffffffff)
|
||||||
UART_SendText("ignore freq ..\r\n");
|
return;
|
||||||
for (index = 0; index < ignore_frequencies_count; index++)
|
|
||||||
UART_printf("%2u %10u\r\n", index, ignore_frequencies[index]);
|
int index = FI_freq_ignored(frequency);
|
||||||
#endif
|
if (index < 0)
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
if (index < (ignore_frequencies_count - 1))
|
||||||
|
memmove(&ignore_frequencies[index], &ignore_frequencies[index + 1], sizeof(ignore_frequencies[0]) * (ignore_frequencies_count - 1));
|
||||||
|
ignore_frequencies_count--;
|
||||||
|
|
||||||
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
|
for (index = 0; index < ignore_frequencies_count; index++)
|
||||||
|
UART_printf("%2u %10u\r\n", index, ignore_frequencies[index]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user