ESPHome  2024.12.2
gcja5.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace gcja5 {
9 
10 class GCJA5Component : public Component, public uart::UARTDevice {
11  public:
12  void setup() override;
13  void dump_config() override;
14  void loop() override;
15  float get_setup_priority() const override { return setup_priority::DATA; }
16 
17  void set_pm_1_0_sensor(sensor::Sensor *pm_1_0) { pm_1_0_sensor_ = pm_1_0; }
18  void set_pm_2_5_sensor(sensor::Sensor *pm_2_5) { pm_2_5_sensor_ = pm_2_5; }
19  void set_pm_10_0_sensor(sensor::Sensor *pm_10_0) { pm_10_0_sensor_ = pm_10_0; }
20 
21  void set_pmc_0_3_sensor(sensor::Sensor *pmc_0_3) { pmc_0_3_sensor_ = pmc_0_3; }
22  void set_pmc_0_5_sensor(sensor::Sensor *pmc_0_5) { pmc_0_5_sensor_ = pmc_0_5; }
23  void set_pmc_1_0_sensor(sensor::Sensor *pmc_1_0) { pmc_1_0_sensor_ = pmc_1_0; }
24  void set_pmc_2_5_sensor(sensor::Sensor *pmc_2_5) { pmc_2_5_sensor_ = pmc_2_5; }
25  void set_pmc_5_0_sensor(sensor::Sensor *pmc_5_0) { pmc_5_0_sensor_ = pmc_5_0; }
26  void set_pmc_10_0_sensor(sensor::Sensor *pmc_10_0) { pmc_10_0_sensor_ = pmc_10_0; }
27 
28  protected:
29  void parse_data_();
30  bool calculate_checksum_();
31 
32  uint32_t get_32_bit_uint_(uint8_t start_index);
33  uint16_t get_16_bit_uint_(uint8_t start_index);
34  uint32_t last_transmission_{0};
35  std::vector<uint8_t> rx_message_;
36 
37  bool have_good_data_{false};
38  bool first_status_log_{false};
42 
49 };
50 
51 } // namespace gcja5
52 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_pmc_2_5_sensor(sensor::Sensor *pmc_2_5)
Definition: gcja5.h:24
void set_pmc_5_0_sensor(sensor::Sensor *pmc_5_0)
Definition: gcja5.h:25
float get_setup_priority() const override
Definition: gcja5.h:15
sensor::Sensor * pmc_2_5_sensor_
Definition: gcja5.h:46
sensor::Sensor * pmc_10_0_sensor_
Definition: gcja5.h:48
uint32_t get_32_bit_uint_(uint8_t start_index)
Definition: gcja5.cpp:80
void set_pm_2_5_sensor(sensor::Sensor *pm_2_5)
Definition: gcja5.h:18
void set_pmc_0_3_sensor(sensor::Sensor *pmc_0_3)
Definition: gcja5.h:21
uint16_t get_16_bit_uint_(uint8_t start_index)
Definition: gcja5.cpp:86
void setup() override
Definition: gcja5.cpp:16
sensor::Sensor * pmc_5_0_sensor_
Definition: gcja5.h:47
void set_pm_10_0_sensor(sensor::Sensor *pm_10_0)
Definition: gcja5.h:19
sensor::Sensor * pm_1_0_sensor_
Definition: gcja5.h:39
void set_pmc_1_0_sensor(sensor::Sensor *pmc_1_0)
Definition: gcja5.h:23
void loop() override
Definition: gcja5.cpp:18
void dump_config() override
Definition: gcja5.cpp:116
void set_pmc_10_0_sensor(sensor::Sensor *pmc_10_0)
Definition: gcja5.h:26
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_pm_1_0_sensor(sensor::Sensor *pm_1_0)
Definition: gcja5.h:17
std::vector< uint8_t > rx_message_
Definition: gcja5.h:35
sensor::Sensor * pmc_1_0_sensor_
Definition: gcja5.h:45
Base-class for all sensors.
Definition: sensor.h:57
void set_pmc_0_5_sensor(sensor::Sensor *pmc_0_5)
Definition: gcja5.h:22
sensor::Sensor * pm_2_5_sensor_
Definition: gcja5.h:40
sensor::Sensor * pmc_0_3_sensor_
Definition: gcja5.h:43
sensor::Sensor * pmc_0_5_sensor_
Definition: gcja5.h:44
sensor::Sensor * pm_10_0_sensor_
Definition: gcja5.h:41