From 21ce87eb3e72a7d8925ea5fec407222ffbd2ce6c Mon Sep 17 00:00:00 2001 From: peteGSX Date: Thu, 7 Sep 2023 05:33:26 +1000 Subject: [PATCH] Descriptions available --- DCCEXParser.cpp | 13 ++++++++++--- EXRAILMacros.h | 19 +++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 404685d..405512c 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -702,6 +702,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) if (tto->isHidden()) continue; StringFormatter::send(stream, F(" %d"),tto->getId()); } + StringFormatter::send(stream, F(">\n")); } else { // Turntable *tto=Turntable::get(id); if (!tto || tto->isHidden()) { @@ -711,19 +712,25 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) uint8_t type = tto->isEXTT(); uint8_t posCount = tto->getPositionCount(); const FSH *todesc = NULL; + const FSH *tpdesc = NULL; #ifdef EXRAIL_ACTIVE todesc = RMFT2::getTurntableDescription(id); #endif if (todesc == NULL) todesc = F(""); - StringFormatter::send(stream, F(" %d %d %d"), id, type, pos, todesc); + StringFormatter::send(stream, F(" %d %d %d %d \"%S\">\n"), id, type, pos, posCount, todesc); for (uint8_t p = 0; p < posCount; p++) { + StringFormatter::send(stream, F("jO>")); int16_t value = tto->getPositionValue(p); - StringFormatter::send(stream, F(" %d"), value); +#ifdef EXRAIL_ACTIVE + tpdesc = RMFT2::getTurntablePositionDescription(id, p); +#endif + if (tpdesc == NULL) todesc = F(""); + StringFormatter::send(stream, F(" %d \"%S\""), value, tpdesc); + StringFormatter::send(stream, F(">\n")); } } } - StringFormatter::send(stream, F(">\n")); return; #endif default: break; diff --git a/EXRAILMacros.h b/EXRAILMacros.h index c413989..97604c5 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -54,6 +54,8 @@ // helper macro for turnout descriptions, creates NULL for missing description #define O_DESC(id, desc) case id: return ("" desc)[0]?F("" desc):NULL; +// helper macro for turntable descriptions, creates NULL for missing description +#define T_DESC(tid,pid,desc) if(turntableId==tid && positionId==pid) return ("" desc)[0]?F("" desc):NULL; // helper macro for turnout description as HIDDEN #define HIDDEN "\x01" @@ -203,17 +205,14 @@ const FSH * RMFT2::getTurntableDescription(int16_t turntableId) { } // Pass to get turntable position descriptions (optional) -// #include "EXRAIL2MacroReset.h" -// #undef TT_ADDPOSITION -// #define TT_ADDPOSITION(turntable_id,value,description...) O_DESC(turntable_id,description) +#include "EXRAIL2MacroReset.h" +#undef TT_ADDPOSITION +#define TT_ADDPOSITION(turntable_id,position,value,description...) T_DESC(turntable_id,position,description) -// const FSH * RMFT2::getTurntablePositionDescription(int16_t turntableId, uint8_t positionId) { -// switch (turntableId) { -// #include "myAutomation.h" -// default:break; -// } -// return NULL; -// } +const FSH * RMFT2::getTurntablePositionDescription(int16_t turntableId, uint8_t positionId) { + #include "myAutomation.h" + return NULL; +} // Pass 6: Roster IDs (count) #include "EXRAIL2MacroReset.h"