BRN-POCSAG: 171 channels, 26 x 40 char messages, make toggles

EEPROM layout (settings.h), replacing the broken 24 byte layout from
85fb527 (200 x 24 B channels overran the VFOs, attributes and settings;
names were saved at ch*24 but read at ch*20):
- 32 byte channel records with the 10 char name and the 16 bit scrambler
  inside, 171 channels in two areas (0x0000, 0x11E0); VFOs at 0x1020 with
  the same record; attributes moved to 0x0F50.
- Message store from 0x1900: 26 messages of 40 characters.
- Reset VFO no longer wipes the memory channels and messages.
- Static asserts that no area overlaps another or the calibration.

Identity: reports "BRN-POCSAG v4.0" to CHIRP and in the packed image, so
stock / egzumer / F4HWN drivers do not accept the new layout; the name is
shown on the welcome screen.

Make toggles: ENABLE_POCSAG, ENABLE_POCSAG_DEBUG, ENABLE_POCSAG_DEV_TUNING,
ENABLE_OOK_SENDER (POCSAG code and the OOK sender compile out completely).

Fonts: removed the unused big font, big digits and small digits; the 3x5
font is only built with the spectrum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 01:43:05 +01:00
co-authored by Claude Opus 5.5
parent c5a2b41fdb
commit aabd0f4956
20 changed files with 159 additions and 312 deletions

No files matched your search

+30 -17
View File
@@ -41,6 +41,12 @@ static const uint32_t gDefaultFrequencyTable[] =
};
#endif
// EEPROM layout checks (see settings.h)
_Static_assert(EEPROM_CH_A_COUNT * EEPROM_CH_SIZE <= 0x0E40U, "channels overlap the settings");
_Static_assert(EEPROM_CH_ATTR_BASE + 207U <= EEPROM_VFO_BASE, "channel attributes overlap the VFOs");
_Static_assert(MR_CHANNEL_LAST + 1U > EEPROM_CH_A_COUNT, "channel layout expects a second channel area");
_Static_assert(EEPROM_CH_END <= SEQParameterEEPROM, "channels overlap the message store");
EEPROM_Config_t gEeprom = {0};
void SETTINGS_InitEEPROM(void) {
@@ -137,7 +143,7 @@ void SETTINGS_InitEEPROM(void) {
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
gEeprom.SCAN_RESUME_MODE = (Data[5] < 105) ? Data[5] : 14;
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 41) ? Data[6] : 0;
gEeprom.FSKMode = (Data[7] <= MOD_POCSAG_2400) ? Data[7] : MOD_FSK_1200;
gEeprom.FSKMode = (Data[7] <= MODEM_LAST) ? Data[7] : MOD_FSK_1200;
// 0E98..0E9F
#ifdef ENABLE_PWRON_PASSWORD
EEPROM_ReadBuffer(0x0E98, Data, 8);
@@ -265,7 +271,7 @@ void SETTINGS_InitEEPROM(void) {
}
// 0D60..0E27
EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes));
EEPROM_ReadBuffer(EEPROM_CH_ATTR_BASE, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes));
for (uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) {
ChannelAttributes_t *att = &gMR_ChannelAttributes[i];
if (att->__val == 0xff) {
@@ -387,7 +393,7 @@ uint32_t SETTINGS_FetchChannelFrequency(const int channel) {
uint32_t offset;
} __attribute__((packed)) info;
EEPROM_ReadBuffer(channel * 20, &info, sizeof(info));
EEPROM_ReadBuffer(EEPROM_CH_ADDR(channel), &info, sizeof(info));
return info.frequency;
}
@@ -404,7 +410,7 @@ void SETTINGS_FetchChannelName(char *s, const int channel) {
if (!RADIO_CheckValidChannel(channel, false, 0))
return;
EEPROM_ReadBuffer(0x0F50 + (channel * 20), s, 10);
EEPROM_ReadBuffer(EEPROM_CH_ADDR(channel) + EEPROM_CH_NAME_OFFSET, s, 10);
int i;
for (i = 0; i < 10; i++)
@@ -431,9 +437,10 @@ void SETTINGS_FactoryReset(bool bIsAll) {
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
(bIsAll ||
(
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
!(i < 0x0E40) && // MR Channels (area A)
!(i >= EEPROM_CH_ATTR_BASE && i < EEPROM_VFO_BASE) && // MR Channel Attributes
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names
!(i >= EEPROM_CH_B_BASE) && // MR Channels (area B) + messages
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
!(i >= 0x0E88 && i < 0x0E90) // FM settings
))
@@ -724,11 +731,10 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
return;
#endif
uint16_t OffsetVFO = Channel * 24;
uint16_t OffsetVFO = EEPROM_CH_ADDR(Channel);
if (IS_FREQ_CHANNEL(Channel)) { // it's a VFO, not a channel
OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C98;
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
OffsetVFO = EEPROM_VFO_ADDR(Channel - FREQ_CHANNEL_FIRST, VFO);
}
if (Mode >= 2 || IS_FREQ_CHANNEL(Channel)) { // copy VFO to a channel
@@ -756,8 +762,10 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
State._8[6] = pVFO->STEP_SETTING;
EEPROM_WriteBuffer(OffsetVFO + sizeof (State._32), State._8);
State._16[0] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + sizeof (State._32) + sizeof (State._8), State._16);
// +24 block: name[8..9] (kept), scrambler, spare
EEPROM_ReadBuffer(OffsetVFO + 24, State._8, sizeof(State._8));
State._16[1] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + 24, State._8);
SETTINGS_UpdateChannel(Channel, pVFO, true, true, true);
@@ -786,11 +794,16 @@ void SETTINGS_SaveBatteryCalibration(const uint16_t *batteryCalibration) {
}
void SETTINGS_SaveChannelName(uint8_t channel, const char *name) {
uint16_t offset = channel * 24;
// name[0..7] at +16, name[8..9] at +24 (the rest of that block is the scrambler)
const uint16_t offset = EEPROM_CH_ADDR(channel) + EEPROM_CH_NAME_OFFSET;
uint8_t buf[16] = {0};
memcpy(buf, name, MIN(strlen(name), 10u));
EEPROM_WriteBuffer(0x0F50 + offset, buf);
EEPROM_WriteBuffer(0x0F58 + offset, buf + 8);
EEPROM_WriteBuffer(offset, buf);
uint8_t tail[8];
EEPROM_ReadBuffer(offset + 8, tail, sizeof(tail));
tail[0] = buf[8];
tail[1] = buf[9];
EEPROM_WriteBuffer(offset + 8, tail);
}
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, bool check, bool save) {
@@ -807,7 +820,7 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep,
.scanlist3 = 0,
}; // default attributes
uint16_t offset = 0x0D60 + (channel & ~7u);
uint16_t offset = EEPROM_CH_ATTR_BASE + (channel & ~7u);
EEPROM_ReadBuffer(offset, state, sizeof(state));
if (keep) {
@@ -921,8 +934,8 @@ void SETTINGS_WriteCurrentVol(void) {
void SETTINGS_ResetTxLock(void) {
uint8_t State[8];
for (uint8_t channel = 0; channel < 200; channel++) {
uint16_t OffsetVFO = channel * 24;
for (uint8_t channel = MR_CHANNEL_FIRST; channel <= MR_CHANNEL_LAST; channel++) {
uint16_t OffsetVFO = EEPROM_CH_ADDR(channel);
EEPROM_ReadBuffer(OffsetVFO + 8, State, sizeof(State));
State[4] |= (1 << 6);
EEPROM_WriteBuffer(OffsetVFO + 8, State);