DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Turnout.h
1 /**********************************************************************
2 
3 Turnout.h renamed from Accessories.h
4 COPYRIGHT (c) 2013-2016 Gregg E. Berman
5 
6 Part of DCC++ BASE STATION for the Arduino
7 
8 **********************************************************************/
9 
10 #ifndef Turnout_h
11 #define Turnout_h
12 
13 #include "DCCpp.h"
14 
15 #ifdef USE_TURNOUT
16 #include "Arduino.h"
17 
18 struct TurnoutData {
19  byte tStatus;
20  byte subAddress;
21  int id;
22  int address;
23 };
24 
98 struct Turnout{
99  struct TurnoutData data;
100 
101  void begin(int id, int add, int subAdd);
102  void set(int id, int add, int subAdd);
103  void activate(int s = 1);
104  inline void inactivate() { activate(0); }
105  inline bool isActivated() { return this->data.tStatus > 0; }
106 
107 #if defined(USE_EEPROM) || defined(USE_TEXTCOMMAND)
108  static Turnout *firstTurnout;
109  Turnout *nextTurnout;
110  static Turnout* get(int id);
111  static void remove(int id);
112  static int count();
113 
114 #ifdef DCCPP_PRINT_DCCPP
115  static void show();
116 #endif
117 
118 #if defined(USE_EEPROM)
119  int eepromPos;
120 
121  static void load();
122  static void store();
123 #endif
124 
125 #endif
126 
127 #if defined(USE_TEXTCOMMAND)
128  static void parse(char *c);
129  static Turnout *create(int id, int add, int subAdd);
130 #endif
131 
132 }; // Turnout
133 
134 #endif
135 #endif
136 
137