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

More FM radio key fixes

This commit is contained in:
OneOfEleven 2023-10-11 17:55:34 +01:00
parent 41553b50fa
commit d676c77e85
5 changed files with 34 additions and 62 deletions

View File

@ -130,7 +130,8 @@ void ACTION_Scan(bool bRestart)
g_monitor_enabled = false;
if (g_fm_scan_state != FM_SCAN_OFF)
{
{ // already scanning
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
@ -142,10 +143,11 @@ void ACTION_Scan(bool bRestart)
uint16_t Frequency;
if (bRestart)
{
{ // going to scan and auto store what we find
FM_EraseChannels();
g_fm_auto_scan = true;
g_fm_channel_position = 0;
FM_EraseChannels();
Frequency = g_eeprom.fm_lower_limit;
}
else
@ -156,6 +158,7 @@ void ACTION_Scan(bool bRestart)
}
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
#ifdef ENABLE_VOICE

View File

@ -1817,7 +1817,6 @@ void cancelUserInputModes(void)
if (g_dtmf_input_mode || g_dtmf_input_box_index > 0)
{
DTMF_clear_input_box();
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
g_request_display_screen = DISPLAY_MAIN;
g_update_display = true;
}
@ -1827,7 +1826,6 @@ void cancelUserInputModes(void)
g_fkey_pressed = false;
g_input_box_index = 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;
}

View File

@ -30,9 +30,9 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#define STATE_FREQ_MODE 0
#define STATE_USER_MODE 1
#define STATE_SAVE 2
uint16_t g_fm_channels[20];
bool g_fm_radio_mode;
@ -62,8 +62,10 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
else
if (Channel >= ARRAY_SIZE(g_fm_channels))
Channel = 0;
if (FM_CheckValidChannel(Channel))
return Channel;
Channel += Direction;
}
@ -82,6 +84,7 @@ int FM_ConfigureChannelState(void)
g_eeprom.fm_is_channel_mode = false;
return -1;
}
g_eeprom.fm_selected_channel = Channel;
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
}
@ -226,10 +229,6 @@ Bail:
static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
{
#define STATE_FREQ_MODE 0
#define STATE_USER_MODE 1
#define STATE_SAVE 2
// beeps cause bad audio clicks anf audio breaks :(
@ -243,7 +242,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
if (!key_held && key_pressed)
{ // key just pressed
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
@ -252,10 +250,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
uint8_t State;
if (g_ask_to_delete)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (g_ask_to_save)
{
@ -264,10 +259,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
else
{
if (g_fm_scan_state != FM_SCAN_OFF)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
}
@ -298,7 +290,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
if (Frequency < g_eeprom.fm_lower_limit || g_eeprom.fm_upper_limit < Frequency)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
g_request_display_screen = DISPLAY_FM;
return;
}
@ -312,6 +303,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
g_request_save_fm = true;
return;
}
}
@ -349,7 +341,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
return;
}
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
@ -362,8 +353,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
// with f-key, or long press
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_fkey_pressed = false;
g_update_status = true;
g_request_display_screen = DISPLAY_FM;
@ -382,26 +371,23 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
g_request_save_fm = true;
}
// else
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
default:
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
}
}
static void FM_Key_STAR(bool key_pressed, bool key_held)
{
(void)key_held; // stop compiler warning
if (key_held || key_pressed)
if (key_held && !key_pressed)
return;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
ACTION_Scan(false);
if (!key_held && !key_pressed)
ACTION_Scan(false); // short key press just released .. scan without store
else
if (key_held && key_pressed)
ACTION_Scan(true); // long key press still pressed .. scan and store
}
static void FM_Key_EXIT(bool key_pressed, bool key_held)
@ -409,8 +395,6 @@ static void FM_Key_EXIT(bool key_pressed, bool key_held)
if (key_held || key_pressed)
return;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
if (g_fm_scan_state == FM_SCAN_OFF)
{
if (g_input_box_index == 0)
@ -453,6 +437,7 @@ static void FM_Key_EXIT(bool key_pressed, bool key_held)
else
{
FM_PlayAndUpdate();
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif
@ -475,7 +460,6 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
channel = i; // found it in the channel list
g_request_display_screen = DISPLAY_FM;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
if (g_fm_scan_state == FM_SCAN_OFF)
{ // not scanning
@ -516,7 +500,6 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
{ // scanning
if (g_fm_auto_scan || !g_fm_found_frequency)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
g_input_box_index = 0;
return;
}
@ -537,22 +520,15 @@ static void FM_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Step)
{
if (key_held || !key_pressed)
{
if (g_input_box_index)
if (g_input_box_index > 0)
return;
if (!key_pressed)
return;
}
else
{
if (g_input_box_index)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
if (g_input_box_index > 0)
return;
}
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
}
if (g_ask_to_save)
{
@ -564,10 +540,7 @@ static void FM_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Step)
if (g_fm_scan_state != FM_SCAN_OFF)
{
if (g_fm_auto_scan)
{
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
FM_Tune(g_eeprom.fm_frequency_playing, Step, false);
g_request_display_screen = DISPLAY_FM;
@ -642,8 +615,6 @@ void FM_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
GENERIC_Key_PTT(key_pressed);
break;
default:
// if (!key_held && key_pressed)
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
}
}
@ -667,10 +638,10 @@ void FM_Play(void)
return;
}
if (g_fm_channel_position < 20)
if (g_fm_channel_position < ARRAY_SIZE(g_fm_channels))
g_fm_channels[g_fm_channel_position++] = g_eeprom.fm_frequency_playing;
if (g_fm_channel_position >= 20)
if (g_fm_channel_position >= ARRAY_SIZE(g_fm_channels))
{
FM_PlayAndUpdate();
GUI_SelectNextDisplay(DISPLAY_FM);

Binary file not shown.

Binary file not shown.