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

fix freq/chan scan + add 4th FM radio band

This commit is contained in:
OneOfEleven 2023-10-24 11:47:49 +01:00
parent 2d7d327fd0
commit fa1cbeb049
28 changed files with 197 additions and 168 deletions

View File

@ -12,13 +12,13 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
# UART Programming 2.9 kB # UART Programming 2.9 kB
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 1 ENABLE_UART_DEBUG := 0
# AirCopy 2.5 kB # AirCopy 2.5 kB
ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY := 1
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1
ENABLE_AIRCOPY_RX_REBOOT := 0 ENABLE_AIRCOPY_RX_REBOOT := 0
# FM Radio 4.2 kB # FM Radio 4.2 kB
#ENABLE_FMRADIO_76_90 := 0 ENABLE_FMRADIO_76_90 := 0
ENABLE_FMRADIO_68_108 := 0 ENABLE_FMRADIO_68_108 := 0
ENABLE_FMRADIO_76_108 := 0 ENABLE_FMRADIO_76_108 := 0
ENABLE_FMRADIO_875_108 := 1 ENABLE_FMRADIO_875_108 := 1
@ -66,7 +66,7 @@ ENABLE_RX_SIGNAL_BAR := 1
# Tx Timeout Bar 0.2 kB # Tx Timeout Bar 0.2 kB
ENABLE_TX_TIMEOUT_BAR := 0 ENABLE_TX_TIMEOUT_BAR := 0
# Tx Audio Bar 0.3 kB # Tx Audio Bar 0.3 kB
ENABLE_TX_AUDIO_BAR := 1 ENABLE_TX_AUDIO_BAR := 0
# Side Button Menu 0.3 kB # Side Button Menu 0.3 kB
ENABLE_SIDE_BUTT_MENU := 1 ENABLE_SIDE_BUTT_MENU := 1
# Key Lock 0.4 kB # Key Lock 0.4 kB
@ -101,6 +101,12 @@ ifeq ($(ENABLE_LTO),1)
ENABLE_OVERLAY := 0 ENABLE_OVERLAY := 0
endif endif
ifeq ($(filter $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108) $(ENABLE_FMRADIO_875_108), 1), 1)
ENABLE_FMRADIO := 1
else
ENABLE_FMRADIO := 0
endif
ifeq ($(ENABLE_TX_TIMEOUT_BAR),1) ifeq ($(ENABLE_TX_TIMEOUT_BAR),1)
# can't have ENABLE_TX_TIMEOUT_BAR and ENABLE_TX_AUDIO_BAR enabled at same time # can't have ENABLE_TX_TIMEOUT_BAR and ENABLE_TX_AUDIO_BAR enabled at same time
ENABLE_TX_AUDIO_BAR := 0 ENABLE_TX_AUDIO_BAR := 0
@ -130,7 +136,7 @@ ifeq ($(ENABLE_UART),1)
OBJS += driver/aes.o OBJS += driver/aes.o
endif endif
OBJS += driver/backlight.o OBJS += driver/backlight.o
ifeq ($(filter $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108) $(ENABLE_FMRADIO_875_108), 1), 1) ifeq ($(ENABLE_FMRADIO), 1)
OBJS += driver/bk1080.o OBJS += driver/bk1080.o
endif endif
OBJS += driver/bk4819.o OBJS += driver/bk4819.o
@ -159,7 +165,7 @@ ifeq ($(ENABLE_AIRCOPY),1)
endif endif
OBJS += app/app.o OBJS += app/app.o
OBJS += app/dtmf.o OBJS += app/dtmf.o
ifeq ($(filter $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108) $(ENABLE_FMRADIO_875_108), 1), 1) ifeq ($(ENABLE_FMRADIO), 1)
OBJS += app/fm.o OBJS += app/fm.o
endif endif
OBJS += app/generic.o OBJS += app/generic.o
@ -195,7 +201,7 @@ ifeq ($(ENABLE_AIRCOPY),1)
OBJS += ui/aircopy.o OBJS += ui/aircopy.o
endif endif
OBJS += ui/battery.o OBJS += ui/battery.o
ifeq ($(filter $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108) $(ENABLE_FMRADIO_875_108), 1), 1) ifeq ($(ENABLE_FMRADIO), 1)
OBJS += ui/fmradio.o OBJS += ui/fmradio.o
endif endif
OBJS += ui/helper.o OBJS += ui/helper.o
@ -297,6 +303,9 @@ endif
ifeq ($(ENABLE_FMRADIO_875_108),1) ifeq ($(ENABLE_FMRADIO_875_108),1)
CFLAGS += -DENABLE_FMRADIO_875_108 CFLAGS += -DENABLE_FMRADIO_875_108
endif endif
ifeq ($(ENABLE_FMRADIO),1)
CFLAGS += -DENABLE_FMRADIO
endif
ifeq ($(ENABLE_UART),1) ifeq ($(ENABLE_UART),1)
CFLAGS += -DENABLE_UART CFLAGS += -DENABLE_UART
endif endif

View File

@ -45,9 +45,9 @@ ENABLE_UART_DEBUG := 0 just for code debugging, it sends de
ENABLE_AIRCOPY := 1 clone radio-to-radio via RF ENABLE_AIRCOPY := 1 clone radio-to-radio via RF
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 remember the aircopy frequency ENABLE_AIRCOPY_REMEMBER_FREQ := 1 remember the aircopy frequency
ENABLE_AIRCOPY_RX_REBOOT := 0 auto reboot on an aircopy successful RX completion ENABLE_AIRCOPY_RX_REBOOT := 0 auto reboot on an aircopy successful RX completion
#ENABLE_FMRADIO_76_90 := 0 not yet implemented ENABLE_FMRADIO_76_90 := 0 enable FM radio 76MHz ~ 90MHz
ENABLE_FMRADIO_68_108 := 0 enable FM radio 68MHz ~ 108MHz ENABLE_FMRADIO_68_108 := 0 enable FM radio 68MHz ~ 108MHz
ENABLE_FMRADIO_76_108 := 0 enable FM radio 76MHz ~ 108MHz ENABLE_FMRADIO_76_108 := 0 enable FM radio 76MHz ~ 108MHz
ENABLE_FMRADIO_875_108 := 1 enable FM radio 87.5MHz ~ 108MHz ENABLE_FMRADIO_875_108 := 1 enable FM radio 87.5MHz ~ 108MHz
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA) ENABLE_NOAA := 0 everything NOAA (only of any use in the USA)
ENABLE_VOICE := 0 want to hear voices ? ENABLE_VOICE := 0 want to hear voices ?
@ -85,7 +85,7 @@ ENABLE_RX_SIGNAL_BAR := 1 enable a menu option for showing an
ENABLE_TX_TIMEOUT_BAR := 0 show the remainng TX time ENABLE_TX_TIMEOUT_BAR := 0 show the remainng TX time
ENABLE_TX_AUDIO_BAR := 1 enable a menu option for showing a TX audio level bar ENABLE_TX_AUDIO_BAR := 1 enable a menu option for showing a TX audio level bar
ENABLE_SIDE_BUTT_MENU := 1 enable menu option for configuring the programmable side buttons ENABLE_SIDE_BUTT_MENU := 1 enable menu option for configuring the programmable side buttons
ENABLE_KEYLOCK := 1 auto lock after 30 sec or long press F to lock ENABLE_KEYLOCK := 1 enable keylock menu option + keylock code
#ENABLE_BAND_SCOPE := 0 not yet implemented - spectrum/pan-adapter #ENABLE_BAND_SCOPE := 0 not yet implemented - spectrum/pan-adapter
#ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible #ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible
``` ```

View File

@ -19,13 +19,13 @@
#include "app/action.h" #include "app/action.h"
#include "app/app.h" #include "app/app.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/search.h" #include "app/search.h"
#include "audio.h" #include "audio.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "driver/bk1080.h" #include "driver/bk1080.h"
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -102,7 +102,7 @@ void ACTION_Monitor(void)
RADIO_setup_registers(true); RADIO_setup_registers(true);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
{ {
FM_Start(); FM_Start();
@ -115,7 +115,7 @@ void ACTION_Monitor(void)
void ACTION_Scan(bool bRestart) void ACTION_Scan(bool bRestart)
{ {
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
{ {
if (g_current_function != FUNCTION_RECEIVE && if (g_current_function != FUNCTION_RECEIVE &&
@ -306,7 +306,7 @@ void ACTION_Scan(bool bRestart)
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
void ACTION_FM(void) void ACTION_FM(void)
{ {
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_MONITOR) if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_MONITOR)
@ -400,7 +400,7 @@ void ACTION_process(const key_code_t Key, const bool key_pressed, const bool key
ACTION_AlarmOr1750(false); ACTION_AlarmOr1750(false);
#endif #endif
break; break;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
case ACTION_OPT_FM: case ACTION_OPT_FM:
ACTION_FM(); ACTION_FM();
break; break;

View File

@ -29,7 +29,7 @@ void ACTION_Scan(bool bFlag);
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
//static void ACTION_AlarmOr1750(bool b1750) //static void ACTION_AlarmOr1750(bool b1750)
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
void ACTION_FM(void); void ACTION_FM(void);
#endif #endif

125
app/app.c
View File

@ -23,7 +23,7 @@
#endif #endif
#include "app/app.h" #include "app/app.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
@ -36,7 +36,7 @@
#include "board.h" #include "board.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#include "driver/backlight.h" #include "driver/backlight.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "driver/bk1080.h" #include "driver/bk1080.h"
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -466,7 +466,7 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
if (g_setting_backlight_on_tx_rx >= 2) if (g_setting_backlight_on_tx_rx >= 2)
backlight_turn_on(backlight_tx_rx_time_500ms); backlight_turn_on(backlight_tx_rx_time_500ms);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif
@ -573,7 +573,7 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
FUNCTION_Select(Function); FUNCTION_Select(Function);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (Function == FUNCTION_MONITOR || g_fm_radio_mode) if (Function == FUNCTION_MONITOR || g_fm_radio_mode)
#else #else
if (Function == FUNCTION_MONITOR) if (Function == FUNCTION_MONITOR)
@ -700,6 +700,10 @@ static void APP_next_freq(void)
g_rx_vfo->freq_config_rx.frequency = frequency; g_rx_vfo->freq_config_rx.frequency = frequency;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("APP_next_freq %u %u\r\n", frequency, new_band);
#endif
if (new_band != old_band) if (new_band != old_band)
{ // original slow method { // original slow method
@ -811,6 +815,10 @@ static void APP_next_channel(void)
if (g_scan_next_channel != prev_chan) if (g_scan_next_channel != prev_chan)
{ {
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("APP_next_channel %u\r\n", g_scan_next_channel);
#endif
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_next_channel; g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_next_channel; g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
@ -1046,7 +1054,7 @@ void APP_end_tx(void)
g_vox_pause_count_down = 0; g_vox_pause_count_down = 0;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
return; return;
#endif #endif
@ -1139,7 +1147,7 @@ void APP_process(void)
APP_process_function(); APP_process_function();
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
return; return;
#endif #endif
@ -1160,7 +1168,37 @@ void APP_process(void)
// TODO: check to see if signal stays present for minimum time before pausing (debounce) // TODO: check to see if signal stays present for minimum time before pausing (debounce)
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode)
{
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
}
else
{ // switch to next channel
g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
if (g_scan_next_channel <= USER_CHANNEL_LAST)
APP_next_channel();
else
if (IS_FREQ_CHANNEL(g_scan_next_channel))
APP_next_freq();
}
/* /*
if (g_scan_next_channel <= USER_CHANNEL_LAST)
{ // channel mode
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode)
{
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
}
else
{ // switch to next channel
g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
APP_next_channel();
}
}
else
if (IS_FREQ_CHANNEL(g_scan_next_channel)) if (IS_FREQ_CHANNEL(g_scan_next_channel))
{ // frequency mode { // frequency mode
@ -1175,20 +1213,8 @@ void APP_process(void)
APP_next_freq(); APP_next_freq();
} }
} }
else */
*/ { // channel mode
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode)
{
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
}
else
{ // switch to next channel
g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
APP_next_channel();
}
}
} }
} }
@ -1223,7 +1249,7 @@ void APP_process(void)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_voice_write_index == 0 && g_voice_write_index == 0 &&
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
!g_fm_radio_mode && !g_fm_radio_mode &&
#endif #endif
g_dtmf_call_state == DTMF_CALL_STATE_NONE && g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
@ -1242,7 +1268,7 @@ void APP_process(void)
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_schedule_fm && if (g_schedule_fm &&
g_fm_scan_state != FM_SCAN_OFF && g_fm_scan_state != FM_SCAN_OFF &&
g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_MONITOR &&
@ -1263,7 +1289,7 @@ void APP_process(void)
{ {
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if ( if (
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_radio_mode || g_fm_radio_mode ||
#endif #endif
g_ptt_is_pressed || g_ptt_is_pressed ||
@ -1289,7 +1315,7 @@ void APP_process(void)
} }
#else #else
if ( if (
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_radio_mode || g_fm_radio_mode ||
#endif #endif
g_ptt_is_pressed || g_ptt_is_pressed ||
@ -1611,7 +1637,7 @@ void APP_time_slice_10ms(void)
g_flag_save_settings = false; g_flag_save_settings = false;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_flag_save_fm) if (g_flag_save_fm)
{ {
SETTINGS_save_fm(); SETTINGS_save_fm();
@ -1697,7 +1723,7 @@ void APP_time_slice_10ms(void)
// Skipping authentic device checks // Skipping authentic device checks
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0) if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
return; return;
#endif #endif
@ -1779,7 +1805,7 @@ void APP_time_slice_10ms(void)
} }
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_restore_count_down_10ms > 0) if (g_fm_radio_mode && g_fm_restore_count_down_10ms > 0)
{ {
if (--g_fm_restore_count_down_10ms == 0) if (--g_fm_restore_count_down_10ms == 0)
@ -2021,7 +2047,7 @@ void APP_cancel_user_input_modes(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();
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
g_request_display_screen = DISPLAY_FM; g_request_display_screen = DISPLAY_FM;
else else
@ -2100,7 +2126,7 @@ void APP_time_slice_500ms(void)
// Skipped authentic device check // Skipped authentic device check
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_count_down_500ms > 0) if (g_fm_radio_count_down_500ms > 0)
{ {
g_fm_radio_count_down_500ms--; g_fm_radio_count_down_500ms--;
@ -2159,7 +2185,7 @@ void APP_time_slice_500ms(void)
#endif #endif
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_scan_state == FM_SCAN_OFF || g_ask_to_save) if (g_fm_scan_state == FM_SCAN_OFF || g_ask_to_save)
#endif #endif
{ {
@ -2227,7 +2253,7 @@ void APP_time_slice_500ms(void)
{ {
gui_display_type_t disp = DISPLAY_INVALID; gui_display_type_t disp = DISPLAY_INVALID;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && if (g_fm_radio_mode &&
g_current_function != FUNCTION_RECEIVE && g_current_function != FUNCTION_RECEIVE &&
g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_MONITOR &&
@ -2256,7 +2282,7 @@ void APP_time_slice_500ms(void)
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT) if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
APP_update_rssi(g_eeprom.rx_vfo); APP_update_rssi(g_eeprom.rx_vfo);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_ptt_is_pressed && g_fm_resume_count_down_500ms > 0) if (!g_ptt_is_pressed && g_fm_resume_count_down_500ms > 0)
{ {
if (--g_fm_resume_count_down_500ms == 0) if (--g_fm_resume_count_down_500ms == 0)
@ -2411,7 +2437,7 @@ void APP_time_slice_500ms(void)
} }
#endif #endif
void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction) void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction)
{ {
RADIO_select_vfos(); RADIO_select_vfos();
@ -2419,24 +2445,33 @@ void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction)
g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1;
g_scan_state_dir = scan_direction; g_scan_state_dir = scan_direction;
if (remember_current)
{
g_scan_restore_channel = 0xff;
g_scan_restore_frequency = 0xffffffff;
}
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("APP_channel_next %u\r\n", g_scan_next_channel);
#endif
if (g_scan_next_channel <= USER_CHANNEL_LAST) if (g_scan_next_channel <= USER_CHANNEL_LAST)
{ // channel mode { // channel mode
if (flag) if (remember_current)
{ g_scan_restore_channel = g_scan_next_channel;
g_scan_restore_frequency = 0xffffffff;
g_scan_restore_channel = g_scan_next_channel;
}
APP_next_channel(); APP_next_channel();
} }
else else
if (IS_FREQ_CHANNEL(g_scan_next_channel))
{ // frequency mode { // frequency mode
if (flag) if (remember_current)
{
g_scan_restore_channel = 0xff;
g_scan_restore_frequency = g_rx_vfo->freq_config_rx.frequency; g_scan_restore_frequency = g_rx_vfo->freq_config_rx.frequency;
}
APP_next_freq(); APP_next_freq();
} }
else
{
return;
}
g_scan_pause_10ms = scan_pause_css_10ms; g_scan_pause_10ms = scan_pause_css_10ms;
g_scan_pause_time_mode = false; g_scan_pause_time_mode = false;
@ -2528,7 +2563,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
g_keypad_locked = 4; // 2 second pop-up g_keypad_locked = 4; // 2 second pop-up
g_update_display = true; g_update_display = true;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode) // don't beep when the FM radio is on, it cause bad gaps and loud clicks if (!g_fm_radio_mode) // don't beep when the FM radio is on, it cause bad gaps and loud clicks
#endif #endif
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -2721,7 +2756,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
MAIN_process_key(Key, key_pressed, key_held); MAIN_process_key(Key, key_pressed, key_held);
break; break;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
case DISPLAY_FM: case DISPLAY_FM:
FM_process_key(Key, key_pressed, key_held); FM_process_key(Key, key_pressed, key_held);
break; break;
@ -2757,7 +2792,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
} }
else else
{ {
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode) if (!g_fm_radio_mode)
#endif #endif
if (!key_held && key_pressed) if (!key_held && key_pressed)
@ -2799,7 +2834,7 @@ Skip:
g_update_status = true; g_update_status = true;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_request_save_fm) if (g_request_save_fm)
{ {
if (!key_held) if (!key_held)

View File

@ -30,7 +30,7 @@ extern const uint8_t orig_pga;
void APP_end_tx(void); void APP_end_tx(void);
void APP_stop_scan(void); void APP_stop_scan(void);
void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction); void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction);
bool APP_start_listening(function_type_t Function, const bool reset_am_fix); bool APP_start_listening(function_type_t Function, const bool reset_am_fix);
uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step); uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step);
void APP_process(void); void APP_process(void);

View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> // NULL #include <stdio.h> // NULL
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/search.h" #include "app/search.h"
@ -248,7 +248,7 @@ void DTMF_HandleRequest(void)
g_dtmf_reply_state = DTMF_REPLY_AB; g_dtmf_reply_state = DTMF_REPLY_AB;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
{ {
FM_TurnOff(); FM_TurnOff();

View File

@ -25,6 +25,7 @@
#include "driver/eeprom.h" #include "driver/eeprom.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "frequencies.h"
#include "functions.h" #include "functions.h"
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"

View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "app/app.h" #include "app/app.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
@ -40,7 +40,7 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
if (g_input_box_index > 0) if (g_input_box_index > 0)
{ {
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode) if (!g_fm_radio_mode)
#endif #endif
if (!key_held && key_pressed) if (!key_held && key_pressed)
@ -74,7 +74,7 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
if (key_pressed) if (key_pressed)
{ {
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode) if (!g_fm_radio_mode)
#endif #endif
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
@ -171,7 +171,7 @@ void GENERIC_Key_PTT(bool key_pressed)
goto cancel_tx; goto cancel_tx;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_scan_state != FM_SCAN_OFF) if (g_fm_scan_state != FM_SCAN_OFF)
{ // FM radio is scanning .. stop { // FM radio is scanning .. stop
FM_PlayAndUpdate(); FM_PlayAndUpdate();

View File

@ -18,7 +18,7 @@
#include "app/action.h" #include "app/action.h"
#include "app/app.h" #include "app/app.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/generic.h" #include "app/generic.h"
@ -197,7 +197,7 @@ void processFKeyFunction(const key_code_t Key)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF) if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
APP_stop_scan(); APP_stop_scan();
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
ACTION_FM(); ACTION_FM();
#else #else
@ -636,7 +636,7 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
return; return;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode) if (!g_fm_radio_mode)
#endif #endif
{ {
@ -666,7 +666,7 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
return; return;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
ACTION_FM(); ACTION_FM();
#endif #endif
@ -1006,7 +1006,7 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
// UART_printf(" main 1 key %2u %u %u %u\r\n", key, key_pressed, key_held); // UART_printf(" main 1 key %2u %u %u %u\r\n", key, key_pressed, key_held);
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #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) if (!key_held && key_pressed)

View File

@ -21,7 +21,7 @@
#if !defined(ENABLE_OVERLAY) #if !defined(ENABLE_OVERLAY)
#include "ARMCM0.h" #include "ARMCM0.h"
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/uart.h" #include "app/uart.h"

14
audio.c
View File

@ -17,12 +17,12 @@
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
#include "app/aircopy.h" #include "app/aircopy.h"
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "audio.h" #include "audio.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "driver/bk1080.h" #include "driver/bk1080.h"
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -104,7 +104,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode) if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#ifdef MUTE_AUDIO_FOR_VOICE #ifdef MUTE_AUDIO_FOR_VOICE
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(true); BK1080_Mute(true);
@ -223,7 +223,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
if (g_speaker_enabled) if (g_speaker_enabled)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(false); BK1080_Mute(false);
#endif #endif
@ -290,7 +290,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#ifdef MUTE_AUDIO_FOR_VOICE #ifdef MUTE_AUDIO_FOR_VOICE
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(true); BK1080_Mute(true);
@ -317,7 +317,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR) if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(false); BK1080_Mute(false);
#endif #endif
@ -465,7 +465,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR) if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Mute(false); BK1080_Mute(false);
#endif #endif

View File

@ -249,7 +249,7 @@ const uint8_t BITMAP_MONITOR[6] =
__extension__ 0b01111111 __extension__ 0b01111111
}; };
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
const uint8_t BITMAP_FM[12] = const uint8_t BITMAP_FM[12] =
{ // "FM" { // "FM"
__extension__ 0b00000000, __extension__ 0b00000000,

View File

@ -37,7 +37,7 @@ extern const uint8_t BITMAP_TDR_HOLDING[12];
extern const uint8_t BITMAP_MONITOR[6]; extern const uint8_t BITMAP_MONITOR[6];
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern const uint8_t BITMAP_FM[12]; extern const uint8_t BITMAP_FM[12];
#endif #endif

10
board.c
View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "board.h" #include "board.h"
@ -27,7 +27,7 @@
#include "bsp/dp32g030/syscon.h" #include "bsp/dp32g030/syscon.h"
#include "driver/adc.h" #include "driver/adc.h"
//#include "driver/backlight.h" //#include "driver/backlight.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "driver/bk1080.h" #include "driver/bk1080.h"
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -121,7 +121,7 @@ void BOARD_GPIO_Init(void)
| GPIO_DIR_5_MASK // INPUT | GPIO_DIR_5_MASK // INPUT
); );
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
#endif #endif
} }
@ -512,7 +512,7 @@ void BOARD_Init(void)
BOARD_ADC_Init(); BOARD_ADC_Init();
ST7565_Init(true); ST7565_Init(true);
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif
} }
@ -567,7 +567,7 @@ void BOARD_EEPROM_load(void)
g_eeprom.noaa_channel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST; g_eeprom.noaa_channel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST;
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
{ // 0E88..0E8F { // 0E88..0E8F
struct struct
{ {

View File

@ -25,7 +25,9 @@ uint32_t g_aircopy_freq = 41002500;
const freq_band_table_t AIR_BAND = {10800000, 13700000}; const freq_band_table_t AIR_BAND = {10800000, 13700000};
// FM broadcast band lower/upper limit // FM broadcast band lower/upper limit
#if defined(ENABLE_FMRADIO_68_108) #if defined(ENABLE_FMRADIO_76_90)
const freq_band_table_t FM_RADIO_BAND = {760, 900};
#elif defined(ENABLE_FMRADIO_68_108)
const freq_band_table_t FM_RADIO_BAND = {680, 1080}; const freq_band_table_t FM_RADIO_BAND = {680, 1080};
#elif defined(ENABLE_FMRADIO_76_108) #elif defined(ENABLE_FMRADIO_76_108)
const freq_band_table_t FM_RADIO_BAND = {760, 1080}; const freq_band_table_t FM_RADIO_BAND = {760, 1080};

View File

@ -43,7 +43,7 @@ extern uint32_t g_aircopy_freq;
extern const freq_band_table_t AIR_BAND; extern const freq_band_table_t AIR_BAND;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern const freq_band_table_t FM_RADIO_BAND; extern const freq_band_table_t FM_RADIO_BAND;
#endif #endif

View File

@ -17,13 +17,13 @@
#include <string.h> #include <string.h>
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#include "dcs.h" #include "dcs.h"
#include "driver/backlight.h" #include "driver/backlight.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "driver/bk1080.h" #include "driver/bk1080.h"
#endif #endif
#include "driver/bk4819.h" #include "driver/bk4819.h"
@ -116,7 +116,7 @@ void FUNCTION_Select(function_type_t Function)
if (prev_func != FUNCTION_RECEIVE) if (prev_func != FUNCTION_RECEIVE)
break; break;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
g_fm_restore_count_down_10ms = fm_restore_countdown_10ms; g_fm_restore_count_down_10ms = fm_restore_countdown_10ms;
#endif #endif
@ -200,7 +200,7 @@ void FUNCTION_Select(function_type_t Function)
g_dtmf_rx_live_timeout = 0; g_dtmf_rx_live_timeout = 0;
memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live));
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
// disable the FM radio // disable the FM radio
if (g_fm_radio_mode) if (g_fm_radio_mode)
BK1080_Init(0, false); BK1080_Init(0, false);
@ -288,7 +288,7 @@ void FUNCTION_Select(function_type_t Function)
g_battery_save_count_down_10ms = battery_save_count_10ms; g_battery_save_count_down_10ms = battery_save_count_10ms;
g_schedule_power_save = false; g_schedule_power_save = false;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_restore_count_down_10ms = 0; g_fm_restore_count_down_10ms = 0;
#endif #endif

View File

@ -134,58 +134,40 @@ uint16_t reverse_bits(const uint16_t bits_in, const unsigned int num_bits)
void error_correction(uint8_t *data) void error_correction(uint8_t *data)
{ {
int i; int i;
uint8_t csr[FEC_K]; uint8_t shift_reg;
uint8_t syn = 0; uint8_t syn;
// uint8_t shift_reg = 0;
syn = 0; for (i = 0, shift_reg = 0, syn = 0; i < FEC_K; i++)
for (i = 0; i < FEC_K; i++)
csr[i] = 0;
for (i = 0; i < FEC_K; i++)
{ {
const uint8_t bi = data[i]; const uint8_t bi = data[i];
int bit_num; int bit_num;
for (bit_num = 0; bit_num < 8; bit_num++) for (bit_num = 0; bit_num < 8; bit_num++)
{ {
uint8_t b; uint8_t b;
int k; unsigned int k = 0;
unsigned int ec = 0;
#if 0 shift_reg = (shift_reg << 1) | ((bi >> bit_num) & 1u);
shift_reg = (shift_reg << 1) | ((bi >> bit_num) & 1u); b = ((shift_reg >> 6) ^ (shift_reg >> 5) ^ (shift_reg >> 2) ^ (shift_reg >> 0)) & 1u;
b = ((shift_reg >> 6) ^ (shift_reg >> 5) ^ (shift_reg >> 2) ^ (shift_reg >> 0)) & 1u; syn = (syn << 1) | (((b ^ (data[i + FEC_K] >> bit_num)) & 1u) ? 1u : 0u);
#else
for (k = FEC_K - 1; k > 0; k--)
csr[k] = csr[k - 1];
csr[0] = (bi >> bit_num) & 1u;
b = (csr[0] + csr[2] + csr[5] + csr[6]) & 1u;
#endif
syn = (syn << 1) | (((b ^ (data[i + FEC_K] >> bit_num)) & 1u) ? 1u : 0u);
if (syn & 0x80) ec++; if (syn & 0x80) k++;
if (syn & 0x20) ec++; if (syn & 0x20) k++;
if (syn & 0x04) ec++; if (syn & 0x04) k++;
if (syn & 0x02) ec++; if (syn & 0x02) k++;
if (ec >= 3) if (k >= 3)
{ // correct error { // correct bit error
int ii = i;
int fix_i = i; int bn = bit_num - 7;
int fix_j = bit_num - 7; if (bn < 0)
syn ^= 0xA6;
if (fix_j < 0)
{ {
--fix_i; bn += 8;
fix_j += 8; ii--;
} }
if (ii >= 0)
if (fix_i >= 0) data[ii] ^= 1u << bn;
data[fix_i] ^= 1u << fix_j; syn ^= 0xA6; // 10100110
} }
} }
} }
@ -202,12 +184,12 @@ uint8_t * decode_data(uint8_t *data)
unsigned int i; unsigned int i;
unsigned int k; unsigned int k;
unsigned int m;
uint8_t deinterleaved[(FEC_K * 2) * 8]; uint8_t deinterleaved[(FEC_K * 2) * 8];
// de-interleave the received bits // de-interleave the received bits
for (i = 0, k = 0; i < 16; i++) for (i = 0, k = 0; i < 16; i++)
{ {
unsigned int m;
for (m = 0; m < FEC_K; m++) for (m = 0; m < FEC_K; m++)
{ {
const unsigned int n = (m * 16) + i; const unsigned int n = (m * 16) + i;
@ -216,12 +198,12 @@ uint8_t * decode_data(uint8_t *data)
} }
// copy the de-interleaved bits to the data buffer // copy the de-interleaved bits to the data buffer
for (i = 0; i < (FEC_K * 2); i++) for (i = 0, m = 0; i < (FEC_K * 2); i++)
{ {
unsigned int k; unsigned int k;
uint8_t b = 0; uint8_t b = 0;
for (k = 0; k < 8; k++) for (k = 0; k < 8; k++)
if (deinterleaved[(i * 8) + k]) if (deinterleaved[m++])
b |= 1u << k; b |= 1u << k;
data[i] = b; data[i] = b;
} }

6
misc.c
View File

@ -189,7 +189,7 @@ bool g_flag_reset_vfos;
bool g_request_save_vfo; bool g_request_save_vfo;
uint8_t g_request_save_channel; uint8_t g_request_save_channel;
bool g_request_save_settings; bool g_request_save_settings;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
bool g_request_save_fm; bool g_request_save_fm;
#endif #endif
bool g_flag_prepare_tx; bool g_flag_prepare_tx;
@ -200,7 +200,7 @@ bool g_flag_refresh_menu;
bool g_flag_save_vfo; bool g_flag_save_vfo;
bool g_flag_save_settings; bool g_flag_save_settings;
bool g_flag_save_channel; bool g_flag_save_channel;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
bool g_flag_save_fm; bool g_flag_save_fm;
#endif #endif
bool g_cdcss_lost; bool g_cdcss_lost;
@ -260,7 +260,7 @@ volatile bool g_next_time_slice_40ms;
volatile bool g_schedule_noaa = true; volatile bool g_schedule_noaa = true;
#endif #endif
volatile bool g_flag_tail_tone_elimination_complete; volatile bool g_flag_tail_tone_elimination_complete;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
volatile bool g_schedule_fm; volatile bool g_schedule_fm;
#endif #endif

10
misc.h
View File

@ -240,7 +240,7 @@ extern volatile bool g_tx_timeout_reached;
extern volatile uint16_t g_tail_tone_elimination_count_down_10ms; extern volatile uint16_t g_tail_tone_elimination_count_down_10ms;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern volatile uint16_t g_fm_play_count_down_10ms; extern volatile uint16_t g_fm_play_count_down_10ms;
#endif #endif
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
@ -275,7 +275,7 @@ extern bool g_flag_reset_vfos;
extern bool g_request_save_vfo; extern bool g_request_save_vfo;
extern uint8_t g_request_save_channel; extern uint8_t g_request_save_channel;
extern bool g_request_save_settings; extern bool g_request_save_settings;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern bool g_request_save_fm; extern bool g_request_save_fm;
#endif #endif
extern bool g_flag_prepare_tx; extern bool g_flag_prepare_tx;
@ -286,7 +286,7 @@ extern bool g_flag_refresh_menu; // refresh menu display
extern bool g_flag_save_vfo; extern bool g_flag_save_vfo;
extern bool g_flag_save_settings; extern bool g_flag_save_settings;
extern bool g_flag_save_channel; extern bool g_flag_save_channel;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern bool g_flag_save_fm; extern bool g_flag_save_fm;
#endif #endif
extern bool g_cdcss_lost; extern bool g_cdcss_lost;
@ -327,7 +327,7 @@ extern uint8_t g_backup_cross_vfo_rx_tx;
extern volatile bool g_next_time_slice; extern volatile bool g_next_time_slice;
extern bool g_update_display; extern bool g_update_display;
extern bool g_unhide_hidden; extern bool g_unhide_hidden;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern uint8_t g_fm_channel_position; extern uint8_t g_fm_channel_position;
#endif #endif
extern volatile uint8_t g_found_cdcss_count_down_10ms; extern volatile uint8_t g_found_cdcss_count_down_10ms;
@ -341,7 +341,7 @@ extern volatile bool g_next_time_slice_40ms;
extern volatile bool g_schedule_noaa; extern volatile bool g_schedule_noaa;
#endif #endif
extern volatile bool g_flag_tail_tone_elimination_complete; extern volatile bool g_flag_tail_tone_elimination_complete;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
extern volatile bool g_schedule_fm; extern volatile bool g_schedule_fm;
#endif #endif
extern int16_t g_current_rssi[2]; // now one per VFO extern int16_t g_current_rssi[2]; // now one per VFO

View File

@ -18,7 +18,7 @@
#include "app/app.h" #include "app/app.h"
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "audio.h" #include "audio.h"
@ -736,7 +736,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if ( if (
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
!g_fm_radio_mode && !g_fm_radio_mode &&
#endif #endif
g_eeprom.vox_switch && g_eeprom.vox_switch &&
@ -919,7 +919,7 @@ void RADIO_Setg_vfo_state(vfo_state_t State)
g_vfo_state[0] = VFO_STATE_NORMAL; g_vfo_state[0] = VFO_STATE_NORMAL;
g_vfo_state[1] = VFO_STATE_NORMAL; g_vfo_state[1] = VFO_STATE_NORMAL;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_resume_count_down_500ms = 0; g_fm_resume_count_down_500ms = 0;
#endif #endif
} }
@ -936,7 +936,7 @@ void RADIO_Setg_vfo_state(vfo_state_t State)
g_vfo_state[vfo] = State; g_vfo_state[vfo] = State;
} }
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_resume_count_down_500ms = fm_resume_countdown_500ms; g_fm_resume_count_down_500ms = fm_resume_countdown_500ms;
#endif #endif
} }

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/search.h" #include "app/search.h"
@ -100,7 +100,7 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(g_count_down_to_play_next_voice_10ms, g_flag_play_queued_voice); DECREMENT_AND_TRIGGER(g_count_down_to_play_next_voice_10ms, g_flag_play_queued_voice);
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR) if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR)
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(g_fm_play_count_down_10ms, g_schedule_fm); DECREMENT_AND_TRIGGER(g_fm_play_count_down_10ms, g_schedule_fm);

View File

@ -16,7 +16,7 @@
#include <string.h> #include <string.h>
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "driver/eeprom.h" #include "driver/eeprom.h"
@ -26,7 +26,7 @@
eeprom_config_t g_eeprom; eeprom_config_t g_eeprom;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
void SETTINGS_save_fm(void) void SETTINGS_save_fm(void)
{ {
unsigned int i; unsigned int i;

View File

@ -469,7 +469,7 @@ typedef struct {
uint8_t field7_0xa; uint8_t field7_0xa;
uint8_t field8_0xb; uint8_t field8_0xb;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
uint16_t fm_selected_frequency; uint16_t fm_selected_frequency;
uint8_t fm_selected_channel; uint8_t fm_selected_channel;
bool fm_is_channel_mode; bool fm_is_channel_mode;
@ -565,7 +565,7 @@ typedef struct {
extern eeprom_config_t g_eeprom; extern eeprom_config_t g_eeprom;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
void SETTINGS_save_fm(void); void SETTINGS_save_fm(void);
#endif #endif
void SETTINGS_save_vfo_indices(void); void SETTINGS_save_vfo_indices(void);

View File

@ -17,7 +17,7 @@
#ifndef UI_FM_H #ifndef UI_FM_H
#define UI_FM_H #define UI_FM_H
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
void UI_DisplayFM(void); void UI_DisplayFM(void);
#endif #endif

View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "app/search.h" #include "app/search.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "bitmaps.h" #include "bitmaps.h"
@ -89,7 +89,7 @@ void UI_DisplayStatus(const bool test_display)
else else
#endif #endif
{ {
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
// FM indicator // FM indicator
if (g_fm_radio_mode || test_display) if (g_fm_radio_mode || test_display)
{ {

View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
#include "app/dtmf.h" #include "app/dtmf.h"
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#include "app/search.h" #include "app/search.h"
@ -26,7 +26,7 @@
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
#include "ui/aircopy.h" #include "ui/aircopy.h"
#endif #endif
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
#include "ui/fmradio.h" #include "ui/fmradio.h"
#endif #endif
#include "ui/inputbox.h" #include "ui/inputbox.h"
@ -51,7 +51,7 @@ void GUI_DisplayScreen(void)
UI_DisplayMain(); UI_DisplayMain();
break; break;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
case DISPLAY_FM: case DISPLAY_FM:
UI_DisplayFM(); UI_DisplayFM();
break; break;
@ -89,7 +89,7 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
g_in_sub_menu = false; g_in_sub_menu = false;
g_css_scan_mode = CSS_SCAN_MODE_OFF; g_css_scan_mode = CSS_SCAN_MODE_OFF;
g_scan_state_dir = SCAN_STATE_DIR_OFF; g_scan_state_dir = SCAN_STATE_DIR_OFF;
#if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) #ifdef ENABLE_FMRADIO
g_fm_scan_state = FM_SCAN_OFF; g_fm_scan_state = FM_SCAN_OFF;
#endif #endif
g_ask_for_confirmation = 0; g_ask_for_confirmation = 0;