FM频道地址修改 (#2)

* FM频道增加到30个(K版)

* FM保存地址修改

---------

Co-authored-by: guanzi008 <245205080@侵qq.com>
This commit is contained in:
guanzi008 2024-01-22 01:19:23 +08:00 committed by GitHub
parent b777edfd0a
commit 2e114a1021
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 67 additions and 10 deletions

View file

@ -36,7 +36,15 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
uint16_t gFM_Channels[20];
// 根据 ENABLE_CHINESE_FULL 宏的值来定义数组长度
#if ENABLE_CHINESE_FULL != 4
#define FM_CHANNEL_COUNT 20
#else
#define FM_CHANNEL_COUNT 30
#endif
uint16_t gFM_Channels[FM_CHANNEL_COUNT];
bool gFmRadioMode;
uint8_t gFmRadioCountdown_500ms;
volatile uint16_t gFmPlayCountdown_10ms;
@ -124,10 +132,17 @@ void FM_EraseChannels(void)
uint8_t Template[8];
memset(Template, 0xFF, sizeof(Template));
#if ENABLE_CHINESE_FULL != 4
for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template,8);
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
#else
for (i = 0; i < 8; i++)
EEPROM_WriteBuffer(0x1FFC0 + (i * 8), Template,8);
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
#endif
}
void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
@ -209,7 +224,7 @@ if (BK1080_REG_07_GET_SNR(Test2) <= 2){
// not BLE(less than or equal)
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) {
if (BK1080_FrequencyDeviation & 0x800 || (BK1080_FrequencyDeviation < 20))
if (BK1080_FrequencyDeviation & 0x800 || (BK1080_FrequencyDeviation < FM_CHANNEL_COUNT))
goto Bail;
}
@ -304,7 +319,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
return;
}
}
else if (Channel < 20) {
else if (Channel < FM_CHANNEL_COUNT) {
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
@ -490,7 +505,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
if (gAskToSave) {
gRequestDisplayScreen = DISPLAY_FM;
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19);
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, FM_CHANNEL_COUNT - 1);
return;
}
@ -600,10 +615,10 @@ void FM_Play(void)
return;
}
if (gFM_ChannelPosition < 20)
if (gFM_ChannelPosition < FM_CHANNEL_COUNT)
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
if (gFM_ChannelPosition >= 20)
if (gFM_ChannelPosition >= FM_CHANNEL_COUNT)
{
FM_PlayAndUpdate();
GUI_SelectNextDisplay(DISPLAY_FM);

View file

@ -29,7 +29,15 @@ enum {
};
extern bool FM_EXIT_FLAG;
extern uint16_t gFM_Channels[20];
// 根据 ENABLE_CHINESE_FULL 宏的值来定义数组长度
#if ENABLE_CHINESE_FULL != 4
#define FM_CHANNEL_COUNT 20
#else
#define FM_CHANNEL_COUNT 30
#endif
extern uint16_t gFM_Channels[FM_CHANNEL_COUNT];
extern bool gFmRadioMode;
extern uint8_t gFmRadioCountdown_500ms;
extern volatile uint16_t gFmPlayCountdown_10ms;

View file

@ -106,7 +106,16 @@ void SETTINGS_InitEEPROM(void)
}
// 0E40..0E67
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
//0x1FFF0..0x20000
// 根据 ENABLE_CHINESE_FULL 宏的值来定义数组长度
#if ENABLE_CHINESE_FULL != 4
// 使用 0E40
EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
#else
// 使用 1E451
EEPROM_ReadBuffer(0x1FFF0 , gFM_Channels, sizeof(gFM_Channels));
#endif
// EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels));
FM_ConfigureChannelState();
#endif
@ -430,7 +439,11 @@ void SETTINGS_FactoryReset(bool bIsAll)
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
#if ENABLE_CHINESE_FULL != 4
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
#else
!(i >= 0x1FFF0 && i < 0x20000) && // FM Channels
#endif
!(i >= 0x0E88 && i < 0x0E90) // FM settings
))
)
@ -474,9 +487,19 @@ void SETTINGS_SaveFM(void)
State.IsChannelSelected = gEeprom.FM_IsMrMode;
EEPROM_WriteBuffer(0x0E88, &State,8);
#if ENABLE_CHINESE_FULL != 4
for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4],8);
}
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4],8);
// EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4],8);
#else
for (i = 0; i < 8; i++)
EEPROM_WriteBuffer(0x1FFF0 + (i * 8), &gFM_Channels[i * 4],8);
// EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4],8);
#endif
}
#endif
void SETTINGS_SaveVfoIndices(void)

View file

@ -45,6 +45,7 @@ UI_DisplayClear();
pPrintStr = String;
} else {
pPrintStr = "VFO";
#if ENABLE_CHINESE_FULL != 4
for (unsigned int i = 0; i < 20; i++) {
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
sprintf(String, "VFO(CH%02u)", i + 1);
@ -52,6 +53,16 @@ UI_DisplayClear();
break;
}
}
#else
for (unsigned int i = 0; i < 30; i++) {
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
sprintf(String, "VFO(CH%02u)", i + 1);
pPrintStr = String;
break;
}
}
#endif
}
} else if (gFM_AutoScan) {
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);