ESPHome  2024.6.1
pronto_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "remote_base.h"
5 
6 #include <vector>
7 
8 namespace esphome {
9 namespace remote_base {
10 
11 std::vector<uint16_t> encode_pronto(const std::string &str);
12 
13 struct ProntoData {
14  std::string data;
15  int delta;
16 
17  bool operator==(const ProntoData &rhs) const;
18 };
19 
20 class ProntoProtocol : public RemoteProtocol<ProntoData> {
21  private:
22  void send_pronto_(RemoteTransmitData *dst, const std::vector<uint16_t> &data);
23  void send_pronto_(RemoteTransmitData *dst, const std::string &str);
24 
25  uint16_t effective_frequency_(uint16_t frequency);
26  uint16_t to_timebase_(uint16_t frequency);
27  uint16_t to_frequency_code_(uint16_t frequency);
28  std::string dump_digit_(uint8_t x);
29  std::string dump_number_(uint16_t number, bool end = false);
30  std::string dump_duration_(uint32_t duration, uint16_t timebase, bool end = false);
31  std::string compensate_and_dump_sequence_(const RawTimings &data, uint16_t timebase);
32 
33  public:
34  void encode(RemoteTransmitData *dst, const ProntoData &data) override;
35  optional<ProntoData> decode(RemoteReceiveData src) override;
36  void dump(const ProntoData &data) override;
37 };
38 
40 
41 template<typename... Ts> class ProntoAction : public RemoteTransmitterActionBase<Ts...> {
42  public:
43  TEMPLATABLE_VALUE(std::string, data)
44  TEMPLATABLE_VALUE(int, delta)
45 
46  void encode(RemoteTransmitData *dst, Ts... x) override {
47  ProntoData data{};
48  data.data = this->data_.value(x...);
49  data.delta = this->delta_.value(x...);
50  ProntoProtocol().encode(dst, data);
51  }
52 };
53 
54 } // namespace remote_base
55 } // namespace esphome
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
bool operator==(const ProntoData &rhs) const
std::vector< int32_t > RawTimings
Definition: remote_base.h:23
std::vector< uint16_t > encode_pronto(const std::string &str)
uint16_le_t frequency
Definition: bl0942.h:21
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
uint8_t end[39]
Definition: sun_gtil2.cpp:31
void encode(RemoteTransmitData *dst, const ProntoData &data) override