0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

key-repeat speed-up update

This commit is contained in:
OneOfEleven 2023-11-22 09:38:41 +00:00
parent 279829b366
commit 18a5fdffd6
5 changed files with 22 additions and 14 deletions

View File

@ -1277,7 +1277,8 @@ void APP_end_tx(void)
}
#endif
uint32_t key_repeat_ticks = SQR(100 / 10);
int key_repeat_speedup_ticks = 2500 / 10; // 2.5 seconds
uint8_t key_repeat_ticks = 300 / 10; // 300ms
// called every 10ms
void APP_check_keys(void)
@ -1371,8 +1372,9 @@ 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);
// reset the key repeat speed-up settings
key_repeat_speedup_ticks = 2500 / 10; // speed-up once every 2.5 seconds
key_repeat_ticks = key_repeat_initial_10ms;
if (g_key_debounce_press > 0)
{
@ -1430,20 +1432,25 @@ void APP_check_keys(void)
if (key == KEY_UP || key == KEY_DOWN)
{ // only the up and down keys are made repeatable
// speed up key repeat the longer it's held down
if (key_repeat_ticks > key_repeat_fastest_10ms)
{
if (--key_repeat_speedup_ticks <= 0)
{
key_repeat_speedup_ticks = 2500 / 10; // speed-up once every 2.5 seconds
key_repeat_ticks = (key_repeat_ticks > (60 / 10)) ? key_repeat_ticks >> 1 : key_repeat_ticks - 1;
}
}
key_repeat_ticks = (key_repeat_ticks < key_repeat_fastest_10ms) ? key_repeat_fastest_10ms : key_repeat_ticks;
// 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 : NUMBER_isqrt(key_repeat_ticks);
const uint8_t repeat_ticks = NUMBER_isqrt(key_repeat_ticks);
// const uint8_t repeat_ticks = (g_manual_scanning && g_monitor_enabled && freq_chan && g_current_display_screen == DISPLAY_MAIN) ? 2 : key_repeat_ticks;
const uint8_t repeat_ticks = 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

Binary file not shown.

Binary file not shown.

4
misc.c
View File

@ -48,8 +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 = 200 / 10; // 200ms
const uint8_t key_repeat_initial_10ms = 300 / 10; // 300ms
const uint8_t key_repeat_fastest_10ms = 10 / 10; // 10ms
const uint16_t search_freq_css_10ms = 10000 / 10; // 10 seconds
const uint16_t search_10ms = 210 / 10; // 210ms .. don't reduce this

3
misc.h
View File

@ -148,7 +148,8 @@ extern const uint8_t key_input_timeout_500ms;
extern const uint8_t key_debounce_10ms;
extern const uint8_t key_side_long_press_10ms;
extern const uint8_t key_long_press_10ms;
extern const uint8_t key_repeat_10ms;
extern const uint8_t key_repeat_initial_10ms;
extern const uint8_t key_repeat_fastest_10ms;
extern const uint16_t search_freq_css_10ms;
extern const uint16_t search_10ms;