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

Key being ignored fix - hopefully

This commit is contained in:
OneOfEleven 2023-10-15 22:34:21 +01:00
parent 1ecc6e8769
commit 798f0f97f3
5 changed files with 57 additions and 39 deletions

View File

@ -16,7 +16,7 @@ ENABLE_FMRADIO := 1
ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_MUTE_RADIO_FOR_VOICE := 1
ENABLE_VOX := 1
ENABLE_VOX := 0
ENABLE_LOWER_LOW_MID_TX := 1
ENABLE_ALARM := 1
ENABLE_TX1750 := 1

View File

@ -1164,7 +1164,7 @@ void APP_Update(void)
if (g_screen_to_display != DISPLAY_SEARCH && g_eeprom.dual_watch != DUAL_WATCH_OFF)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
//UART_SendText("dual watch\r\n");
UART_SendText("dual watch\r\n");
#endif
#ifdef ENABLE_VOICE
@ -1277,7 +1277,7 @@ void APP_Update(void)
if (g_rx_idle_mode)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
//UART_SendText("ps wake up\r\n");
// UART_SendText("ps wake up\r\n");
#endif
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
@ -1368,7 +1368,7 @@ void APP_CheckKeys(void)
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);
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
#endif
}
}
@ -1389,7 +1389,7 @@ void APP_CheckKeys(void)
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);
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
#endif
}
}
@ -1425,7 +1425,7 @@ void APP_CheckKeys(void)
{ // 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);
// 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
#ifdef ENABLE_AIRCOPY
@ -1463,7 +1463,7 @@ void APP_CheckKeys(void)
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);
// 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;
@ -1490,7 +1490,7 @@ void APP_CheckKeys(void)
g_key_held = true;
#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);
// 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
#ifdef ENABLE_AIRCOPY
@ -1514,7 +1514,7 @@ void APP_CheckKeys(void)
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);
// 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
#ifdef ENABLE_AIRCOPY
@ -2512,35 +2512,48 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
// ********************
if (Key == KEY_PTT && g_ptt_was_pressed)
if (g_ptt_was_pressed)
{
flag = key_held;
if (!key_pressed)
if (Key == KEY_PTT)
{
flag = true;
g_ptt_was_pressed = false;
flag = key_held;
if (!key_pressed)
{
flag = true;
g_ptt_was_pressed = false;
}
}
// g_ptt_was_pressed = 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
}
// this bit of code has caused soooooo many problems due
// to this causing key releases to be ignored :( .. 1of11
if (Key != KEY_PTT && g_ptt_was_released)
if (g_ptt_was_released)
{
if (key_held)
flag = true;
if (key_pressed) // I now use key released for button press detections
// if (Key != KEY_PTT)
if (Key == KEY_PTT)
{
flag = true;
g_ptt_was_released = false;
if (key_held)
flag = true;
if (key_pressed) // I now use key released for button press detections
{
flag = true;
g_ptt_was_released = false;
}
}
// 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);
UART_printf("proc key 2 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
#endif
}
#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);
UART_printf("proc key 3 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
#endif
if (!flag) // this flag is responsible for keys being ignored :(
@ -2619,7 +2632,7 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
if (Key == KEY_PTT)
g_ptt_was_pressed = true;
else
if (!key_held)
// if (!key_held)
g_ptt_was_released = true;
}
#endif

View File

@ -27,6 +27,7 @@
#include "audio.h"
#include "board.h"
#include "driver/bk4819.h"
#include "driver/uart.h"
#include "dtmf.h"
#include "frequencies.h"
#include "misc.h"
@ -117,7 +118,7 @@ static void processFKeyFunction(const key_code_t Key)
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_request_display_screen = DISPLAY_MAIN;
break;
@ -141,7 +142,7 @@ static void processFKeyFunction(const key_code_t Key)
g_request_save_settings = 1;
g_flag_reconfigure_vfos = true;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_request_display_screen = DISPLAY_MAIN;
break;
@ -166,7 +167,7 @@ static void processFKeyFunction(const key_code_t Key)
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
}
@ -184,7 +185,7 @@ static void processFKeyFunction(const key_code_t Key)
g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
}
}
@ -202,7 +203,7 @@ static void processFKeyFunction(const key_code_t Key)
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_update_status = true;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_5: // NOAA
@ -229,13 +230,13 @@ static void processFKeyFunction(const key_code_t Key)
#endif
#endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_6: // H/M/L
ACTION_Power();
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_7: // VOX
@ -252,7 +253,7 @@ static void processFKeyFunction(const key_code_t Key)
g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false;
g_request_save_channel = 1;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
case KEY_9: // CALL
@ -271,7 +272,7 @@ static void processFKeyFunction(const key_code_t Key)
break;
}
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
default:
@ -280,9 +281,9 @@ static void processFKeyFunction(const key_code_t Key)
g_fkey_pressed = false;
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
// if (!g_fm_radio_mode)
#endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break;
}
}
@ -825,10 +826,14 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
// g_ptt_was_released = true; // why is this being set ?
}
void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
void MAIN_ProcessKeys(key_code_t key, bool key_pressed, bool key_held)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf(" main 1 key %2u %u %u %u\r\n", key, key_pressed, key_held);
#endif
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && Key != KEY_PTT && Key != KEY_EXIT)
if (g_fm_radio_mode && key != KEY_PTT && key != KEY_EXIT)
{
if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -838,7 +843,7 @@ void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
if (g_dtmf_input_mode)
{
const char Character = DTMF_GetCharacter(Key);
const char Character = DTMF_GetCharacter(key);
if (Character != 0xFF)
{ // add key to DTMF string
if (key_pressed && !key_held)
@ -853,7 +858,7 @@ void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
}
}
switch (Key)
switch (key)
{
case KEY_0:
case KEY_1:
@ -865,7 +870,7 @@ void MAIN_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
case KEY_7:
case KEY_8:
case KEY_9:
MAIN_Key_DIGITS(Key, key_pressed, key_held);
MAIN_Key_DIGITS(key, key_pressed, key_held);
break;
case KEY_MENU:
MAIN_Key_MENU(key_pressed, key_held);

Binary file not shown.

Binary file not shown.