mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 01:52:48 +00:00
parent
deada41cee
commit
2ebfcea94e
@ -49,10 +49,16 @@ int32_t DetectionSensorModule::runOnce()
|
|||||||
|
|
||||||
// LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin));
|
// LOG_DEBUG("Detection Sensor Module: Current pin state: %i\n", digitalRead(moduleConfig.detection_sensor.monitor_pin));
|
||||||
|
|
||||||
if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) &&
|
if ((millis() - lastSentToMesh) >= Default::getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs)) {
|
||||||
hasDetectionEvent()) {
|
if (hasDetectionEvent()) {
|
||||||
sendDetectionMessage();
|
wasDetected = true;
|
||||||
return DELAYED_INTERVAL;
|
sendDetectionMessage();
|
||||||
|
return DELAYED_INTERVAL;
|
||||||
|
} else if (wasDetected) {
|
||||||
|
wasDetected = false;
|
||||||
|
sendCurrentStateMessage();
|
||||||
|
return DELAYED_INTERVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort
|
// Even if we haven't detected an event, broadcast our current state to the mesh on the scheduled interval as a sort
|
||||||
// of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state
|
// of heartbeat. We only do this if the minimum broadcast interval is greater than zero, otherwise we'll only broadcast state
|
||||||
|
@ -15,6 +15,7 @@ class DetectionSensorModule : public SinglePortModule, private concurrency::OSTh
|
|||||||
private:
|
private:
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
uint32_t lastSentToMesh = 0;
|
uint32_t lastSentToMesh = 0;
|
||||||
|
bool wasDetected = false;
|
||||||
void sendDetectionMessage();
|
void sendDetectionMessage();
|
||||||
void sendCurrentStateMessage();
|
void sendCurrentStateMessage();
|
||||||
bool hasDetectionEvent();
|
bool hasDetectionEvent();
|
||||||
|
Loading…
Reference in New Issue
Block a user