ESPHome 2025.5.0
Loading...
Searching...
No Matches
ir_transmitter.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ARDUINO
4#ifdef USE_REMOTE_TRANSMITTER
6
7namespace esphome {
8namespace midea {
9
10using remote_base::RemoteTransmitterBase;
12
13class 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
19 // Direct from temperature in celsius and beeper values
20 IrFollowMeData(uint8_t temp, bool beeper = false) : IrFollowMeData() {
21 this->set_temp(temp, false);
22 this->set_beeper(beeper);
23 }
24 // Direct from temperature, fahrenheit and beeper values
26 this->set_temp(temp, fahrenheit);
27 this->set_beeper(beeper);
28 }
29
30 /* TEMPERATURE */
31 uint8_t temp() const {
32 if (this->fahrenheit()) {
33 return this->get_value_(4) + 31;
34 }
35 return this->get_value_(4) - 1;
36 }
37 void set_temp(uint8_t val, bool fahrenheit = false) {
39 if (this->fahrenheit()) {
40 // see https://github.com/esphome/feature-requests/issues/1627#issuecomment-1365639966
42 } else {
44 }
45 this->set_value_(4, val);
46 }
47
48 /* BEEPER */
49 bool beeper() const { return this->get_value_(3, 128); }
50 void set_beeper(bool val) { this->set_mask_(3, val, 128); }
51
52 /* FAHRENHEIT */
53 bool fahrenheit() const { return this->get_value_(2, 32); }
54 void set_fahrenheit(bool val) { this->set_mask_(2, val, 32); }
55
56 protected:
57 static const uint8_t MIN_TEMP_C = 0;
58 static const uint8_t MAX_TEMP_C = 37;
59
60 // see
61 // https://github.com/crankyoldgit/IRremoteESP8266/blob/9bdf8abcb465268c5409db99dc83a26df64c7445/src/ir_Midea.h#L116
62 static const uint8_t MIN_TEMP_F = 32;
63 // see
64 // https://github.com/crankyoldgit/IRremoteESP8266/blob/9bdf8abcb465268c5409db99dc83a26df64c7445/src/ir_Midea.h#L117
65 static const uint8_t MAX_TEMP_F = 99;
66};
67
68class IrSpecialData : public IrData {
69 public:
70 IrSpecialData(uint8_t code) : IrData({MIDEA_TYPE_SPECIAL, code, 0xFF, 0xFF, 0xFF}) {}
71};
72
74 public:
75 void set_transmitter(RemoteTransmitterBase *transmitter) { this->transmitter_ = transmitter; }
76 void transmit(IrData &data) {
77 data.finalize();
78 auto transmit = this->transmitter_->transmit();
79 remote_base::MideaProtocol().encode(transmit.get_data(), data);
80 transmit.perform();
81 }
82
83 protected:
85};
86
87} // namespace midea
88} // namespace esphome
89
90#endif
91#endif // USE_ARDUINO
IrFollowMeData(uint8_t temp, bool beeper=false)
static const uint8_t MIN_TEMP_F
static const uint8_t MIN_TEMP_C
static const uint8_t MAX_TEMP_F
IrFollowMeData(const IrData &data)
IrFollowMeData(uint8_t temp, bool fahrenheit, bool beeper)
static const uint8_t MAX_TEMP_C
void set_temp(uint8_t val, bool fahrenheit=false)
void set_transmitter(RemoteTransmitterBase *transmitter)
RemoteTransmitterBase * transmitter_
void set_value_(uint8_t idx, uint8_t value, uint8_t mask=255, uint8_t shift=0)
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)
void encode(RemoteTransmitData *dst, const MideaData &src) override
mopeka_std_values val[4]
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Definition helpers.h:101