mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
key repeat speeds up with time
This commit is contained in:
parent
0c1eeb0e92
commit
279829b366
2
Makefile
2
Makefile
@ -58,7 +58,7 @@ ENABLE_BOOT_BEEPS := 0
|
|||||||
ENABLE_DTMF_CALL_FLASH_LIGHT := 1
|
ENABLE_DTMF_CALL_FLASH_LIGHT := 1
|
||||||
ENABLE_FLASH_LIGHT_SOS_TONE := 0
|
ENABLE_FLASH_LIGHT_SOS_TONE := 0
|
||||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
ENABLE_SHOW_CHARGE_LEVEL := 0
|
||||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
ENABLE_REVERSE_BAT_SYMBOL := 0
|
||||||
ENABLE_FREQ_SEARCH_LNA := 0
|
ENABLE_FREQ_SEARCH_LNA := 0
|
||||||
ENABLE_FREQ_SEARCH_TIMEOUT := 0
|
ENABLE_FREQ_SEARCH_TIMEOUT := 0
|
||||||
ENABLE_CODE_SEARCH_TIMEOUT := 0
|
ENABLE_CODE_SEARCH_TIMEOUT := 0
|
||||||
|
23
app/app.c
23
app/app.c
@ -1277,6 +1277,8 @@ void APP_end_tx(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t key_repeat_ticks = SQR(100 / 10);
|
||||||
|
|
||||||
// called every 10ms
|
// called every 10ms
|
||||||
void APP_check_keys(void)
|
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))
|
if (key == KEY_INVALID || (g_key_prev != KEY_INVALID && key != g_key_prev))
|
||||||
{ // key not pressed or different key pressed
|
{ // 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)
|
||||||
{
|
{
|
||||||
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
|
{ // only the up and down keys are made repeatable
|
||||||
|
|
||||||
// key repeat max 10ms speed if user is moving up/down in freq/channel
|
// 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 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 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))
|
if (++g_key_debounce_repeat >= (long_press_ticks + repeat_ticks))
|
||||||
{ // key repeat
|
{ // 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;
|
g_key_debounce_repeat = long_press_ticks;
|
||||||
|
|
||||||
APP_process_key(g_key_prev, true, g_key_held);
|
APP_process_key(g_key_prev, true, g_key_held);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
18
misc.c
18
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_debounce_10ms = 30 / 10; // 30ms
|
||||||
const uint8_t key_side_long_press_10ms = 1000 / 10; // 1 second
|
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_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_freq_css_10ms = 10000 / 10; // 10 seconds
|
||||||
const uint16_t search_10ms = 210 / 10; // 210ms .. don't reduce this
|
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;
|
||||||
|
}
|
||||||
|
5
misc.h
5
misc.h
@ -28,6 +28,10 @@
|
|||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SQR
|
||||||
|
#define SQR(x) ((x) * (x))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
// #define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
|
// #define MAX(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
|
||||||
#endif
|
#endif
|
||||||
@ -333,6 +337,7 @@ void NUMBER_Get(char *pDigits, uint32_t *pInteger);
|
|||||||
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
|
||||||
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
|
||||||
void NUMBER_trim_trailing_zeros(char *str);
|
void NUMBER_trim_trailing_zeros(char *str);
|
||||||
|
uint16_t NUMBER_isqrt(const uint32_t y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ void PAN_process_10ms(void)
|
|||||||
const uint16_t rssi = BK4819_GetRSSI();
|
const uint16_t rssi = BK4819_GetRSSI();
|
||||||
g_panadapter_rssi[panadapter_rssi_index] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi;
|
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))
|
if (++panadapter_rssi_index >= (int)ARRAY_SIZE(g_panadapter_rssi))
|
||||||
{
|
{
|
||||||
panadapter_rssi_index = 0;
|
panadapter_rssi_index = 0;
|
||||||
@ -245,7 +245,7 @@ void PAN_process_10ms(void)
|
|||||||
|
|
||||||
// completed a full sweep/scan, draw the panadapter on-screen
|
// 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++;
|
g_panadapter_cycles++;
|
||||||
|
|
||||||
PAN_update_min_max();
|
PAN_update_min_max();
|
||||||
|
17
ui/main.c
17
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
|
#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)
|
bool UI_DisplayAudioBar(const bool now)
|
||||||
{
|
{
|
||||||
if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
|
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
|
// make non-linear to make more sensitive at low values
|
||||||
const unsigned int level = voice_amp * 8;
|
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;
|
const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
|
||||||
|
|
||||||
draw_bar(p_line + bar_x, len, bar_width);
|
draw_bar(p_line + bar_x, len, bar_width);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user