Skip to content

Commit

Permalink
Created <q ID> return for sensors
Browse files Browse the repository at this point in the history
Sensors now send a serial message of <Q ID> or <q ID> depending on
whether transition was from HIGH->LOW (triggered) or LOW->HIGH
(un-triggered) state.  For sensors to be used as one-shot detectors,
simp,y ignore the <q ID> messages.
  • Loading branch information
DccPlusPlus committed Nov 21, 2015
1 parent a670e37 commit a9cf8bc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions DCCpp_Uno/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ If you later make edits/additions/deletions to the sensor definitions, you must
new definitions updated in the EEPROM.
All sensors defined as per above are repeatedly and sequentially checked within the main loop of this sketch.
If a Sensor Pin is found to have transitioned from a HIGH state to a LOW state, the following serial message is generated:
If a Sensor Pin is found to have transitioned from one state to another, one of the following serial messages are generated:
<Q ID>
<Q ID> - for transition of Sensor ID from HIGH state to LOW state (i.e. the sensor is triggered)
<q ID> - for transition of Sensor ID from LOW state to HIGH state (i.e. the sensor is no longer triggered)
where ID is the ID of the Sensor that was triggered
No message is generated when a Sensor Pin transitions back to a HIGH state from a LOW state.
Depending on whether the physical sensor is acting as an "event-trigger" or a "detection-sensor," you may
decide to ignore the <q ID> return and only react to <Q ID> triggers.
**********************************************************************/

Expand All @@ -73,8 +73,11 @@ void Sensor::check(){
Serial.print("<Q");
Serial.print(tt->data.snum);
Serial.print(">");
} else if(tt->active && tt->signal>0.99){
} else if(tt->active && tt->signal>0.9){
tt->active=false;
Serial.print("<q");
Serial.print(tt->data.snum);
Serial.print(">");
}
} // loop over all sensors

Expand Down

0 comments on commit a9cf8bc

Please sign in to comment.