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

EXRAIL ready for testing

This commit is contained in:
peteGSX 2023-09-02 08:29:49 +10:00
parent bcb250bacf
commit e734661d1b
6 changed files with 124 additions and 10 deletions

View File

@ -52,6 +52,7 @@
#include "Turnouts.h" #include "Turnouts.h"
#include "CommandDistributor.h" #include "CommandDistributor.h"
#include "TrackManager.h" #include "TrackManager.h"
#include "Turntables.h"
// Command parsing keywords // Command parsing keywords
const int16_t HASH_KEYWORD_EXRAIL=15435; const int16_t HASH_KEYWORD_EXRAIL=15435;
@ -94,6 +95,7 @@ LookList * RMFT2::onAmberLookup=NULL;
LookList * RMFT2::onGreenLookup=NULL; LookList * RMFT2::onGreenLookup=NULL;
LookList * RMFT2::onChangeLookup=NULL; LookList * RMFT2::onChangeLookup=NULL;
LookList * RMFT2::onClockLookup=NULL; LookList * RMFT2::onClockLookup=NULL;
LookList * RMFT2::onRotateLookup=NULL;
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter) #define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
#define SKIPOP progCounter+=3 #define SKIPOP progCounter+=3
@ -175,6 +177,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
onGreenLookup=LookListLoader(OPCODE_ONGREEN); onGreenLookup=LookListLoader(OPCODE_ONGREEN);
onChangeLookup=LookListLoader(OPCODE_ONCHANGE); onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
onClockLookup=LookListLoader(OPCODE_ONTIME); onClockLookup=LookListLoader(OPCODE_ONTIME);
onRotateLookup=LookListLoader(OPCODE_ONROTATE);
// Second pass startup, define any turnouts or servos, set signals red // Second pass startup, define any turnouts or servos, set signals red
@ -238,6 +241,32 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
setTurnoutHiddenState(VpinTurnout::create(id,pin)); setTurnoutHiddenState(VpinTurnout::create(id,pin));
break; break;
} }
case OPCODE_DCCTURNTABLE: {
VPIN id=operand;
setTurntableHiddenState(DCCTurntable::create(id));
Turntable *tto=Turntable::get(id);
tto->addPosition(0);
break;
}
case OPCODE_EXTTTURNTABLE: {
VPIN id=operand;
VPIN pin=getOperand(progCounter,1);
int home=getOperand(progCounter,2);
setTurntableHiddenState(EXTTTurntable::create(id,pin));
Turntable *tto=Turntable::get(id);
tto->addPosition(home);
break;
}
case OPCODE_TTADDPOSITION: {
VPIN id=operand;
int value=getOperand(progCounter,1);
Turntable *tto=Turntable::get(id);
tto->addPosition(value);
break;
}
case OPCODE_AUTOSTART: case OPCODE_AUTOSTART:
// automatically create a task from here at startup. // automatically create a task from here at startup.
@ -263,6 +292,10 @@ void RMFT2::setTurnoutHiddenState(Turnout * t) {
t->setHidden(GETFLASH(getTurnoutDescription(t->getId()))==0x01); t->setHidden(GETFLASH(getTurnoutDescription(t->getId()))==0x01);
} }
void RMFT2::setTurntableHiddenState(Turntable * tto) {
tto->setHidden(GETFLASH(getTurntableDescription(tto->getId()))==0x01);
}
char RMFT2::getRouteType(int16_t id) { char RMFT2::getRouteType(int16_t id) {
for (int16_t i=0;;i+=2) { for (int16_t i=0;;i+=2) {
int16_t rid= GETHIGHFLASHW(routeIdList,i); int16_t rid= GETHIGHFLASHW(routeIdList,i);
@ -598,6 +631,13 @@ void RMFT2::loop2() {
case OPCODE_CLOSE: case OPCODE_CLOSE:
Turnout::setClosed(operand, true); Turnout::setClosed(operand, true);
break; break;
case OPCODE_ROTATE:
uint8_t activity;
activity=getOperand(2);
if (!activity) activity=0;
Turntable::setPosition(operand,getOperand(1),activity);
break;
case OPCODE_REV: case OPCODE_REV:
forward = false; forward = false;
@ -788,6 +828,10 @@ void RMFT2::loop2() {
case OPCODE_IFCLOSED: case OPCODE_IFCLOSED:
skipIf=Turnout::isThrown(operand); skipIf=Turnout::isThrown(operand);
break; break;
case OPCODE_IFTTPOSITION: // do block if turntable at this position
skipIf=Turntable::getPosition(operand)!=(int)getOperand(1);
break;
case OPCODE_ENDIF: case OPCODE_ENDIF:
break; break;
@ -986,6 +1030,10 @@ void RMFT2::loop2() {
case OPCODE_ONGREEN: case OPCODE_ONGREEN:
case OPCODE_ONCHANGE: case OPCODE_ONCHANGE:
case OPCODE_ONTIME: case OPCODE_ONTIME:
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:
break; break;
@ -1130,6 +1178,11 @@ void RMFT2::changeEvent(int16_t vpin, bool change) {
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin); if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
} }
void RMFT2::rotateEvent(int16_t turntableId, bool change) {
// Hunt or an ONROTATE for this turntable
if (change) handleEvent(F("ROTATE"),onRotateLookup,turntableId);
}
void RMFT2::clockEvent(int16_t clocktime, bool change) { void RMFT2::clockEvent(int16_t clocktime, bool change) {
// Hunt for an ONTIME for this time // Hunt for an ONTIME for this time
if (Diag::CMD) if (Diag::CMD)

View File

@ -25,6 +25,7 @@
#include "FSH.h" #include "FSH.h"
#include "IODevice.h" #include "IODevice.h"
#include "Turnouts.h" #include "Turnouts.h"
#include "Turntables.h"
// The following are the operation codes (or instructions) for a kind of virtual machine. // The following are the operation codes (or instructions) for a kind of virtual machine.
// Each instruction is normally 3 bytes long with an operation code followed by a parameter. // Each instruction is normally 3 bytes long with an operation code followed by a parameter.
@ -62,6 +63,8 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
OPCODE_ONCHANGE, OPCODE_ONCHANGE,
OPCODE_ONCLOCKTIME, OPCODE_ONCLOCKTIME,
OPCODE_ONTIME, OPCODE_ONTIME,
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_IFTTPOSITION,
// OPcodes below this point are skip-nesting IF operations // OPcodes below this point are skip-nesting IF operations
// placed here so that they may be skipped as a group // placed here so that they may be skipped as a group
@ -130,6 +133,7 @@ class LookList {
static void activateEvent(int16_t addr, bool active); static void activateEvent(int16_t addr, bool active);
static void changeEvent(int16_t id, bool change); static void changeEvent(int16_t id, bool change);
static void clockEvent(int16_t clocktime, bool change); static void clockEvent(int16_t clocktime, bool change);
static void rotateEvent(int16_t id, bool change);
static const int16_t SERVO_SIGNAL_FLAG=0x4000; static const int16_t SERVO_SIGNAL_FLAG=0x4000;
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;
@ -144,6 +148,8 @@ class LookList {
static const FSH * getTurnoutDescription(int16_t id); static const FSH * getTurnoutDescription(int16_t id);
static const FSH * getRosterName(int16_t id); static const FSH * getRosterName(int16_t id);
static const FSH * getRosterFunctions(int16_t id); static const FSH * getRosterFunctions(int16_t id);
static const FSH * getTurntableDescription(int16_t id);
// static const FSH * getTurntablePositionDescription(int16_t id, uint8_t position);
private: private:
static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]); static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);
@ -156,6 +162,7 @@ private:
static bool isSignal(int16_t id,char rag); static bool isSignal(int16_t id,char rag);
static int16_t getSignalSlot(int16_t id); static int16_t getSignalSlot(int16_t id);
static void setTurnoutHiddenState(Turnout * t); static void setTurnoutHiddenState(Turnout * t);
static void setTurntableHiddenState(Turntable * tto);
static LookList* LookListLoader(OPCODE op1, static LookList* LookListLoader(OPCODE op1,
OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL); OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL);
static void handleEvent(const FSH* reason,LookList* handlers, int16_t id); static void handleEvent(const FSH* reason,LookList* handlers, int16_t id);
@ -188,6 +195,7 @@ private:
static LookList * onGreenLookup; static LookList * onGreenLookup;
static LookList * onChangeLookup; static LookList * onChangeLookup;
static LookList * onClockLookup; static LookList * onClockLookup;
static LookList * onRotateLookup;
// Local variables - exist for each instance/task // Local variables - exist for each instance/task
RMFT2 *next; // loop chain RMFT2 *next; // loop chain

View File

@ -40,6 +40,7 @@
#undef CALL #undef CALL
#undef CLOSE #undef CLOSE
#undef DCC_SIGNAL #undef DCC_SIGNAL
#undef DCC_TURNTABLE
#undef DEACTIVATE #undef DEACTIVATE
#undef DEACTIVATEL #undef DEACTIVATEL
#undef DELAY #undef DELAY
@ -51,8 +52,9 @@
#undef ENDEXRAIL #undef ENDEXRAIL
#undef ENDIF #undef ENDIF
#undef ENDTASK #undef ENDTASK
#undef ESTOP #undef ESTOP
#undef EXRAIL #undef EXRAIL
#undef EXTT_TURNTABLE
#undef FADE #undef FADE
#undef FOFF #undef FOFF
#undef FOLLOW #undef FOLLOW
@ -75,6 +77,7 @@
#undef IFRESERVE #undef IFRESERVE
#undef IFTHROWN #undef IFTHROWN
#undef IFTIMEOUT #undef IFTIMEOUT
#undef IFTTPOSITION
#undef IFRE #undef IFRE
#undef INVERT_DIRECTION #undef INVERT_DIRECTION
#undef JOIN #undef JOIN
@ -95,6 +98,7 @@
#undef ONCLOCKMINS #undef ONCLOCKMINS
#undef ONGREEN #undef ONGREEN
#undef ONRED #undef ONRED
#undef ONROTATE
#undef ONTHROW #undef ONTHROW
#undef ONCHANGE #undef ONCHANGE
#undef PARSE #undef PARSE
@ -113,7 +117,8 @@
#undef RESUME #undef RESUME
#undef RETURN #undef RETURN
#undef REV #undef REV
#undef ROSTER #undef ROSTER
#undef ROTATE
#undef ROUTE #undef ROUTE
#undef SENDLOCO #undef SENDLOCO
#undef SEQUENCE #undef SEQUENCE
@ -136,7 +141,8 @@
#undef SPEED #undef SPEED
#undef START #undef START
#undef STOP #undef STOP
#undef THROW #undef THROW
#undef TT_ADDPOSITION
#undef TURNOUT #undef TURNOUT
#undef TURNOUTL #undef TURNOUTL
#undef UNJOIN #undef UNJOIN
@ -165,6 +171,7 @@
#define CALL(route) #define CALL(route)
#define CLOSE(id) #define CLOSE(id)
#define DCC_SIGNAL(id,add,subaddr) #define DCC_SIGNAL(id,add,subaddr)
#define DCC_TURNTABLE(id,description)
#define DEACTIVATE(addr,subaddr) #define DEACTIVATE(addr,subaddr)
#define DEACTIVATEL(addr) #define DEACTIVATEL(addr)
#define DELAY(mindelay) #define DELAY(mindelay)
@ -177,7 +184,8 @@
#define ENDIF #define ENDIF
#define ENDTASK #define ENDTASK
#define ESTOP #define ESTOP
#define EXRAIL #define EXRAIL
#define EXTT_TURNTABLE(id,vpin,home,description)
#define FADE(pin,value,ms) #define FADE(pin,value,ms)
#define FOFF(func) #define FOFF(func)
#define FOLLOW(route) #define FOLLOW(route)
@ -200,6 +208,7 @@
#define IFTHROWN(turnout_id) #define IFTHROWN(turnout_id)
#define IFRESERVE(block) #define IFRESERVE(block)
#define IFTIMEOUT #define IFTIMEOUT
#define IFTTPOSITION(turntable_id,position)
#define IFRE(sensor_id,value) #define IFRE(sensor_id,value)
#define INVERT_DIRECTION #define INVERT_DIRECTION
#define JOIN #define JOIN
@ -219,7 +228,8 @@
#define ONDEACTIVATEL(linear) #define ONDEACTIVATEL(linear)
#define ONCLOSE(turnout_id) #define ONCLOSE(turnout_id)
#define ONGREEN(signal_id) #define ONGREEN(signal_id)
#define ONRED(signal_id) #define ONRED(signal_id)
#define ONROTATE(turntable_id)
#define ONTHROW(turnout_id) #define ONTHROW(turnout_id)
#define ONCHANGE(sensor_id) #define ONCHANGE(sensor_id)
#define PAUSE #define PAUSE
@ -238,8 +248,9 @@
#define RESUME #define RESUME
#define RETURN #define RETURN
#define REV(speed) #define REV(speed)
#define ROUTE(id,description) #define ROTATE(turntable_id,position,activity)
#define ROSTER(cab,name,funcmap...) #define ROSTER(cab,name,funcmap...)
#define ROUTE(id,description)
#define SENDLOCO(cab,route) #define SENDLOCO(cab,route)
#define SEQUENCE(id) #define SEQUENCE(id)
#define SERIAL(msg) #define SERIAL(msg)
@ -261,7 +272,8 @@
#define SPEED(speed) #define SPEED(speed)
#define START(route) #define START(route)
#define STOP #define STOP
#define THROW(id) #define THROW(id)
#define TT_ADDPOSITION(turntable_id,value,description)
#define TURNOUT(id,addr,subaddr,description...) #define TURNOUT(id,addr,subaddr,description...)
#define TURNOUTL(id,addr,description...) #define TURNOUTL(id,addr,description...)
#define UNJOIN #define UNJOIN

View File

@ -187,6 +187,30 @@ const FSH * RMFT2::getTurnoutDescription(int16_t turnoutid) {
return NULL; return NULL;
} }
// Pass to get turntable descriptions (optional)
#include "EXRAIL2MacroReset.h"
#undef DCC_TURNTABLE
#define DCC_TURNTABLE(id,description...) O_DESC(id,description)
#undef EXTT_TURNTABLE
#define EXTT_TURNTABLE(id,vpin,home,description...) O_DESC(id,description)
const FSH * RMFT2::getTurntableDescription(int16_t turntableId) {
switch (turntableId) {
#include "myAutomation.h"
default:break;
}
return NULL;
}
// Pass to get turntable position descriptions (optional)
// #include "EXRAIL2MacroReset.h"
// #undef TT_ADDPOSITION
// #define TT_ADDPOSITION(turntable_id,value,description...) 0_DESC(id,description)
// const FSH * RMFT2::getTurntablePositionDescription(int16_t turntableId, uint8_t positionId) {
// }
// Pass 6: Roster IDs (count) // Pass 6: Roster IDs (count)
#include "EXRAIL2MacroReset.h" #include "EXRAIL2MacroReset.h"
#undef ROSTER #undef ROSTER
@ -268,6 +292,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define BROADCAST(msg) PRINT(msg) #define BROADCAST(msg) PRINT(msg)
#define CALL(route) OPCODE_CALL,V(route), #define CALL(route) OPCODE_CALL,V(route),
#define CLOSE(id) OPCODE_CLOSE,V(id), #define CLOSE(id) OPCODE_CLOSE,V(id),
#define DCC_TURNTABLE(id,description...) OPCODE_DCCTURNTABLE,V(id),
#define DEACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1), #define DEACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1),
#define DEACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<1), #define DEACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<1),
#define DELAY(ms) ms<30000?OPCODE_DELAYMS:OPCODE_DELAY,V(ms/(ms<30000?1L:100L)), #define DELAY(ms) ms<30000?OPCODE_DELAYMS:OPCODE_DELAY,V(ms/(ms<30000?1L:100L)),
@ -281,7 +306,8 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define ENDIF OPCODE_ENDIF,0,0, #define ENDIF OPCODE_ENDIF,0,0,
#define ENDTASK OPCODE_ENDTASK,0,0, #define ENDTASK OPCODE_ENDTASK,0,0,
#define ESTOP OPCODE_SPEED,V(1), #define ESTOP OPCODE_SPEED,V(1),
#define EXRAIL #define EXRAIL
#define EXTT_TURNTABLE(id,vpin,home,description...) OPCODE_EXTTTURNTABLE,V(id),OPCODE_PAD,V(vpin),OPCODE_PAD,V(home),
#define FADE(pin,value,ms) OPCODE_SERVO,V(pin),OPCODE_PAD,V(value),OPCODE_PAD,V(PCA9685::ProfileType::UseDuration|PCA9685::NoPowerOff),OPCODE_PAD,V(ms/100L), #define FADE(pin,value,ms) OPCODE_SERVO,V(pin),OPCODE_PAD,V(value),OPCODE_PAD,V(PCA9685::ProfileType::UseDuration|PCA9685::NoPowerOff),OPCODE_PAD,V(ms/100L),
#define FOFF(func) OPCODE_FOFF,V(func), #define FOFF(func) OPCODE_FOFF,V(func),
#define FOLLOW(route) OPCODE_FOLLOW,V(route), #define FOLLOW(route) OPCODE_FOLLOW,V(route),
@ -304,6 +330,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define IFRESERVE(block) OPCODE_IFRESERVE,V(block), #define IFRESERVE(block) OPCODE_IFRESERVE,V(block),
#define IFTHROWN(turnout_id) OPCODE_IFTHROWN,V(turnout_id), #define IFTHROWN(turnout_id) OPCODE_IFTHROWN,V(turnout_id),
#define IFTIMEOUT OPCODE_IFTIMEOUT,0,0, #define IFTIMEOUT OPCODE_IFTIMEOUT,0,0,
#define IFTTPOSITION(id,position) OPCODE_IFTTPOSITION,V(id),OPCODE_PAD,V(position),
#define IFRE(sensor_id,value) OPCODE_IFRE,V(sensor_id),OPCODE_PAD,V(value), #define IFRE(sensor_id,value) OPCODE_IFRE,V(sensor_id),OPCODE_PAD,V(value),
#define INVERT_DIRECTION OPCODE_INVERT_DIRECTION,0,0, #define INVERT_DIRECTION OPCODE_INVERT_DIRECTION,0,0,
#define JOIN OPCODE_JOIN,0,0, #define JOIN OPCODE_JOIN,0,0,
@ -324,6 +351,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define ONDEACTIVATEL(linear) OPCODE_ONDEACTIVATE,V(linear+3), #define ONDEACTIVATEL(linear) OPCODE_ONDEACTIVATE,V(linear+3),
#define ONGREEN(signal_id) OPCODE_ONGREEN,V(signal_id), #define ONGREEN(signal_id) OPCODE_ONGREEN,V(signal_id),
#define ONRED(signal_id) OPCODE_ONRED,V(signal_id), #define ONRED(signal_id) OPCODE_ONRED,V(signal_id),
#define ONROTATE(id) OPCODE_ONROTATE,V(id),
#define ONTHROW(turnout_id) OPCODE_ONTHROW,V(turnout_id), #define ONTHROW(turnout_id) OPCODE_ONTHROW,V(turnout_id),
#define ONCHANGE(sensor_id) OPCODE_ONCHANGE,V(sensor_id), #define ONCHANGE(sensor_id) OPCODE_ONCHANGE,V(sensor_id),
#define PAUSE OPCODE_PAUSE,0,0, #define PAUSE OPCODE_PAUSE,0,0,
@ -343,6 +371,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define RETURN OPCODE_RETURN,0,0, #define RETURN OPCODE_RETURN,0,0,
#define REV(speed) OPCODE_REV,V(speed), #define REV(speed) OPCODE_REV,V(speed),
#define ROSTER(cabid,name,funcmap...) #define ROSTER(cabid,name,funcmap...)
#define ROTATE(id,position,activity) OPCODE_ROTATE,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(activity),
#define ROUTE(id, description) OPCODE_ROUTE, V(id), #define ROUTE(id, description) OPCODE_ROUTE, V(id),
#define SENDLOCO(cab,route) OPCODE_SENDLOCO,V(cab),OPCODE_PAD,V(route), #define SENDLOCO(cab,route) OPCODE_SENDLOCO,V(cab),OPCODE_PAD,V(route),
#define SEQUENCE(id) OPCODE_SEQUENCE, V(id), #define SEQUENCE(id) OPCODE_SEQUENCE, V(id),
@ -366,6 +395,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#define START(route) OPCODE_START,V(route), #define START(route) OPCODE_START,V(route),
#define STOP OPCODE_SPEED,V(0), #define STOP OPCODE_SPEED,V(0),
#define THROW(id) OPCODE_THROW,V(id), #define THROW(id) OPCODE_THROW,V(id),
#define TT_ADDPOSITION(id,value,description...) OPCODE_TTADDPOSITION,V(id),OPCODE_PAD,V(value),
#define TURNOUT(id,addr,subaddr,description...) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr), #define TURNOUT(id,addr,subaddr,description...) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr),
#define TURNOUTL(id,addr,description...) TURNOUT(id,(addr-1)/4+1,(addr-1)%4, description) #define TURNOUTL(id,addr,description...) TURNOUT(id,(addr-1)/4+1,(addr-1)%4, description)
#define UNJOIN OPCODE_UNJOIN,0,0, #define UNJOIN OPCODE_UNJOIN,0,0,

View File

@ -108,6 +108,13 @@ Turntable *Turntable::getByVpin(VPIN vpin) {
return nullptr; return nullptr;
} }
// Get the current position for turntable with the specified ID
uint8_t Turntable::getPosition(uint16_t id) {
Turntable *tto = get(id);
if (!tto) return false;
return tto->getPosition();
}
// Broadcast position changes // Broadcast position changes
bool Turntable::setPositionStateOnly(uint16_t id, uint8_t position, bool moving) { bool Turntable::setPositionStateOnly(uint16_t id, uint8_t position, bool moving) {
Turntable *tto = get(id); Turntable *tto = get(id);
@ -234,7 +241,10 @@ DCCTurntable::DCCTurntable(uint16_t id) : Turntable(id, TURNTABLE_DCC) {}
int16_t value = getPositionValue(position); int16_t value = getPositionValue(position);
if (position == 0 || !value) return false; // Return false if it's not a valid position if (position == 0 || !value) return false; // Return false if it's not a valid position
// Set position via device driver // Set position via device driver
// DCC activate function here int16_t addr=value>>3;
int16_t subaddr=(value>>1) & 0x03;
bool active=value & 0x01;
DCC::setAccessory(addr, subaddr, active);
#else #else
(void)position; (void)position;
#endif #endif

View File

@ -172,6 +172,7 @@ public:
inline static bool exists(uint16_t id) { return get(id) != 0; } 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 bool setPosition(uint16_t id, uint8_t position, uint8_t activity=0);
static bool setPositionStateOnly(uint16_t id, uint8_t position, bool moving); static bool setPositionStateOnly(uint16_t id, uint8_t position, bool moving);
static uint8_t getPosition(uint16_t id);
inline static Turntable *first() { return _firstTurntable; } inline static Turntable *first() { return _firstTurntable; }
static bool printAll(Print *stream) { static bool printAll(Print *stream) {
bool gotOne = false; bool gotOne = false;