mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
MEGA-ONLY exrail strings >64kb
This commit is contained in:
parent
08e2f781b4
commit
41b568989a
62
EXRAIL2.cpp
62
EXRAIL2.cpp
|
@ -1106,3 +1106,65 @@ void RMFT2::handleEvent(const FSH* reason,LookList* handlers, int16_t id) {
|
|||
void RMFT2::printMessage2(const FSH * 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -67,6 +67,11 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
|||
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
|
||||
|
@ -111,7 +116,6 @@ class LookList {
|
|||
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
|
||||
static const int16_t DCC_SIGNAL_FLAG=0x1000;
|
||||
static const int16_t SIGNAL_ID_MASK=0x0FFF;
|
||||
|
||||
// Throttle Info Access functions built by exrail macros
|
||||
static const byte rosterNameCount;
|
||||
static const int16_t HIGHFLASH routeIdList[];
|
||||
|
@ -148,6 +152,7 @@ private:
|
|||
void kill(const FSH * reason=NULL,int operand=0);
|
||||
void printMessage(uint16_t id); // Built by RMFTMacros.h
|
||||
void printMessage2(const FSH * msg);
|
||||
void thrungeString(uint32_t strfar, thrunger mode, byte id=0);
|
||||
|
||||
static bool diag;
|
||||
static const HIGHFLASH byte RouteCode[];
|
||||
|
|
|
@ -100,30 +100,48 @@ const FSH * RMFT2::getRouteDescription(int16_t id) {
|
|||
// Pass 4... Create Text sending functions
|
||||
#include "EXRAIL2MacroReset.h"
|
||||
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
|
||||
#define BROADCAST(msg) case (__COUNTER__ - StringMacroTracker1) : CommandDistributor::broadcastText(F(msg));break;
|
||||
#define BROADCAST(msg) THRUNGE(msg,thrunge_broadcast)
|
||||
#undef PARSE
|
||||
#define PARSE(msg) case (__COUNTER__ - StringMacroTracker1) : DCCEXParser::parse(F(msg));break;
|
||||
#define PARSE(msg) THRUNGE(msg,thrunge_parse)
|
||||
#undef PRINT
|
||||
#define PRINT(msg) case (__COUNTER__ - StringMacroTracker1) : printMessage2(F(msg));break;
|
||||
#define PRINT(msg) THRUNGE(msg,thrunge_print)
|
||||
#undef LCN
|
||||
#define LCN(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&LCN_SERIAL,F(msg));break;
|
||||
#define LCN(msg) THRUNGE(msg,thrunge_lcn)
|
||||
#undef SERIAL
|
||||
#define SERIAL(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial,F(msg));break;
|
||||
#define SERIAL(msg) THRUNGE(msg,thrunge_serial)
|
||||
#undef SERIAL1
|
||||
#define SERIAL1(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial1,F(msg));break;
|
||||
#define SERIAL1(msg) THRUNGE(msg,thrunge_serial1)
|
||||
#undef SERIAL2
|
||||
#define SERIAL2(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial2,F(msg));break;
|
||||
#define SERIAL2(msg) THRUNGE(msg,thrunge_serial2)
|
||||
#undef SERIAL3
|
||||
#define SERIAL3(msg) case (__COUNTER__ - StringMacroTracker1) : StringFormatter::send(&Serial3,F(msg));break;
|
||||
#define SERIAL3(msg) THRUNGE(msg,thrunge_serial3)
|
||||
#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) {
|
||||
thrunger tmode;
|
||||
uint32_t strfar=0;
|
||||
byte lcdid=0;
|
||||
switch(id) {
|
||||
#include "myAutomation.h"
|
||||
default: break ;
|
||||
}
|
||||
if (strfar) thrungeString(strfar,tmode,lcdid);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user