diff --git a/Turnouts.cpp b/Turnouts.cpp index a8bbaff..7754a21 100644 --- a/Turnouts.cpp +++ b/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){ diff --git a/Turnouts.h b/Turnouts.h index 39a67e7..8152c36 100644 --- a/Turnouts.h +++ b/Turnouts.h @@ -16,7 +16,7 @@ struct Turnout{ int num; struct TurnoutData data; Turnout *nextTurnout; - static bool activate(int n, bool state); + static bool activate(int n, bool state); static Turnout* get(int); static bool remove(int); static void load(); @@ -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