mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-21 17:57:59 +00:00
fix #81 fm radio 10s scan timeout, eeprom frequency validation
This commit is contained in:
parent
ef98c1e9f8
commit
9159fea8c6
5
app/fm.c
5
app/fm.c
@ -30,6 +30,9 @@
|
||||
#include "settings.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
const uint16_t FM_RADIO_MAX_FREQ = 1080; // 108 Mhz
|
||||
const uint16_t FM_RADIO_MIN_FREQ = 875; // 87.5 Mhz
|
||||
|
||||
bool gFmRadioMode;
|
||||
uint8_t gFmRadioCountdown_500ms;
|
||||
volatile uint16_t gFmPlayCountdown_10ms;
|
||||
@ -59,7 +62,7 @@ static void Key_EXIT()
|
||||
|
||||
static void Key_UP_DOWN(bool direction)
|
||||
{
|
||||
BK1080_TuneNext(direction);
|
||||
BK1080_TuneNext(direction);
|
||||
gEeprom.FM_FrequencyPlaying = BK1080_GetFrequency();
|
||||
// save
|
||||
gRequestSaveSettings = true;
|
||||
|
3
app/fm.h
3
app/fm.h
@ -22,6 +22,9 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
extern const uint16_t FM_RADIO_MAX_FREQ;
|
||||
extern const uint16_t FM_RADIO_MIN_FREQ;
|
||||
|
||||
enum {
|
||||
FM_SCAN_OFF = 0U,
|
||||
};
|
||||
|
4
board.c
4
board.c
@ -564,6 +564,10 @@ void BOARD_EEPROM_Init(void)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
EEPROM_ReadBuffer(0x0E88, Data, 8);
|
||||
memmove(&gEeprom.FM_FrequencyPlaying, Data, 2);
|
||||
// validate that its within the supported range
|
||||
if(gEeprom.FM_FrequencyPlaying < FM_RADIO_MIN_FREQ || gEeprom.FM_FrequencyPlaying > FM_RADIO_MAX_FREQ)
|
||||
gEeprom.FM_FrequencyPlaying = FM_RADIO_MIN_FREQ;
|
||||
|
||||
#endif
|
||||
|
||||
// 0E90..0E97
|
||||
|
@ -114,6 +114,7 @@ void BK1080_TuneNext(bool direction)
|
||||
{
|
||||
uint16_t reg_11;
|
||||
uint16_t reg_02;
|
||||
uint8_t scanCounter_100ms = 100; // timeouts after 10s
|
||||
|
||||
reg_02 = BK1080_ReadRegister(BK1080_REG_02_POWER_CONFIGURATION);
|
||||
reg_11 = BK1080_ReadRegister(BK1080_REG_11);
|
||||
@ -128,7 +129,10 @@ void BK1080_TuneNext(bool direction)
|
||||
|
||||
// wait until we find the channel
|
||||
while((BK1080_ReadRegister(BK1080_REG_10) >> 14) == 0){
|
||||
SYSTEM_DelayMs(5);
|
||||
if(scanCounter_100ms-- == 0)
|
||||
break;
|
||||
|
||||
SYSTEM_DelayMs(100);
|
||||
}
|
||||
|
||||
//read found freq
|
||||
|
Loading…
Reference in New Issue
Block a user