mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-29 06:41:25 +03:00
.
This commit is contained in:
parent
18a5fdffd6
commit
56836a3faf
78
app/app.c
78
app/app.c
@ -1277,14 +1277,14 @@ void APP_end_tx(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int key_repeat_speedup_ticks = 2500 / 10; // 2.5 seconds
|
|
||||||
uint8_t key_repeat_ticks = 300 / 10; // 300ms
|
|
||||||
|
|
||||||
// called every 10ms
|
// called every 10ms
|
||||||
void APP_check_keys(void)
|
void APP_process_keys(void)
|
||||||
{
|
{
|
||||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT);
|
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;
|
key_code_t key;
|
||||||
|
|
||||||
#ifdef ENABLE_KILL_REVIVE
|
#ifdef ENABLE_KILL_REVIVE
|
||||||
@ -1352,13 +1352,11 @@ void APP_check_keys(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// button processing (non-PTT)
|
// key/button processing (non-PTT)
|
||||||
|
|
||||||
// scan the hardware keys
|
// scan the hardware keys
|
||||||
key = KEYBOARD_Poll();
|
key = KEYBOARD_Poll();
|
||||||
|
|
||||||
g_boot_tick_10ms = 0; // cancel boot screen/beeps
|
|
||||||
|
|
||||||
if (g_serial_config_tick_500ms > 0)
|
if (g_serial_config_tick_500ms > 0)
|
||||||
{ // config upload/download in progress
|
{ // config upload/download in progress
|
||||||
g_key_debounce_press = 0;
|
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))
|
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-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)
|
||||||
{
|
{
|
||||||
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_debounce_repeat = 0;
|
||||||
g_key_prev = KEY_INVALID;
|
g_key_prev = KEY_INVALID;
|
||||||
g_key_held = false;
|
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_status = true;
|
||||||
// g_update_display = true;
|
// g_update_display = true;
|
||||||
}
|
}
|
||||||
@ -1396,49 +1390,54 @@ void APP_check_keys(void)
|
|||||||
if (g_key_debounce_repeat > 0)
|
if (g_key_debounce_repeat > 0)
|
||||||
g_key_debounce_repeat--;
|
g_key_debounce_repeat--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // key pressed
|
|
||||||
|
|
||||||
// long press time can be different for different keys
|
return;
|
||||||
const uint8_t long_press_ticks = (key == KEY_SIDE1 || key == KEY_SIDE2) ? key_side_long_press_10ms : key_long_press_10ms;
|
}
|
||||||
|
|
||||||
|
// key pressed
|
||||||
|
|
||||||
if (g_key_debounce_press < key_debounce_10ms)
|
if (g_key_debounce_press < key_debounce_10ms)
|
||||||
{
|
{
|
||||||
if (++g_key_debounce_press >= key_debounce_10ms)
|
if (++g_key_debounce_press >= key_debounce_10ms)
|
||||||
{
|
{
|
||||||
if (key != g_key_prev)
|
if (key != g_key_prev)
|
||||||
{ // key now fully pressed
|
{ // 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_debounce_repeat = key_debounce_10ms;
|
||||||
g_key_held = false;
|
|
||||||
g_key_prev = key;
|
g_key_prev = key;
|
||||||
|
g_key_held = false;
|
||||||
APP_process_key(g_key_prev, true, g_key_held);
|
APP_process_key(g_key_prev, true, g_key_held);
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
// g_update_display = true;
|
// g_update_display = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// 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)
|
||||||
{
|
{
|
||||||
if (++g_key_debounce_repeat >= long_press_ticks)
|
if (++g_key_debounce_repeat >= long_press_ticks)
|
||||||
{ // key long press
|
{ // key long press
|
||||||
g_key_held = true;
|
g_key_held = true;
|
||||||
APP_process_key(g_key_prev, true, g_key_held);
|
APP_process_key(g_key_prev, true, g_key_held);
|
||||||
g_update_status = true;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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 != 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_ticks > key_repeat_fastest_10ms)
|
||||||
{
|
{
|
||||||
if (--key_repeat_speedup_ticks <= 0)
|
if (--key_repeat_speedup_ticks <= 0)
|
||||||
{
|
{
|
||||||
key_repeat_speedup_ticks = 2500 / 10; // speed-up once every 2.5 seconds
|
key_repeat_speedup_ticks = key_repeat_speedup_10ms;
|
||||||
key_repeat_ticks = (key_repeat_ticks > (60 / 10)) ? key_repeat_ticks >> 1 : key_repeat_ticks - 1;
|
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_ticks = (key_repeat_ticks < key_repeat_fastest_10ms) ? key_repeat_fastest_10ms : key_repeat_ticks;
|
||||||
@ -1446,23 +1445,21 @@ void APP_check_keys(void)
|
|||||||
// 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_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;
|
const uint8_t repeat_ticks = 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
|
return;
|
||||||
|
|
||||||
|
// key repeat
|
||||||
|
|
||||||
|
g_key_debounce_repeat = long_press_ticks;
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
// UART_printf("rp %u\n", key_repeat_ticks);
|
// UART_printf("rp %u\n", key_repeat_ticks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APP_cancel_user_input_modes(void)
|
void APP_cancel_user_input_modes(void)
|
||||||
@ -1726,14 +1723,14 @@ void APP_process_search(void)
|
|||||||
{
|
{
|
||||||
if (--g_search_tick_10ms > 0)
|
if (--g_search_tick_10ms > 0)
|
||||||
{
|
{
|
||||||
APP_check_keys();
|
APP_process_keys();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_search_edit_state != SEARCH_EDIT_STATE_NONE)
|
if (g_search_edit_state != SEARCH_EDIT_STATE_NONE)
|
||||||
{ // waiting for user input choice
|
{ // waiting for user input choice
|
||||||
APP_check_keys();
|
APP_process_keys();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1860,7 +1857,6 @@ void APP_process_power_save(void)
|
|||||||
g_ptt_is_pressed ||
|
g_ptt_is_pressed ||
|
||||||
g_fkey_pressed ||
|
g_fkey_pressed ||
|
||||||
g_key_pressed != KEY_INVALID ||
|
g_key_pressed != KEY_INVALID ||
|
||||||
g_key_held ||
|
|
||||||
g_eeprom.config.setting.battery_save_ratio == 0 ||
|
g_eeprom.config.setting.battery_save_ratio == 0 ||
|
||||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||||
@ -2386,7 +2382,7 @@ void APP_time_slice_10ms(void)
|
|||||||
|
|
||||||
AIRCOPY_process_fsk_rx_10ms();
|
AIRCOPY_process_fsk_rx_10ms();
|
||||||
|
|
||||||
APP_check_keys();
|
APP_process_keys();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2551,7 +2547,7 @@ void APP_time_slice_10ms(void)
|
|||||||
|
|
||||||
APP_process_search();
|
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)
|
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_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 = 320 / 10; // 320ms
|
||||||
const uint8_t key_repeat_initial_10ms = 300 / 10; // 300ms
|
const uint8_t key_repeat_initial_10ms = 320 / 10; // 320ms
|
||||||
const uint8_t key_repeat_fastest_10ms = 10 / 10; // 10ms
|
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_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
|
||||||
|
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_long_press_10ms;
|
||||||
extern const uint8_t key_repeat_initial_10ms;
|
extern const uint8_t key_repeat_initial_10ms;
|
||||||
extern const uint8_t key_repeat_fastest_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_freq_css_10ms;
|
||||||
extern const uint16_t search_10ms;
|
extern const uint16_t search_10ms;
|
||||||
|
17
ui/menu.c
17
ui/menu.c
@ -390,6 +390,8 @@ const char g_sub_menu_side_butt[9][16] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char back_light_str[] = "BACKLITE\n";
|
||||||
|
|
||||||
// ***************************************************************************************
|
// ***************************************************************************************
|
||||||
|
|
||||||
uint8_t g_menu_list_sorted[ARRAY_SIZE(g_menu_list)];
|
uint8_t g_menu_list_sorted[ARRAY_SIZE(g_menu_list)];
|
||||||
@ -718,13 +720,13 @@ void UI_DisplayMenu(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case MENU_AUTO_BACKLITE:
|
case MENU_AUTO_BACKLITE:
|
||||||
strcpy(str, "BACKLITE\n");
|
strcpy(str, back_light_str);
|
||||||
strcat(str, g_sub_menu_backlight[g_sub_menu_selection]);
|
strcat(str, g_sub_menu_backlight[g_sub_menu_selection]);
|
||||||
BACKLIGHT_turn_on(5);
|
BACKLIGHT_turn_on(5);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MENU_AUTO_BACKLITE_ON_TX_RX:
|
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]);
|
strcat(str, g_sub_menu_rx_tx[g_sub_menu_selection]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -756,8 +758,12 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
#ifdef ENABLE_CONTRAST
|
#ifdef ENABLE_CONTRAST
|
||||||
case MENU_CONTRAST:
|
case MENU_CONTRAST:
|
||||||
|
#if 0
|
||||||
strcpy(str, "CONTRAST\n");
|
strcpy(str, "CONTRAST\n");
|
||||||
sprintf(str + strlen(str), "%d", g_sub_menu_selection);
|
sprintf(str + strlen(str), "%d", g_sub_menu_selection);
|
||||||
|
#else
|
||||||
|
sprintf(str, "%d", g_sub_menu_selection);
|
||||||
|
#endif
|
||||||
ST7565_SetContrast(g_sub_menu_selection);
|
ST7565_SetContrast(g_sub_menu_selection);
|
||||||
g_update_display = true;
|
g_update_display = true;
|
||||||
break;
|
break;
|
||||||
@ -956,7 +962,7 @@ void UI_DisplayMenu(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case MENU_DUAL_WATCH:
|
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]);
|
strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1051,7 +1057,6 @@ void UI_DisplayMenu(void)
|
|||||||
|
|
||||||
case MENU_DTMF_PRE:
|
case MENU_DTMF_PRE:
|
||||||
strcpy(str, "DTMF BOT\nDELAY\n");
|
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);
|
sprintf(str + strlen(str), "%dms", 10 * g_sub_menu_selection);
|
||||||
break;
|
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__);
|
strcat(str, "\n \n" __DATE__ "\n" __TIME__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1358,7 +1363,7 @@ void UI_DisplayMenu(void)
|
|||||||
g_menu_cursor == MENU_MEM_NAME ||
|
g_menu_cursor == MENU_MEM_NAME ||
|
||||||
g_menu_cursor == MENU_MEM_DEL) && g_ask_for_confirmation)
|
g_menu_cursor == MENU_MEM_DEL) && g_ask_for_confirmation)
|
||||||
{ // display 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);
|
UI_PrintString(str, sub_menu_x1, sub_menu_x2, 5, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user