diff --git a/sensors/SensorInterrupt.h b/sensors/SensorInterrupt.h index a5e03a0c..8f5ab3c6 100644 --- a/sensors/SensorInterrupt.h +++ b/sensors/SensorInterrupt.h @@ -41,14 +41,14 @@ class SensorInterrupt: public Sensor { setInterruptMode(CHANGE); }; - // [105] Invert the value to report. E.g. if FALLING and value is LOW, report HIGH (default: false) + // [105] Invert the value to report. E.g. if FALLING and value is LOW, report HIGH (default: false) void setInvertValueToReport(bool value) { _invert_value_to_report = value; }; #if NODEMANAGER_TIME == ON // [107] when keeping track of the time, trigger only after X consecutive interrupts within the same minute (default: 1) void setThreshold(int value) { - _threshold = value; + _threshold = value; }; #endif @@ -90,6 +90,16 @@ class SensorInterrupt: public Sensor { child->setValue(value); }; + void onLoop(Child* child) { + // read the value + int value = digitalRead(_pin); + // invert the value if needed + if (_invert_value_to_report) value = !value; + // store the value + child->setValue(value); + }; + + #if NODEMANAGER_OTA_CONFIGURATION == ON // define what to do when receiving an OTA configuration request void onOTAConfiguration(ConfigurationRequest* request) { @@ -100,4 +110,4 @@ class SensorInterrupt: public Sensor { }; #endif }; -#endif \ No newline at end of file +#endif