1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00

MEGA-ONLY exrail strings >64kb

This commit is contained in:
Asbelos 2022-11-07 11:51:56 +00:00
parent 08e2f781b4
commit 41b568989a
3 changed files with 95 additions and 10 deletions

View File

@ -1106,3 +1106,65 @@ void RMFT2::handleEvent(const FSH* reason,LookList* handlers, int16_t id) {
void RMFT2::printMessage2(const FSH * msg) { void RMFT2::printMessage2(const FSH * msg) {
DIAG(F("EXRAIL(%d) %S"),loco,msg); DIAG(F("EXRAIL(%d) %S"),loco,msg);
} }
static StringBuffer * buffer=NULL;
/* thrungeString is used to stream a HIGHFLASH string to a suitable Serial
and handle the oddities like LCD, BROADCAST and PARSE */
void RMFT2::thrungeString(uint32_t strfar, thrunger mode, byte id) {
//DIAG(F("thrunge addr=%l mode=%d id=%d"), strfar,mode,id);
Print * stream=NULL;
// Find out where the string is going
switch (mode) {
case thrunge_print:
StringFormatter::send(&Serial,F("<* EXRAIL(%d) "),loco);
stream=&Serial;
break;
case thrunge_serial: stream=&Serial; break;
case thrunge_serial1: stream=&Serial1; break;
case thrunge_serial2: stream=&Serial2; break;
case thrunge_serial3: stream=&Serial3; break;
// TODO more serials for SAMx case thrunge_serial4: stream=&Serial4; break;
case thrunge_lcn:
#if defined(LCN_SERIAL)
stream=&LCN_SERIAL;
#endif
break;
case thrunge_parse:
case thrunge_broadcast:
case thrunge_lcd:
if (!buffer) buffer=new StringBuffer();
buffer->flush();
stream=buffer;
break;
}
if (!stream) return;
// if mega stream it out
for (;;strfar++) {
char c=pgm_read_byte_far(strfar);
if (c=='\0') break;
stream->write(c);
}
// else other CPUs
// stream.print((FSH *)strfar)
// and decide what to do next
switch (mode) {
case thrunge_print:
StringFormatter::send(&Serial,F(" *>/n"));
break;
// TODO more serials for SAMx case thrunge_serial4: stream=&Serial4; break;
case thrunge_parse:
DCCEXParser::parseOne(&Serial,(byte*)buffer->getString(),NULL);
break;
case thrunge_broadcast:
// TODO CommandDistributor::broadcastText(buffer->getString());
break;
case thrunge_lcd:
LCD(id,F("%s%"),buffer->getString());
break;
default: break;
}
}

View File

@ -67,6 +67,11 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
OPCODE_IFCLOSED,OPCODE_IFTHROWN OPCODE_IFCLOSED,OPCODE_IFTHROWN
}; };
enum thrunger: byte {
thrunge_print, thrunge_broadcast, thrunge_serial,thrunge_parse,
thrunge_serial1, thrunge_serial2, thrunge_serial3,
thrunge_lcd, thrunge_lcn};
// Flag bits for status of hardware and TPL // Flag bits for status of hardware and TPL
@ -111,7 +116,6 @@ class LookList {
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000; static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
static const int16_t DCC_SIGNAL_FLAG=0x1000; static const int16_t DCC_SIGNAL_FLAG=0x1000;
static const int16_t SIGNAL_ID_MASK=0x0FFF; static const int16_t SIGNAL_ID_MASK=0x0FFF;
// Throttle Info Access functions built by exrail macros // Throttle Info Access functions built by exrail macros
static const byte rosterNameCount; static const byte rosterNameCount;
static const int16_t HIGHFLASH routeIdList[]; static const int16_t HIGHFLASH routeIdList[];
@ -148,6 +152,7 @@ private:
void kill(const FSH * reason=NULL,int operand=0); void kill(const FSH * reason=NULL,int operand=0);
void printMessage(uint16_t id); // Built by RMFTMacros.h void printMessage(uint16_t id); // Built by RMFTMacros.h
void printMessage2(const FSH * msg); void printMessage2(const FSH * msg);
void thrungeString(uint32_t strfar, thrunger mode, byte id=0);
static bool diag; static bool diag;
static const HIGHFLASH byte RouteCode[]; static const HIGHFLASH byte RouteCode[];

View File

@ -100,30 +100,48 @@ const FSH * RMFT2::getRouteDescription(int16_t id) {
// Pass 4... Create Text sending functions // Pass 4... Create Text sending functions
#include "EXRAIL2MacroReset.h" #include "EXRAIL2MacroReset.h"
const int StringMacroTracker1=__COUNTER__; const int StringMacroTracker1=__COUNTER__;
#define THRUNGE(msg,mode) \
case (__COUNTER__ - StringMacroTracker1) : {\
static const char HIGHFLASH thrunge[]=msg;\
strfar=(uint32_t)pgm_get_far_address(thrunge);\
tmode=mode;\
break;\
}
#undef BROADCAST #undef BROADCAST
#define BROADCAST(msg) case (__COUNTER__ - StringMacroTracker1) : CommandDistributor::broadcastText(F(msg));break; #define BROADCAST(msg) THRUNGE(msg,thrunge_broadcast)
#undef PARSE #undef PARSE
#define PARSE(msg) case (__COUNTER__ - StringMacroTracker1) : DCCEXParser::parse(F(msg));break; #define PARSE(msg) THRUNGE(msg,thrunge_parse)
#undef PRINT #undef PRINT
#define PRINT(msg) case (__COUNTER__ - StringMacroTracker1) : printMessage2(F(msg));break; #define PRINT(msg) THRUNGE(msg,thrunge_print)
#undef LCN #undef LCN
#define LCN(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&LCN_SERIAL,F(msg));break; #define LCN(msg) THRUNGE(msg,thrunge_lcn)
#undef SERIAL #undef SERIAL
#define SERIAL(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial,F(msg));break; #define SERIAL(msg) THRUNGE(msg,thrunge_serial)
#undef SERIAL1 #undef SERIAL1
#define SERIAL1(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial1,F(msg));break; #define SERIAL1(msg) THRUNGE(msg,thrunge_serial1)
#undef SERIAL2 #undef SERIAL2
#define SERIAL2(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial2,F(msg));break; #define SERIAL2(msg) THRUNGE(msg,thrunge_serial2)
#undef SERIAL3 #undef SERIAL3
#define SERIAL3(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial3,F(msg));break; #define SERIAL3(msg) THRUNGE(msg,thrunge_serial3)
#undef LCD #undef LCD
#define LCD(id,msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::lcd(id,F(msg));break; #define LCD(id,msg) \
case (__COUNTER__ - StringMacroTracker1) : {\
static const char HIGHFLASH thrunge[]=msg;\
strfar=(uint32_t)pgm_get_far_address(thrunge);\
tmode=thrunge_lcd; \
lcdid=id;\
break;\
}
void RMFT2::printMessage(uint16_t id) { void RMFT2::printMessage(uint16_t id) {
thrunger tmode;
uint32_t strfar=0;
byte lcdid=0;
switch(id) { switch(id) {
#include "myAutomation.h" #include "myAutomation.h"
default: break ; default: break ;
} }
if (strfar) thrungeString(strfar,tmode,lcdid);
} }