1
0
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:
Asbelos 2020-06-22 11:58:33 +01:00
parent cc0821520e
commit 7c68a9de70
2 changed files with 10 additions and 6 deletions

View File

@ -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){

View File

@ -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