ESPHome  2024.10.2
at581x.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
6 #include "esphome/core/hal.h"
7 #include "esphome/core/defines.h"
8 #ifdef USE_SWITCH
10 #endif
12 
13 namespace esphome {
14 namespace at581x {
15 
16 class AT581XComponent : public Component, public i2c::I2CDevice {
17 #ifdef USE_SWITCH
18  protected:
20 
21  public:
23  this->rf_power_switch_ = s;
24  s->turn_on();
25  }
26 #endif
27 
28  void setup() override;
29  void dump_config() override;
30  // float get_setup_priority() const override;
31 
32  void set_sensing_distance(int distance) { this->delta_ = 1023 - distance; }
33 
34  void set_rf_mode(bool enabled);
35  void set_frequency(int frequency) { this->freq_ = frequency; }
36  void set_poweron_selfcheck_time(int value) { this->self_check_time_ms_ = value; }
37  void set_protect_time(int value) { this->protect_time_ms_ = value; }
38  void set_trigger_base(int value) { this->trigger_base_time_ms_ = value; }
39  void set_trigger_keep(int value) { this->trigger_keep_time_ms_ = value; }
40  void set_stage_gain(int value) { this->gain_ = value; }
41  void set_power_consumption(int value) { this->power_ = value; }
42 
43  bool i2c_write_config();
45  bool i2c_write_reg(uint8_t addr, uint8_t data);
46  bool i2c_write_reg(uint8_t addr, uint32_t data);
47  bool i2c_write_reg(uint8_t addr, uint16_t data);
48  bool i2c_read_reg(uint8_t addr, uint8_t &data);
49 
50  protected:
51  int freq_;
56  int delta_;
57  int gain_;
58  int power_;
59 };
60 
61 } // namespace at581x
62 } // namespace esphome
bool i2c_read_reg(uint8_t addr, uint8_t &data)
Definition: at581x.cpp:70
Base class for all switches.
Definition: switch.h:39
void dump_config() override
Definition: at581x.cpp:75
bool i2c_write_reg(uint8_t addr, uint8_t data)
Definition: at581x.cpp:57
void set_rf_mode(bool enabled)
Definition: at581x.cpp:184
switch_::Switch * rf_power_switch_
Definition: at581x.h:19
void set_sensing_distance(int distance)
Definition: at581x.h:32
void set_trigger_base(int value)
Definition: at581x.h:38
void set_stage_gain(int value)
Definition: at581x.h:40
void set_trigger_keep(int value)
Definition: at581x.h:39
void turn_on()
Turn this switch on.
Definition: switch.cpp:11
void set_frequency(int frequency)
Definition: at581x.h:35
uint16_le_t frequency
Definition: bl0942.h:72
void set_rf_power_switch(switch_::Switch *s)
Definition: at581x.h:22
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_power_consumption(int value)
Definition: at581x.h:41
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
void set_protect_time(int value)
Definition: at581x.h:37
void set_poweron_selfcheck_time(int value)
Definition: at581x.h:36