diff --git a/am_fix.c b/am_fix.c index 7c314d2..706ecb7 100644 --- a/am_fix.c +++ b/am_fix.c @@ -19,8 +19,6 @@ // // that is until someone works out how to properly configure the BK chip ! -#include - #include "am_fix.h" #include "app/main.h" #include "board.h" diff --git a/app/action.c b/app/action.c index 4cf5968..0799d57 100644 --- a/app/action.c +++ b/app/action.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/action.h" #include "app/app.h" #include "app/dtmf.h" @@ -183,7 +181,7 @@ void ACTION_Scan(bool bRestart) } g_fm_channel_position = 0; - BK1080_GetFrequencyDeviation(Frequency); + BK1080_get_freq_offset(Frequency); FM_tune(Frequency, FM_SCAN_STATE_DIR_UP, bRestart); diff --git a/app/aircopy.c b/app/aircopy.c index bafe175..2be708d 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #ifndef ENABLE_OVERLAY #include "ARMCM0.h" #endif diff --git a/app/app.c b/app/app.c index a99415a..c760afa 100644 --- a/app/app.c +++ b/app/app.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include // abs() - #ifdef ENABLE_AM_FIX #include "am_fix.h" #endif @@ -1911,8 +1908,8 @@ void APP_time_slice_500ms(void) if (g_fm_radio_tick_500ms > 0) g_fm_radio_tick_500ms--; - if (g_fm_radio_mode && g_current_display_screen == DISPLAY_FM && g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF) - g_update_display = true; // can't do this if not FM scanning, it causes audio clicks +// if (g_fm_radio_mode && g_current_display_screen == DISPLAY_FM && g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF) +// g_update_display = true; // can't do this if not FM scanning, it causes audio clicks #endif if (g_backlight_count_down > 0 && @@ -2116,18 +2113,23 @@ void APP_time_slice_500ms(void) { if (g_fm_resume_tick_500ms > 0) { - if (--g_fm_resume_tick_500ms == 0) + if (g_fm_radio_mode) { - RADIO_set_vfo_state(VFO_STATE_NORMAL); - - if (g_current_function != FUNCTION_RECEIVE && - !g_monitor_enabled && - g_fm_radio_mode) - { // switch back to FM radio mode - FM_turn_on(); - GUI_SelectNextDisplay(DISPLAY_FM); + if (--g_fm_resume_tick_500ms == 0) + { + RADIO_set_vfo_state(VFO_STATE_NORMAL); + + if (g_current_function != FUNCTION_RECEIVE && g_fm_radio_mode) + { // switch back to FM radio mode + if (g_current_display_screen != DISPLAY_FM) + FM_turn_on(); + //GUI_SelectNextDisplay(DISPLAY_FM); + } } + GUI_SelectNextDisplay(DISPLAY_FM); } + else + FM_turn_off(); } } diff --git a/app/dtmf.c b/app/dtmf.c index 40ae15a..eec0bec 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include // NULL - #ifdef ENABLE_FMRADIO #include "app/fm.h" #endif diff --git a/app/fm.c b/app/fm.c index 198b2c0..cbce0be 100644 --- a/app/fm.c +++ b/app/fm.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/action.h" #include "app/fm.h" #include "app/generic.h" @@ -45,7 +43,6 @@ fm_scan_state_dir_t g_fm_scan_state_dir; bool g_fm_auto_scan; uint8_t g_fm_channel_position; bool g_fm_found_frequency; -bool g_fm_auto_scan; uint8_t g_fm_resume_tick_500ms; uint16_t g_fm_restore_tick_10ms; uint8_t g_fm_radio_tick_500ms; @@ -138,20 +135,28 @@ void FM_tune(uint16_t frequency, const fm_scan_state_dir_t scan_state_dir, const g_fm_scan_state_dir = scan_state_dir; BK1080_SetFrequency(g_eeprom.fm_frequency_playing); + + if (g_fm_resume_tick_500ms < 10) + g_fm_resume_tick_500ms = 10; // update display for next 5 seconds } void FM_stop_scan(void) { - // stop scanning + if (g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF) + return; + g_fm_scan_state_dir = FM_SCAN_STATE_DIR_OFF; - if (g_fm_auto_scan) + if (g_fm_auto_scan || g_eeprom.fm_channel_mode) { // switch to channel mode g_eeprom.fm_channel_mode = true; g_eeprom.fm_selected_channel = 0; + FM_configure_channel_state(); + } + else + { + g_eeprom.fm_channel_mode = false; } - - FM_configure_channel_state(); BK1080_SetFrequency(g_eeprom.fm_frequency_playing); @@ -163,55 +168,41 @@ void FM_stop_scan(void) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); + if (g_fm_resume_tick_500ms < 10) + g_fm_resume_tick_500ms = 10; // update display for next 5 seconds + g_update_display = true; } -int FM_check_frequency_lock(uint16_t Frequency, uint16_t LowerLimit) +int FM_check_frequency_lock(const uint16_t frequency, const uint16_t lower_limit) { int ret = -1; - const uint16_t Test2 = BK1080_ReadRegister(BK1080_REG_07); + const uint16_t rssi_status = BK1080_ReadRegister(BK1080_REG_10); + const uint16_t dev_snr = BK1080_ReadRegister(BK1080_REG_07); - // This is supposed to be a signed value, but above function is unsigned - const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2); + const int16_t freq_offset = (int16_t)dev_snr / 16; + const uint8_t snr = dev_snr & 0x000f; - if (BK1080_REG_07_GET_SNR(Test2) >= 2) - { - const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10); +// const uint8_t stc = (rssi_status >> 14) & 1u; +// const uint8_t sf_bl = (rssi_status >> 13) & 1u; + const uint8_t afc_railed = (rssi_status >> 12) & 1u; +// const uint8_t ste = (rssi_status >> 9) & 1u; +// const uint8_t st = (rssi_status >> 8) & 1u; + const uint8_t rssi = rssi_status & 0x00ff; - 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) - { - if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) - { - if (BK1080_FrequencyDeviation & 0x800) - goto Bail; + if (afc_railed || snr < 2 || rssi < 10 || abs(freq_offset) > 250) + goto Bail; - if (BK1080_FrequencyDeviation < 20) - goto Bail; - } + if (frequency >= lower_limit && abs(((int)BK1080_freq_base - frequency)) == 1) + if (abs(BK1080_freq_offset) < 20) + goto Bail; - if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) - { - if ((BK1080_FrequencyDeviation & 0x800) == 0) - goto Bail; - - // if (BK1080_FrequencyDeviation > -21) - if (BK1080_FrequencyDeviation > 4075) - goto Bail; - } - - ret = 0; - } - } - } + ret = 0; Bail: - BK1080_FrequencyDeviation = Deviation; - BK1080_BaseFrequency = Frequency; + BK1080_freq_offset = freq_offset; + BK1080_freq_base = frequency; return ret; } @@ -255,13 +246,15 @@ void FM_scan(void) void FM_turn_on(void) { + // mute the audio from the other radio chip (the transceiver chip) BK4819_SetAF(BK4819_AF_MUTE); g_fm_radio_mode = true; g_fm_scan_state_dir = FM_SCAN_STATE_DIR_OFF; g_fm_restore_tick_10ms = 0; + g_fm_resume_tick_500ms = fm_resume_500ms; // update display again in 'n' seconds - // enable the FM radio chip + // enable the FM radio chip/audio BK1080_Init(g_eeprom.fm_frequency_playing, true); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); @@ -272,18 +265,35 @@ void FM_turn_on(void) void FM_turn_off(void) { + if (g_fm_radio_mode) + { + if (!g_squelch_open && !g_monitor_enabled) + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); + + // disable the FM chip + BK1080_Init(0, false); + + g_update_display = true; + g_update_status = true; + } + g_fm_radio_mode = false; g_fm_scan_state_dir = FM_SCAN_STATE_DIR_OFF; g_fm_restore_tick_10ms = 0; + g_fm_resume_tick_500ms = 0; +} - if (!g_squelch_open && !g_monitor_enabled) - GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); +void FM_toggle_chan_freq_mode(void) +{ + g_eeprom.fm_channel_mode = !g_eeprom.fm_channel_mode; - // disable the FM chip - BK1080_Init(0, false); + FM_stop_scan(); - g_update_display = true; - g_update_status = true; + if (!FM_configure_channel_state()) + { + BK1080_SetFrequency(g_eeprom.fm_frequency_playing); + g_request_save_fm = true; + } } // *************************************** @@ -306,6 +316,18 @@ static void FM_Key_DIGITS(const key_code_t Key, const bool key_pressed, const bo // long press key or short key release + if (g_input_box_index == 0) + { + if (Key == KEY_0 || (Key >= KEY_2 && Key <= KEY_5)) + { // can't start a frequency with those keys + if (Key == KEY_3) + { // can't start a frequency with a '3', so just go straight to the function + FM_toggle_chan_freq_mode(); + } + return; + } + } + if (!g_fkey_pressed && !key_held) { // short key release uint8_t State; @@ -432,13 +454,7 @@ static void FM_Key_DIGITS(const key_code_t Key, const bool key_pressed, const bo break; case KEY_3: - g_eeprom.fm_channel_mode = !g_eeprom.fm_channel_mode; - - if (!FM_configure_channel_state()) - { - BK1080_SetFrequency(g_eeprom.fm_frequency_playing); - g_request_save_fm = true; - } + FM_toggle_chan_freq_mode(); break; default: @@ -676,6 +692,15 @@ static void FM_Key_UP_DOWN(const bool key_pressed, const bool key_held, const fm g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; } + if (g_current_display_screen == DISPLAY_FM && g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF) + { +// if (g_fm_resume_tick_500ms < fm_resume_500ms) +// g_fm_resume_tick_500ms = fm_resume_500ms; // update display for next 'n' seconds + if (g_fm_resume_tick_500ms < 10) + g_fm_resume_tick_500ms = 10; // update display for next 5 seconds + g_update_display = true; + } + g_request_save_fm = true; Bail: diff --git a/app/fm.h b/app/fm.h index bb2e533..9d3f922 100644 --- a/app/fm.h +++ b/app/fm.h @@ -37,7 +37,6 @@ extern uint8_t g_fm_channel_position; // Doubts about whether this should be signed or not extern uint16_t g_fm_frequency_deviation; extern bool g_fm_found_frequency; -extern bool g_fm_auto_scan; extern uint8_t g_fm_resume_tick_500ms; extern uint16_t g_fm_restore_tick_10ms; extern uint8_t g_fm_radio_tick_500ms; @@ -50,7 +49,7 @@ int FM_configure_channel_state(void); void FM_erase_channels(void); void FM_tune(uint16_t frequency, const fm_scan_state_dir_t scan_state_dir, const bool flag); void FM_stop_scan(void); -int FM_check_frequency_lock(uint16_t Frequency, uint16_t LowerLimit); +int FM_check_frequency_lock(const uint16_t frequency, const uint16_t lower_limit); void FM_scan(void); void FM_turn_on(void); void FM_turn_off(void); diff --git a/app/generic.c b/app/generic.c index 811dfec..aead342 100644 --- a/app/generic.c +++ b/app/generic.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/app.h" #ifdef ENABLE_FMRADIO #include "app/fm.h" diff --git a/app/main.c b/app/main.c index df1db70..b7b05df 100644 --- a/app/main.c +++ b/app/main.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/action.h" #include "app/app.h" #ifdef ENABLE_FMRADIO diff --git a/app/menu.c b/app/menu.c index bef1f3a..bc61da5 100644 --- a/app/menu.c +++ b/app/menu.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #if !defined(ENABLE_OVERLAY) #include "ARMCM0.h" #endif diff --git a/app/uart.c b/app/uart.c index 9147fad..73ec176 100644 --- a/app/uart.c +++ b/app/uart.c @@ -16,8 +16,6 @@ #define INCLUDE_AES -#include - #if !defined(ENABLE_OVERLAY) #include "ARMCM0.h" #endif diff --git a/board.c b/board.c index 7b6efa3..3ac295b 100644 --- a/board.c +++ b/board.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/dtmf.h" #ifdef ENABLE_FMRADIO #include "app/fm.h" diff --git a/driver/bk1080.c b/driver/bk1080.c index 94dd8d8..e9bea4b 100644 --- a/driver/bk1080.c +++ b/driver/bk1080.c @@ -23,8 +23,8 @@ #include "misc.h" //#define CHAN_SPACING 0u // 200kHz - #define CHAN_SPACING 1u // 100kHz -//#define CHAN_SPACING 2u // 50kHz +//#define CHAN_SPACING 1u // 100kHz +#define CHAN_SPACING 2u // 50kHz #define VOLUME 15u @@ -101,8 +101,8 @@ static const uint16_t BK1080_RegisterTable[] = bool is_init; uint16_t BK1080_freq_lower; uint16_t BK1080_freq_upper; -uint16_t BK1080_BaseFrequency; -uint16_t BK1080_FrequencyDeviation; +uint16_t BK1080_freq_base; +int16_t BK1080_freq_offset; void BK1080_Init(const uint16_t frequency, const bool initialise) { @@ -115,6 +115,9 @@ void BK1080_Init(const uint16_t frequency, const bool initialise) if (!is_init) { + BK1080_freq_base = 0; + BK1080_freq_offset = 0; + BK1080_freq_lower = 0xffff; BK1080_freq_upper = 0; @@ -201,14 +204,14 @@ void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value) I2C_Stop(); } -void BK1080_Mute(bool Mute) +void BK1080_Mute(const bool Mute) { BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 0) | (Mute ? 1u << 14 : 0u)); } void BK1080_SetFrequency(uint16_t Frequency) { - uint16_t channel; + int channel; uint16_t band = 0; // #if (ARRAY_SIZE(FM_RADIO_FREQ_BAND_TABLE) > 1) // compiler doesn't like this :( @@ -229,18 +232,20 @@ void BK1080_SetFrequency(uint16_t Frequency) #endif - channel = Frequency - FM_RADIO_FREQ_BAND_TABLE[band].lower; // 100kHz channel spacing +// channel = (int)Frequency - FM_RADIO_FREQ_BAND_TABLE[band].lower; // 100kHz channel spacing + channel = ((int)Frequency - FM_RADIO_FREQ_BAND_TABLE[band].lower) * 2; // 50kHz channel spacing + channel = (channel < 0) ? 0 : (channel > 1023) ? 1023 : channel; BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, (SEEK_THRESHOLD << 8) | (band << 6) | (CHAN_SPACING << 4) | (VOLUME << 0)); - BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel); + BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (uint16_t)channel); SYSTEM_DelayMs(1); - BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | (1u << 15)); + BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (uint16_t)channel | (1u << 15)); } -uint16_t BK1080_GetFrequencyDeviation(uint16_t Frequency) +int16_t BK1080_get_freq_offset(const uint16_t Frequency) { - BK1080_BaseFrequency = Frequency; - BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) >> 4; - return BK1080_FrequencyDeviation; + BK1080_freq_base = Frequency; + BK1080_freq_offset = (int16_t)BK1080_ReadRegister(BK1080_REG_07) / 16; + return BK1080_freq_offset; } diff --git a/driver/bk1080.h b/driver/bk1080.h index 082a220..efc4fb2 100644 --- a/driver/bk1080.h +++ b/driver/bk1080.h @@ -24,15 +24,15 @@ extern uint16_t BK1080_freq_lower; extern uint16_t BK1080_freq_upper; -extern uint16_t BK1080_BaseFrequency; -extern uint16_t BK1080_FrequencyDeviation; +extern uint16_t BK1080_freq_base; +extern int16_t BK1080_freq_offset; void BK1080_Init(const uint16_t frequency, const bool initialise); uint16_t BK1080_ReadRegister(BK1080_Register_t Register); void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value); -void BK1080_Mute(bool Mute); +void BK1080_Mute(const bool Mute); void BK1080_SetFrequency(uint16_t Frequency); -uint16_t BK1080_GetFrequencyDeviation(uint16_t Frequency); +int16_t BK1080_get_freq_offset(const uint16_t Frequency); #endif diff --git a/driver/bk4819.c b/driver/bk4819.c index 554aa4d..5250139 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include // NULL and memset - #include "bk4819.h" #include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/portcon.h" diff --git a/driver/uart.c b/driver/uart.c index 7d5764d..eaca866 100644 --- a/driver/uart.c +++ b/driver/uart.c @@ -14,14 +14,12 @@ * limitations under the License. */ -#include -#include - #include "bsp/dp32g030/dma.h" #include "bsp/dp32g030/syscon.h" #include "bsp/dp32g030/uart.h" #include "driver/uart.h" #include "external/printf/printf.h" +#include "misc.h" static bool UART_IsLogEnabled; uint8_t UART_DMA_Buffer[256]; diff --git a/firmware.bin b/firmware.bin index 2b0b507..65d9e37 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 1c09e04..afb25c2 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 5fb31ae..10e7ffd 100644 --- a/functions.c +++ b/functions.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/dtmf.h" #ifdef ENABLE_FMRADIO #include "app/fm.h" diff --git a/helper/boot.c b/helper/boot.c index ea5d7b1..42696fc 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #ifdef ENABLE_AIRCOPY #include "app/aircopy.h" #endif diff --git a/main.c b/main.c index 31d3afb..8a7e68f 100644 --- a/main.c +++ b/main.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include // NULL - #ifdef ENABLE_AM_FIX #include "am_fix.h" #endif diff --git a/mdc1200.c b/mdc1200.c index fc5a19e..3246ecd 100644 --- a/mdc1200.c +++ b/mdc1200.c @@ -1,6 +1,4 @@ -#include - #include "driver/bk4819.h" #include "driver/crc.h" #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) diff --git a/misc.c b/misc.c index 7b42d24..dd401a2 100644 --- a/misc.c +++ b/misc.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "misc.h" #include "settings.h" diff --git a/misc.h b/misc.h index 416e651..a8e6abf 100644 --- a/misc.h +++ b/misc.h @@ -17,6 +17,8 @@ #ifndef MISC_H #define MISC_H +#include +#include // abs() #include #include diff --git a/radio.c b/radio.c index 96e2b6e..0538160 100644 --- a/radio.c +++ b/radio.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/app.h" #include "app/dtmf.h" #ifdef ENABLE_FMRADIO @@ -965,10 +963,6 @@ void RADIO_set_vfo_state(vfo_state_t State) { g_vfo_state[0] = VFO_STATE_NORMAL; g_vfo_state[1] = VFO_STATE_NORMAL; - - #ifdef ENABLE_FMRADIO - g_fm_resume_tick_500ms = 0; - #endif } else { @@ -984,7 +978,8 @@ void RADIO_set_vfo_state(vfo_state_t State) } #ifdef ENABLE_FMRADIO - g_fm_resume_tick_500ms = fm_resume_500ms; + if (g_fm_radio_mode && g_fm_resume_tick_500ms < fm_resume_500ms) + g_fm_resume_tick_500ms = fm_resume_500ms; #endif } diff --git a/settings.c b/settings.c index 72d39c4..56f6723 100644 --- a/settings.c +++ b/settings.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #ifdef ENABLE_FMRADIO #include "app/fm.h" #endif diff --git a/ui/aircopy.c b/ui/aircopy.c index d3a662a..3efdd8e 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/aircopy.h" #include "driver/st7565.h" #include "external/printf/printf.h" diff --git a/ui/fmradio.c b/ui/fmradio.c index 3158b16..2a5637d 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/fm.h" #include "driver/backlight.h" #include "driver/bk1080.h" @@ -144,16 +142,31 @@ void UI_DisplayFM(void) // ************************************* // can't do this during FM radio - audio clicks else - if (g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF) + if (g_fm_scan_state_dir != FM_SCAN_STATE_DIR_OFF || g_fm_resume_tick_500ms > 0) { - const uint16_t val_07 = BK1080_ReadRegister(0x07); - const uint16_t val_0A = BK1080_ReadRegister(0x0A); - sprintf(str, "%s %s %2udBuV %2u", - ((val_0A >> 9) & 1u) ? "STE" : "ste", - ((val_0A >> 8) & 1u) ? "ST" : "st", - (val_0A >> 0) & 0x00ff, - (val_07 >> 0) & 0x000f); - UI_PrintStringSmall(str, 0, LCD_WIDTH, 6); + const uint16_t rssi_status = BK1080_ReadRegister(BK1080_REG_10); + const uint16_t dev_snr = BK1080_ReadRegister(BK1080_REG_07); + + const int16_t freq_offset = (int16_t)dev_snr / 16; + const uint8_t snr = dev_snr & 0x000f; + +// const uint8_t stc = (rssi_status >> 14) & 1u; +// const uint8_t sf_bl = (rssi_status >> 13) & 1u; + const uint8_t afc_railed = (rssi_status >> 12) & 1u; + const uint8_t ste = (rssi_status >> 9) & 1u; + const uint8_t st = (rssi_status >> 8) & 1u; + const uint8_t rssi = rssi_status & 0x00ff; + + sprintf(str, "%s %s %c %2udBuV %2u", + ste ? "STE" : "ste", + st ? "ST" : "st", + afc_railed ? 'R' : 'r', + rssi, + snr); + UI_PrintStringSmall(str, 0, 0, 6); + + sprintf(str, "%c%d", (freq_offset > 0) ? '+' : (freq_offset < 0) ? '-' : ' ', abs(freq_offset)); + UI_PrintStringSmall(str, 0, 0, 5); } // ************************************* diff --git a/ui/helper.c b/ui/helper.c index 2877b49..3f63689 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -14,11 +14,10 @@ * limitations under the License. */ -#include - #include "driver/st7565.h" #include "external/printf/printf.h" #include "font.h" +#include "misc.h" #include "ui/helper.h" #include "ui/inputbox.h" diff --git a/ui/inputbox.c b/ui/inputbox.c index 52dde33..1429640 100644 --- a/ui/inputbox.c +++ b/ui/inputbox.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "misc.h" #include "ui/inputbox.h" diff --git a/ui/lock.c b/ui/lock.c index dc7ea6a..7bcb651 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -16,8 +16,6 @@ #ifdef ENABLE_PWRON_PASSWORD -#include - #include "ARMCM0.h" #include "app/uart.h" #include "audio.h" diff --git a/ui/main.c b/ui/main.c index 5e3617c..9d914c9 100644 --- a/ui/main.c +++ b/ui/main.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include // abs() - #include "app/dtmf.h" #ifdef ENABLE_AM_FIX_SHOW_DATA #include "am_fix.h" diff --git a/ui/menu.c b/ui/menu.c index cddd3f4..1db295c 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include // abs() - #include "app/dtmf.h" #include "app/menu.h" #include "bitmaps.h" diff --git a/ui/search.c b/ui/search.c index ad23751..00e015a 100644 --- a/ui/search.c +++ b/ui/search.c @@ -14,9 +14,6 @@ * limitations under the License. */ -#include -#include - #include "app/search.h" #include "board.h" #include "dcs.h" diff --git a/ui/status.c b/ui/status.c index 48ba06a..c498f35 100644 --- a/ui/status.c +++ b/ui/status.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/search.h" #ifdef ENABLE_FMRADIO #include "app/fm.h" diff --git a/ui/ui.c b/ui/ui.c index 01bfa35..1187f3b 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include "app/dtmf.h" #ifdef ENABLE_FMRADIO #include "app/fm.h"