mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-05-19 08:21:18 +03:00
Some fixes to the FM radio, more are needed
This commit is contained in:
parent
774e34bf43
commit
72f3fd8d85
101
app/app.c
101
app/app.c
@ -1931,27 +1931,33 @@ void APP_TimeSlice500ms(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if ((g_fm_scan_state == FM_SCAN_OFF || g_ask_to_save) && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
#else
|
||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
#endif
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_scan_state == FM_SCAN_OFF || g_ask_to_save)
|
||||
#endif
|
||||
{
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (g_screen_to_display != DISPLAY_AIRCOPY)
|
||||
#endif
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_OFF &&
|
||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
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_FREQ_FAILED))
|
||||
{
|
||||
if (g_eeprom.auto_keypad_lock && g_key_lock_count_down_500ms > 0 && !g_dtmf_input_mode)
|
||||
|
||||
if (g_eeprom.auto_keypad_lock &&
|
||||
g_key_lock_count_down_500ms > 0 &&
|
||||
!g_dtmf_input_mode &&
|
||||
g_input_box_index == 0 &&
|
||||
g_screen_to_display != DISPLAY_MENU)
|
||||
{
|
||||
if (--g_key_lock_count_down_500ms == 0)
|
||||
g_eeprom.key_lock = true; // lock the keyboard
|
||||
g_update_status = true; // lock symbol needs showing
|
||||
{ // lock the keyboard
|
||||
g_eeprom.key_lock = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (exit_menu)
|
||||
@ -2222,6 +2228,49 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
if (g_eeprom.auto_keypad_lock)
|
||||
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
|
||||
|
||||
if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
||||
{ // keyboard is locked
|
||||
|
||||
if (Key == KEY_F)
|
||||
{ // function/key-lock key
|
||||
|
||||
if (!key_pressed)
|
||||
return;
|
||||
|
||||
if (key_held)
|
||||
{ // unlock the keypad
|
||||
g_eeprom.key_lock = false;
|
||||
g_request_save_settings = true;
|
||||
g_update_status = true;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_UNLOCK;
|
||||
#endif
|
||||
|
||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
|
||||
{
|
||||
if (!key_pressed || key_held)
|
||||
return;
|
||||
|
||||
backlight_turn_on();
|
||||
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
// AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||
|
||||
// keypad is locked, tell the user
|
||||
g_keypad_locked = 4; // 2 second pop-up
|
||||
g_update_display = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
if (g_flag_SaveVfo)
|
||||
@ -2255,7 +2304,8 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (key_pressed)
|
||||
{
|
||||
if (Key != KEY_PTT || g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3)
|
||||
backlight_turn_on();
|
||||
@ -2292,37 +2342,6 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
||||
{ // keyboard is locked
|
||||
|
||||
if (Key == KEY_F)
|
||||
{ // function/key-lock key
|
||||
|
||||
if (!key_pressed)
|
||||
return;
|
||||
|
||||
if (!key_held)
|
||||
{ // keypad is locked, tell the user
|
||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||
g_keypad_locked = 4; // 2 seconds
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
|
||||
{
|
||||
if (!key_pressed || key_held)
|
||||
return;
|
||||
|
||||
// keypad is locked, tell the user
|
||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||
g_keypad_locked = 4; // 2 seconds
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
|
||||
|
57
app/fm.c
57
app/fm.c
@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "app/action.h"
|
||||
@ -184,7 +182,9 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
|
||||
if (BK1080_REG_07_GET_SNR(Test2) >= 2)
|
||||
{
|
||||
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
|
||||
if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10)
|
||||
|
||||
if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED &&
|
||||
BK1080_REG_10_GET_RSSI(Status) >= 10)
|
||||
{
|
||||
//if (Deviation > -281 && Deviation < 280)
|
||||
if (Deviation < 280 || Deviation > 3815)
|
||||
@ -230,8 +230,20 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
#define STATE_USER_MODE 1
|
||||
#define STATE_SAVE 2
|
||||
|
||||
if (!key_held && key_pressed)
|
||||
if (key_held)
|
||||
{
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
return; // no sofiticatedness here - yet
|
||||
}
|
||||
|
||||
if (key_pressed)
|
||||
{
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_fkey_pressed)
|
||||
{
|
||||
uint8_t State;
|
||||
@ -356,7 +368,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
ACTION_FM();
|
||||
break;
|
||||
|
||||
case KEY_1:
|
||||
case KEY_3:
|
||||
g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode;
|
||||
|
||||
if (!FM_ConfigureChannelState())
|
||||
@ -368,27 +380,33 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
break;
|
||||
|
||||
case KEY_2:
|
||||
ACTION_Scan(true);
|
||||
break;
|
||||
|
||||
case KEY_3:
|
||||
ACTION_Scan(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FM_Key_STAR(bool key_pressed, bool key_held)
|
||||
{
|
||||
// if (key_held)
|
||||
// return;
|
||||
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
ACTION_Scan(false);
|
||||
}
|
||||
|
||||
static void FM_Key_EXIT(bool key_pressed, bool key_held)
|
||||
{
|
||||
if (key_held)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!key_pressed)
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
@ -446,9 +464,11 @@ static void FM_Key_EXIT(bool key_pressed, bool key_held)
|
||||
static void FM_Key_MENU(bool key_pressed, bool key_held)
|
||||
{
|
||||
if (key_held)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!key_pressed)
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
@ -599,6 +619,9 @@ void FM_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
|
||||
case KEY_DOWN:
|
||||
FM_Key_UP_DOWN(key_pressed, key_held, -1);
|
||||
break;;
|
||||
case KEY_STAR:
|
||||
FM_Key_STAR(key_pressed, key_held);
|
||||
break;
|
||||
case KEY_EXIT:
|
||||
FM_Key_EXIT(key_pressed, key_held);
|
||||
break;
|
||||
@ -666,5 +689,3 @@ void FM_Start(void)
|
||||
g_enable_speaker = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
6
app/fm.h
6
app/fm.h
@ -17,15 +17,13 @@
|
||||
#ifndef APP_FM_H
|
||||
#define APP_FM_H
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
#define FM_CHANNEL_UP 0x01
|
||||
#define FM_CHANNEL_DOWN 0xFF
|
||||
|
||||
enum {
|
||||
FM_SCAN_OFF = 0U,
|
||||
FM_SCAN_OFF = 0,
|
||||
};
|
||||
|
||||
extern uint16_t g_fm_channels[20];
|
||||
@ -59,5 +57,3 @@ void FM_Start(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
|
||||
void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
{
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
if (g_input_box_index > 0)
|
||||
{
|
||||
if (!key_held && key_pressed)
|
||||
@ -43,23 +45,10 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_held || !key_pressed)
|
||||
{
|
||||
if (key_held || key_pressed)
|
||||
{
|
||||
if (!key_held)
|
||||
return;
|
||||
if (key_held)
|
||||
{ // f-key held
|
||||
|
||||
if (!key_pressed)
|
||||
return;
|
||||
|
||||
#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)
|
||||
if (key_pressed && g_screen_to_display != DISPLAY_MENU && g_current_function != FUNCTION_TRANSMIT)
|
||||
{ // toggle the keyboad lock
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -67,56 +56,35 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
||||
#endif
|
||||
|
||||
g_eeprom.key_lock = !g_eeprom.key_lock;
|
||||
|
||||
g_request_save_settings = true;
|
||||
g_update_status = true;
|
||||
|
||||
// keypad is locked, tell the user
|
||||
g_keypad_locked = 4; // 2 second pop-up
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (key_pressed)
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if ((g_fm_radio_mode || g_screen_to_display != DISPLAY_MAIN) &&
|
||||
g_screen_to_display != DISPLAY_FM)
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
#else
|
||||
if (g_screen_to_display != DISPLAY_MAIN)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
// toggle the fkey on/off
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
return;
|
||||
|
||||
// toggle the f-key flag
|
||||
g_fkey_pressed = !g_fkey_pressed;
|
||||
|
||||
if (g_fkey_pressed)
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (!g_fkey_pressed)
|
||||
g_another_voice_id = VOICE_ID_CANCEL;
|
||||
#endif
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_screen_to_display != DISPLAY_FM)
|
||||
{
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||
{
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_beep_to_play = BEEP_440HZ_500MS;
|
||||
|
||||
// g_ptt_was_released = true; // why is this being set ???
|
||||
}
|
||||
}
|
||||
|
||||
void GENERIC_Key_PTT(bool key_pressed)
|
||||
|
@ -596,7 +596,7 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
case MENU_AUTOLK:
|
||||
g_eeprom.auto_keypad_lock = g_sub_menu_selection;
|
||||
g_key_lock_count_down_500ms = 30;
|
||||
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
|
||||
break;
|
||||
|
||||
case MENU_S_ADD1:
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
42
ui/fmradio.c
42
ui/fmradio.c
@ -19,6 +19,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "app/fm.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/st7565.h"
|
||||
#include "external/printf/printf.h"
|
||||
#include "misc.h"
|
||||
@ -35,11 +36,23 @@ void UI_DisplayFM(void)
|
||||
|
||||
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
strcpy(String, "FM");
|
||||
UI_PrintString(String, 0, 127, 0, 12);
|
||||
// *************************************
|
||||
|
||||
if (g_eeprom.key_lock && g_keypad_locked > 0)
|
||||
{ // tell user how to unlock the keyboard
|
||||
backlight_turn_on();
|
||||
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
|
||||
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
|
||||
ST7565_BlitFullScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
// *************************************
|
||||
|
||||
UI_PrintString("FM", 0, 127, 0, 12);
|
||||
|
||||
// *************************************
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
if (g_ask_to_save)
|
||||
{
|
||||
strcpy(String, "SAVE?");
|
||||
@ -51,11 +64,13 @@ void UI_DisplayFM(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(String, 0, sizeof(String));
|
||||
|
||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||
{
|
||||
if (!g_eeprom.fm_is_channel_mode)
|
||||
{
|
||||
for (i = 0; i < 20; i++)
|
||||
for (i = 0; i < ARRAY_SIZE(g_fm_channels); i++)
|
||||
{
|
||||
if (g_eeprom.fm_frequency_playing == g_fm_channels[i])
|
||||
{
|
||||
@ -64,23 +79,25 @@ void UI_DisplayFM(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 20)
|
||||
if (i >= ARRAY_SIZE(g_fm_channels))
|
||||
strcpy(String, "VFO");
|
||||
}
|
||||
else
|
||||
sprintf(String, "MR(CH%02u)", g_eeprom.fm_selected_channel + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_fm_auto_scan)
|
||||
strcpy(String, "M-SCAN");
|
||||
else
|
||||
sprintf(String, "A-SCAN(%u)", g_fm_channel_position + 1);
|
||||
}
|
||||
}
|
||||
|
||||
UI_PrintString(String, 0, 127, 2, 10);
|
||||
|
||||
// *************************************
|
||||
|
||||
memset(String, 0, sizeof(String));
|
||||
|
||||
if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0))
|
||||
{
|
||||
UI_GenerateChannelString(String, g_fm_channel_position);
|
||||
@ -94,16 +111,17 @@ void UI_DisplayFM(void)
|
||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_DisplayFrequency(g_input_box, 23, 4, true, false);
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(String, "CH-%02u", g_eeprom.fm_selected_channel + 1);
|
||||
}
|
||||
UI_PrintString(String, 0, 127, 4, 10);
|
||||
}
|
||||
|
||||
// *************************************
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user