mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 02:32:09 +00:00
Fix thread to use getConfiguredOrDefaultMs (#2727)
* WIP * Updates * Move it out of the macro guard so portduino can build * Changes from feedback * Use minimum_broadcast_secs as interval if we just broadcasted to avoid wasting cpu cycles * Fmt * Merge conflict resolution boogered me up * Missed a spot * getConfiguredOrDefaultMs * Get the minimum interval
This commit is contained in:
parent
5d76771fab
commit
929b8f6209
@ -46,7 +46,10 @@ int32_t DetectionSensorModule::runOnce()
|
|||||||
if ((millis() - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) &&
|
if ((millis() - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs) &&
|
||||||
hasDetectionEvent()) {
|
hasDetectionEvent()) {
|
||||||
sendDetectionMessage();
|
sendDetectionMessage();
|
||||||
return moduleConfig.detection_sensor.minimum_broadcast_secs;
|
return getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs <
|
||||||
|
moduleConfig.detection_sensor.state_broadcast_secs
|
||||||
|
? moduleConfig.detection_sensor.minimum_broadcast_secs
|
||||||
|
: moduleConfig.detection_sensor.state_broadcast_secs);
|
||||||
}
|
}
|
||||||
// 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
|
||||||
@ -54,7 +57,10 @@ int32_t DetectionSensorModule::runOnce()
|
|||||||
else if (moduleConfig.detection_sensor.state_broadcast_secs > 0 &&
|
else if (moduleConfig.detection_sensor.state_broadcast_secs > 0 &&
|
||||||
(millis() - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.detection_sensor.state_broadcast_secs)) {
|
(millis() - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.detection_sensor.state_broadcast_secs)) {
|
||||||
sendCurrentStateMessage();
|
sendCurrentStateMessage();
|
||||||
return moduleConfig.detection_sensor.minimum_broadcast_secs;
|
return getConfiguredOrDefaultMs(moduleConfig.detection_sensor.minimum_broadcast_secs <
|
||||||
|
moduleConfig.detection_sensor.state_broadcast_secs
|
||||||
|
? moduleConfig.detection_sensor.minimum_broadcast_secs
|
||||||
|
: moduleConfig.detection_sensor.state_broadcast_secs);
|
||||||
}
|
}
|
||||||
return GPIO_POLLING_INTERVAL;
|
return GPIO_POLLING_INTERVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user