another attempt
This commit is contained in:
No files matched your search
@@ -87,6 +87,7 @@ const t_menu_item MenuList[] =
|
||||
{"ChDisp", MENU_MDF}, // was "MDF"
|
||||
{"FSKMod", MENU_FSKMOD},
|
||||
{"FSKSRC", MENU_FSKSRC}, // was "AUTOLk"
|
||||
{"PocMon", MENU_PMON}, // POCSAG monitor: receive all RICs
|
||||
{"BLTime", MENU_ABR}, // was "ABR"
|
||||
{"BLMin", MENU_ABR_MIN},
|
||||
{"BLMax", MENU_ABR_MAX},
|
||||
@@ -234,7 +235,9 @@ const char gSubMenu_FSKMod[][8] =
|
||||
"A1200",
|
||||
"A2400",
|
||||
"NOAA",
|
||||
"POCSAG"
|
||||
"PCS1200",
|
||||
"PCS512",
|
||||
"PCS2400"
|
||||
};
|
||||
|
||||
const char gSubMenu_ROGER[][6] =
|
||||
@@ -632,6 +635,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
|
||||
#endif
|
||||
case MENU_BCL:
|
||||
case MENU_BEEP:
|
||||
case MENU_PMON:
|
||||
case MENU_S_ADD1:
|
||||
case MENU_S_ADD2:
|
||||
case MENU_S_ADD3:
|
||||
|
||||
@@ -83,6 +83,7 @@ enum {
|
||||
MENU_D_LIVE_DEC,
|
||||
MENU_FSKSRC,
|
||||
MENU_FSKMOD,
|
||||
MENU_PMON,
|
||||
MENU_ROGER,
|
||||
MENU_BAT_TXT,
|
||||
MENU_AM,
|
||||
@@ -144,7 +145,7 @@ extern const char gSubMenu_SET_PTT[2][4];
|
||||
#endif
|
||||
|
||||
extern const char *const gSubMenu_PTT_ID[5];
|
||||
extern const char gSubMenu_FSKMod[8][8];
|
||||
extern const char gSubMenu_FSKMod[10][8];
|
||||
extern const char gSubMenu_ROGER[3][6];
|
||||
extern const char gSubMenu_RESET[2][4];
|
||||
extern const char *const gSubMenu_F_LOCK[F_LOCK_LEN];
|
||||
|
||||
+35
-21
@@ -23,21 +23,38 @@ void u8_to_str(uint8_t num, char *str) {
|
||||
}
|
||||
|
||||
|
||||
// Print text wrapped over `lines` display lines starting at `line`.
|
||||
static void UI_PrintWrapped(const char *text, const uint8_t line, const uint8_t lines) {
|
||||
char chunk[MESSAGES_LINE_CHARS + 1U];
|
||||
const size_t length = strlen(text);
|
||||
|
||||
for (uint8_t l = 0; l < lines && l * MESSAGES_LINE_CHARS < length; l++) {
|
||||
strncpy(chunk, text + l * MESSAGES_LINE_CHARS, MESSAGES_LINE_CHARS);
|
||||
chunk[MESSAGES_LINE_CHARS] = '\0';
|
||||
UI_PrintStringSmallNormal(chunk, 1, 0, line + l);
|
||||
}
|
||||
}
|
||||
|
||||
void UI_DisplayMessages(void) {
|
||||
char String[19];
|
||||
UI_DisplayClear();
|
||||
if (gEnteringSMS != SMS_NOT_ENTERING) {
|
||||
if (gEnteringSMS == SMS_ENTERING_DEST) {
|
||||
UI_PrintString(gEeprom.FSKMode == MOD_POCSAG_1200 ? "RIC" : "SMS dest", 0, 0, 0 /*, 8 */);
|
||||
UI_PrintString(MODEM_IS_POCSAG(gEeprom.FSKMode) ? "RIC" : "SMS dest", 0, 0, 0 /*, 8 */);
|
||||
u32_to_str(dataPacket.dest, String);
|
||||
UI_PrintStringSmallNormal(String, 0, 0, 2);
|
||||
} else if (gEnteringSMS == SMS_ENTERING_MESSAGE) {
|
||||
UI_PrintString("SMS data", 0, 0, 0 /*, 8 */);
|
||||
UI_PrintStringSmallNormal((const char *) dataPacket.data, 1, 0, 1);
|
||||
memset(gFrameBuffer[1] + 2 + (7 * strlen((const char *) dataPacket.data)), gKeyTimeout == 0 ? 0xFF : 0x80,
|
||||
6);
|
||||
const size_t length = strlen(gMessageText);
|
||||
UI_PrintString(MODEM_IS_POCSAG(gEeprom.FSKMode) ? "Page text" : "SMS data", 0, 0, 0 /*, 8 */);
|
||||
UI_PrintWrapped(gMessageText, 1, MESSAGES_TEXT_LINES);
|
||||
// cursor block after the last character
|
||||
const uint8_t cursorLine = 1U + length / MESSAGES_LINE_CHARS;
|
||||
if (length < MESSAGES_TEXT_LENGTH && cursorLine < 8U)
|
||||
memset(gFrameBuffer[cursorLine] + 2 + (7 * (length % MESSAGES_LINE_CHARS)),
|
||||
gKeyTimeout == 0 ? 0xFF : 0x80, 6);
|
||||
}
|
||||
} else {
|
||||
char text[MESSAGES_TEXT_LENGTH + 1U];
|
||||
uint8_t Data[8];
|
||||
EEPROM_ReadBuffer(SEQParameterEEPROM, Data, 8);
|
||||
uint8_t msgIndex = Data[1]; // index of latest written message
|
||||
@@ -45,21 +62,16 @@ void UI_DisplayMessages(void) {
|
||||
// Determine oldest message index (next to be overwritten)
|
||||
uint8_t startIndex = (msgIndex + 1) % MESSAGES_COUNT;
|
||||
|
||||
// Each bank shows 3 messages
|
||||
uint8_t messagesPerPage = 3;
|
||||
|
||||
// Compute offset for scrolling (0 = newest, higher = older)
|
||||
uint8_t pageOffset = gActiveMessageBank * messagesPerPage;
|
||||
|
||||
for (uint8_t ixa = 0; ixa < messagesPerPage; ixa++) {
|
||||
// Logical order from oldest to newest
|
||||
uint8_t logicalIndex = (startIndex + pageOffset + ixa) % MESSAGES_COUNT;
|
||||
// Pages run from oldest to newest
|
||||
uint8_t pageOffset = gActiveMessageBank * MESSAGES_PER_PAGE;
|
||||
|
||||
for (uint8_t ixa = 0; ixa < MESSAGES_PER_PAGE; ixa++) {
|
||||
// If out of stored range, stop
|
||||
if (pageOffset + ixa >= MESSAGES_COUNT)
|
||||
break;
|
||||
|
||||
gActiveMessage = logicalIndex;
|
||||
// Logical order from oldest to newest
|
||||
gActiveMessage = (startIndex + pageOffset + ixa) % MESSAGES_COUNT;
|
||||
MESSAGES_GET();
|
||||
|
||||
// Build the display string
|
||||
@@ -71,23 +83,25 @@ void UI_DisplayMessages(void) {
|
||||
memcpy(String + 2, capcodeString + 3, 7);
|
||||
String[9] = ' ';
|
||||
} else {
|
||||
u32_to_str(gActiveMessage == MESSAGES_COUNT ? dataPacket.dest : loadedPacket.src, &String[0]);
|
||||
u32_to_str(loadedPacket.src, &String[0]);
|
||||
}
|
||||
String[10] = '-';
|
||||
u8_to_str(loadedPacket.seq, &String[11]);
|
||||
String[14] = '-';
|
||||
|
||||
// Display a visual index (0,1,2,3... not EEPROM slot)
|
||||
uint8_t visualIndex = ixa + (gActiveMessageBank * 3);
|
||||
uint8_t visualIndex = ixa + pageOffset;
|
||||
String[15] = (visualIndex < 10) ? ('0' + visualIndex) : ('A' + visualIndex - 10);
|
||||
String[16] = '-';
|
||||
String[17] = (gActiveMessage < 10) ? ('0' + gActiveMessage) : ('A' + gActiveMessage - 10);
|
||||
String[18] = 0;
|
||||
|
||||
// Print both metadata and message
|
||||
UI_PrintString(String, 2, 0, ixa * 2);
|
||||
UI_PrintString((const char *) loadedPacket.data, 2, 0, ixa * 2 + 1);
|
||||
// header line, then the text wrapped over MESSAGES_TEXT_LINES lines
|
||||
const uint8_t line = ixa * (1U + MESSAGES_TEXT_LINES);
|
||||
UI_PrintString(String, 2, 0, line);
|
||||
MESSAGES_GetText(text);
|
||||
UI_PrintWrapped(text, line + 1U, MESSAGES_TEXT_LINES);
|
||||
}
|
||||
}
|
||||
ST7565_BlitFullScreen();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user