ESPHome  2024.12.2
ir_transmitter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_ARDUINO
4 #ifdef USE_REMOTE_TRANSMITTER
6 
7 namespace esphome {
8 namespace midea {
9 
10 using remote_base::RemoteTransmitterBase;
12 
13 class IrFollowMeData : public IrData {
14  public:
15  // Default constructor (temp: 30C, beeper: off)
16  IrFollowMeData() : IrData({MIDEA_TYPE_FOLLOW_ME, 0x82, 0x48, 0x7F, 0x1F}) {}
17  // Copy from Base
18  IrFollowMeData(const IrData &data) : IrData(data) {}
19  // Direct from temperature and beeper values
20  IrFollowMeData(uint8_t temp, bool beeper = false) : IrFollowMeData() {
21  this->set_temp(temp);
22  this->set_beeper(beeper);
23  }
24 
25  /* TEMPERATURE */
26  uint8_t temp() const { return this->get_value_(4) - 1; }
27  void set_temp(uint8_t val) { this->set_value_(4, std::min(MAX_TEMP, val) + 1); }
28 
29  /* BEEPER */
30  bool beeper() const { return this->get_value_(3, 128); }
31  void set_beeper(bool val) { this->set_mask_(3, val, 128); }
32 
33  protected:
34  static const uint8_t MAX_TEMP = 37;
35 };
36 
37 class IrSpecialData : public IrData {
38  public:
39  IrSpecialData(uint8_t code) : IrData({MIDEA_TYPE_SPECIAL, code, 0xFF, 0xFF, 0xFF}) {}
40 };
41 
43  public:
44  void set_transmitter(RemoteTransmitterBase *transmitter) { this->transmitter_ = transmitter; }
45  void transmit(IrData &data) {
46  data.finalize();
47  auto transmit = this->transmitter_->transmit();
48  remote_base::MideaProtocol().encode(transmit.get_data(), data);
49  transmit.perform();
50  }
51 
52  protected:
53  RemoteTransmitterBase *transmitter_{nullptr};
54 };
55 
56 } // namespace midea
57 } // namespace esphome
58 
59 #endif
60 #endif // USE_ARDUINO
void set_transmitter(RemoteTransmitterBase *transmitter)
IrFollowMeData(const IrData &data)
IrFollowMeData(uint8_t temp, bool beeper=false)
mopeka_std_values val[4]
void encode(RemoteTransmitData *dst, const MideaData &src) override
void set_value_(uint8_t idx, uint8_t value, uint8_t mask=255, uint8_t shift=0)
void transmit(IrData &data)
uint8_t get_value_(uint8_t idx, uint8_t mask=255, uint8_t shift=0) const
void set_mask_(uint8_t idx, bool state, uint8_t mask=255)
static const uint8_t MAX_TEMP
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7