mirror of
https://github.com/silenty4ng/uv-k5-firmware-chinese-lts
synced 2025-01-15 14:54:40 +00:00
FM频道地址修改 (#2)
* FM频道增加到30个(K版) * FM保存地址修改 --------- Co-authored-by: guanzi008 <245205080@侵qq.com>
This commit is contained in:
parent
b777edfd0a
commit
2e114a1021
4 changed files with 67 additions and 10 deletions
27
app/fm.c
27
app/fm.c
|
@ -36,7 +36,15 @@
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#endif
|
#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;
|
bool gFmRadioMode;
|
||||||
uint8_t gFmRadioCountdown_500ms;
|
uint8_t gFmRadioCountdown_500ms;
|
||||||
volatile uint16_t gFmPlayCountdown_10ms;
|
volatile uint16_t gFmPlayCountdown_10ms;
|
||||||
|
@ -124,10 +132,17 @@ void FM_EraseChannels(void)
|
||||||
uint8_t Template[8];
|
uint8_t Template[8];
|
||||||
|
|
||||||
memset(Template, 0xFF, sizeof(Template));
|
memset(Template, 0xFF, sizeof(Template));
|
||||||
|
#if ENABLE_CHINESE_FULL != 4
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template,8);
|
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template,8);
|
||||||
|
|
||||||
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
|
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)
|
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)
|
// not BLE(less than or equal)
|
||||||
if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) {
|
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;
|
goto Bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +319,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Channel < 20) {
|
else if (Channel < FM_CHANNEL_COUNT) {
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
@ -490,7 +505,7 @@ static void Key_UP_DOWN(uint8_t state, int8_t Step)
|
||||||
|
|
||||||
if (gAskToSave) {
|
if (gAskToSave) {
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,10 +615,10 @@ void FM_Play(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gFM_ChannelPosition < 20)
|
if (gFM_ChannelPosition < FM_CHANNEL_COUNT)
|
||||||
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
|
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
|
||||||
|
|
||||||
if (gFM_ChannelPosition >= 20)
|
if (gFM_ChannelPosition >= FM_CHANNEL_COUNT)
|
||||||
{
|
{
|
||||||
FM_PlayAndUpdate();
|
FM_PlayAndUpdate();
|
||||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||||
|
|
10
app/fm.h
10
app/fm.h
|
@ -29,7 +29,15 @@ enum {
|
||||||
};
|
};
|
||||||
extern bool FM_EXIT_FLAG;
|
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 bool gFmRadioMode;
|
||||||
extern uint8_t gFmRadioCountdown_500ms;
|
extern uint8_t gFmRadioCountdown_500ms;
|
||||||
extern volatile uint16_t gFmPlayCountdown_10ms;
|
extern volatile uint16_t gFmPlayCountdown_10ms;
|
||||||
|
|
29
settings.c
29
settings.c
|
@ -106,7 +106,16 @@ void SETTINGS_InitEEPROM(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0E40..0E67
|
// 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();
|
FM_ConfigureChannelState();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -430,7 +439,11 @@ void SETTINGS_FactoryReset(bool bIsAll)
|
||||||
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
|
||||||
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
|
||||||
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
|
||||||
|
#if ENABLE_CHINESE_FULL != 4
|
||||||
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
|
||||||
|
#else
|
||||||
|
!(i >= 0x1FFF0 && i < 0x20000) && // FM Channels
|
||||||
|
#endif
|
||||||
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
!(i >= 0x0E88 && i < 0x0E90) // FM settings
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
@ -474,9 +487,19 @@ void SETTINGS_SaveFM(void)
|
||||||
State.IsChannelSelected = gEeprom.FM_IsMrMode;
|
State.IsChannelSelected = gEeprom.FM_IsMrMode;
|
||||||
|
|
||||||
EEPROM_WriteBuffer(0x0E88, &State,8);
|
EEPROM_WriteBuffer(0x0E88, &State,8);
|
||||||
|
#if ENABLE_CHINESE_FULL != 4
|
||||||
for (i = 0; i < 5; i++)
|
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
|
#endif
|
||||||
|
|
||||||
void SETTINGS_SaveVfoIndices(void)
|
void SETTINGS_SaveVfoIndices(void)
|
||||||
|
|
11
ui/fmradio.c
11
ui/fmradio.c
|
@ -45,6 +45,7 @@ UI_DisplayClear();
|
||||||
pPrintStr = String;
|
pPrintStr = String;
|
||||||
} else {
|
} else {
|
||||||
pPrintStr = "VFO";
|
pPrintStr = "VFO";
|
||||||
|
#if ENABLE_CHINESE_FULL != 4
|
||||||
for (unsigned int i = 0; i < 20; i++) {
|
for (unsigned int i = 0; i < 20; i++) {
|
||||||
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
|
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
|
||||||
sprintf(String, "VFO(CH%02u)", i + 1);
|
sprintf(String, "VFO(CH%02u)", i + 1);
|
||||||
|
@ -52,6 +53,16 @@ UI_DisplayClear();
|
||||||
break;
|
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) {
|
} else if (gFM_AutoScan) {
|
||||||
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
|
||||||
|
|
Loading…
Reference in a new issue