From a9cf8bc8e1ad450f1e7542165268f25ce544a788 Mon Sep 17 00:00:00 2001 From: DccPlusPlus Date: Sat, 21 Nov 2015 15:12:17 -0500 Subject: [PATCH] Created return for sensors Sensors now send a serial message of or 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 messages. --- DCCpp_Uno/Sensor.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/DCCpp_Uno/Sensor.cpp b/DCCpp_Uno/Sensor.cpp index 723cb38..cf21c61 100644 --- a/DCCpp_Uno/Sensor.cpp +++ b/DCCpp_Uno/Sensor.cpp @@ -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: - + - for transition of Sensor ID from HIGH state to LOW state (i.e. the sensor is triggered) + - 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 return and only react to triggers. **********************************************************************/ @@ -73,8 +73,11 @@ void Sensor::check(){ Serial.print("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("data.snum); + Serial.print(">"); } } // loop over all sensors