diff --git a/app/app.c b/app/app.c index e57bb33..bc4ca37 100644 --- a/app/app.c +++ b/app/app.c @@ -1951,6 +1951,20 @@ void APP_time_slice_500ms(void) 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) { // update display once every 500ms 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) exit_menu = (g_current_display_screen == DISPLAY_MENU); // exit menu mode diff --git a/firmware.bin b/firmware.bin index 1512bdf..ad73f23 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index ad803e1..64b7cb5 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/freq_ignore.c b/freq_ignore.c index 4374020..3e82c78 100644 --- a/freq_ignore.c +++ b/freq_ignore.c @@ -12,6 +12,10 @@ int ignore_frequencies_count = 0; void FI_clear_freq_ignored(void) { // clear the ignore list 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) @@ -20,8 +24,8 @@ int FI_freq_ignored(const uint32_t frequency) if (frequency == 0 || frequency == 0xffffffff || ignore_frequencies_count <= 0) return -1; - if (ignore_frequencies_count > 4) - { // binary search .. becomes much faster than sequencial as the list grows + if (ignore_frequencies_count >= 8) + { // binary search .. becomes much faster than sequencial search when the list is bigger int low = 0; int high = ignore_frequencies_count; while (low < high) @@ -34,7 +38,12 @@ int FI_freq_ignored(const uint32_t frequency) if (freq < frequency) low = mid + 1; else + { + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_printf("ignored bin %u %u\r\n", frequency, mid); + #endif return mid; + } } } else @@ -44,7 +53,12 @@ int FI_freq_ignored(const uint32_t frequency) { register uint32_t freq = ignore_frequencies[i]; 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) 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; #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_printf("ignore %u\r\n", frequency); + UART_printf("ignore add %u\r\n", frequency); #endif + if (frequency == 0 || frequency == 0xffffffff) + return; + if (ignore_frequencies_count >= (int)ARRAY_SIZE(ignore_frequencies)) { // the list is full #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_SendText("ignore full\r\n"); + UART_SendText("ignore add full\r\n"); #endif return; } @@ -77,7 +94,7 @@ void FI_add_freq_ignored(const uint32_t frequency) if (frequency == freq) { // already in the list #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_SendText("ignore already\r\n"); + UART_SendText("ignore add already\r\n"); #endif 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 - #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_SendText("ignore adding ..\r\n"); - #endif - // make room for the new frequency 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 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) { // remove a frequency from the ignore list - int index = FI_freq_ignored(frequency); - if (index >= 0) - { - 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) + UART_printf("ignore sub %u\r\n", frequency); + #endif - #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_SendText("ignore freq ..\r\n"); - for (index = 0; index < ignore_frequencies_count; index++) - UART_printf("%2u %10u\r\n", index, ignore_frequencies[index]); - #endif - } + if (frequency == 0 || frequency == 0xffffffff) + return; + + int index = FI_freq_ignored(frequency); + 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 }