mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
.
This commit is contained in:
parent
18a5fdffd6
commit
56836a3faf
158
app/app.c
158
app/app.c
@ -1277,14 +1277,14 @@ void APP_end_tx(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
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)
|
||||
void APP_process_keys(void)
|
||||
{
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT);
|
||||
|
||||
static int key_repeat_speedup_ticks = 0;
|
||||
static uint8_t key_repeat_ticks = 0;
|
||||
|
||||
key_code_t key;
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
@ -1352,13 +1352,11 @@ void APP_check_keys(void)
|
||||
#endif
|
||||
|
||||
// *****************
|
||||
// button processing (non-PTT)
|
||||
// key/button processing (non-PTT)
|
||||
|
||||
// scan the hardware keys
|
||||
key = KEYBOARD_Poll();
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel boot screen/beeps
|
||||
|
||||
if (g_serial_config_tick_500ms > 0)
|
||||
{ // config upload/download in progress
|
||||
g_key_debounce_press = 0;
|
||||
@ -1372,10 +1370,6 @@ 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-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)
|
||||
{
|
||||
if (--g_key_debounce_press == 0)
|
||||
@ -1387,7 +1381,7 @@ void APP_check_keys(void)
|
||||
g_key_debounce_repeat = 0;
|
||||
g_key_prev = KEY_INVALID;
|
||||
g_key_held = false;
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_boot_tick_10ms = 0; // cancel boot screen/beeps
|
||||
g_update_status = true;
|
||||
// g_update_display = true;
|
||||
}
|
||||
@ -1396,73 +1390,76 @@ void APP_check_keys(void)
|
||||
if (g_key_debounce_repeat > 0)
|
||||
g_key_debounce_repeat--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // key pressed
|
||||
|
||||
// long press time can be different for different keys
|
||||
const uint8_t long_press_ticks = (key == KEY_SIDE1 || key == KEY_SIDE2) ? key_side_long_press_10ms : key_long_press_10ms;
|
||||
|
||||
if (g_key_debounce_press < key_debounce_10ms)
|
||||
{
|
||||
if (++g_key_debounce_press >= key_debounce_10ms)
|
||||
{
|
||||
if (key != g_key_prev)
|
||||
{ // key now fully pressed
|
||||
g_key_debounce_repeat = key_debounce_10ms;
|
||||
g_key_held = false;
|
||||
g_key_prev = key;
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
g_update_status = true;
|
||||
// g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_key_debounce_repeat < long_press_ticks)
|
||||
{
|
||||
if (++g_key_debounce_repeat >= long_press_ticks)
|
||||
{ // key long press
|
||||
g_key_held = true;
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
g_update_status = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
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 : key_repeat_ticks;
|
||||
const uint8_t repeat_ticks = key_repeat_ticks;
|
||||
|
||||
if (++g_key_debounce_repeat >= (long_press_ticks + repeat_ticks))
|
||||
{ // key repeat
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// *****************
|
||||
// key pressed
|
||||
|
||||
if (g_key_debounce_press < key_debounce_10ms)
|
||||
{
|
||||
if (++g_key_debounce_press >= key_debounce_10ms)
|
||||
{
|
||||
if (key != g_key_prev)
|
||||
{ // key pressed
|
||||
key_repeat_speedup_ticks = key_repeat_speedup_10ms;
|
||||
key_repeat_ticks = key_repeat_initial_10ms;
|
||||
g_key_debounce_repeat = key_debounce_10ms;
|
||||
g_key_prev = key;
|
||||
g_key_held = false;
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
g_update_status = true;
|
||||
// g_update_display = true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// long press time can be different for different keys
|
||||
const uint8_t long_press_ticks = (key == KEY_SIDE1 || key == KEY_SIDE2) ? key_side_long_press_10ms : key_long_press_10ms;
|
||||
|
||||
if (g_key_debounce_repeat < long_press_ticks)
|
||||
{
|
||||
if (++g_key_debounce_repeat >= long_press_ticks)
|
||||
{ // key long press
|
||||
g_key_held = true;
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key != KEY_UP && key != KEY_DOWN)
|
||||
return; // up and down keys are the only repeatables
|
||||
|
||||
// speed up key repeat
|
||||
if (key_repeat_ticks > key_repeat_fastest_10ms)
|
||||
{
|
||||
if (--key_repeat_speedup_ticks <= 0)
|
||||
{
|
||||
key_repeat_speedup_ticks = key_repeat_speedup_10ms;
|
||||
key_repeat_ticks = (key_repeat_ticks > (80 / 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 : key_repeat_ticks;
|
||||
|
||||
const uint8_t repeat_ticks = key_repeat_ticks;
|
||||
|
||||
if (++g_key_debounce_repeat < (long_press_ticks + repeat_ticks))
|
||||
return;
|
||||
|
||||
// key repeat
|
||||
|
||||
g_key_debounce_repeat = long_press_ticks;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("rp %u\n", key_repeat_ticks);
|
||||
#endif
|
||||
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
}
|
||||
|
||||
void APP_cancel_user_input_modes(void)
|
||||
@ -1726,14 +1723,14 @@ void APP_process_search(void)
|
||||
{
|
||||
if (--g_search_tick_10ms > 0)
|
||||
{
|
||||
APP_check_keys();
|
||||
APP_process_keys();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_search_edit_state != SEARCH_EDIT_STATE_NONE)
|
||||
{ // waiting for user input choice
|
||||
APP_check_keys();
|
||||
APP_process_keys();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1860,7 +1857,6 @@ void APP_process_power_save(void)
|
||||
g_ptt_is_pressed ||
|
||||
g_fkey_pressed ||
|
||||
g_key_pressed != KEY_INVALID ||
|
||||
g_key_held ||
|
||||
g_eeprom.config.setting.battery_save_ratio == 0 ||
|
||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
@ -2386,7 +2382,7 @@ void APP_time_slice_10ms(void)
|
||||
|
||||
AIRCOPY_process_fsk_rx_10ms();
|
||||
|
||||
APP_check_keys();
|
||||
APP_process_keys();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -2551,7 +2547,7 @@ void APP_time_slice_10ms(void)
|
||||
|
||||
APP_process_search();
|
||||
|
||||
APP_check_keys();
|
||||
APP_process_keys();
|
||||
}
|
||||
|
||||
static void APP_process_key(const key_code_t Key, const bool key_pressed, const bool key_held)
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
5
misc.c
5
misc.c
@ -47,9 +47,10 @@ 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_initial_10ms = 300 / 10; // 300ms
|
||||
const uint8_t key_long_press_10ms = 320 / 10; // 320ms
|
||||
const uint8_t key_repeat_initial_10ms = 320 / 10; // 320ms
|
||||
const uint8_t key_repeat_fastest_10ms = 10 / 10; // 10ms
|
||||
const uint16_t key_repeat_speedup_10ms = 2500 / 10; // speed-up key repeat once every 2.5 seconds
|
||||
|
||||
const uint16_t search_freq_css_10ms = 10000 / 10; // 10 seconds
|
||||
const uint16_t search_10ms = 210 / 10; // 210ms .. don't reduce this
|
||||
|
1
misc.h
1
misc.h
@ -150,6 +150,7 @@ extern const uint8_t key_side_long_press_10ms;
|
||||
extern const uint8_t key_long_press_10ms;
|
||||
extern const uint8_t key_repeat_initial_10ms;
|
||||
extern const uint8_t key_repeat_fastest_10ms;
|
||||
extern const uint16_t key_repeat_speedup_10ms;
|
||||
|
||||
extern const uint16_t search_freq_css_10ms;
|
||||
extern const uint16_t search_10ms;
|
||||
|
29
ui/menu.c
29
ui/menu.c
@ -390,6 +390,8 @@ const char g_sub_menu_side_butt[9][16] =
|
||||
};
|
||||
#endif
|
||||
|
||||
const char back_light_str[] = "BACKLITE\n";
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
uint8_t g_menu_list_sorted[ARRAY_SIZE(g_menu_list)];
|
||||
@ -678,7 +680,7 @@ void UI_DisplayMenu(void)
|
||||
str[i] = '.';
|
||||
while (i < 8)
|
||||
{
|
||||
str[1 + i] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0';
|
||||
str[1 + i] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0';
|
||||
i++;
|
||||
}
|
||||
UI_PrintString(str, sub_menu_x1, sub_menu_x2, 1, 8);
|
||||
@ -718,13 +720,13 @@ void UI_DisplayMenu(void)
|
||||
#endif
|
||||
|
||||
case MENU_AUTO_BACKLITE:
|
||||
strcpy(str, "BACKLITE\n");
|
||||
strcpy(str, back_light_str);
|
||||
strcat(str, g_sub_menu_backlight[g_sub_menu_selection]);
|
||||
BACKLIGHT_turn_on(5);
|
||||
break;
|
||||
|
||||
case MENU_AUTO_BACKLITE_ON_TX_RX:
|
||||
strcpy(str, "BACKLITE\n");
|
||||
strcpy(str, back_light_str);
|
||||
strcat(str, g_sub_menu_rx_tx[g_sub_menu_selection]);
|
||||
break;
|
||||
|
||||
@ -756,8 +758,12 @@ void UI_DisplayMenu(void)
|
||||
|
||||
#ifdef ENABLE_CONTRAST
|
||||
case MENU_CONTRAST:
|
||||
strcpy(str, "CONTRAST\n");
|
||||
sprintf(str + strlen(str), "%d", g_sub_menu_selection);
|
||||
#if 0
|
||||
strcpy(str, "CONTRAST\n");
|
||||
sprintf(str + strlen(str), "%d", g_sub_menu_selection);
|
||||
#else
|
||||
sprintf(str, "%d", g_sub_menu_selection);
|
||||
#endif
|
||||
ST7565_SetContrast(g_sub_menu_selection);
|
||||
g_update_display = true;
|
||||
break;
|
||||
@ -956,7 +962,7 @@ void UI_DisplayMenu(void)
|
||||
#endif
|
||||
|
||||
case MENU_DUAL_WATCH:
|
||||
// strcpy(String, g_sub_menu_dual_watch[g_sub_menu_selection]);
|
||||
// strcpy(str, g_sub_menu_dual_watch[g_sub_menu_selection]);
|
||||
strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
|
||||
break;
|
||||
|
||||
@ -1051,7 +1057,6 @@ void UI_DisplayMenu(void)
|
||||
|
||||
case MENU_DTMF_PRE:
|
||||
strcpy(str, "DTMF BOT\nDELAY\n");
|
||||
// sprintf(String + strlen(String), "%d*10ms", g_sub_menu_selection);
|
||||
sprintf(str + strlen(str), "%dms", 10 * g_sub_menu_selection);
|
||||
break;
|
||||
|
||||
@ -1061,7 +1066,7 @@ void UI_DisplayMenu(void)
|
||||
strcat(str, g_sub_menu_mdc1200_mode[g_sub_menu_selection]);
|
||||
channel_setting = true;
|
||||
break;
|
||||
|
||||
|
||||
case MENU_MDC1200_ID:
|
||||
sprintf(str, "MDC1200\nID\n%04X", g_sub_menu_selection);
|
||||
break;
|
||||
@ -1094,7 +1099,7 @@ void UI_DisplayMenu(void)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MENU_PON_MSG:
|
||||
strcpy(str, g_sub_menu_pwr_on_msg[g_sub_menu_selection]);
|
||||
break;
|
||||
@ -1152,7 +1157,7 @@ void UI_DisplayMenu(void)
|
||||
}
|
||||
}
|
||||
|
||||
// add the date and time
|
||||
// add the compiled date and time
|
||||
strcat(str, "\n \n" __DATE__ "\n" __TIME__);
|
||||
break;
|
||||
}
|
||||
@ -1354,11 +1359,11 @@ void UI_DisplayMenu(void)
|
||||
}
|
||||
|
||||
if ((g_menu_cursor == MENU_RESET ||
|
||||
g_menu_cursor == MENU_MEM_SAVE ||
|
||||
g_menu_cursor == MENU_MEM_SAVE ||
|
||||
g_menu_cursor == MENU_MEM_NAME ||
|
||||
g_menu_cursor == MENU_MEM_DEL) && g_ask_for_confirmation)
|
||||
{ // display confirmation
|
||||
strcpy(str, (g_ask_for_confirmation == 1) ? "SURE?" : "WAIT!");
|
||||
strcpy(str, (g_ask_for_confirmation == 1) ? "SURE ?" : "WAIT !");
|
||||
UI_PrintString(str, sub_menu_x1, sub_menu_x2, 5, 8);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user