mirror of
https://github.com/egzumer/uv-k5-firmware-custom
synced 2024-11-21 17:19:57 +00:00
FM radio band selection #230
This commit is contained in:
parent
adbc466c49
commit
46e2d1a0fd
@ -368,7 +368,7 @@ static void ACTION_Scan_FM(bool bRestart)
|
|||||||
gFM_AutoScan = true;
|
gFM_AutoScan = true;
|
||||||
gFM_ChannelPosition = 0;
|
gFM_ChannelPosition = 0;
|
||||||
FM_EraseChannels();
|
FM_EraseChannels();
|
||||||
freq = gEeprom.FM_LowerLimit;
|
freq = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
} else {
|
} else {
|
||||||
gFM_AutoScan = false;
|
gFM_AutoScan = false;
|
||||||
gFM_ChannelPosition = 0;
|
gFM_ChannelPosition = 0;
|
||||||
|
@ -447,7 +447,7 @@ void APP_StartListening(FUNCTION_Type_t function)
|
|||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clear the other vfo's rssi level (to hide the antenna symbol)
|
// clear the other vfo's rssi level (to hide the antenna symbol)
|
||||||
|
54
app/fm.c
54
app/fm.c
@ -62,7 +62,9 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state);
|
|||||||
|
|
||||||
bool FM_CheckValidChannel(uint8_t Channel)
|
bool FM_CheckValidChannel(uint8_t Channel)
|
||||||
{
|
{
|
||||||
return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080));
|
return Channel < ARRAY_SIZE(gFM_Channels) &&
|
||||||
|
gFM_Channels[Channel] >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) &&
|
||||||
|
gFM_Channels[Channel] < BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
|
||||||
@ -106,7 +108,7 @@ void FM_TurnOff(void)
|
|||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
gEnableSpeaker = false;
|
gEnableSpeaker = false;
|
||||||
|
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
|
|
||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
}
|
}
|
||||||
@ -138,17 +140,17 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
|
|||||||
|
|
||||||
if (!bFlag) {
|
if (!bFlag) {
|
||||||
Frequency += Step;
|
Frequency += Step;
|
||||||
if (Frequency < gEeprom.FM_LowerLimit)
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_UpperLimit;
|
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
else if (Frequency > gEeprom.FM_UpperLimit)
|
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_LowerLimit;
|
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
|
|
||||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
gFM_ScanState = Step;
|
gFM_ScanState = Step;
|
||||||
|
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FM_PlayAndUpdate(void)
|
void FM_PlayAndUpdate(void)
|
||||||
@ -161,7 +163,7 @@ void FM_PlayAndUpdate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FM_ConfigureChannelState();
|
FM_ConfigureChannelState();
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
SETTINGS_SaveFM();
|
SETTINGS_SaveFM();
|
||||||
|
|
||||||
gFmPlayCountdown_10ms = 0;
|
gFmPlayCountdown_10ms = 0;
|
||||||
@ -261,7 +263,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii());
|
Frequency = StrToUL(INPUTBOX_GetAscii());
|
||||||
|
|
||||||
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) {
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band) || BK1080_GetFreqHiLimit(gEeprom.FM_Band) < Frequency) {
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
return;
|
return;
|
||||||
@ -272,7 +274,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -290,7 +292,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
|||||||
#endif
|
#endif
|
||||||
gEeprom.FM_SelectedChannel = Channel;
|
gEeprom.FM_SelectedChannel = Channel;
|
||||||
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -332,11 +334,21 @@ static void Key_FUNC(KEY_Code_t Key, uint8_t state)
|
|||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KEY_1:
|
||||||
|
gEeprom.FM_Band++;
|
||||||
|
gRequestSaveFM = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// case KEY_2:
|
||||||
|
// gEeprom.FM_Space = (gEeprom.FM_Space + 1) % 3;
|
||||||
|
// gRequestSaveFM = true;
|
||||||
|
// break;
|
||||||
|
|
||||||
case KEY_3:
|
case KEY_3:
|
||||||
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
|
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode;
|
||||||
|
|
||||||
if (!FM_ConfigureChannelState()) {
|
if (!FM_ConfigureChannelState()) {
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -424,7 +436,7 @@ static void Key_MENU(uint8_t state)
|
|||||||
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
|
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
|
||||||
|
|
||||||
FM_ConfigureChannelState();
|
FM_ConfigureChannelState();
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
}
|
}
|
||||||
@ -487,10 +499,10 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
|||||||
else {
|
else {
|
||||||
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
|
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
|
||||||
|
|
||||||
if (Frequency < gEeprom.FM_LowerLimit)
|
if (Frequency < BK1080_GetFreqLoLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_UpperLimit;
|
Frequency = BK1080_GetFreqHiLimit(gEeprom.FM_Band);
|
||||||
else if (Frequency > gEeprom.FM_UpperLimit)
|
else if (Frequency > BK1080_GetFreqHiLimit(gEeprom.FM_Band))
|
||||||
Frequency = gEeprom.FM_LowerLimit;
|
Frequency = BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
|
|
||||||
gEeprom.FM_FrequencyPlaying = Frequency;
|
gEeprom.FM_FrequencyPlaying = Frequency;
|
||||||
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
|
||||||
@ -499,7 +511,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
|||||||
gRequestSaveFM = true;
|
gRequestSaveFM = true;
|
||||||
|
|
||||||
Bail:
|
Bail:
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
}
|
}
|
||||||
@ -542,7 +554,7 @@ void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
void FM_Play(void)
|
void FM_Play(void)
|
||||||
{
|
{
|
||||||
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit)) {
|
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, BK1080_GetFreqLoLimit(gEeprom.FM_Band))) {
|
||||||
if (!gFM_AutoScan) {
|
if (!gFM_AutoScan) {
|
||||||
gFmPlayCountdown_10ms = 0;
|
gFmPlayCountdown_10ms = 0;
|
||||||
gFM_FoundFrequency = true;
|
gFM_FoundFrequency = true;
|
||||||
@ -567,7 +579,7 @@ void FM_Play(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit)
|
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= BK1080_GetFreqHiLimit(1))
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
else
|
else
|
||||||
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
|
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
|
||||||
@ -582,7 +594,7 @@ void FM_Start(void)
|
|||||||
gFM_ScanState = FM_SCAN_OFF;
|
gFM_ScanState = FM_SCAN_OFF;
|
||||||
gFM_RestoreCountdown_10ms = 0;
|
gFM_RestoreCountdown_10ms = 0;
|
||||||
|
|
||||||
BK1080_Init(gEeprom.FM_FrequencyPlaying, true);
|
BK1080_Init(gEeprom.FM_FrequencyPlaying, gEeprom.FM_Band/*, gEeprom.FM_Space*/);
|
||||||
|
|
||||||
AUDIO_AudioPathOn();
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
|
2
board.c
2
board.c
@ -495,7 +495,7 @@ void BOARD_Init(void)
|
|||||||
BOARD_ADC_Init();
|
BOARD_ADC_Init();
|
||||||
ST7565_Init();
|
ST7565_Init();
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
|
#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY)
|
||||||
|
@ -39,11 +39,16 @@ static bool gIsInitBK1080;
|
|||||||
uint16_t BK1080_BaseFrequency;
|
uint16_t BK1080_BaseFrequency;
|
||||||
uint16_t BK1080_FrequencyDeviation;
|
uint16_t BK1080_FrequencyDeviation;
|
||||||
|
|
||||||
void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
void BK1080_Init0(void)
|
||||||
|
{
|
||||||
|
BK1080_Init(0,0/*,0*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BK1080_Init(uint16_t freq, uint8_t band/*, uint8_t space*/)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (bDoScan) {
|
if (freq) {
|
||||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
|
||||||
|
|
||||||
if (!gIsInitBK1080) {
|
if (!gIsInitBK1080) {
|
||||||
@ -63,8 +68,8 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
|
|||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
|
||||||
}
|
}
|
||||||
|
|
||||||
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
|
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A1F);
|
||||||
BK1080_SetFrequency(Frequency);
|
BK1080_SetFrequency(freq, band/*, space*/);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
|
||||||
@ -100,9 +105,19 @@ void BK1080_Mute(bool Mute)
|
|||||||
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
|
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK1080_SetFrequency(uint16_t frequency)
|
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/)
|
||||||
{
|
{
|
||||||
uint16_t channel = frequency - 760;
|
//uint8_t spacings[] = {20,10,5};
|
||||||
|
//space %= 3;
|
||||||
|
|
||||||
|
uint16_t channel = (frequency - BK1080_GetFreqLoLimit(band))/* * 10 / spacings[space]*/;
|
||||||
|
|
||||||
|
uint16_t regval = BK1080_ReadRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2);
|
||||||
|
regval = (regval & ~(0b11 << 6)) | ((band & 0b11) << 6);
|
||||||
|
//regval = (regval & ~(0b11 << 4)) | ((space & 0b11) << 4);
|
||||||
|
|
||||||
|
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, regval);
|
||||||
|
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
|
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
|
||||||
SYSTEM_DelayMs(10);
|
SYSTEM_DelayMs(10);
|
||||||
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | 0x8000);
|
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | 0x8000);
|
||||||
@ -113,3 +128,17 @@ void BK1080_GetFrequencyDeviation(uint16_t Frequency)
|
|||||||
BK1080_BaseFrequency = Frequency;
|
BK1080_BaseFrequency = Frequency;
|
||||||
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
|
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t BK1080_GetFreqLoLimit(uint8_t band)
|
||||||
|
{
|
||||||
|
uint16_t lim[] = {875, 760, 760, 640};
|
||||||
|
return lim[band % 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t BK1080_GetFreqHiLimit(uint8_t band)
|
||||||
|
{
|
||||||
|
band %= 4;
|
||||||
|
uint16_t lim[] = {1080, 1080, 900, 760};
|
||||||
|
return lim[band % 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,14 @@
|
|||||||
extern uint16_t BK1080_BaseFrequency;
|
extern uint16_t BK1080_BaseFrequency;
|
||||||
extern uint16_t BK1080_FrequencyDeviation;
|
extern uint16_t BK1080_FrequencyDeviation;
|
||||||
|
|
||||||
void BK1080_Init(uint16_t Frequency, bool bDoScan);
|
void BK1080_Init0(void);
|
||||||
|
void BK1080_Init(uint16_t Frequency, uint8_t band/*, uint8_t space*/);
|
||||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
||||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
||||||
void BK1080_Mute(bool Mute);
|
void BK1080_Mute(bool Mute);
|
||||||
void BK1080_SetFrequency(uint16_t frequency);
|
uint16_t BK1080_GetFreqLoLimit(uint8_t band);
|
||||||
|
uint16_t BK1080_GetFreqHiLimit(uint8_t band);
|
||||||
|
void BK1080_SetFrequency(uint16_t frequency, uint8_t band/*, uint8_t space*/);
|
||||||
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
|
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -152,7 +152,7 @@ void FUNCTION_Transmit()
|
|||||||
|
|
||||||
#if defined(ENABLE_FMRADIO)
|
#if defined(ENABLE_FMRADIO)
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
BK1080_Init(0, false);
|
BK1080_Init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_ALARM
|
#ifdef ENABLE_ALARM
|
||||||
|
49
settings.c
49
settings.c
@ -20,6 +20,7 @@
|
|||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "driver/bk1080.h"
|
||||||
#include "driver/bk4819.h"
|
#include "driver/bk4819.h"
|
||||||
#include "driver/eeprom.h"
|
#include "driver/eeprom.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@ -89,17 +90,20 @@ void SETTINGS_InitEEPROM(void)
|
|||||||
{
|
{
|
||||||
uint16_t selFreq;
|
uint16_t selFreq;
|
||||||
uint8_t selChn;
|
uint8_t selChn;
|
||||||
uint8_t isMrMode;
|
uint8_t isMrMode:1;
|
||||||
|
uint8_t band:2;
|
||||||
|
//uint8_t space:2;
|
||||||
} __attribute__((packed)) fmCfg;
|
} __attribute__((packed)) fmCfg;
|
||||||
EEPROM_ReadBuffer(0x0E88, &fmCfg, 4);
|
EEPROM_ReadBuffer(0x0E88, &fmCfg, 4);
|
||||||
|
|
||||||
gEeprom.FM_LowerLimit = 760;
|
gEeprom.FM_Band = fmCfg.band;
|
||||||
gEeprom.FM_UpperLimit = 1080;
|
//gEeprom.FM_Space = fmCfg.space;
|
||||||
gEeprom.FM_SelectedFrequency =
|
gEeprom.FM_SelectedFrequency =
|
||||||
(fmCfg.selFreq >= gEeprom.FM_LowerLimit && fmCfg.selFreq <= gEeprom.FM_UpperLimit) ? fmCfg.selFreq : 960;
|
(fmCfg.selFreq >= BK1080_GetFreqLoLimit(gEeprom.FM_Band) && fmCfg.selFreq <= BK1080_GetFreqHiLimit(gEeprom.FM_Band)) ?
|
||||||
|
fmCfg.selFreq : BK1080_GetFreqLoLimit(gEeprom.FM_Band);
|
||||||
|
|
||||||
gEeprom.FM_SelectedChannel = fmCfg.selChn;
|
gEeprom.FM_SelectedChannel = fmCfg.selChn;
|
||||||
gEeprom.FM_IsMrMode = (fmCfg.isMrMode < 2) ? fmCfg.isMrMode : false;
|
gEeprom.FM_IsMrMode = fmCfg.isMrMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0E40..0E67
|
// 0E40..0E67
|
||||||
@ -415,25 +419,28 @@ void SETTINGS_FactoryReset(bool bIsAll)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
void SETTINGS_SaveFM(void)
|
void SETTINGS_SaveFM(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t selFreq;
|
||||||
|
uint8_t selChn;
|
||||||
|
uint8_t isMrMode:1;
|
||||||
|
uint8_t band:2;
|
||||||
|
//uint8_t space:2;
|
||||||
|
};
|
||||||
|
uint8_t __raw[8];
|
||||||
|
} __attribute__((packed)) fmCfg;
|
||||||
|
|
||||||
struct
|
memset(fmCfg.__raw, 0xFF, sizeof(fmCfg.__raw));
|
||||||
{
|
fmCfg.selChn = gEeprom.FM_SelectedChannel;
|
||||||
uint16_t Frequency;
|
fmCfg.selFreq = gEeprom.FM_SelectedFrequency;
|
||||||
uint8_t Channel;
|
fmCfg.isMrMode = gEeprom.FM_IsMrMode;
|
||||||
bool IsChannelSelected;
|
fmCfg.band = gEeprom.FM_Band;
|
||||||
uint8_t Padding[4];
|
//fmCfg.space = gEeprom.FM_Space;
|
||||||
} State;
|
EEPROM_WriteBuffer(0x0E88, fmCfg.__raw);
|
||||||
|
|
||||||
memset(&State, 0xFF, sizeof(State));
|
for (unsigned i = 0; i < 5; i++)
|
||||||
State.Channel = gEeprom.FM_SelectedChannel;
|
|
||||||
State.Frequency = gEeprom.FM_SelectedFrequency;
|
|
||||||
State.IsChannelSelected = gEeprom.FM_IsMrMode;
|
|
||||||
|
|
||||||
EEPROM_WriteBuffer(0x0E88, &State);
|
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
|
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,8 +148,8 @@ typedef struct {
|
|||||||
uint8_t FM_SelectedChannel;
|
uint8_t FM_SelectedChannel;
|
||||||
bool FM_IsMrMode;
|
bool FM_IsMrMode;
|
||||||
uint16_t FM_FrequencyPlaying;
|
uint16_t FM_FrequencyPlaying;
|
||||||
uint16_t FM_LowerLimit;
|
uint8_t FM_Band : 2;
|
||||||
uint16_t FM_UpperLimit;
|
//uint8_t FM_Space : 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t SQUELCH_LEVEL;
|
uint8_t SQUELCH_LEVEL;
|
||||||
|
21
ui/fmradio.c
21
ui/fmradio.c
@ -19,6 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/fm.h"
|
#include "app/fm.h"
|
||||||
|
#include "driver/bk1080.h"
|
||||||
#include "driver/st7565.h"
|
#include "driver/st7565.h"
|
||||||
#include "external/printf/printf.h"
|
#include "external/printf/printf.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@ -34,7 +35,19 @@ void UI_DisplayFM(void)
|
|||||||
char *pPrintStr = String;
|
char *pPrintStr = String;
|
||||||
UI_DisplayClear();
|
UI_DisplayClear();
|
||||||
|
|
||||||
UI_PrintString("FM", 0, 127, 0, 12);
|
UI_PrintString("FM", 2, 0, 0, 8);
|
||||||
|
|
||||||
|
sprintf(String, "%d%s-%dM",
|
||||||
|
BK1080_GetFreqLoLimit(gEeprom.FM_Band)/10,
|
||||||
|
gEeprom.FM_Band == 0 ? ".5" : "",
|
||||||
|
BK1080_GetFreqHiLimit(gEeprom.FM_Band)/10
|
||||||
|
);
|
||||||
|
|
||||||
|
UI_PrintStringSmallNormal(String, 1, 0, 6);
|
||||||
|
|
||||||
|
//uint8_t spacings[] = {20,10,5};
|
||||||
|
//sprintf(String, "%d0k", spacings[gEeprom.FM_Space % 3]);
|
||||||
|
//UI_PrintStringSmallNormal(String, 127 - 4*7, 0, 6);
|
||||||
|
|
||||||
if (gAskToSave) {
|
if (gAskToSave) {
|
||||||
pPrintStr = "SAVE?";
|
pPrintStr = "SAVE?";
|
||||||
@ -61,7 +74,7 @@ void UI_DisplayFM(void)
|
|||||||
pPrintStr = "M-SCAN";
|
pPrintStr = "M-SCAN";
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintString(pPrintStr, 0, 127, 2, 10);
|
UI_PrintString(pPrintStr, 0, 127, 3, 10); // memory, vfo, scan
|
||||||
|
|
||||||
memset(String, 0, sizeof(String));
|
memset(String, 0, sizeof(String));
|
||||||
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) {
|
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) {
|
||||||
@ -76,12 +89,12 @@ void UI_DisplayFM(void)
|
|||||||
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
sprintf(String, "%.3s.%.1s",ascii, ascii + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_DisplayFrequency(String, 32, 4, gInputBoxIndex == 0);
|
UI_DisplayFrequency(String, 36, 1, gInputBoxIndex == 0); // frequency
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintString(String, 0, 127, 4, 10);
|
UI_PrintString(String, 0, 127, 1, 10);
|
||||||
|
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user