mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
virtual turnout activate
This commit is contained in:
parent
cc0821520e
commit
7c68a9de70
13
Turnouts.cpp
13
Turnouts.cpp
|
@ -2,16 +2,19 @@
|
|||
#include "EEStore.h"
|
||||
#include "StringFormatter.h"
|
||||
|
||||
bool Turnout::activate(int n,bool state){
|
||||
bool Turnout::activate(int n,bool state){
|
||||
Turnout * tt=get(n);
|
||||
if (tt==NULL) return false;
|
||||
tt->data.tStatus=state;
|
||||
DCC::setAccessory(tt->data.address, tt->data.subAddress, tt->data.tStatus);
|
||||
if(n>0)
|
||||
EEPROM.put(n,tt->data.tStatus);
|
||||
tt->activate(state);
|
||||
if(n>0) EEPROM.put(n,tt->data.tStatus);
|
||||
return true;
|
||||
}
|
||||
|
||||
// activate is virtual here so that it can be overridden by a non-DCC turnout mechanism
|
||||
void Turnout::activate(bool state) {
|
||||
data.tStatus=state;
|
||||
DCC::setAccessory(data.address,data.subAddress, data.tStatus);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Turnout* Turnout::get(int n){
|
||||
|
|
|
@ -24,6 +24,7 @@ struct Turnout{
|
|||
static Turnout *create(int, int, int);
|
||||
static void show(Print & stream, int n);
|
||||
static bool showAll(Print & stream);
|
||||
virtual void activate(bool state);
|
||||
}; // Turnout
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user