From 3507631b22c07371f99cc1d1154c92e88d3cf79d Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 29 Nov 2022 20:08:26 +0000 Subject: [PATCH] Serials 1-6 in exrail --- EXRAIL2.cpp | 35 +++++++++++++++++++++++++++++++---- EXRAIL2.h | 1 + EXRAIL2MacroReset.h | 6 ++++++ EXRAILMacros.h | 9 +++++++++ FSH.h | 7 +++++-- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 072fb5b..7cf5396 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -1141,9 +1141,36 @@ void RMFT2::thrungeString(uint32_t strfar, thrunger mode, byte id) { 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; + case thrunge_serial1: + #ifdef SERIAL1_COMMANDS + stream=&Serial1; + #endif + break; + case thrunge_serial2: + #ifdef SERIAL2_COMMANDS + stream=&Serial2; + #endif + break; + case thrunge_serial3: + #ifdef SERIAL3_COMMANDS + stream=&Serial3; + #endif + break; + case thrunge_serial4: + #ifdef SERIAL4_COMMANDS + stream=&Serial4; + #endif + break; + case thrunge_serial5: + #ifdef SERIAL5_COMMANDS + stream=&Serial5; + #endif + break; + case thrunge_serial6: + #ifdef SERIAL6_COMMANDS + stream=&Serial6; + #endif + break; // TODO more serials for SAMx case thrunge_serial4: stream=&Serial4; break; case thrunge_lcn: #if defined(LCN_SERIAL) @@ -1170,7 +1197,7 @@ void RMFT2::thrungeString(uint32_t strfar, thrunger mode, byte id) { #else // UNO/NANO CPUs dont have high memory // 32 bit cpus dont care anyway - stream.print((FSH *)strfar) + stream->print((FSH *)strfar); #endif // and decide what to do next diff --git a/EXRAIL2.h b/EXRAIL2.h index 61d128f..9831a41 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -70,6 +70,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, enum thrunger: byte { thrunge_print, thrunge_broadcast, thrunge_serial,thrunge_parse, thrunge_serial1, thrunge_serial2, thrunge_serial3, + thrunge_serial4, thrunge_serial5, thrunge_serial6, thrunge_lcd, thrunge_lcn}; diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 0211e22..63fc6bd 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -110,6 +110,9 @@ #undef SERIAL1 #undef SERIAL2 #undef SERIAL3 +#undef SERIAL4 +#undef SERIAL5 +#undef SERIAL6 #undef SERVO #undef SERVO2 #undef SERVO_TURNOUT @@ -220,6 +223,9 @@ #define SERIAL1(msg) #define SERIAL2(msg) #define SERIAL3(msg) +#define SERIAL4(msg) +#define SERIAL5(msg) +#define SERIAL6(msg) #define SERVO(id,position,profile) #define SERVO2(id,position,duration) #define SERVO_SIGNAL(vpin,redpos,amberpos,greenpos) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index e222556..1c39cd3 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -123,6 +123,12 @@ const int StringMacroTracker1=__COUNTER__; #define SERIAL2(msg) THRUNGE(msg,thrunge_serial2) #undef SERIAL3 #define SERIAL3(msg) THRUNGE(msg,thrunge_serial3) +#undef SERIAL4 +#define SERIAL4(msg) THRUNGE(msg,thrunge_serial4) +#undef SERIAL5 +#define SERIAL5(msg) THRUNGE(msg,thrunge_serial5) +#undef SERIAL6 +#define SERIAL6(msg) THRUNGE(msg,thrunge_serial6) #undef LCD #define LCD(id,msg) \ case (__COUNTER__ - StringMacroTracker1) : {\ @@ -317,6 +323,9 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = { #define SERIAL1(msg) PRINT(msg) #define SERIAL2(msg) PRINT(msg) #define SERIAL3(msg) PRINT(msg) +#define SERIAL4(msg) PRINT(msg) +#define SERIAL5(msg) PRINT(msg) +#define SERIAL6(msg) PRINT(msg) #define SERVO(id,position,profile) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::profile),OPCODE_PAD,V(0), #define SERVO2(id,position,ms) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::Instant),OPCODE_PAD,V(ms/100L), #define SERVO_SIGNAL(vpin,redpos,amberpos,greenpos) diff --git a/FSH.h b/FSH.h index fd1df6d..5ca4b8a 100644 --- a/FSH.h +++ b/FSH.h @@ -59,7 +59,7 @@ typedef __FlashStringHelper FSH; // AVR_UNO/NANO runtime does not support _far functions so just use _near equivalent // as there is no progmem above 32kb anyway. #define HIGHFLASH PROGMEM -#define GETFARPTR(data) ((const byte *)(data)) +#define GETFARPTR(data) ((uint32_t)(data)) #define GETHIGHFLASH(data,offset) pgm_read_byte_near(GETFARPTR(data)+(offset)) #define GETHIGHFLASHW(data,offset) pgm_read_word_near(GETFARPTR(data)+(offset)) #endif @@ -69,11 +69,14 @@ typedef __FlashStringHelper FSH; #ifdef F #undef F #endif +#ifdef FLASH + #undef FLASH +#endif #define F(str) (str) typedef char FSH; #define FLASH #define HIGHFLASH -#define GETFARPTR(data) ((const byte *)(data)) +#define GETFARPTR(data) ((uint32_t)(data)) #define GETFLASH(addr) (*(const byte *)(addr)) #define GETHIGHFLASH(data,offset) (*(const byte *)(GETFARPTR(data)+offset)) #define GETHIGHFLASHW(data,offset) (*(const uint16_t *)(GETFARPTR(data)+offset))