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:
parent
41553b50fa
commit
d676c77e85
15
app/action.c
15
app/action.c
@ -130,7 +130,8 @@ void ACTION_Scan(bool bRestart)
|
|||||||
g_monitor_enabled = false;
|
g_monitor_enabled = false;
|
||||||
|
|
||||||
if (g_fm_scan_state != FM_SCAN_OFF)
|
if (g_fm_scan_state != FM_SCAN_OFF)
|
||||||
{
|
{ // already scanning
|
||||||
|
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@ -142,20 +143,22 @@ void ACTION_Scan(bool bRestart)
|
|||||||
uint16_t Frequency;
|
uint16_t Frequency;
|
||||||
|
|
||||||
if (bRestart)
|
if (bRestart)
|
||||||
{
|
{ // going to scan and auto store what we find
|
||||||
|
FM_EraseChannels();
|
||||||
|
|
||||||
g_fm_auto_scan = true;
|
g_fm_auto_scan = true;
|
||||||
g_fm_channel_position = 0;
|
g_fm_channel_position = 0;
|
||||||
FM_EraseChannels();
|
Frequency = g_eeprom.fm_lower_limit;
|
||||||
Frequency = g_eeprom.fm_lower_limit;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_fm_auto_scan = false;
|
g_fm_auto_scan = false;
|
||||||
g_fm_channel_position = 0;
|
g_fm_channel_position = 0;
|
||||||
Frequency = g_eeprom.fm_frequency_playing;
|
Frequency = g_eeprom.fm_frequency_playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
BK1080_GetFrequencyDeviation(Frequency);
|
BK1080_GetFrequencyDeviation(Frequency);
|
||||||
|
|
||||||
FM_Tune(Frequency, 1, bRestart);
|
FM_Tune(Frequency, 1, bRestart);
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
@ -305,7 +308,7 @@ void ACTION_Scan(bool bRestart)
|
|||||||
{
|
{
|
||||||
FM_TurnOff();
|
FM_TurnOff();
|
||||||
|
|
||||||
g_input_box_index = 0;
|
g_input_box_index = 0;
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
g_vox_resume_count_down = 80;
|
g_vox_resume_count_down = 80;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1817,7 +1817,6 @@ void cancelUserInputModes(void)
|
|||||||
if (g_dtmf_input_mode || g_dtmf_input_box_index > 0)
|
if (g_dtmf_input_mode || g_dtmf_input_box_index > 0)
|
||||||
{
|
{
|
||||||
DTMF_clear_input_box();
|
DTMF_clear_input_box();
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
g_request_display_screen = DISPLAY_MAIN;
|
g_request_display_screen = DISPLAY_MAIN;
|
||||||
g_update_display = true;
|
g_update_display = true;
|
||||||
}
|
}
|
||||||
@ -1827,7 +1826,6 @@ void cancelUserInputModes(void)
|
|||||||
g_fkey_pressed = false;
|
g_fkey_pressed = false;
|
||||||
g_input_box_index = 0;
|
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_status = true;
|
||||||
g_update_display = true;
|
g_update_display = true;
|
||||||
}
|
}
|
||||||
|
79
app/fm.c
79
app/fm.c
@ -30,9 +30,9 @@
|
|||||||
#include "ui/inputbox.h"
|
#include "ui/inputbox.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#define STATE_FREQ_MODE 0
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define STATE_USER_MODE 1
|
||||||
#endif
|
#define STATE_SAVE 2
|
||||||
|
|
||||||
uint16_t g_fm_channels[20];
|
uint16_t g_fm_channels[20];
|
||||||
bool g_fm_radio_mode;
|
bool g_fm_radio_mode;
|
||||||
@ -58,12 +58,14 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
|||||||
for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++)
|
for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++)
|
||||||
{
|
{
|
||||||
if (Channel == 0xFF)
|
if (Channel == 0xFF)
|
||||||
Channel = ARRAY_SIZE(g_fm_channels) - 1;
|
Channel = ARRAY_SIZE(g_fm_channels) - 1;
|
||||||
else
|
else
|
||||||
if (Channel >= ARRAY_SIZE(g_fm_channels))
|
if (Channel >= ARRAY_SIZE(g_fm_channels))
|
||||||
Channel = 0;
|
Channel = 0;
|
||||||
|
|
||||||
if (FM_CheckValidChannel(Channel))
|
if (FM_CheckValidChannel(Channel))
|
||||||
return Channel;
|
return Channel;
|
||||||
|
|
||||||
Channel += Direction;
|
Channel += Direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ int FM_ConfigureChannelState(void)
|
|||||||
g_eeprom.fm_is_channel_mode = false;
|
g_eeprom.fm_is_channel_mode = false;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_eeprom.fm_selected_channel = Channel;
|
g_eeprom.fm_selected_channel = Channel;
|
||||||
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
|
g_eeprom.fm_frequency_playing = g_fm_channels[Channel];
|
||||||
}
|
}
|
||||||
@ -92,7 +95,7 @@ int FM_ConfigureChannelState(void)
|
|||||||
void FM_TurnOff(void)
|
void FM_TurnOff(void)
|
||||||
{
|
{
|
||||||
g_fm_radio_mode = false;
|
g_fm_radio_mode = false;
|
||||||
g_fm_scan_state = FM_SCAN_OFF;
|
g_fm_scan_state = FM_SCAN_OFF;
|
||||||
g_fm_restore_count_down_10ms = 0;
|
g_fm_restore_count_down_10ms = 0;
|
||||||
|
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||||
@ -226,12 +229,8 @@ Bail:
|
|||||||
|
|
||||||
static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
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 :(
|
// beeps cause bad audio clicks anf audio breaks :(
|
||||||
// so don't use them
|
// so don't use them
|
||||||
|
|
||||||
@ -243,7 +242,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
|
|
||||||
if (!key_held && key_pressed)
|
if (!key_held && key_pressed)
|
||||||
{ // key just pressed
|
{ // key just pressed
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,10 +250,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
uint8_t State;
|
uint8_t State;
|
||||||
|
|
||||||
if (g_ask_to_delete)
|
if (g_ask_to_delete)
|
||||||
{
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ask_to_save)
|
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
|
else
|
||||||
{
|
{
|
||||||
if (g_fm_scan_state != FM_SCAN_OFF)
|
if (g_fm_scan_state != FM_SCAN_OFF)
|
||||||
{
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
|
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)
|
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;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
return;
|
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;
|
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
|
||||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||||
g_request_save_fm = true;
|
g_request_save_fm = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +341,6 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
return;
|
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
|
// with f-key, or long press
|
||||||
|
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
|
|
||||||
g_fkey_pressed = false;
|
g_fkey_pressed = false;
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
g_request_display_screen = DISPLAY_FM;
|
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);
|
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||||
g_request_save_fm = true;
|
g_request_save_fm = true;
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FM_Key_STAR(bool key_pressed, bool key_held)
|
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;
|
return;
|
||||||
|
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
if (!key_held && !key_pressed)
|
||||||
|
ACTION_Scan(false); // short key press just released .. scan without store
|
||||||
ACTION_Scan(false);
|
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)
|
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)
|
if (key_held || key_pressed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
|
|
||||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||||
{
|
{
|
||||||
if (g_input_box_index == 0)
|
if (g_input_box_index == 0)
|
||||||
@ -453,6 +437,7 @@ static void FM_Key_EXIT(bool key_pressed, bool key_held)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
||||||
#endif
|
#endif
|
||||||
@ -475,7 +460,6 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
|||||||
channel = i; // found it in the channel list
|
channel = i; // found it in the channel list
|
||||||
|
|
||||||
g_request_display_screen = DISPLAY_FM;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
|
|
||||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||||
{ // not scanning
|
{ // not scanning
|
||||||
@ -516,7 +500,6 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
|||||||
{ // scanning
|
{ // scanning
|
||||||
if (g_fm_auto_scan || !g_fm_found_frequency)
|
if (g_fm_auto_scan || !g_fm_found_frequency)
|
||||||
{
|
{
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
g_input_box_index = 0;
|
g_input_box_index = 0;
|
||||||
return;
|
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 (key_held || !key_pressed)
|
||||||
{
|
{
|
||||||
if (g_input_box_index)
|
if (g_input_box_index > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!key_pressed)
|
if (!key_pressed)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
if (g_input_box_index > 0)
|
||||||
if (g_input_box_index)
|
return;
|
||||||
{
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ask_to_save)
|
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_scan_state != FM_SCAN_OFF)
|
||||||
{
|
{
|
||||||
if (g_fm_auto_scan)
|
if (g_fm_auto_scan)
|
||||||
{
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
FM_Tune(g_eeprom.fm_frequency_playing, Step, false);
|
FM_Tune(g_eeprom.fm_frequency_playing, Step, false);
|
||||||
g_request_display_screen = DISPLAY_FM;
|
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);
|
GENERIC_Key_PTT(key_pressed);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// if (!key_held && key_pressed)
|
|
||||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,7 +626,7 @@ void FM_Play(void)
|
|||||||
if (!g_fm_auto_scan)
|
if (!g_fm_auto_scan)
|
||||||
{
|
{
|
||||||
g_fm_play_count_down_10ms = 0;
|
g_fm_play_count_down_10ms = 0;
|
||||||
g_fm_found_frequency = true;
|
g_fm_found_frequency = true;
|
||||||
|
|
||||||
if (!g_eeprom.fm_is_channel_mode)
|
if (!g_eeprom.fm_is_channel_mode)
|
||||||
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
|
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
|
||||||
@ -667,10 +638,10 @@ void FM_Play(void)
|
|||||||
return;
|
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;
|
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();
|
FM_PlayAndUpdate();
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
@ -689,13 +660,13 @@ void FM_Play(void)
|
|||||||
void FM_Start(void)
|
void FM_Start(void)
|
||||||
{
|
{
|
||||||
g_fm_radio_mode = true;
|
g_fm_radio_mode = true;
|
||||||
g_fm_scan_state = FM_SCAN_OFF;
|
g_fm_scan_state = FM_SCAN_OFF;
|
||||||
g_fm_restore_count_down_10ms = 0;
|
g_fm_restore_count_down_10ms = 0;
|
||||||
|
|
||||||
BK1080_Init(g_eeprom.fm_frequency_playing, true);
|
BK1080_Init(g_eeprom.fm_frequency_playing, true);
|
||||||
|
|
||||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||||
|
|
||||||
g_enable_speaker = true;
|
g_enable_speaker = true;
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
}
|
}
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user