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 #ifdef ARDUINO_ARCH_AVR
14 #include "Arduino.h"
15 
16 #include "DCCpp.h"
17 
18 #ifdef USE_TURNOUT
19 
20 struct TurnoutData {
21  byte tStatus;
22  byte subAddress;
23  int id;
24  int address;
25 };
26 
118 struct Turnout{
119  struct TurnoutData data;
127  void begin(int id, int add, int subAdd);
134  void set(int id, int add, int subAdd);
138  void activate(int s = 1);
141  inline void inactivate() { activate(0); }
145  inline bool isActivated() { return this->data.tStatus > 0; }
146 
147 #if defined(USE_EEPROM) || defined(USE_TEXTCOMMAND)
148  static Turnout *firstTurnout;
149  Turnout *nextTurnout;
155  static Turnout* get(int id);
160  static void remove(int id);
165  static int count();
166 
167 #ifdef DCCPP_PRINT_DCCPP
168 
171  static void show();
172 #endif
173 
174 #if defined(USE_EEPROM)
175  int eepromPos;
180  static void load();
184  static void store();
185 #endif
186 
187 #endif
188 
189 #if defined(USE_TEXTCOMMAND)
190 
194  static void parse(char *c);
202  static Turnout *create(int id, int add, int subAdd);
203 #endif
204 
205 }; // Turnout
206 
207 #endif
208 #endif
209 #endif