1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +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 "EEStore.h"
#include "StringFormatter.h" #include "StringFormatter.h"
bool Turnout::activate(int n,bool state){ bool Turnout::activate(int n,bool state){
Turnout * tt=get(n); Turnout * tt=get(n);
if (tt==NULL) return false; if (tt==NULL) return false;
tt->data.tStatus=state; tt->activate(state);
DCC::setAccessory(tt->data.address, tt->data.subAddress, tt->data.tStatus); if(n>0) EEPROM.put(n,tt->data.tStatus);
if(n>0)
EEPROM.put(n,tt->data.tStatus);
return true; 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){ Turnout* Turnout::get(int n){

View File

@ -24,6 +24,7 @@ struct Turnout{
static Turnout *create(int, int, int); static Turnout *create(int, int, int);
static void show(Print & stream, int n); static void show(Print & stream, int n);
static bool showAll(Print & stream); static bool showAll(Print & stream);
virtual void activate(bool state);
}; // Turnout }; // Turnout
#endif #endif