DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Sensor.h
1 /**********************************************************************
2 
3 Sensor.h
4 COPYRIGHT (c) 2013-2016 Gregg E. Berman
5 
6 Part of DCC++ BASE STATION for the Arduino
7 
8 **********************************************************************/
9 
10 #ifndef Sensor_h
11 #define Sensor_h
12 
13 #include "DCCpp.h"
14 
15 #ifdef USE_SENSOR
16 #include "Arduino.h"
17 
18 #define SENSOR_DECAY 0.03
19 
21 struct SensorData {
22  int snum;
23  byte pin;
24  byte pullUp;
25 };
26 
115 struct Sensor{
116  static Sensor *firstSensor;
117  SensorData data;
118  boolean active;
119  float signal;
120  Sensor *nextSensor;
128  void begin(int snum, int pin, int pullUp);
135  void set(int snum, int pin, int pullUp);
141  static Sensor* get(int snum);
146  static void remove(int snum);
151  static int count();
154  static void check();
158  boolean isActive() { return this->active; }
159 
160 #ifdef DCCPP_PRINT_DCCPP
161 
164  static void show();
168  static void status();
169 #endif
170 
171 #ifdef USE_EEPROM
172 
175  static void load();
179  static void store();
180 #endif
181 
182 #if defined(USE_TEXTCOMMAND)
183 
187  static void parse(char *c);
195  static Sensor *create(int snum, int pin, int pullUp);
196 #endif
197 }; // Sensor
198 
199 #endif
200 
201 #endif