ESPHome  2024.11.0
tx20.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
6 
7 namespace esphome {
8 namespace tx20 {
9 
12  volatile uint16_t *buffer;
13  volatile uint32_t start_time;
14  volatile uint8_t buffer_index;
15  volatile uint32_t spent_time;
16  volatile bool tx20_available;
17  volatile bool pin_state;
19 
20  void reset();
21  static void gpio_intr(Tx20ComponentStore *arg);
22 };
23 
25 class Tx20Component : public Component {
26  public:
28  std::string get_wind_cardinal_direction() const;
29 
30  void set_pin(InternalGPIOPin *pin) { pin_ = pin; }
31  void set_wind_speed_sensor(sensor::Sensor *wind_speed_sensor) { wind_speed_sensor_ = wind_speed_sensor; }
32  void set_wind_direction_degrees_sensor(sensor::Sensor *wind_direction_degrees_sensor) {
33  wind_direction_degrees_sensor_ = wind_direction_degrees_sensor;
34  }
35 
36  void setup() override;
37  void dump_config() override;
38  float get_setup_priority() const override;
39  void loop() override;
40 
41  protected:
42  void decode_and_publish_();
43 
46  sensor::Sensor *wind_speed_sensor_{nullptr};
47  sensor::Sensor *wind_direction_degrees_sensor_{nullptr};
49 };
50 
51 } // namespace tx20
52 } // namespace esphome
void setup()
volatile uint8_t buffer_index
Definition: tx20.h:14
void loop()
InternalGPIOPin * pin_
Definition: tx20.h:45
volatile uint32_t spent_time
Definition: tx20.h:15
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition: gpio.h:66
static void gpio_intr(Tx20ComponentStore *arg)
Definition: tx20.cpp:145
This class implements support for the Tx20 Wind sensor.
Definition: tx20.h:25
volatile uint32_t start_time
Definition: tx20.h:13
void set_wind_speed_sensor(sensor::Sensor *wind_speed_sensor)
Definition: tx20.h:31
void set_wind_direction_degrees_sensor(sensor::Sensor *wind_direction_degrees_sensor)
Definition: tx20.h:32
ISRInternalGPIOPin pin
Definition: tx20.h:18
Store data in a class that doesn't use multiple-inheritance (vtables in flash)
Definition: tx20.h:11
volatile bool tx20_available
Definition: tx20.h:16
std::string wind_cardinal_direction_
Definition: tx20.h:44
volatile uint16_t * buffer
Definition: tx20.h:12
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_pin(InternalGPIOPin *pin)
Definition: tx20.h:30
Tx20ComponentStore store_
Definition: tx20.h:48
Base-class for all sensors.
Definition: sensor.h:57