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;
118  boolean active;
119  float signal;
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
static Sensor * create(int snum, int pin, int pullUp)
Definition: Sensor.cpp:281
static void parse(char *c)
Definition: Sensor.cpp:249
static void store()
Definition: Sensor.cpp:227
static void check()
Definition: Sensor.cpp:120
static int count()
Definition: Sensor.cpp:110
static void load()
Definition: Sensor.cpp:200
void begin(int snum, int pin, int pullUp)
Definition: Sensor.cpp:24
Sensor * nextSensor
Definition: Sensor.h:120
float signal
Definition: Sensor.h:119
boolean active
Definition: Sensor.h:118
SensorData data
Definition: Sensor.h:117
static Sensor * firstSensor
Definition: Sensor.h:116
Definition: Sensor.h:115
byte pullUp
Definition: Sensor.h:24
byte pin
Definition: Sensor.h:23
int snum
Definition: Sensor.h:22
boolean isActive()
Definition: Sensor.h:158