ESPHome 2025.7.1
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace sx126x {
9
10template<typename... Ts> class RunImageCalAction : public Action<Ts...>, public Parented<SX126x> {
11 public:
12 void play(Ts... x) override { this->parent_->run_image_cal(); }
13};
14
15template<typename... Ts> class SendPacketAction : public Action<Ts...>, public Parented<SX126x> {
16 public:
17 void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func) {
18 this->data_func_ = func;
19 this->static_ = false;
20 }
21
22 void set_data_static(const std::vector<uint8_t> &data) {
23 this->data_static_ = data;
24 this->static_ = true;
25 }
26
27 void play(Ts... x) override {
28 if (this->static_) {
29 this->parent_->transmit_packet(this->data_static_);
30 } else {
31 this->parent_->transmit_packet(this->data_func_(x...));
32 }
33 }
34
35 protected:
36 bool static_{false};
37 std::function<std::vector<uint8_t>(Ts...)> data_func_{};
38 std::vector<uint8_t> data_static_{};
39};
40
41template<typename... Ts> class SetModeTxAction : public Action<Ts...>, public Parented<SX126x> {
42 public:
43 void play(Ts... x) override { this->parent_->set_mode_tx(); }
44};
45
46template<typename... Ts> class SetModeRxAction : public Action<Ts...>, public Parented<SX126x> {
47 public:
48 void play(Ts... x) override { this->parent_->set_mode_rx(); }
49};
50
51template<typename... Ts> class SetModeSleepAction : public Action<Ts...>, public Parented<SX126x> {
52 public:
53 void play(Ts... x) override { this->parent_->set_mode_sleep(); }
54};
55
56template<typename... Ts> class SetModeStandbyAction : public Action<Ts...>, public Parented<SX126x> {
57 public:
58 void play(Ts... x) override { this->parent_->set_mode_standby(STDBY_XOSC); }
59};
60
61} // namespace sx126x
62} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:599
void play(Ts... x) override
Definition automation.h:12
std::vector< uint8_t > data_static_
Definition automation.h:38
void play(Ts... x) override
Definition automation.h:27
void set_data_static(const std::vector< uint8_t > &data)
Definition automation.h:22
void set_data_template(std::function< std::vector< uint8_t >(Ts...)> func)
Definition automation.h:17
std::function< std::vector< uint8_t >(Ts...)> data_func_
Definition automation.h:37
void play(Ts... x) override
Definition automation.h:48
void play(Ts... x) override
Definition automation.h:53
void play(Ts... x) override
Definition automation.h:43
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5