mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-13 16:13:32 +02:00
Fix broken PULSE_METER (#4199)
fixes https://github.com/esphome/issues/issues/3730
This commit is contained in:
@@ -29,7 +29,11 @@ class PulseMeterSensor : public sensor::Sensor, public Component {
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
enum StateChange { TO_LOW = 0, TO_HIGH, NONE };
|
||||
|
||||
static void gpio_intr(PulseMeterSensor *sensor);
|
||||
void handle_state_change_(uint32_t now, uint32_t last_detected_edge_us, uint32_t last_valid_edge_us,
|
||||
bool has_valid_edge);
|
||||
|
||||
InternalGPIOPin *pin_{nullptr};
|
||||
ISRInternalGPIOPin isr_pin_;
|
||||
@@ -42,14 +46,12 @@ class PulseMeterSensor : public sensor::Sensor, public Component {
|
||||
Deduplicator<uint32_t> total_dedupe_;
|
||||
|
||||
volatile uint32_t last_detected_edge_us_ = 0;
|
||||
volatile uint32_t last_valid_high_edge_us_ = 0;
|
||||
volatile uint32_t last_valid_low_edge_us_ = 0;
|
||||
volatile uint32_t last_valid_edge_us_ = 0;
|
||||
volatile uint32_t pulse_width_us_ = 0;
|
||||
volatile uint32_t total_pulses_ = 0;
|
||||
volatile bool sensor_is_high_ = false;
|
||||
volatile bool has_detected_edge_ = false;
|
||||
volatile bool has_valid_high_edge_ = false;
|
||||
volatile bool has_valid_low_edge_ = false;
|
||||
volatile bool has_valid_edge_ = false;
|
||||
volatile StateChange pending_state_change_{NONE};
|
||||
};
|
||||
|
||||
} // namespace pulse_meter
|
||||
|
||||
Reference in New Issue
Block a user