mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Fixed button/ptt being ignored, re-wrote a keyboard function as well.
This commit is contained in:
parent
fe77e62fe0
commit
c76891be6d
2
Makefile
2
Makefile
@ -26,7 +26,7 @@ ENABLE_TX_WHEN_AM := 0
|
||||
ENABLE_F_CAL_MENU := 0
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_BOOT_BEEPS := 0
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 1
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
||||
ENABLE_CODE_SCAN_TIMEOUT := 0
|
||||
ENABLE_FREQ_CODE_SCAN_TIMEOUT := 1
|
||||
|
29
app/action.c
29
app/action.c
@ -332,35 +332,6 @@ void ACTION_Handle(key_code_t Key, bool key_pressed, bool key_held)
|
||||
uint8_t Short = ACTION_OPT_NONE;
|
||||
uint8_t Long = ACTION_OPT_NONE;
|
||||
|
||||
if (g_screen_to_display == DISPLAY_MAIN && g_dtmf_input_mode)
|
||||
{
|
||||
if (Key == KEY_SIDE1 && !key_held && key_pressed)
|
||||
{
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
if (g_dtmf_input_box_index > 0)
|
||||
{
|
||||
g_dtmf_input_box[--g_dtmf_input_box_index] = '-';
|
||||
if (g_dtmf_input_box_index > 0)
|
||||
{
|
||||
g_ptt_was_released = true;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_dtmf_input_mode = false;
|
||||
}
|
||||
|
||||
g_ptt_was_released = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Key == KEY_SIDE1)
|
||||
{
|
||||
Short = g_eeprom.key1_short_press_action;
|
||||
|
488
app/app.c
488
app/app.c
@ -70,7 +70,7 @@ const uint8_t orig_lna = 2; // -14dB
|
||||
const uint8_t orig_mixer = 3; // 0dB
|
||||
const uint8_t orig_pga = 6; // -3dB
|
||||
|
||||
static void APP_ProcessKey(key_code_t Key, bool key_pressed, bool key_held);
|
||||
static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const bool key_held);
|
||||
|
||||
static void updateRSSI(const int vfo)
|
||||
{
|
||||
@ -992,7 +992,9 @@ void APP_EndTransmission(void)
|
||||
if (g_vox_stop_count_down_10ms == 0)
|
||||
g_vox_noise_detected = false;
|
||||
|
||||
if (g_current_function == FUNCTION_TRANSMIT && !g_ptt_is_pressed && !g_vox_noise_detected)
|
||||
if (g_current_function == FUNCTION_TRANSMIT &&
|
||||
!g_ptt_is_pressed &&
|
||||
!g_vox_noise_detected)
|
||||
{
|
||||
if (g_flag_end_tx)
|
||||
{
|
||||
@ -1067,36 +1069,39 @@ void APP_Update(void)
|
||||
APP_HandleFunction();
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
// if (g_fm_radio_count_down_500ms > 0)
|
||||
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) // 1of11
|
||||
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (g_screen_to_display != DISPLAY_SCANNER && g_scan_state_dir != SCAN_OFF && g_schedule_scan_listen && !g_ptt_is_pressed && g_voice_write_index == 0)
|
||||
#else
|
||||
if (g_screen_to_display != DISPLAY_SCANNER && g_scan_state_dir != SCAN_OFF && g_schedule_scan_listen && !g_ptt_is_pressed)
|
||||
if (g_voice_write_index == 0)
|
||||
#endif
|
||||
{ // scanning
|
||||
{
|
||||
if (g_screen_to_display != DISPLAY_SCANNER &&
|
||||
g_scan_state_dir != SCAN_OFF &&
|
||||
g_schedule_scan_listen &&
|
||||
!g_ptt_is_pressed)
|
||||
{ // scanning
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_next_channel))
|
||||
{
|
||||
if (g_current_function == FUNCTION_INCOMING)
|
||||
APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
if (IS_FREQ_CHANNEL(g_next_channel))
|
||||
{
|
||||
if (g_current_function == FUNCTION_INCOMING)
|
||||
APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
else
|
||||
FREQ_NextChannel(); // switch to next frequency
|
||||
}
|
||||
else
|
||||
FREQ_NextChannel(); // switch to next frequency
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_current_code_type == CODE_TYPE_OFF && g_current_function == FUNCTION_INCOMING)
|
||||
APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
else
|
||||
USER_NextChannel(); // switch to next channel
|
||||
}
|
||||
{
|
||||
if (g_current_code_type == CODE_TYPE_OFF && g_current_function == FUNCTION_INCOMING)
|
||||
APP_StartListening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
|
||||
else
|
||||
USER_NextChannel(); // switch to next channel
|
||||
}
|
||||
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
g_schedule_scan_listen = false;
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
g_schedule_scan_listen = false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -1129,29 +1134,32 @@ void APP_Update(void)
|
||||
if (g_screen_to_display != DISPLAY_SCANNER && g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
if (g_schedule_dual_watch && g_voice_write_index == 0)
|
||||
#else
|
||||
if (g_schedule_dual_watch)
|
||||
if (g_voice_write_index == 0)
|
||||
#endif
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
if (g_schedule_dual_watch)
|
||||
{
|
||||
if (!g_ptt_is_pressed &&
|
||||
#ifdef ENABLE_FMRADIO
|
||||
!g_fm_radio_mode &&
|
||||
#endif
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
|
||||
g_current_function != FUNCTION_POWER_SAVE)
|
||||
if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
DUALWATCH_Alternate(); // toggle between the two VFO's
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (!g_fm_radio_mode)
|
||||
#endif
|
||||
{
|
||||
if (!g_ptt_is_pressed &&
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
|
||||
g_current_function != FUNCTION_POWER_SAVE)
|
||||
{
|
||||
DUALWATCH_Alternate(); // toggle between the two VFO's
|
||||
|
||||
if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
g_rx_vfo_is_active = false;
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
g_schedule_dual_watch = false;
|
||||
g_rx_vfo_is_active = false;
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
g_schedule_dual_watch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1182,8 +1190,8 @@ void APP_Update(void)
|
||||
g_fm_radio_mode ||
|
||||
#endif
|
||||
g_ptt_is_pressed ||
|
||||
g_key_being_held ||
|
||||
g_eeprom.battery_save == 0 ||
|
||||
g_key_held ||
|
||||
g_eeprom.battery_save == 0 ||
|
||||
g_scan_state_dir != SCAN_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
g_screen_to_display != DISPLAY_MAIN ||
|
||||
@ -1194,8 +1202,7 @@ void APP_Update(void)
|
||||
else
|
||||
if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) && IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) || !g_is_noaa_mode)
|
||||
{
|
||||
//if (g_current_function != FUNCTION_POWER_SAVE)
|
||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1207,8 +1214,8 @@ void APP_Update(void)
|
||||
g_fm_radio_mode ||
|
||||
#endif
|
||||
g_ptt_is_pressed ||
|
||||
g_key_being_held ||
|
||||
g_eeprom.battery_save == 0 ||
|
||||
g_key_held ||
|
||||
g_eeprom.battery_save == 0 ||
|
||||
g_scan_state_dir != SCAN_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
g_screen_to_display != DISPLAY_MAIN ||
|
||||
@ -1218,8 +1225,7 @@ void APP_Update(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (g_current_function != FUNCTION_POWER_SAVE)
|
||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||
}
|
||||
|
||||
g_schedule_power_save = false;
|
||||
@ -1254,7 +1260,7 @@ void APP_Update(void)
|
||||
FUNCTION_Init();
|
||||
|
||||
g_power_save_10ms = power_save1_10ms; // come back here in a bit
|
||||
g_rx_idle_mode = false; // RX is awake
|
||||
g_rx_idle_mode = false; // RX is awake
|
||||
}
|
||||
else
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF || g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF || g_update_rssi)
|
||||
@ -1265,7 +1271,7 @@ void APP_Update(void)
|
||||
// go back to sleep
|
||||
|
||||
g_power_save_10ms = g_eeprom.battery_save * 10;
|
||||
g_rx_idle_mode = true;
|
||||
g_rx_idle_mode = true;
|
||||
|
||||
BK4819_DisableVox();
|
||||
BK4819_Sleep();
|
||||
@ -1279,8 +1285,8 @@ void APP_Update(void)
|
||||
// toggle between the two VFO's
|
||||
DUALWATCH_Alternate();
|
||||
|
||||
g_update_rssi = true;
|
||||
g_power_save_10ms = power_save1_10ms;
|
||||
g_update_rssi = true;
|
||||
g_power_save_10ms = power_save1_10ms;
|
||||
}
|
||||
|
||||
g_power_save_count_down_expired = false;
|
||||
@ -1290,7 +1296,9 @@ void APP_Update(void)
|
||||
// called every 10ms
|
||||
void APP_CheckKeys(void)
|
||||
{
|
||||
key_code_t Key;
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && (g_serial_config_count_down_500ms == 0) && g_setting_tx_enable;
|
||||
|
||||
key_code_t key;
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (g_setting_killed || (g_screen_to_display == DISPLAY_AIRCOPY && g_aircopy_state != AIRCOPY_READY))
|
||||
@ -1300,133 +1308,164 @@ void APP_CheckKeys(void)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (g_ptt_is_pressed)
|
||||
{
|
||||
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || g_serial_config_count_down_500ms > 0 || !g_setting_tx_enable)
|
||||
{ // PTT released or serial comms config in progress
|
||||
if (++g_ptt_debounce_counter >= 3 || g_serial_config_count_down_500ms > 0) // 30ms
|
||||
{ // stop transmitting
|
||||
APP_ProcessKey(KEY_PTT, false, false);
|
||||
g_ptt_is_pressed = false;
|
||||
if (g_key_reading_1 != KEY_INVALID)
|
||||
g_ptt_was_released = true;
|
||||
// *****************
|
||||
// PTT is treated completely separately from all the other buttons
|
||||
|
||||
if (ptt_pressed)
|
||||
{ // PTT pressed
|
||||
if (!g_ptt_is_pressed)
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
{ // start TX'ing
|
||||
|
||||
g_boot_counter_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = true;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_ProcessKey(KEY_PTT, true, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
g_ptt_debounce_counter = 0;
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
else
|
||||
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && g_serial_config_count_down_500ms == 0 && g_setting_tx_enable)
|
||||
{ // PTT pressed
|
||||
if (++g_ptt_debounce_counter >= 3) // 30ms
|
||||
{ // start transmitting
|
||||
g_boot_counter_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_debounce_counter = 0;
|
||||
g_ptt_is_pressed = true;
|
||||
APP_ProcessKey(KEY_PTT, true, false);
|
||||
{ // PTT released
|
||||
if (g_ptt_is_pressed)
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
{ // stop TX'ing
|
||||
|
||||
g_ptt_is_pressed = false;
|
||||
g_ptt_was_released = true;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_ProcessKey(KEY_PTT, false, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
else
|
||||
g_ptt_debounce_counter = 0;
|
||||
|
||||
// *****************
|
||||
// button processing (non-PTT)
|
||||
|
||||
// scan the hardware keys
|
||||
Key = KEYBOARD_Poll();
|
||||
|
||||
if (Key == KEY_INVALID)
|
||||
{
|
||||
// g_key_reading_0 = KEY_INVALID;
|
||||
// g_key_reading_1 = KEY_INVALID;
|
||||
// g_debounce_counter = 0;
|
||||
// g_key_being_held = false;
|
||||
// return;
|
||||
}
|
||||
key = KEYBOARD_Poll();
|
||||
|
||||
g_boot_counter_10ms = 0; // cancel boot screen/beeps
|
||||
|
||||
if (g_serial_config_count_down_500ms > 0)
|
||||
{
|
||||
g_boot_counter_10ms = 0; // cancel the boot-up screen
|
||||
return; // the PC is uploading/downloading config
|
||||
}
|
||||
|
||||
if (g_key_reading_0 != Key)
|
||||
{ // new key pressed
|
||||
|
||||
if (g_key_reading_0 != KEY_INVALID && Key != KEY_INVALID)
|
||||
APP_ProcessKey(g_key_reading_1, false, g_key_being_held); // key pressed without releasing previous key
|
||||
|
||||
g_key_reading_0 = Key;
|
||||
g_debounce_counter = 0;
|
||||
{ // config upload/download in progress
|
||||
g_key_debounce_press = 0;
|
||||
g_key_debounce_repeat = 0;
|
||||
g_key_prev = KEY_INVALID;
|
||||
g_key_held = false;
|
||||
g_fkey_pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (++g_debounce_counter == key_debounce_10ms)
|
||||
{ // debounced new key pressed
|
||||
|
||||
if (Key == KEY_INVALID)
|
||||
if (key == KEY_INVALID || (g_key_prev != KEY_INVALID && key != g_key_prev))
|
||||
{ // key not pressed or different key pressed
|
||||
if (g_key_debounce_press > 0)
|
||||
{
|
||||
if (g_key_reading_1 != KEY_INVALID)
|
||||
if (--g_key_debounce_press == 0)
|
||||
{
|
||||
APP_ProcessKey(g_key_reading_1, false, g_key_being_held);
|
||||
g_key_reading_1 = KEY_INVALID;
|
||||
if (g_key_prev != KEY_INVALID)
|
||||
{ // key now fully released
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf(" old key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
#endif
|
||||
|
||||
APP_ProcessKey(g_key_prev, false, g_key_held);
|
||||
g_key_debounce_press = 0;
|
||||
g_key_debounce_repeat = 0;
|
||||
g_key_prev = KEY_INVALID;
|
||||
g_key_held = false;
|
||||
g_boot_counter_10ms = 0; // cancel the boot-up screen
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_key_reading_1 = Key;
|
||||
APP_ProcessKey(Key, true, false);
|
||||
}
|
||||
|
||||
g_key_being_held = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_debounce_counter < key_repeat_delay_10ms)
|
||||
return;
|
||||
|
||||
// key is being held pressed
|
||||
|
||||
if (g_debounce_counter == key_repeat_delay_10ms)
|
||||
{ // initial key repeat delay after pressed
|
||||
if (Key != KEY_PTT)
|
||||
{
|
||||
g_key_being_held = true;
|
||||
APP_ProcessKey(Key, true, true);
|
||||
if (g_key_debounce_repeat > 0)
|
||||
g_key_debounce_repeat--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // key repeat
|
||||
if (Key == KEY_UP || Key == KEY_DOWN)
|
||||
{ // key pressed
|
||||
if (g_key_debounce_press < key_debounce_10ms)
|
||||
{
|
||||
g_key_being_held = true;
|
||||
if ((g_debounce_counter % key_repeat_10ms) == 0)
|
||||
APP_ProcessKey(Key, true, true);
|
||||
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;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("\r\n new key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
#endif
|
||||
|
||||
g_key_prev = key;
|
||||
APP_ProcessKey(g_key_prev, true, g_key_held);
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_key_debounce_repeat < key_long_press_10ms)
|
||||
{
|
||||
if (++g_key_debounce_repeat >= key_long_press_10ms)
|
||||
{ // key long press
|
||||
g_key_held = true;
|
||||
|
||||
if (g_debounce_counter < 0xFFFF)
|
||||
return;
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("long key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
#endif
|
||||
|
||||
g_debounce_counter = key_repeat_delay_10ms;
|
||||
APP_ProcessKey(g_key_prev, true, g_key_held);
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (key == KEY_UP || key == KEY_DOWN)
|
||||
{ // only the up and down keys are repeatable
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + key_repeat_10ms))
|
||||
{ // key repeat
|
||||
g_key_debounce_repeat -= key_repeat_10ms;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("rept key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
#endif
|
||||
|
||||
APP_ProcessKey(g_key_prev, true, g_key_held);
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *****************
|
||||
}
|
||||
|
||||
void APP_TimeSlice10ms(void)
|
||||
{
|
||||
g_flash_light_bBlink_counter++;
|
||||
|
||||
#ifdef ENABLE_BOOT_BEEPS
|
||||
if (g_boot_counter_10ms > 0)
|
||||
if ((g_boot_counter_10ms % 25) == 0)
|
||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix)
|
||||
if (g_rx_vfo->am_mode && g_setting_am_fix)
|
||||
AM_fix_10ms(g_eeprom.rx_vfo);
|
||||
#endif
|
||||
g_flash_light_blink_counter++;
|
||||
|
||||
if (UART_IsCommandAvailable())
|
||||
{
|
||||
@ -1435,6 +1474,17 @@ void APP_TimeSlice10ms(void)
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BOOT_BEEPS
|
||||
if (g_boot_counter_10ms > 0 && ((g_boot_counter_10ms % 25) == 0)
|
||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix)
|
||||
if (g_rx_vfo->am_mode && g_setting_am_fix)
|
||||
AM_fix_10ms(g_eeprom.rx_vfo);
|
||||
#endif
|
||||
|
||||
if (g_reduced_service)
|
||||
return;
|
||||
|
||||
@ -1444,16 +1494,13 @@ void APP_TimeSlice10ms(void)
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
{ // transmitting
|
||||
#ifdef ENABLE_AUDIO_BAR
|
||||
if (g_setting_mic_bar && (g_flash_light_bBlink_counter % (150 / 10)) == 0) // once every 150ms
|
||||
if (g_setting_mic_bar && (g_flash_light_blink_counter % (150 / 10)) == 0) // once every 150ms
|
||||
UI_DisplayAudioBar();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (g_update_display)
|
||||
{
|
||||
g_update_display = false;
|
||||
GUI_DisplayScreen();
|
||||
}
|
||||
|
||||
if (g_update_status)
|
||||
UI_DisplayStatus(false);
|
||||
@ -1461,11 +1508,11 @@ void APP_TimeSlice10ms(void)
|
||||
// Skipping authentic device checks
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) // 1of11
|
||||
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (g_flash_light_state == FLASHLIGHT_BLINK && (g_flash_light_bBlink_counter & 15u) == 0)
|
||||
if (g_flash_light_state == FLASHLIGHT_BLINK && (g_flash_light_blink_counter & 15u) == 0)
|
||||
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
@ -1489,7 +1536,7 @@ void APP_TimeSlice10ms(void)
|
||||
Tone = 500 + (g_alarm_tone_counter * 25);
|
||||
if (Tone > 1500)
|
||||
{
|
||||
Tone = 500;
|
||||
Tone = 500;
|
||||
g_alarm_tone_counter = 0;
|
||||
}
|
||||
|
||||
@ -1535,9 +1582,7 @@ void APP_TimeSlice10ms(void)
|
||||
{
|
||||
if (--g_rtte_count_down == 0)
|
||||
{
|
||||
//if (g_current_function != FUNCTION_FOREGROUND)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
}
|
||||
@ -1747,18 +1792,20 @@ void cancelUserInputModes(void)
|
||||
{
|
||||
DTMF_clear_input_box();
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
if (g_f_key_was_pressed || g_key_input_count_down > 0 || g_input_box_index > 0)
|
||||
if (g_fkey_pressed || g_key_input_count_down > 0 || g_input_box_index > 0)
|
||||
{
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_input_box_index = 0;
|
||||
g_key_input_count_down = 0;
|
||||
g_key_input_count_down = 0;
|
||||
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1882,57 +1929,57 @@ void APP_TimeSlice500ms(void)
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (g_screen_to_display != DISPLAY_AIRCOPY)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_OFF &&
|
||||
(g_screen_to_display != DISPLAY_SCANNER ||
|
||||
g_scan_css_state == SCAN_CSS_STATE_FOUND ||
|
||||
g_scan_css_state == SCAN_CSS_STATE_FAILED ||
|
||||
g_scan_css_state == SCAN_CSS_STATE_FAILED ||
|
||||
g_scan_css_state == SCAN_CSS_STATE_FREQ_FAILED))
|
||||
{
|
||||
if (g_eeprom.auto_keypad_lock && g_key_lock_count_down > 0 && !g_dtmf_input_mode)
|
||||
if (g_eeprom.auto_keypad_lock && g_key_lock_count_down_500ms > 0 && !g_dtmf_input_mode)
|
||||
{
|
||||
if (--g_key_lock_count_down == 0)
|
||||
g_eeprom.key_lock = true; // lock the keyboard
|
||||
if (--g_key_lock_count_down_500ms == 0)
|
||||
g_eeprom.key_lock = true; // lock the keyboard
|
||||
g_update_status = true; // lock symbol needs showing
|
||||
}
|
||||
|
||||
|
||||
if (exit_menu)
|
||||
{
|
||||
g_menu_count_down = 0;
|
||||
|
||||
|
||||
if (g_eeprom.backlight == 0)
|
||||
{
|
||||
g_backlight_count_down = 0;
|
||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||
}
|
||||
|
||||
|
||||
if (g_input_box_index > 0 || g_dtmf_input_mode)
|
||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||
/*
|
||||
/*
|
||||
if (g_screen_to_display == DISPLAY_SCANNER)
|
||||
{
|
||||
BK4819_StopScan();
|
||||
|
||||
|
||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
DTMF_clear_input_box();
|
||||
|
||||
g_f_key_was_pressed = false;
|
||||
g_input_box_index = 0;
|
||||
|
||||
g_ask_to_save = false;
|
||||
g_ask_to_delete = false;
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
|
||||
|
||||
g_fkey_pressed = false;
|
||||
g_input_box_index = 0;
|
||||
|
||||
g_ask_to_save = false;
|
||||
g_ask_to_delete = false;
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
|
||||
{
|
||||
gui_display_type_t disp = DISPLAY_INVALID;
|
||||
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode &&
|
||||
g_current_function != FUNCTION_RECEIVE &&
|
||||
@ -1942,7 +1989,7 @@ void APP_TimeSlice500ms(void)
|
||||
disp = DISPLAY_FM;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (disp == DISPLAY_INVALID)
|
||||
{
|
||||
#ifndef ENABLE_CODE_SCAN_TIMEOUT
|
||||
@ -1950,7 +1997,7 @@ void APP_TimeSlice500ms(void)
|
||||
#endif
|
||||
disp = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
|
||||
if (disp != DISPLAY_INVALID)
|
||||
GUI_SelectNextDisplay(disp);
|
||||
}
|
||||
@ -2141,8 +2188,8 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
{
|
||||
bool flag = false;
|
||||
|
||||
// if (Key == KEY_INVALID)
|
||||
// return;
|
||||
if (Key == KEY_INVALID && !key_pressed && !key_held)
|
||||
return;
|
||||
|
||||
// reset the state so as to remove it from the screen
|
||||
if (Key != KEY_INVALID && Key != KEY_PTT)
|
||||
@ -2163,7 +2210,7 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
g_battery_save_count_down_10ms = battery_save_count_10ms;
|
||||
|
||||
if (g_eeprom.auto_keypad_lock)
|
||||
g_key_lock_count_down = 30; // 15 seconds
|
||||
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
@ -2211,7 +2258,7 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
{
|
||||
memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live));
|
||||
g_dtmf_rx_live_timeout = 0;
|
||||
g_update_display = true;
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
// cancel user input
|
||||
@ -2229,7 +2276,7 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
|
||||
if (Key != KEY_PTT)
|
||||
{
|
||||
g_ptt_was_released = true;
|
||||
// g_ptt_was_released = true; // why is this being set ?
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2276,36 +2323,47 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
}
|
||||
}
|
||||
|
||||
if (Key == KEY_PTT)
|
||||
if (Key == KEY_PTT && g_ptt_was_pressed)
|
||||
{
|
||||
if (g_ptt_was_pressed)
|
||||
{
|
||||
flag = key_held;
|
||||
if (!key_pressed)
|
||||
{
|
||||
flag = true;
|
||||
g_ptt_was_pressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_ptt_was_released)
|
||||
{
|
||||
if (key_held)
|
||||
flag = true;
|
||||
flag = key_held;
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
flag = true;
|
||||
g_ptt_was_released = false;
|
||||
flag = true;
|
||||
g_ptt_was_pressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_f_key_was_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
|
||||
{ // cancel the F-key
|
||||
g_f_key_was_pressed = false;
|
||||
g_update_status = true;
|
||||
// this bit of code has caused soooooo many problems due
|
||||
// to this causing key releases to be totally ignored :( .. 1of11
|
||||
if (Key != KEY_PTT && g_ptt_was_released)
|
||||
{
|
||||
/* if (key_held)
|
||||
flag = true;
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
flag = true;
|
||||
*/
|
||||
g_ptt_was_released = false;
|
||||
/* }
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("proc key 1 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
if (g_fkey_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
|
||||
{ // cancel the F-key
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("proc key 2 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
|
||||
#endif
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
|
6
app/fm.c
6
app/fm.c
@ -232,7 +232,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
|
||||
if (!key_held && key_pressed)
|
||||
{
|
||||
if (!g_f_key_was_pressed)
|
||||
if (!g_fkey_pressed)
|
||||
{
|
||||
uint8_t State;
|
||||
|
||||
@ -346,8 +346,8 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
}
|
||||
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_f_key_was_pressed = false;
|
||||
g_update_status = true;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
|
||||
switch (Key)
|
||||
|
@ -52,40 +52,44 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
if (!key_pressed)
|
||||
return;
|
||||
|
||||
if (g_screen_to_display != DISPLAY_MENU &&
|
||||
g_screen_to_display != DISPLAY_FM &&
|
||||
#ifdef ENABLE_FMRADIO
|
||||
!g_fm_radio_mode &&
|
||||
#endif
|
||||
g_current_function != FUNCTION_TRANSMIT)
|
||||
{ // toggle the keyboad lock
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (!g_fm_radio_mode)
|
||||
#endif
|
||||
{
|
||||
if (g_screen_to_display != DISPLAY_MENU &&
|
||||
g_screen_to_display != DISPLAY_FM &&
|
||||
g_current_function != FUNCTION_TRANSMIT)
|
||||
{ // toggle the keyboad lock
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = g_eeprom.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
#endif
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = g_eeprom.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||
#endif
|
||||
|
||||
g_eeprom.key_lock = !g_eeprom.key_lock;
|
||||
g_eeprom.key_lock = !g_eeprom.key_lock;
|
||||
|
||||
g_request_save_settings = true;
|
||||
g_request_save_settings = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if ((g_fm_radio_mode || g_screen_to_display != DISPLAY_MAIN) && g_screen_to_display != DISPLAY_FM)
|
||||
if ((g_fm_radio_mode || g_screen_to_display != DISPLAY_MAIN) &&
|
||||
g_screen_to_display != DISPLAY_FM)
|
||||
return;
|
||||
#else
|
||||
if (g_screen_to_display != DISPLAY_MAIN)
|
||||
return;
|
||||
#endif
|
||||
|
||||
g_f_key_was_pressed = !g_f_key_was_pressed;
|
||||
// toggle the fkey on/off
|
||||
g_fkey_pressed = !g_fkey_pressed;
|
||||
|
||||
if (g_f_key_was_pressed)
|
||||
if (g_fkey_pressed)
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (!g_f_key_was_pressed)
|
||||
if (!g_fkey_pressed)
|
||||
g_another_voice_id = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
|
||||
@ -108,9 +112,9 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
}
|
||||
#endif
|
||||
|
||||
g_beep_to_play = BEEP_440HZ_500MS;
|
||||
g_beep_to_play = BEEP_440HZ_500MS;
|
||||
|
||||
g_ptt_was_released = true;
|
||||
// g_ptt_was_released = true; // why is this being set ???
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,14 +261,10 @@ start_tx:
|
||||
goto done;
|
||||
|
||||
cancel_tx:
|
||||
if (g_ptt_is_pressed)
|
||||
{
|
||||
g_ptt_is_pressed = false;
|
||||
g_ptt_was_pressed = true;
|
||||
}
|
||||
g_ptt_was_pressed = true;
|
||||
|
||||
done:
|
||||
g_ptt_debounce_counter = 0;
|
||||
g_ptt_debounce = 0;
|
||||
if (g_screen_to_display != DISPLAY_MENU && g_request_display_screen != DISPLAY_FM) // 1of11 .. don't close the menu
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_update_status = true;
|
||||
|
30
app/main.c
30
app/main.c
@ -97,7 +97,7 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
|
||||
case KEY_1:
|
||||
if (!IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
@ -192,7 +192,7 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
|
||||
break;
|
||||
|
||||
case KEY_4:
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_flag_start_scan = true;
|
||||
g_scan_single_frequency = false;
|
||||
g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
|
||||
@ -267,7 +267,7 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
|
||||
|
||||
default:
|
||||
g_update_status = true;
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
|
||||
if (beep)
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
@ -290,7 +290,7 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
|
||||
processFKeyFunction(Key, false);
|
||||
@ -306,7 +306,7 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
return; // don't use the key till it's released
|
||||
}
|
||||
|
||||
if (!g_f_key_was_pressed)
|
||||
if (!g_fkey_pressed)
|
||||
{ // F-key wasn't pressed
|
||||
|
||||
const uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
@ -466,7 +466,7 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
|
||||
processFKeyFunction(Key, true);
|
||||
@ -550,7 +550,7 @@ static void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
if (key_pressed)
|
||||
{ // long press MENU key
|
||||
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
|
||||
if (g_screen_to_display == DISPLAY_MAIN)
|
||||
{
|
||||
@ -560,7 +560,7 @@ static void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
|
||||
#ifdef ENABLE_COPY_CHAN_TO_VFO
|
||||
@ -646,7 +646,7 @@ static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_held && !g_f_key_was_pressed)
|
||||
if (key_held && !g_fkey_pressed)
|
||||
{ // long press .. toggle scanning
|
||||
if (!key_pressed)
|
||||
return; // released
|
||||
@ -666,7 +666,7 @@ static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
|
||||
// just released
|
||||
|
||||
if (!g_f_key_was_pressed)
|
||||
if (!g_fkey_pressed)
|
||||
{ // pressed without the F-key
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -687,7 +687,7 @@ static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
}
|
||||
else
|
||||
{ // with the F-key
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
@ -704,7 +704,7 @@ static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
}
|
||||
|
||||
g_ptt_was_released = true;
|
||||
// g_ptt_was_released = true; // why is this being set ?
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
@ -807,7 +807,7 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
|
||||
g_scan_pause_delay_in_10ms = 1;
|
||||
g_schedule_scan_listen = false;
|
||||
|
||||
g_ptt_was_released = true;
|
||||
// g_ptt_was_released = true; // why is this being set ?
|
||||
}
|
||||
|
||||
void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
|
||||
@ -829,7 +829,9 @@ void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
|
||||
DTMF_Append(Character);
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_ptt_was_released = true;
|
||||
|
||||
// g_ptt_was_released = true; // why is this being set ?
|
||||
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
case MENU_AUTOLK:
|
||||
g_eeprom.auto_keypad_lock = g_sub_menu_selection;
|
||||
g_key_lock_count_down = 30;
|
||||
g_key_lock_count_down_500ms = 30;
|
||||
break;
|
||||
|
||||
case MENU_S_ADD1:
|
||||
@ -1672,6 +1672,7 @@ static void MENU_Key_STAR(const bool key_pressed, const bool key_held)
|
||||
}
|
||||
|
||||
g_ptt_was_released = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,17 @@
|
||||
#include "driver/i2c.h"
|
||||
#include "misc.h"
|
||||
|
||||
key_code_t g_key_reading_0 = KEY_INVALID;
|
||||
key_code_t g_key_reading_1 = KEY_INVALID;
|
||||
uint16_t g_debounce_counter = 0;
|
||||
bool g_f_key_was_pressed = false;
|
||||
uint8_t g_ptt_debounce;
|
||||
uint8_t g_key_debounce_press;
|
||||
uint8_t g_key_debounce_repeat;
|
||||
key_code_t g_key_prev = KEY_INVALID;
|
||||
bool g_key_held;
|
||||
bool g_fkey_pressed;
|
||||
bool g_ptt_is_pressed;
|
||||
|
||||
bool g_ptt_was_released;
|
||||
bool g_ptt_was_pressed;
|
||||
uint8_t g_keypad_locked;
|
||||
|
||||
static const struct {
|
||||
|
||||
@ -96,9 +103,6 @@ key_code_t KEYBOARD_Poll(void)
|
||||
{
|
||||
key_code_t Key = KEY_INVALID;
|
||||
|
||||
// if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||
// return KEY_PTT;
|
||||
|
||||
// *****************
|
||||
|
||||
for (unsigned int j = 0; j < ARRAY_SIZE(keyboard); j++)
|
||||
|
@ -22,33 +22,41 @@
|
||||
#include <stdint.h>
|
||||
|
||||
enum key_code_e {
|
||||
KEY_0 = 0, // 0
|
||||
KEY_1, // 1
|
||||
KEY_2, // 2
|
||||
KEY_3, // 3
|
||||
KEY_4, // 4
|
||||
KEY_5, // 5
|
||||
KEY_6, // 6
|
||||
KEY_7, // 7
|
||||
KEY_8, // 8
|
||||
KEY_9, // 9
|
||||
KEY_MENU, // A
|
||||
KEY_UP, // B
|
||||
KEY_DOWN, // C
|
||||
KEY_EXIT, // D
|
||||
KEY_STAR, // *
|
||||
KEY_F, // #
|
||||
KEY_INVALID = 0,
|
||||
KEY_0, // DTMF 0
|
||||
KEY_1, // DTMF 1
|
||||
KEY_2, // DTMF 2
|
||||
KEY_3, // DTMF 3
|
||||
KEY_4, // DTMF 4
|
||||
KEY_5, // DTMF 5
|
||||
KEY_6, // DTMF 6
|
||||
KEY_7, // DTMF 7
|
||||
KEY_8, // DTMF 8
|
||||
KEY_9, // DTMF 9
|
||||
KEY_MENU, // DTMF A
|
||||
KEY_UP, // DTMF B
|
||||
KEY_DOWN, // DTMF C
|
||||
KEY_EXIT, // DTMF D
|
||||
KEY_STAR, // DTMF *
|
||||
KEY_F, // DTMF #
|
||||
KEY_PTT, //
|
||||
KEY_SIDE2, //
|
||||
KEY_SIDE1, //
|
||||
KEY_INVALID //
|
||||
// KEY_INVALID //
|
||||
};
|
||||
typedef enum key_code_e key_code_t;
|
||||
|
||||
extern key_code_t g_key_reading_0;
|
||||
extern key_code_t g_key_reading_1;
|
||||
extern uint16_t g_debounce_counter;
|
||||
extern bool g_f_key_was_pressed;
|
||||
extern uint8_t g_ptt_debounce;
|
||||
extern uint8_t g_key_debounce_press;
|
||||
extern uint8_t g_key_debounce_repeat;
|
||||
extern key_code_t g_key_prev;
|
||||
extern bool g_key_held;
|
||||
extern bool g_fkey_pressed;
|
||||
extern bool g_ptt_is_pressed;
|
||||
|
||||
extern bool g_ptt_was_released;
|
||||
extern bool g_ptt_was_pressed;
|
||||
extern uint8_t g_keypad_locked;
|
||||
|
||||
key_code_t KEYBOARD_Poll(void);
|
||||
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -46,11 +46,6 @@ BOOT_Mode_t BOOT_GetMode(void)
|
||||
|
||||
if (Keys[0] == Keys[1])
|
||||
{
|
||||
g_key_reading_0 = Keys[0];
|
||||
g_key_reading_1 = Keys[0];
|
||||
|
||||
g_debounce_counter = 2;
|
||||
|
||||
if (Keys[0] == KEY_SIDE1)
|
||||
return BOOT_MODE_F_LOCK;
|
||||
|
||||
|
3
main.c
3
main.c
@ -129,9 +129,6 @@ void Main(void)
|
||||
i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0;
|
||||
SYSTEM_DelayMs(10);
|
||||
}
|
||||
g_key_reading_0 = KEY_INVALID;
|
||||
g_key_reading_1 = KEY_INVALID;
|
||||
g_debounce_counter = 0;
|
||||
}
|
||||
|
||||
if (!g_charging_with_type_c && g_battery_display_level == 0)
|
||||
|
18
misc.c
18
misc.c
@ -38,9 +38,11 @@ const uint8_t dtmf_txstop_countdown_500ms = 3000 / 500; // 6 seco
|
||||
const uint8_t serial_config_count_down_500ms = 3000 / 500; // 3 seconds
|
||||
|
||||
const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds
|
||||
const uint16_t key_repeat_delay_10ms = 400 / 10; // 400ms
|
||||
const uint16_t key_repeat_10ms = 80 / 10; // 80ms .. MUST be less than 'key_repeat_delay'
|
||||
const uint16_t key_debounce_10ms = 20 / 10; // 20ms
|
||||
const uint8_t key_lock_timeout_500ms = 30000 / 500; // 30 seconds
|
||||
|
||||
const uint8_t key_debounce_10ms = 30 / 10; // 30ms
|
||||
const uint8_t key_long_press_10ms = 300 / 10; // 300ms
|
||||
const uint8_t key_repeat_10ms = 80 / 10; // 80ms
|
||||
|
||||
const uint16_t scan_freq_css_timeout_10ms = 10000 / 10; // 10 seconds
|
||||
const uint8_t scan_freq_css_delay_10ms = 210 / 10; // 210ms .. don't reduce this
|
||||
@ -155,7 +157,7 @@ volatile uint16_t g_tail_tone_elimination_count_down_10ms;
|
||||
|
||||
bool g_enable_speaker;
|
||||
uint8_t g_key_input_count_down = 0;
|
||||
uint8_t g_key_lock_count_down;
|
||||
uint8_t g_key_lock_count_down_500ms;
|
||||
uint8_t g_rtte_count_down;
|
||||
bool g_is_in_lock_screen;
|
||||
uint8_t g_update_status;
|
||||
@ -174,9 +176,6 @@ bool g_update_rssi;
|
||||
alarm_state_t g_alarm_state;
|
||||
#endif
|
||||
uint16_t g_menu_count_down;
|
||||
bool g_ptt_was_released;
|
||||
bool g_ptt_was_pressed;
|
||||
uint8_t g_keypad_locked;
|
||||
bool g_flag_reconfigure_vfos;
|
||||
uint8_t g_vfo_configure_mode;
|
||||
bool g_flag_reset_vfos;
|
||||
@ -209,7 +208,7 @@ bool g_CxCSS_tail_found;
|
||||
#endif
|
||||
bool g_squelch_lost;
|
||||
uint8_t g_flash_light_state;
|
||||
volatile uint16_t g_flash_light_bBlink_counter;
|
||||
volatile uint16_t g_flash_light_blink_counter;
|
||||
bool g_flag_end_tx;
|
||||
uint16_t g_low_batteryCountdown;
|
||||
uint8_t g_next_channel;
|
||||
@ -224,9 +223,6 @@ bool g_rx_vfo_is_active;
|
||||
uint8_t g_alarm_tone_counter;
|
||||
uint16_t g_alarm_running_counter;
|
||||
#endif
|
||||
bool g_key_being_held;
|
||||
bool g_ptt_is_pressed;
|
||||
uint8_t g_ptt_debounce_counter;
|
||||
uint8_t g_menu_list_count;
|
||||
uint8_t g_backup_cross_vfo_rx_tx;
|
||||
uint8_t g_scan_delay_10ms;
|
||||
|
17
misc.h
17
misc.h
@ -116,10 +116,11 @@ extern const uint8_t dtmf_txstop_countdown_500ms;
|
||||
extern const uint8_t serial_config_count_down_500ms;
|
||||
|
||||
extern const uint8_t key_input_timeout_500ms;
|
||||
extern const uint8_t key_lock_timeout_500ms;
|
||||
|
||||
extern const uint16_t key_repeat_delay_10ms;
|
||||
extern const uint16_t key_repeat_10ms;
|
||||
extern const uint16_t key_debounce_10ms;
|
||||
extern const uint8_t key_debounce_10ms;
|
||||
extern const uint8_t key_long_press_10ms;
|
||||
extern const uint8_t key_repeat_10ms;
|
||||
|
||||
extern const uint16_t scan_freq_css_timeout_10ms;
|
||||
extern const uint8_t scan_freq_css_delay_10ms;
|
||||
@ -233,7 +234,7 @@ extern volatile uint16_t g_tail_tone_elimination_count_down_10ms;
|
||||
#endif
|
||||
extern bool g_enable_speaker;
|
||||
extern uint8_t g_key_input_count_down;
|
||||
extern uint8_t g_key_lock_count_down;
|
||||
extern uint8_t g_key_lock_count_down_500ms;
|
||||
extern uint8_t g_rtte_count_down;
|
||||
extern bool g_is_in_lock_screen;
|
||||
extern uint8_t g_update_status;
|
||||
@ -250,8 +251,6 @@ extern css_scan_mode_t g_css_scan_mode;
|
||||
extern bool g_update_rssi;
|
||||
extern alarm_state_t g_alarm_state;
|
||||
extern uint16_t g_menu_count_down;
|
||||
extern bool g_ptt_was_released;
|
||||
extern bool g_ptt_was_pressed;
|
||||
extern bool g_flag_reconfigure_vfos;
|
||||
extern uint8_t g_vfo_configure_mode;
|
||||
extern bool g_flag_reset_vfos;
|
||||
@ -261,7 +260,6 @@ extern bool g_request_save_settings;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern bool g_request_save_fm;
|
||||
#endif
|
||||
extern uint8_t g_keypad_locked;
|
||||
extern bool g_flag_prepare_tx;
|
||||
|
||||
extern bool g_flag_AcceptSetting; // accept menu setting
|
||||
@ -285,7 +283,7 @@ extern bool g_CxCSS_tail_found;
|
||||
#endif
|
||||
extern bool g_squelch_lost;
|
||||
extern uint8_t g_flash_light_state;
|
||||
extern volatile uint16_t g_flash_light_bBlink_counter;
|
||||
extern volatile uint16_t g_flash_light_blink_counter;
|
||||
extern bool g_flag_end_tx;
|
||||
extern uint16_t g_low_batteryCountdown;
|
||||
extern uint8_t g_next_channel;
|
||||
@ -298,9 +296,6 @@ extern uint32_t g_restore_frequency;
|
||||
extern bool g_rx_vfo_is_active;
|
||||
extern uint8_t g_alarm_tone_counter;
|
||||
extern uint16_t g_alarm_running_counter;
|
||||
extern bool g_key_being_held;
|
||||
extern bool g_ptt_is_pressed;
|
||||
extern uint8_t g_ptt_debounce_counter;
|
||||
extern uint8_t g_menu_list_count;
|
||||
extern uint8_t g_backup_cross_vfo_rx_tx;
|
||||
extern uint8_t g_scan_delay_10ms;
|
||||
|
16
ui/battery.c
16
ui/battery.c
@ -22,23 +22,24 @@
|
||||
#include "functions.h"
|
||||
#include "ui/battery.h"
|
||||
|
||||
void UI_DrawBattery(uint8_t* bitmap, const unsigned int level, const unsigned int blink)
|
||||
void UI_DrawBattery(uint8_t *bitmap, const unsigned int level, const unsigned int blink)
|
||||
{
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
|
||||
if (level >= 1)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t bars = level > 0 ? level - 1 : 0;
|
||||
if(bars>4) bars = 4;
|
||||
unsigned int bars = (level > 0) ? level - 1 : 0;
|
||||
if (bars > 4)
|
||||
bars = 4;
|
||||
for (i = 0; i < bars; i++)
|
||||
{
|
||||
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
||||
#else
|
||||
#ifdef ENABLE_REVERSE_BAT_SYMBOL
|
||||
bitmap[3 + (i * 3) + 0] = 0b01011101;
|
||||
bitmap[3 + (i * 3) + 1] = 0b01011101;
|
||||
#else
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 0] = 0b01011101;
|
||||
bitmap[sizeof(bitmap) - 3 - (i * 3) - 1] = 0b01011101;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -50,7 +51,6 @@ void UI_DrawBattery(uint8_t* bitmap, const unsigned int level, const unsigned in
|
||||
void UI_DisplayBattery(const unsigned int level, const unsigned int blink)
|
||||
{
|
||||
uint8_t bitmap[sizeof(BITMAP_BATTERY_LEVEL)];
|
||||
|
||||
UI_DrawBattery(bitmap, level, blink);
|
||||
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
|
||||
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define UI_BATTERY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void UI_DrawBattery(uint8_t* bitmap, const unsigned int level, const unsigned int blink);
|
||||
void UI_DisplayBattery(const unsigned int Level, const unsigned int blink);
|
||||
|
||||
|
@ -164,21 +164,21 @@ void UI_DisplayStatus(const bool test_display)
|
||||
x1 = x;
|
||||
}
|
||||
else
|
||||
if (g_f_key_was_pressed)
|
||||
if (g_fkey_pressed)
|
||||
{
|
||||
memmove(line + x, BITMAP_F_KEY, sizeof(BITMAP_F_KEY));
|
||||
x += sizeof(BITMAP_F_KEY);
|
||||
x1 = x;
|
||||
}
|
||||
|
||||
{ // battery voltage or percentage
|
||||
{ // battery voltage or percentage text
|
||||
char s[8];
|
||||
unsigned int space_needed;
|
||||
|
||||
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - 3;
|
||||
|
||||
if (g_charging_with_type_c)
|
||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
||||
x2 -= sizeof(BITMAP_USB_C); // the radio is on USB charge
|
||||
|
||||
switch (g_setting_battery_text)
|
||||
{
|
||||
@ -192,9 +192,7 @@ void UI_DisplayStatus(const bool test_display)
|
||||
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
||||
space_needed = (7 * strlen(s));
|
||||
if (x2 >= (x1 + space_needed))
|
||||
{
|
||||
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
4
ui/ui.c
4
ui/ui.c
@ -43,6 +43,8 @@ bool g_ask_to_delete;
|
||||
|
||||
void GUI_DisplayScreen(void)
|
||||
{
|
||||
g_update_display = false;
|
||||
|
||||
switch (g_screen_to_display)
|
||||
{
|
||||
case DISPLAY_MAIN:
|
||||
@ -93,7 +95,7 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
|
||||
g_ask_for_confirmation = 0;
|
||||
g_ask_to_save = false;
|
||||
g_ask_to_delete = false;
|
||||
g_f_key_was_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user