18 #include "DCCpp_Uno.h" 28 #if defined(USE_EEPROM) && defined(DCCPP_DEBUG_MODE) 29 if (strncmp(
EEStore::data.
id, EESTORE_ID,
sizeof(EESTORE_ID)) != 0) {
30 DCCPP_INTERFACE.println(F(
"Sensor::begin() must be called BEFORE DCCpp.begin() !"));
37 else if (
get(snum) == NULL) {
44 this->
set(snum, pin, pullUp);
46 #ifdef USE_TEXTCOMMAND 47 DCCPP_INTERFACE.print(
"<O>");
48 #if !defined(USE_ETHERNET) 49 DCCPP_INTERFACE.println(
"");
59 this->
data.
pullUp = (pullUp == 0 ? LOW : HIGH);
63 dontCheckNextPinAccess =
true;
65 digitalWrite(pin, pullUp);
67 dontCheckNextPinAccess =
true;
87 #ifdef USE_TEXTCOMMAND 88 DCCPP_INTERFACE.print(
"<X>");
89 #if !defined(USE_ETHERNET) 90 DCCPP_INTERFACE.println(
"");
103 #ifdef USE_TEXTCOMMAND 104 DCCPP_INTERFACE.print(
"<O>");
105 #if !defined(USE_ETHERNET) 106 DCCPP_INTERFACE.println(
"");
127 tt->
signal = (float)(tt->
signal * (1.0 - SENSOR_DECAY) + digitalRead(tt->
data.
pin) * SENSOR_DECAY);
131 DCCPP_INTERFACE.print(
"<Q");
132 DCCPP_INTERFACE.print(tt->
data.
snum);
133 DCCPP_INTERFACE.print(
">");
134 #if !defined(USE_ETHERNET) 135 DCCPP_INTERFACE.println(
"");
139 DCCPP_INTERFACE.print(
"<q");
140 DCCPP_INTERFACE.print(tt->
data.
snum);
141 DCCPP_INTERFACE.print(
">");
142 #if !defined(USE_ETHERNET) 143 DCCPP_INTERFACE.println(
"");
150 #ifdef DCCPP_PRINT_DCCPP 157 DCCPP_INTERFACE.print(
"<X>");
158 #if !defined(USE_ETHERNET) 159 DCCPP_INTERFACE.println(
"");
165 DCCPP_INTERFACE.print(
"<Q");
166 DCCPP_INTERFACE.print(tt->
data.
snum);
167 DCCPP_INTERFACE.print(
" ");
168 DCCPP_INTERFACE.print(tt->
data.
pin);
169 DCCPP_INTERFACE.print(
" ");
171 DCCPP_INTERFACE.print(
">");
172 #if !defined(USE_ETHERNET) 173 DCCPP_INTERFACE.println(
"");
184 DCCPP_INTERFACE.print(
"<X>");
185 #if !defined(USE_ETHERNET) 186 DCCPP_INTERFACE.println(
"");
192 DCCPP_INTERFACE.print(tt->
active ?
"<Q" :
"<q");
193 DCCPP_INTERFACE.print(tt->
data.
snum);
194 DCCPP_INTERFACE.print(
">");
195 #if !defined(USE_ETHERNET) 196 DCCPP_INTERFACE.println(
"");
216 #if defined(USE_TEXTCOMMAND) 220 #ifdef DCCPP_DEBUG_MODE 222 DCCPP_INTERFACE.println(F(
"Sensor::begin() must be called BEFORE Sensor::load() !"));
252 #if defined(USE_TEXTCOMMAND) 259 switch (sscanf(c,
"%d %d %d", &n, &s, &m)) {
269 #ifdef DCCPP_PRINT_DCCPP 274 #ifdef USE_TEXTCOMMAND 276 DCCPP_INTERFACE.print(
"<X>");
277 #if !defined(USE_ETHERNET) 278 DCCPP_INTERFACE.println(
"");
292 #ifdef USE_TEXTCOMMAND 293 DCCPP_INTERFACE.print(
"<X>");
294 #if !defined(USE_ETHERNET) 295 DCCPP_INTERFACE.println(
"");
static bool parse(char *c)
static void advance(int inIncrement)
static Sensor * create(int snum, int pin, int pullUp)
static void remove(int snum)
void set(int snum, int pin, int pullUp)
static Sensor * get(int snum)
static Sensor * firstSensor
void begin(int snum, int pin, int pullUp)