ESPHome 2025.5.0
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "at581x.h"
7
8namespace esphome {
9namespace at581x {
10
11template<typename... Ts> class AT581XResetAction : public Action<Ts...>, public Parented<AT581XComponent> {
12 public:
13 void play(Ts... x) { this->parent_->reset_hardware_frontend(); }
14};
15
16template<typename... Ts> class AT581XSettingsAction : public Action<Ts...>, public Parented<AT581XComponent> {
17 public:
18 TEMPLATABLE_VALUE(int8_t, hw_frontend_reset)
20 TEMPLATABLE_VALUE(int, sensing_distance)
21 TEMPLATABLE_VALUE(int, poweron_selfcheck_time)
22 TEMPLATABLE_VALUE(int, power_consumption)
23 TEMPLATABLE_VALUE(int, protect_time)
24 TEMPLATABLE_VALUE(int, trigger_base)
25 TEMPLATABLE_VALUE(int, trigger_keep)
26 TEMPLATABLE_VALUE(int, stage_gain)
27
28 void play(Ts... x) {
29 if (this->frequency_.has_value()) {
30 int v = this->frequency_.value(x...);
31 this->parent_->set_frequency(v);
32 }
33 if (this->sensing_distance_.has_value()) {
34 int v = this->sensing_distance_.value(x...);
35 this->parent_->set_sensing_distance(v);
36 }
37 if (this->poweron_selfcheck_time_.has_value()) {
38 int v = this->poweron_selfcheck_time_.value(x...);
39 this->parent_->set_poweron_selfcheck_time(v);
40 }
41 if (this->power_consumption_.has_value()) {
42 int v = this->power_consumption_.value(x...);
43 this->parent_->set_power_consumption(v);
44 }
45 if (this->protect_time_.has_value()) {
46 int v = this->protect_time_.value(x...);
47 this->parent_->set_protect_time(v);
48 }
49 if (this->trigger_base_.has_value()) {
50 int v = this->trigger_base_.value(x...);
51 this->parent_->set_trigger_base(v);
52 }
53 if (this->trigger_keep_.has_value()) {
54 int v = this->trigger_keep_.value(x...);
55 this->parent_->set_trigger_keep(v);
56 }
57 if (this->stage_gain_.has_value()) {
58 int v = this->stage_gain_.value(x...);
59 this->parent_->set_stage_gain(v);
60 }
61
62 // This actually perform all the modification on the system
63 this->parent_->i2c_write_config();
64
65 if (this->hw_frontend_reset_.has_value() && this->hw_frontend_reset_.value(x...) == true) {
66 this->parent_->reset_hardware_frontend();
67 }
68 }
69};
70} // namespace at581x
71} // namespace esphome
uint16_le_t frequency
Definition bl0942.h:6
virtual void play(Ts... x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:538
TEMPLATABLE_VALUE(int8_t, hw_frontend_reset) TEMPLATABLE_VALUE(int
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5