Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions sensors/SensorInterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand All @@ -100,4 +110,4 @@ class SensorInterrupt: public Sensor {
};
#endif
};
#endif
#endif