Make the pulse meter timeout on startup when no pulses are received (#5388)

This commit is contained in:
Trent Houliston
2023-09-21 08:04:03 +10:00
committed by GitHub
parent 157a3e53dd
commit 2c2821cd96
2 changed files with 27 additions and 11 deletions
@@ -38,7 +38,8 @@ class PulseMeterSensor : public sensor::Sensor, public Component {
InternalFilterMode filter_mode_{FILTER_EDGE};
// Variables used in the loop
bool initialized_ = false;
enum class MeterState { INITIAL, RUNNING, TIMED_OUT };
MeterState meter_state_ = MeterState::INITIAL;
uint32_t total_pulses_ = 0;
uint32_t last_processed_edge_us_ = 0;