diff --git a/app/fm.c b/app/fm.c index 0dffa6b..94309b2 100644 --- a/app/fm.c +++ b/app/fm.c @@ -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); diff --git a/app/fm.h b/app/fm.h index 5f8f81e..5f94713 100644 --- a/app/fm.h +++ b/app/fm.h @@ -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; diff --git a/settings.c b/settings.c index 1dbaa6f..2dd8493 100644 --- a/settings.c +++ b/settings.c @@ -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) diff --git a/ui/fmradio.c b/ui/fmradio.c index 2607b2e..6762811 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -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);