diff --git a/Makefile b/Makefile index 7fb3ad3..609c065 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ ENABLE_BOOT_BEEPS := 0 ENABLE_DTMF_CALL_FLASH_LIGHT := 1 ENABLE_FLASH_LIGHT_SOS_TONE := 0 ENABLE_SHOW_CHARGE_LEVEL := 0 -ENABLE_REVERSE_BAT_SYMBOL := 1 +ENABLE_REVERSE_BAT_SYMBOL := 0 ENABLE_FREQ_SEARCH_LNA := 0 ENABLE_FREQ_SEARCH_TIMEOUT := 0 ENABLE_CODE_SEARCH_TIMEOUT := 0 diff --git a/app/app.c b/app/app.c index 0639a7f..8930367 100644 --- a/app/app.c +++ b/app/app.c @@ -1277,6 +1277,8 @@ void APP_end_tx(void) } #endif +uint32_t key_repeat_ticks = SQR(100 / 10); + // called every 10ms void APP_check_keys(void) { @@ -1368,6 +1370,10 @@ void APP_check_keys(void) if (key == KEY_INVALID || (g_key_prev != KEY_INVALID && key != g_key_prev)) { // key not pressed or different key pressed + + // reset the key repeat speed + key_repeat_ticks = SQR(key_repeat_10ms); + if (g_key_debounce_press > 0) { if (--g_key_debounce_press == 0) @@ -1425,12 +1431,25 @@ void APP_check_keys(void) { // only the up and down keys are made repeatable // key repeat max 10ms speed if user is moving up/down in freq/channel - const bool freq_chan = IS_FREQ_CHANNEL(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen); - const uint8_t repeat_ticks = (g_manual_scanning && g_monitor_enabled && freq_chan && g_current_display_screen == DISPLAY_MAIN) ? 2 : key_repeat_10ms; +// const bool freq_chan = IS_FREQ_CHANNEL(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].screen); +// const uint8_t repeat_ticks = (g_manual_scanning && g_monitor_enabled && freq_chan && g_current_display_screen == DISPLAY_MAIN) ? 2 : NUMBER_isqrt(key_repeat_ticks); + const uint8_t repeat_ticks = NUMBER_isqrt(key_repeat_ticks); if (++g_key_debounce_repeat >= (long_press_ticks + repeat_ticks)) { // key repeat + + // speed up the key repeat the longer the key is help down + if (key_repeat_ticks >= (SQR(2) + 8)) + key_repeat_ticks -= 8; + else + key_repeat_ticks = SQR(2); + + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) +// UART_printf("rp %u\n", key_repeat_ticks); + #endif + g_key_debounce_repeat = long_press_ticks; + APP_process_key(g_key_prev, true, g_key_held); } } diff --git a/firmware.bin b/firmware.bin index 508d525..554e099 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 187e10a..80f489a 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/misc.c b/misc.c index 8ccd5df..1203c02 100644 --- a/misc.c +++ b/misc.c @@ -48,7 +48,8 @@ const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 sec const uint8_t key_debounce_10ms = 30 / 10; // 30ms const uint8_t key_side_long_press_10ms = 1000 / 10; // 1 second const uint8_t key_long_press_10ms = 300 / 10; // 300ms -const uint8_t key_repeat_10ms = 50 / 10; // 50ms +//const uint8_t key_repeat_10ms = 50 / 10; // 50ms +const uint8_t key_repeat_10ms = 200 / 10; // 200ms const uint16_t search_freq_css_10ms = 10000 / 10; // 10 seconds const uint16_t search_10ms = 210 / 10; // 210ms .. don't reduce this @@ -335,3 +336,18 @@ void NUMBER_trim_trailing_zeros(char *str) } } } + +// linear search, ascending, using addition +uint16_t NUMBER_isqrt(const uint32_t y) +{ + uint16_t L = 0; + uint32_t a = 1; + uint32_t d = 3; + while (a <= y) + { + a += d; // (a + 1) ^ 2 + d += 2; + L += 1; + } + return L; +} diff --git a/misc.h b/misc.h index ef95f6f..c0c5527 100644 --- a/misc.h +++ b/misc.h @@ -28,6 +28,10 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif +#ifndef SQR + #define SQR(x) ((x) * (x)) +#endif + #ifndef MAX // #define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; }) #endif @@ -333,6 +337,7 @@ void NUMBER_Get(char *pDigits, uint32_t *pInteger); void NUMBER_ToDigits(uint32_t Value, char *pDigits); int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit); void NUMBER_trim_trailing_zeros(char *str); +uint16_t NUMBER_isqrt(const uint32_t y); #endif diff --git a/panadapter.c b/panadapter.c index 4b9305c..1479771 100644 --- a/panadapter.c +++ b/panadapter.c @@ -221,7 +221,7 @@ void PAN_process_10ms(void) const uint16_t rssi = BK4819_GetRSSI(); g_panadapter_rssi[panadapter_rssi_index] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi; - // next frequency + // next scan/sweep frequency if (++panadapter_rssi_index >= (int)ARRAY_SIZE(g_panadapter_rssi)) { panadapter_rssi_index = 0; @@ -245,7 +245,7 @@ void PAN_process_10ms(void) // completed a full sweep/scan, draw the panadapter on-screen - if (g_panadapter_cycles + 1) // prevent wrap-a-round + if (g_panadapter_cycles + 1) // prevent wrap-a-round/over-flow g_panadapter_cycles++; PAN_update_min_max(); diff --git a/ui/main.c b/ui/main.c index d606efd..eaa5aac 100644 --- a/ui/main.c +++ b/ui/main.c @@ -99,21 +99,6 @@ void draw_bar(uint8_t *line, const int len, const int max_width) #ifdef ENABLE_TX_AUDIO_BAR - // linear search, ascending, using addition - uint16_t isqrt(const uint32_t y) - { - uint16_t L = 0; - uint32_t a = 1; - uint32_t d = 3; - while (a <= y) - { - a += d; // (a + 1) ^ 2 - d += 2; - L += 1; - } - return L; - } - bool UI_DisplayAudioBar(const bool now) { if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN) @@ -161,7 +146,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width) // make non-linear to make more sensitive at low values const unsigned int level = voice_amp * 8; - const unsigned int sqrt_level = isqrt((level < 65535) ? level : 65535); + const unsigned int sqrt_level = NUMBER_isqrt((level < 65535) ? level : 65535); const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width; draw_bar(p_line + bar_x, len, bar_width);