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 
19 struct TurnoutData {
20  byte tStatus;
21  byte subAddress;
22  int id;
23  int address;
24 };
25 
117 struct Turnout{
118  struct TurnoutData data;
126  void begin(int id, int add, int subAdd);
133  void set(int id, int add, int subAdd);
137  void activate(int s = 1);
140  inline void inactivate() { activate(0); }
144  inline bool isActivated() { return this->data.tStatus > 0; }
145 
146 #if defined(USE_EEPROM) || defined(USE_TEXTCOMMAND)
147  static Turnout *firstTurnout;
148  Turnout *nextTurnout;
154  static Turnout* get(int id);
159  static void remove(int id);
164  static int count();
165 
166 #ifdef DCCPP_PRINT_DCCPP
167 
170  static void show();
171 #endif
172 
173 #if defined(USE_EEPROM)
174  int eepromPos;
179  static void load();
183  static void store();
184 #endif
185 
186 #endif
187 
188 #if defined(USE_TEXTCOMMAND)
189 
193  static void parse(char *c);
201  static Turnout *create(int id, int add, int subAdd);
202 #endif
203 
204 }; // Turnout
205 
206 #endif
207 #endif
208 
209