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

FM radio tidy up

This commit is contained in:
OneOfEleven 2023-10-11 18:32:10 +01:00
parent d676c77e85
commit 8c21a0e543
8 changed files with 72 additions and 63 deletions

View File

@ -2272,8 +2272,10 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
backlight_turn_on(); backlight_turn_on();
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
// AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
// keypad is locked, tell the user // keypad is locked, tell the user
g_keypad_locked = 4; // 2 second pop-up g_keypad_locked = 4; // 2 second pop-up
@ -2533,9 +2535,14 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
ACTION_Handle(Key, key_pressed, key_held); ACTION_Handle(Key, key_pressed, key_held);
} }
else else
{
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
if (!key_held && key_pressed) if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }
}
Skip: Skip:
if (g_beep_to_play != BEEP_NONE) if (g_beep_to_play != BEEP_NONE)

View File

@ -192,8 +192,6 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
//if (Deviation > -281 && Deviation < 280) //if (Deviation > -281 && Deviation < 280)
if (Deviation < 280 || Deviation > 3815) if (Deviation < 280 || Deviation > 3815)
{ {
// not BLE(less than or equal)
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1)
{ {
if (BK1080_FrequencyDeviation & 0x800) if (BK1080_FrequencyDeviation & 0x800)
@ -203,8 +201,6 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
goto Bail; goto Bail;
} }
// not BLT(less than)
if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1)
{ {
if ((BK1080_FrequencyDeviation & 0x800) == 0) if ((BK1080_FrequencyDeviation & 0x800) == 0)
@ -285,7 +281,9 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
uint32_t Frequency; uint32_t Frequency;
g_input_box_index = 0; g_input_box_index = 0;
NUMBER_Get(g_input_box, &Frequency); NUMBER_Get(g_input_box, &Frequency);
Frequency /= 10000; Frequency /= 10000;
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)

View File

@ -40,6 +40,9 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
if (g_input_box_index > 0) if (g_input_box_index > 0)
{ {
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
if (!key_held && key_pressed) if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -69,6 +72,9 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
if (key_pressed) if (key_pressed)
{ {
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
} }

View File

@ -65,21 +65,17 @@ void toggle_chan_scanlist(void)
g_flag_reset_vfos = true; g_flag_reset_vfos = true;
} }
static void processFKeyFunction(const key_code_t Key, const bool beep) static void processFKeyFunction(const key_code_t Key)
{ {
uint8_t Band; uint8_t Band;
uint8_t Vfo = g_eeprom.tx_vfo; uint8_t Vfo = g_eeprom.tx_vfo;
if (g_screen_to_display == DISPLAY_MENU) if (g_screen_to_display == DISPLAY_MENU)
{ {
// if (beep)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
// if (beep)
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
switch (Key) switch (Key)
{ {
case KEY_0: case KEY_0:
@ -119,11 +115,9 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
g_request_save_vfo = true; g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_request_display_screen = DISPLAY_MAIN;
if (beep)
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_request_display_screen = DISPLAY_MAIN;
break; break;
case KEY_2: case KEY_2:
@ -144,11 +138,9 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
g_request_save_settings = 1; g_request_save_settings = 1;
g_flag_reconfigure_vfos = true; g_flag_reconfigure_vfos = true;
g_request_display_screen = DISPLAY_MAIN;
if (beep)
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_request_display_screen = DISPLAY_MAIN;
break; break;
case KEY_3: case KEY_3:
@ -163,11 +155,15 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
if (IS_USER_CHANNEL(g_tx_vfo->channel_save)) if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
{ // swap to frequency mode { // swap to frequency mode
g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo]; g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_FREQUENCY_MODE; g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
#endif #endif
g_request_save_vfo = true; g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
} }
@ -175,18 +171,21 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
if (Channel != 0xFF) if (Channel != 0xFF)
{ // swap to channel mode { // swap to channel mode
g_eeprom.screen_channel[Vfo] = Channel; g_eeprom.screen_channel[Vfo] = Channel;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, Channel + 1); AUDIO_SetDigitVoice(1, Channel + 1);
g_another_voice_id = (voice_id_t)0xFE; g_another_voice_id = (voice_id_t)0xFE;
#endif #endif
g_request_save_vfo = true; g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
} }
} }
if (beep)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break; break;
@ -199,9 +198,7 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_update_status = true; g_update_status = true;
// if (beep) g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_5: case KEY_5:
@ -227,10 +224,12 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
#endif #endif
#endif #endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_6: case KEY_6:
ACTION_Power(); ACTION_Power();
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_7: case KEY_7:
@ -239,11 +238,13 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
#else #else
toggle_chan_scanlist(); toggle_chan_scanlist();
#endif #endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_8: case KEY_8:
g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false; g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false;
g_request_save_channel = 1; g_request_save_channel = 1;
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
case KEY_9: case KEY_9:
@ -261,7 +262,6 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
break; break;
} }
if (beep)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break; break;
@ -269,7 +269,9 @@ static void processFKeyFunction(const key_code_t Key, const bool beep)
g_update_status = true; g_update_status = true;
g_fkey_pressed = false; g_fkey_pressed = false;
if (beep) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
break; break;
} }
@ -293,7 +295,7 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_fkey_pressed = false; g_fkey_pressed = false;
g_update_status = true; g_update_status = true;
processFKeyFunction(Key, false); processFKeyFunction(Key);
} }
} }
@ -469,7 +471,7 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_fkey_pressed = false; g_fkey_pressed = false;
g_update_status = true; g_update_status = true;
processFKeyFunction(Key, true); processFKeyFunction(Key);
} }
static void MAIN_Key_EXIT(bool key_pressed, bool key_held) static void MAIN_Key_EXIT(bool key_pressed, bool key_held)

Binary file not shown.

Binary file not shown.

View File

@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef ENABLE_FMRADIO
#include <string.h> #include <string.h>
#include "app/fm.h" #include "app/fm.h"
@ -74,7 +72,7 @@ void UI_DisplayFM(void)
{ {
if (g_eeprom.fm_frequency_playing == g_fm_channels[i]) if (g_eeprom.fm_frequency_playing == g_fm_channels[i])
{ {
sprintf(String, "VFO(CH%02u)", i + 1); sprintf(String, "VFO (CH %u)", i + 1);
break; break;
} }
} }
@ -83,13 +81,13 @@ void UI_DisplayFM(void)
strcpy(String, "VFO"); strcpy(String, "VFO");
} }
else else
sprintf(String, "MR(CH%02u)", g_eeprom.fm_selected_channel + 1); sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
} }
else else
if (!g_fm_auto_scan) if (!g_fm_auto_scan)
strcpy(String, "M-SCAN"); strcpy(String, "M-SCAN");
else else
sprintf(String, "A-SCAN(%u)", g_fm_channel_position + 1); sprintf(String, "A-SCAN %u", g_fm_channel_position + 1);
} }
UI_PrintString(String, 0, 127, 2, 10); UI_PrintString(String, 0, 127, 2, 10);
@ -117,7 +115,7 @@ void UI_DisplayFM(void)
} }
else else
{ {
sprintf(String, "CH-%02u", g_eeprom.fm_selected_channel + 1); sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
UI_PrintString(String, 0, 127, 4, 10); UI_PrintString(String, 0, 127, 4, 10);
} }
@ -125,5 +123,3 @@ void UI_DisplayFM(void)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();
} }
#endif

View File

@ -4,7 +4,7 @@
#ifdef GIT_HASH #ifdef GIT_HASH
#define VER GIT_HASH #define VER GIT_HASH
#else #else
#define VER "231009" #define VER "231012"
#endif #endif
#ifndef ONE_OF_ELEVEN_VER #ifndef ONE_OF_ELEVEN_VER