ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
lightwaverf.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP8266
4
6#include "esphome/core/hal.h"
8
9#include <vector>
10
11#include "LwRx.h"
12#include "LwTx.h"
13
14namespace esphome::lightwaverf {
15
16#ifdef USE_ESP8266
17
19 public:
20 void set_pin(InternalGPIOPin *pin_tx, InternalGPIOPin *pin_rx) {
21 pin_tx_ = pin_tx;
22 pin_rx_ = pin_rx;
23 }
24 void update() override;
25 void setup() override;
26 void dump_config() override;
27 void read_tx();
28 void send_rx(const std::vector<uint8_t> &msg, uint8_t repeats, bool inverted, int u_sec);
29
30 protected:
31 void print_msg_(uint8_t *msg, uint8_t len);
32 uint8_t msg_[10];
33 uint8_t msglen_ = 10;
38};
39
40template<typename... Ts> class SendRawAction : public Action<Ts...> {
41 public:
42 SendRawAction(LightWaveRF *parent) : parent_(parent){};
43 TEMPLATABLE_VALUE(int, repeat);
44 TEMPLATABLE_VALUE(int, inverted);
45 TEMPLATABLE_VALUE(int, pulse_length);
46 TEMPLATABLE_VALUE(std::vector<uint8_t>, code);
47 void set_code(std::initializer_list<uint8_t> data) { this->code_ = std::vector<uint8_t>(data); }
48
49 void play(const Ts &...x) {
50 int repeats = this->repeat_.value(x...);
51 int inverted = this->inverted_.value(x...);
52 int pulse_length = this->pulse_length_.value(x...);
53 std::vector<uint8_t> msg = this->code_.value(x...);
54
55 this->parent_->send_rx(msg, repeats, inverted, pulse_length);
56 }
57
58 protected:
60};
61
62#endif
63} // namespace esphome::lightwaverf
64#endif
This class simplifies creating components that periodically check a state.
Definition component.h:602
void set_pin(InternalGPIOPin *pin_tx, InternalGPIOPin *pin_rx)
Definition lightwaverf.h:20
void print_msg_(uint8_t *msg, uint8_t len)
void send_rx(const std::vector< uint8_t > &msg, uint8_t repeats, bool inverted, int u_sec)
TEMPLATABLE_VALUE(std::vector< uint8_t >, code)
void set_code(std::initializer_list< uint8_t > data)
Definition lightwaverf.h:47
SendRawAction(LightWaveRF *parent)
Definition lightwaverf.h:42
TEMPLATABLE_VALUE(int, pulse_length)
std::string size_t len
uint16_t x
Definition tt21100.cpp:5