Files
brnQuanFW/app/messages.h
T
BRNSystemsandClaude Opus 5.5 aabd0f4956 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>
2026-11-15 01:43:05 +01:00

65 lines
2.3 KiB
C

//
// Created by bruno on 3/30/25.
//
#ifndef BRNQUANFW_MESSAGES_H
#define BRNQUANFW_MESSAGES_H
#include "fskmodem.h"
#include "../driver/keyboard.h"
#include "../driver/eeprom.h"
#include "pocsag.h"
// Message store: MESSAGES_COUNT slots between MESSAGES_START and the calibration
// data at MESSAGES_END. Override MESSAGES_COUNT / POCSAG_MAX_MESSAGE_LENGTH with -D;
// changing either moves the slots (old stored messages read back as garbage).
#define MESSAGES_START (SEQParameterEEPROM + 8U)
#define MESSAGES_END (0x1E00U)
#define MESSAGE_FLAG_POCSAG (0x20U)
#define MESSAGES_TEXT_LENGTH POCSAG_MAX_MESSAGE_LENGTH
#define MESSAGES_HEADER_SIZE 7U // src, seq, ttl, flags
// EEPROM is written in 8 byte blocks, so slots are a multiple of 8 bytes
#define MESSAGES_SLOT_SIZE (((MESSAGES_HEADER_SIZE + MESSAGES_TEXT_LENGTH + 7U) / 8U) * 8U)
// default: as many messages as fit (40 characters -> 48 byte slots -> 26 messages)
#ifndef MESSAGES_COUNT
#define MESSAGES_COUNT ((MESSAGES_END - MESSAGES_START) / MESSAGES_SLOT_SIZE)
#endif
// Display: 18 small-font characters per line, header line + text lines per message
#define MESSAGES_LINE_CHARS 18U
#define MESSAGES_TEXT_LINES ((MESSAGES_TEXT_LENGTH + MESSAGES_LINE_CHARS - 1U) / MESSAGES_LINE_CHARS)
#define MESSAGES_PER_PAGE (8U / (1U + MESSAGES_TEXT_LINES))
#define MESSAGES_PAGES ((MESSAGES_COUNT + MESSAGES_PER_PAGE - 1U) / MESSAGES_PER_PAGE)
typedef struct __attribute__((packed)) {
uint32_t src;
uint8_t seq;
uint8_t ttl;
uint8_t flags;
uint8_t data[MESSAGES_SLOT_SIZE - MESSAGES_HEADER_SIZE]; // text, NUL padded
} StoredPacket;
// Text being typed / last sent (SMS mode sends the first DataPacketDataSize - 1 chars)
extern char gMessageText[MESSAGES_TEXT_LENGTH + 1U];
extern uint8_t gActiveMessage;
extern uint8_t gActiveMessageBank;
extern StoredPacket loadedPacket;
extern uint8_t gKeyTimeout;
void MESSAGES_GET();
void MESSAGES_DELETE();
void MESSAGES_SAVE(uint32_t src, uint8_t seq, uint8_t ttl, uint8_t flags,
const uint8_t *text, size_t length);
// loadedPacket text as a NUL terminated string (buffer of MESSAGES_TEXT_LENGTH + 1)
void MESSAGES_GetText(char *text);
// show the newest messages page
void MESSAGES_ShowNewest(void);
void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void MESSAGES_TimeSlice500ms(void);
#endif //BRNQUANFW_MESSAGES_H