mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
key repeat speeds up with time
This commit is contained in:
23
app/app.c
23
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user