last frequency stored and loaded in eeprom

This commit is contained in:
Nunu 2024-01-12 16:25:37 +01:00
parent 32ab50b7d1
commit 867709af65
3 changed files with 10 additions and 21 deletions

View File

@ -189,6 +189,7 @@ static void Key_UP_DOWN(uint8_t state, bool direction)
BK1080_TuneNext(direction);
gEeprom.FM_FrequencyPlaying = BK1080_GetFrequency();
// save
gRequestSaveSettings = true;
}
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

23
board.c
View File

@ -562,27 +562,8 @@ void BOARD_EEPROM_Init(void)
#endif
#ifdef ENABLE_FMRADIO
{ // 0E88..0E8F
struct
{
uint16_t SelectedFrequency;
uint8_t SelectedChannel;
uint8_t IsMrMode;
uint8_t Padding[8];
} __attribute__((packed)) FM;
EEPROM_ReadBuffer(0x0E88, &FM, 8);
gEeprom.FM_LowerLimit = 760;
gEeprom.FM_UpperLimit = 1080;
if (FM.SelectedFrequency < gEeprom.FM_LowerLimit || FM.SelectedFrequency > gEeprom.FM_UpperLimit)
gEeprom.FM_SelectedFrequency = 960;
else
gEeprom.FM_SelectedFrequency = FM.SelectedFrequency;
gEeprom.FM_SelectedChannel = FM.SelectedChannel;
gEeprom.FM_IsMrMode = (FM.IsMrMode < 2) ? FM.IsMrMode : false;
}
EEPROM_ReadBuffer(0x0E88, Data, 8);
memmove(&gEeprom.FM_FrequencyPlaying, Data, 2);
#endif
// 0E90..0E97

View File

@ -167,6 +167,13 @@ void SETTINGS_SaveSettings(void)
State[7] = (State[7] & ~(3u << 6)) | ((gSetting_backlight_on_tx_rx & 3u) << 6);
EEPROM_WriteBuffer(0x0F40, State, true);
#ifdef ENABLE_FMRADIO
//0x0E88..0x0E8F
memset(State, 0xFF, sizeof(State));
memcpy(&State[0], &gEeprom.FM_FrequencyPlaying, 2);
EEPROM_WriteBuffer(0x0E88, State, true);
#endif
}
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)