IRremoteIDF
Infrared send & receive for ESP-IDF
Loading...
Searching...
No Matches
ir_Electra.h
Go to the documentation of this file.
1// Copyright 2019-2021 David Conran
5
6// Supports:
7// Brand: AUX, Model: KFR-35GW/BpNFW=3 A/C
8// Brand: AUX, Model: YKR-T/011 remote
9// Brand: Electra, Model: Classic INV 17 / AXW12DCS A/C
10// Brand: Electra, Model: YKR-M/003E remote
11// Brand: Frigidaire, Model: FGPC102AB1 A/C
12// Brand: Subtropic, Model: SUB-07HN1_18Y A/C
13// Brand: Subtropic, Model: YKR-H/102E remote
14// Brand: Centek, Model: SCT-65Q09 A/C
15// Brand: Centek, Model: YKR-P/002E remote
16// Brand: AEG, Model: Chillflex Pro AXP26U338CW A/C
17// Brand: Electrolux, Model: YKR-H/531E A/C
18// Brand: Delonghi, Modell: PAC EM90
19// Brand: Delonghi, Modell: Pinguino PAC EM82 A/C
20
21#ifndef IR_ELECTRA_H_
22#define IR_ELECTRA_H_
23
24#define __STDC_LIMIT_MACROS
25#include <stdint.h>
26#include "IRplatform.h"
27#include "IRremoteESP8266.h"
28#include "IRsend.h"
29#ifdef UNIT_TEST
30#include "IRsend_test.h"
31#endif
32
36 struct {
37 // Byte 0
38 uint8_t :8;
39 // Byte 1
40 uint8_t SwingV :3;
41 uint8_t Temp :5;
42 // Byte 2
43 uint8_t :5;
44 uint8_t SwingH :3;
45 // Byte 3
46 uint8_t :6;
47 uint8_t SensorUpdate :1;
48 uint8_t :1;
49 // Byte 4
50 uint8_t :5;
51 uint8_t Fan :3;
52 // Byte 5
53 uint8_t :6;
54 uint8_t Turbo :1;
55 uint8_t Quiet :1;
56 // Byte 6
57 uint8_t :3;
58 uint8_t IFeel :1;
59 uint8_t :1;
60 uint8_t Mode :3;
61 // Byte 7
62 uint8_t SensorTemp :8;
63 // Byte 8
64 uint8_t :8;
65 // Byte 9
66 uint8_t :2;
67 uint8_t Clean :1;
68 uint8_t :2;
69 uint8_t Power :1;
70 uint8_t :2;
71 // Byte 10
72 uint8_t :8;
73 // Byte 11
74 uint8_t LightToggle :8;
75 // Byte 12
76 uint8_t Sum :8;
77 };
78};
79
80// Constants
81const uint8_t kElectraAcMinTemp = 16; // 16C
82const uint8_t kElectraAcMaxTemp = 32; // 32C
83const uint8_t kElectraAcTempDelta = 8;
84const uint8_t kElectraAcSwingOn = 0b000;
85const uint8_t kElectraAcSwingOff = 0b111;
86
87const uint8_t kElectraAcFanAuto = 0b101;
88const uint8_t kElectraAcFanLow = 0b011;
89const uint8_t kElectraAcFanMed = 0b010;
90const uint8_t kElectraAcFanHigh = 0b001;
91
92const uint8_t kElectraAcAuto = 0b000;
93const uint8_t kElectraAcCool = 0b001;
94const uint8_t kElectraAcDry = 0b010;
95const uint8_t kElectraAcHeat = 0b100;
96const uint8_t kElectraAcFan = 0b110;
97
98const uint8_t kElectraAcLightToggleOn = 0x15;
99// Light has known ON values of 0x15 (0b00010101) or 0x19 (0b00011001)
100// Thus common bits ON are: 0b00010001 (0x11)
101// We will use this for the getLightToggle() test.
102const uint8_t kElectraAcLightToggleMask = 0x11;
103// and known OFF values of 0x08 (0b00001000) & 0x05 (0x00000101)
104const uint8_t kElectraAcLightToggleOff = 0x08;
105
106// Re: Byte[7]. Or Delta == 0xA and Temperature are stored in last 6 bits,
107// and bit 7 stores Unknown flag
108const uint8_t kElectraAcSensorTempDelta = 0x4A;
109const uint8_t kElectraAcSensorMinTemp = 0; // 0C
110const uint8_t kElectraAcSensorMaxTemp = 50; // 50C
111
112// Classes
115 public:
116 explicit IRElectraAc(const uint16_t pin, const bool inverted = false,
117 const bool use_modulation = true);
118 void stateReset(void);
119#if SEND_ELECTRA_AC
120 void send(const uint16_t repeat = kElectraAcMinRepeat);
125 int8_t calibrate(void) { return _irsend.calibrate(); }
126#endif // SEND_ELECTRA_AC
127 void begin(void);
128 void on(void);
129 void off(void);
130 void setPower(const bool on);
131 bool getPower(void) const;
132 void setMode(const uint8_t mode);
133 uint8_t getMode(void) const;
134 void setTemp(const uint8_t temp);
135 uint8_t getTemp(void) const;
136 void setFan(const uint8_t speed);
137 uint8_t getFan(void) const;
138 void setSwingV(const bool on);
139 bool getSwingV(void) const;
140 void setSwingH(const bool on);
141 bool getSwingH(void) const;
142 void setClean(const bool on);
143 bool getClean(void) const;
144 void setLightToggle(const bool on);
145 bool getLightToggle(void) const;
146 void setTurbo(const bool on);
147 bool getTurbo(void) const;
148 void setQuiet(const bool on);
149 bool getQuiet(void) const;
150 void setIFeel(const bool on);
151 bool getIFeel(void) const;
152 void setSensorUpdate(const bool on);
153 bool getSensorUpdate(void) const;
154 void setSensorTemp(const uint8_t temp);
155 uint8_t getSensorTemp(void) const;
156 uint8_t* getRaw(void);
157 void setRaw(const uint8_t new_code[],
158 const uint16_t length = kElectraAcStateLength);
159 static bool validChecksum(const uint8_t state[],
160 const uint16_t length = kElectraAcStateLength);
161 static uint8_t calcChecksum(const uint8_t state[],
162 const uint16_t length = kElectraAcStateLength);
163 String toString(void) const;
164 static uint8_t convertMode(const stdAc::opmode_t mode);
165 static uint8_t convertFan(const stdAc::fanspeed_t speed);
166 static stdAc::opmode_t toCommonMode(const uint8_t mode);
167 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
168 stdAc::state_t toCommon(void) const;
169#ifndef UNIT_TEST
170
171 private:
173#else
175 IRsendTest _irsend;
177#endif
179 void checksum(const uint16_t length = kElectraAcStateLength);
180};
181#endif // IR_ELECTRA_H_
std::string String
The protocol code builds human readable output with String. On ESP-IDF that is just std::string.
Definition IRplatform.h:21
const uint16_t kElectraAcMinRepeat
Definition IRremoteESP8266.h:1264
const uint16_t kElectraAcStateLength
Definition IRremoteESP8266.h:1262
Class for handling detailed Electra A/C messages.
Definition ir_Electra.h:114
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Electra.cpp:166
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Electra.cpp:179
void setLightToggle(const bool on)
Set the Light (LED) Toggle mode of the A/C.
Definition ir_Electra.cpp:278
void send(const uint16_t repeat=kElectraAcMinRepeat)
Send the current internal state as an IR message.
Definition ir_Electra.cpp:103
bool getQuiet(void) const
Get the Quiet/Silent mode of the A/C.
Definition ir_Electra.cpp:321
void setIFeel(const bool on)
Set the IFeel mode of the A/C.
Definition ir_Electra.cpp:331
void setClean(const bool on)
Set the Clean mode of the A/C.
Definition ir_Electra.cpp:291
ElectraProtocol _
Definition ir_Electra.h:178
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Electra.cpp:243
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Electra.cpp:222
bool getSwingV(void) const
Get the Vertical Swing mode of the A/C.
Definition ir_Electra.cpp:260
void setTemp(const uint8_t temp)
Set the temperature.
Definition ir_Electra.cpp:191
static bool validChecksum(const uint8_t state[], const uint16_t length=kElectraAcStateLength)
Verify the checksum is valid for a given state.
Definition ir_Electra.cpp:87
void checksum(const uint16_t length=kElectraAcStateLength)
Calculate and set the checksum values for the internal state.
Definition ir_Electra.cpp:95
void setSensorTemp(const uint8_t temp)
Set the Sensor temperature for the IFeel mode.
Definition ir_Electra.cpp:358
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Electra.cpp:110
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Electra.cpp:136
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Electra.cpp:373
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Electra.cpp:142
void on(void)
Change the power setting to On.
Definition ir_Electra.cpp:123
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Electra.cpp:206
static uint8_t calcChecksum(const uint8_t state[], const uint16_t length=kElectraAcStateLength)
Calculate the checksum for a given state.
Definition ir_Electra.cpp:77
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Electra.cpp:159
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Electra.cpp:199
void stateReset(void)
Reset the internal state to a fixed known good state.
Definition ir_Electra.cpp:63
void setPower(const bool on)
Change the power setting.
Definition ir_Electra.cpp:130
bool getTurbo(void) const
Get the Turbo mode of the A/C.
Definition ir_Electra.cpp:309
bool getSensorUpdate(void) const
Get the silent Sensor Update setting of the message. i.e. Is this just a sensor temp update message f...
Definition ir_Electra.cpp:346
void setQuiet(const bool on)
Set the Quiet/Silent'mode of the A/C.
Definition ir_Electra.cpp:315
void setTurbo(const bool on)
Set the Turbo mode of the A/C.
Definition ir_Electra.cpp:303
void setRaw(const uint8_t new_code[], const uint16_t length=kElectraAcStateLength)
Set the internal state from a valid code for this protocol.
Definition ir_Electra.cpp:118
void setSwingV(const bool on)
Set the Vertical Swing mode of the A/C.
Definition ir_Electra.cpp:254
bool getSwingH(void) const
Get the Horizontal Swing mode of the A/C.
Definition ir_Electra.cpp:272
bool getLightToggle(void) const
Get the Light (LED) Toggle mode of the A/C.
Definition ir_Electra.cpp:284
bool getIFeel(void) const
Get the IFeel mode of the A/C.
Definition ir_Electra.cpp:327
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Electra.h:125
bool getClean(void) const
Get the Clean mode of the A/C.
Definition ir_Electra.cpp:297
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Electra.cpp:403
IRsend _irsend
instance of the IR send class
Definition ir_Electra.h:172
void setSensorUpdate(const bool on)
Set the silent Sensor Update setting of the message. i.e. Is this just a sensor temp update message f...
Definition ir_Electra.cpp:354
void setSwingH(const bool on)
Set the Horizontal Swing mode of the A/C.
Definition ir_Electra.cpp:266
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Electra.cpp:229
uint8_t getSensorTemp(void) const
Get the current sensor temperature setting for the IFeel mode.
Definition ir_Electra.cpp:366
void off(void)
Change the power setting to Off.
Definition ir_Electra.cpp:126
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Electra.cpp:71
Class for sending all basic IR protocols.
Definition IRsend.h:256
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:286
const uint8_t kElectraAcFan
Definition ir_Electra.h:96
const uint8_t kElectraAcMaxTemp
Definition ir_Electra.h:82
const uint8_t kElectraAcFanAuto
Definition ir_Electra.h:87
const uint8_t kElectraAcFanMed
Definition ir_Electra.h:89
const uint8_t kElectraAcSwingOn
Definition ir_Electra.h:84
const uint8_t kElectraAcAuto
Definition ir_Electra.h:92
const uint8_t kElectraAcFanHigh
Definition ir_Electra.h:90
const uint8_t kElectraAcCool
Definition ir_Electra.h:93
const uint8_t kElectraAcSensorMinTemp
Definition ir_Electra.h:109
const uint8_t kElectraAcSensorTempDelta
Definition ir_Electra.h:108
const uint8_t kElectraAcFanLow
Definition ir_Electra.h:88
const uint8_t kElectraAcDry
Definition ir_Electra.h:94
const uint8_t kElectraAcLightToggleMask
Definition ir_Electra.h:102
const uint8_t kElectraAcSensorMaxTemp
Definition ir_Electra.h:110
const uint8_t kElectraAcLightToggleOn
Definition ir_Electra.h:98
const uint8_t kElectraAcTempDelta
Definition ir_Electra.h:83
const uint8_t kElectraAcMinTemp
Definition ir_Electra.h:81
const uint8_t kElectraAcSwingOff
Definition ir_Electra.h:85
const uint8_t kElectraAcLightToggleOff
Definition ir_Electra.h:104
const uint8_t kElectraAcHeat
Definition ir_Electra.h:95
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:67
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:55
Structure to hold a common A/C state.
Definition IRsend.h:120
Native representation of a Electra A/C message.
Definition ir_Electra.h:34
uint8_t Sum
Definition ir_Electra.h:76
uint8_t SwingV
Definition ir_Electra.h:40
uint8_t Mode
Definition ir_Electra.h:60
uint8_t Quiet
Definition ir_Electra.h:55
uint8_t Fan
Definition ir_Electra.h:51
uint8_t SensorTemp
Definition ir_Electra.h:62
uint8_t Power
Definition ir_Electra.h:69
uint8_t LightToggle
Definition ir_Electra.h:74
uint8_t Clean
Definition ir_Electra.h:67
uint8_t raw[kElectraAcStateLength]
The state of the IR remote.
Definition ir_Electra.h:35
uint8_t SensorUpdate
Definition ir_Electra.h:47
uint8_t IFeel
Definition ir_Electra.h:58
uint8_t SwingH
Definition ir_Electra.h:44
uint8_t Temp
Definition ir_Electra.h:41
uint8_t Turbo
Definition ir_Electra.h:54