mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 16:46:13 +01:00
Compare commits
3 Commits
1f5f7754c1
...
bd02d1c15b
Author | SHA1 | Date | |
---|---|---|---|
|
bd02d1c15b | ||
|
004d7b6631 | ||
|
21ce87eb3e |
|
@ -86,6 +86,7 @@ const int16_t HASH_KEYWORD_C='C';
|
|||
const int16_t HASH_KEYWORD_G='G';
|
||||
const int16_t HASH_KEYWORD_I='I';
|
||||
const int16_t HASH_KEYWORD_O='O';
|
||||
const int16_t HASH_KEYWORD_P='P';
|
||||
const int16_t HASH_KEYWORD_R='R';
|
||||
const int16_t HASH_KEYWORD_T='T';
|
||||
const int16_t HASH_KEYWORD_X='X';
|
||||
|
@ -702,10 +703,11 @@ 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 { // <JO id>
|
||||
Turntable *tto=Turntable::get(id);
|
||||
if (!tto || tto->isHidden()) {
|
||||
StringFormatter::send(stream, F(" %d X"), id);
|
||||
StringFormatter::send(stream, F(" %d X>\n"), id);
|
||||
} else {
|
||||
uint8_t pos = tto->getPosition();
|
||||
uint8_t type = tto->isEXTT();
|
||||
|
@ -715,15 +717,32 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
|||
todesc = RMFT2::getTurntableDescription(id);
|
||||
#endif
|
||||
if (todesc == NULL) todesc = F("");
|
||||
StringFormatter::send(stream, F(" %d %d %d"), id, type, pos, todesc);
|
||||
|
||||
for (uint8_t p = 0; p < posCount; p++) {
|
||||
int16_t value = tto->getPositionValue(p);
|
||||
StringFormatter::send(stream, F(" %d"), value);
|
||||
}
|
||||
StringFormatter::send(stream, F(" %d %d %d %d \"%S\">\n"), id, type, pos, posCount, todesc);
|
||||
}
|
||||
}
|
||||
StringFormatter::send(stream, F(">\n"));
|
||||
return;
|
||||
case HASH_KEYWORD_P: // <JP id> returns turntable position list for the turntable id
|
||||
if (params==2) { // <JP id>
|
||||
Turntable *tto=Turntable::get(id);
|
||||
if (!tto || tto->isHidden()) {
|
||||
StringFormatter::send(stream, F(" %d X>\n"), id);
|
||||
} else {
|
||||
uint8_t posCount = tto->getPositionCount();
|
||||
const FSH *tpdesc = NULL;
|
||||
for (uint8_t p = 0; p < posCount; p++) {
|
||||
StringFormatter::send(stream, F("<jP"));
|
||||
int16_t value = tto->getPositionValue(p);
|
||||
#ifdef EXRAIL_ACTIVE
|
||||
tpdesc = RMFT2::getTurntablePositionDescription(id, p);
|
||||
#endif
|
||||
if (tpdesc == NULL) tpdesc = F("");
|
||||
StringFormatter::send(stream, F(" %d %d %d \"%S\""), id, p, value, tpdesc);
|
||||
StringFormatter::send(stream, F(">\n"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
StringFormatter::send(stream, F("<jP X>\n"));
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
default: break;
|
||||
|
|
20
EXRAIL2.cpp
20
EXRAIL2.cpp
|
@ -95,7 +95,9 @@ LookList * RMFT2::onAmberLookup=NULL;
|
|||
LookList * RMFT2::onGreenLookup=NULL;
|
||||
LookList * RMFT2::onChangeLookup=NULL;
|
||||
LookList * RMFT2::onClockLookup=NULL;
|
||||
#ifndef IO_NO_HAL
|
||||
LookList * RMFT2::onRotateLookup=NULL;
|
||||
#endif
|
||||
|
||||
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
||||
#define SKIPOP progCounter+=3
|
||||
|
@ -177,8 +179,9 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
|||
onGreenLookup=LookListLoader(OPCODE_ONGREEN);
|
||||
onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
|
||||
onClockLookup=LookListLoader(OPCODE_ONTIME);
|
||||
#ifndef IO_NO_HAL
|
||||
onRotateLookup=LookListLoader(OPCODE_ONROTATE);
|
||||
|
||||
#endif
|
||||
|
||||
// Second pass startup, define any turnouts or servos, set signals red
|
||||
// add sequences onRoutines to the lookups
|
||||
|
@ -1014,7 +1017,16 @@ void RMFT2::loop2() {
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
#ifndef IO_NO_HAL
|
||||
case OPCODE_WAITFORTT: // OPCODE_WAITFOR,V(turntable_id)
|
||||
if (Turntable::ttMoving(operand)) {
|
||||
delayMe(100);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case OPCODE_PRINT:
|
||||
printMessage(operand);
|
||||
break;
|
||||
|
@ -1039,10 +1051,12 @@ void RMFT2::loop2() {
|
|||
case OPCODE_ONGREEN:
|
||||
case OPCODE_ONCHANGE:
|
||||
case OPCODE_ONTIME:
|
||||
#ifndef IO_NO_HAL
|
||||
case OPCODE_DCCTURNTABLE: // Turntable definition ignored at runtime
|
||||
case OPCODE_EXTTTURNTABLE: // Turntable definition ignored at runtime
|
||||
case OPCODE_TTADDPOSITION: // Turntable position definition ignored at runtime
|
||||
case OPCODE_ONROTATE:
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1187,10 +1201,12 @@ void RMFT2::changeEvent(int16_t vpin, bool change) {
|
|||
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
|
||||
}
|
||||
|
||||
#ifndef IO_NO_HAL
|
||||
void RMFT2::rotateEvent(int16_t turntableId, bool change) {
|
||||
// Hunt or an ONROTATE for this turntable
|
||||
if (change) handleEvent(F("ROTATE"),onRotateLookup,turntableId);
|
||||
}
|
||||
#endif
|
||||
|
||||
void RMFT2::clockEvent(int16_t clocktime, bool change) {
|
||||
// Hunt for an ONTIME for this time
|
||||
|
|
|
@ -63,8 +63,10 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
|||
OPCODE_ONCHANGE,
|
||||
OPCODE_ONCLOCKTIME,
|
||||
OPCODE_ONTIME,
|
||||
#ifndef IO_NO_HAL
|
||||
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
|
||||
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_IFTTPOSITION,
|
||||
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_IFTTPOSITION,OPCODE_WAITFORTT,
|
||||
#endif
|
||||
|
||||
// OPcodes below this point are skip-nesting IF operations
|
||||
// placed here so that they may be skipped as a group
|
||||
|
@ -197,7 +199,9 @@ private:
|
|||
static LookList * onGreenLookup;
|
||||
static LookList * onChangeLookup;
|
||||
static LookList * onClockLookup;
|
||||
#ifndef IO_NO_HAL
|
||||
static LookList * onRotateLookup;
|
||||
#endif
|
||||
|
||||
// Local variables - exist for each instance/task
|
||||
RMFT2 *next; // loop chain
|
||||
|
|
|
@ -150,6 +150,9 @@
|
|||
#undef VIRTUAL_SIGNAL
|
||||
#undef VIRTUAL_TURNOUT
|
||||
#undef WAITFOR
|
||||
#ifndef IO_NO_HAL
|
||||
#undef WAITFORTT
|
||||
#endif
|
||||
#undef WITHROTTLE
|
||||
#undef XFOFF
|
||||
#undef XFON
|
||||
|
@ -281,6 +284,9 @@
|
|||
#define VIRTUAL_SIGNAL(id)
|
||||
#define VIRTUAL_TURNOUT(id,description...)
|
||||
#define WAITFOR(pin)
|
||||
#ifndef IO_NO_HAL
|
||||
#define WAITFORTT(turntable_id)
|
||||
#endif
|
||||
#define WITHROTTLE(msg)
|
||||
#define XFOFF(cab,func)
|
||||
#define XFON(cab,func)
|
||||
|
|
|
@ -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"
|
||||
|
@ -420,6 +419,9 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
|
|||
#define VIRTUAL_TURNOUT(id,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(0),
|
||||
#define WITHROTTLE(msg) PRINT(msg)
|
||||
#define WAITFOR(pin) OPCODE_WAITFOR,V(pin),
|
||||
#ifndef IO_NO_HAL
|
||||
#define WAITFORTT(turntable_id) OPCODE_WAITFORTT,V(turntable_id),
|
||||
#endif
|
||||
#define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func),
|
||||
#define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func),
|
||||
|
||||
|
|
|
@ -115,6 +115,12 @@ uint8_t Turntable::getPosition(uint16_t id) {
|
|||
return tto->getPosition();
|
||||
}
|
||||
|
||||
bool Turntable::ttMoving(uint16_t id) {
|
||||
Turntable *tto = get(id);
|
||||
if (!tto) return false;
|
||||
return tto->isMoving();
|
||||
}
|
||||
|
||||
// Initiate a turntable move
|
||||
bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) {
|
||||
#if defined(DIAG_IO)
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
inline static bool exists(uint16_t id) { return get(id) != 0; }
|
||||
static bool setPosition(uint16_t id, uint8_t position, uint8_t activity=0);
|
||||
static uint8_t getPosition(uint16_t id);
|
||||
static bool ttMoving(uint16_t id);
|
||||
inline static Turntable *first() { return _firstTurntable; }
|
||||
static bool printAll(Print *stream) {
|
||||
bool gotOne = false;
|
||||
|
|
|
@ -30,7 +30,7 @@ include_dir = .
|
|||
|
||||
[env]
|
||||
build_flags = -Wall -Wextra
|
||||
monitor_filters = time
|
||||
; monitor_filters = time
|
||||
; lib_deps = adafruit/Adafruit ST7735 and ST7789 Library @ ^1.10.0
|
||||
|
||||
[env:samd21-dev-usb]
|
||||
|
|
Loading…
Reference in New Issue
Block a user