IRremoteESP8266
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
20#ifndef IR_ELECTRA_H_
21#define IR_ELECTRA_H_
22
23#define __STDC_LIMIT_MACROS
24#include <stdint.h>
25#ifndef UNIT_TEST
26#include <Arduino.h>
27#endif
28#include "IRremoteESP8266.h"
29#include "IRsend.h"
30#ifdef UNIT_TEST
31#include "IRsend_test.h"
32#endif
33
37 struct {
38 // Byte 0
39 uint8_t :8;
40 // Byte 1
41 uint8_t SwingV :3;
42 uint8_t Temp :5;
43 // Byte 2
44 uint8_t :5;
45 uint8_t SwingH :3;
46 // Byte 3
47 uint8_t :6;
48 uint8_t SensorUpdate :1;
49 uint8_t :1;
50 // Byte 4
51 uint8_t :5;
52 uint8_t Fan :3;
53 // Byte 5
54 uint8_t :6;
55 uint8_t Turbo :1;
56 uint8_t Quiet :1;
57 // Byte 6
58 uint8_t :3;
59 uint8_t IFeel :1;
60 uint8_t :1;
61 uint8_t Mode :3;
62 // Byte 7
63 uint8_t SensorTemp :8;
64 // Byte 8
65 uint8_t :8;
66 // Byte 9
67 uint8_t :2;
68 uint8_t Clean :1;
69 uint8_t :2;
70 uint8_t Power :1;
71 uint8_t :2;
72 // Byte 10
73 uint8_t :8;
74 // Byte 11
75 uint8_t LightToggle :8;
76 // Byte 12
77 uint8_t Sum :8;
78 };
79};
80
81// Constants
82const uint8_t kElectraAcMinTemp = 16; // 16C
83const uint8_t kElectraAcMaxTemp = 32; // 32C
84const uint8_t kElectraAcTempDelta = 8;
85const uint8_t kElectraAcSwingOn = 0b000;
86const uint8_t kElectraAcSwingOff = 0b111;
87
88const uint8_t kElectraAcFanAuto = 0b101;
89const uint8_t kElectraAcFanLow = 0b011;
90const uint8_t kElectraAcFanMed = 0b010;
91const uint8_t kElectraAcFanHigh = 0b001;
92
93const uint8_t kElectraAcAuto = 0b000;
94const uint8_t kElectraAcCool = 0b001;
95const uint8_t kElectraAcDry = 0b010;
96const uint8_t kElectraAcHeat = 0b100;
97const uint8_t kElectraAcFan = 0b110;
98
99const uint8_t kElectraAcLightToggleOn = 0x15;
100// Light has known ON values of 0x15 (0b00010101) or 0x19 (0b00011001)
101// Thus common bits ON are: 0b00010001 (0x11)
102// We will use this for the getLightToggle() test.
103const uint8_t kElectraAcLightToggleMask = 0x11;
104// and known OFF values of 0x08 (0b00001000) & 0x05 (0x00000101)
105const uint8_t kElectraAcLightToggleOff = 0x08;
106
107// Re: Byte[7]. Or Delta == 0xA and Temperature are stored in last 6 bits,
108// and bit 7 stores Unknown flag
109const uint8_t kElectraAcSensorTempDelta = 0x4A;
110const uint8_t kElectraAcSensorMinTemp = 0; // 0C
111const uint8_t kElectraAcSensorMaxTemp = 50; // 50C
112
113// Classes
116 public:
117 explicit IRElectraAc(const uint16_t pin, const bool inverted = false,
118 const bool use_modulation = true);
119 void stateReset(void);
120#if SEND_ELECTRA_AC
121 void send(const uint16_t repeat = kElectraAcMinRepeat);
126 int8_t calibrate(void) { return _irsend.calibrate(); }
127#endif // SEND_ELECTRA_AC
128 void begin(void);
129 void on(void);
130 void off(void);
131 void setPower(const bool on);
132 bool getPower(void) const;
133 void setMode(const uint8_t mode);
134 uint8_t getMode(void) const;
135 void setTemp(const uint8_t temp);
136 uint8_t getTemp(void) const;
137 void setFan(const uint8_t speed);
138 uint8_t getFan(void) const;
139 void setSwingV(const bool on);
140 bool getSwingV(void) const;
141 void setSwingH(const bool on);
142 bool getSwingH(void) const;
143 void setClean(const bool on);
144 bool getClean(void) const;
145 void setLightToggle(const bool on);
146 bool getLightToggle(void) const;
147 void setTurbo(const bool on);
148 bool getTurbo(void) const;
149 void setQuiet(const bool on);
150 bool getQuiet(void) const;
151 void setIFeel(const bool on);
152 bool getIFeel(void) const;
153 void setSensorUpdate(const bool on);
154 bool getSensorUpdate(void) const;
155 void setSensorTemp(const uint8_t temp);
156 uint8_t getSensorTemp(void) const;
157 uint8_t* getRaw(void);
158 void setRaw(const uint8_t new_code[],
159 const uint16_t length = kElectraAcStateLength);
160 static bool validChecksum(const uint8_t state[],
161 const uint16_t length = kElectraAcStateLength);
162 static uint8_t calcChecksum(const uint8_t state[],
163 const uint16_t length = kElectraAcStateLength);
164 String toString(void) const;
165 static uint8_t convertMode(const stdAc::opmode_t mode);
166 static uint8_t convertFan(const stdAc::fanspeed_t speed);
167 static stdAc::opmode_t toCommonMode(const uint8_t mode);
168 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
169 stdAc::state_t toCommon(void) const;
170#ifndef UNIT_TEST
171
172 private:
174#else
176 IRsendTest _irsend;
178#endif
180 void checksum(const uint16_t length = kElectraAcStateLength);
181};
182#endif // IR_ELECTRA_H_
const uint16_t kElectraAcMinRepeat
Definition IRremoteESP8266.h:1265
const uint16_t kElectraAcStateLength
Definition IRremoteESP8266.h:1263
std::string String
Definition IRremoteESP8266.h:1564
Class for handling detailed Electra A/C messages.
Definition ir_Electra.h:115
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:179
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:126
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:173
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:249
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition IRsend.cpp:209
const uint8_t kElectraAcFan
Definition ir_Electra.h:97
const uint8_t kElectraAcMaxTemp
Definition ir_Electra.h:83
const uint8_t kElectraAcFanAuto
Definition ir_Electra.h:88
const uint8_t kElectraAcFanMed
Definition ir_Electra.h:90
const uint8_t kElectraAcSwingOn
Definition ir_Electra.h:85
const uint8_t kElectraAcAuto
Definition ir_Electra.h:93
const uint8_t kElectraAcFanHigh
Definition ir_Electra.h:91
const uint8_t kElectraAcCool
Definition ir_Electra.h:94
const uint8_t kElectraAcSensorMinTemp
Definition ir_Electra.h:110
const uint8_t kElectraAcSensorTempDelta
Definition ir_Electra.h:109
const uint8_t kElectraAcFanLow
Definition ir_Electra.h:89
const uint8_t kElectraAcDry
Definition ir_Electra.h:95
const uint8_t kElectraAcLightToggleMask
Definition ir_Electra.h:103
const uint8_t kElectraAcSensorMaxTemp
Definition ir_Electra.h:111
const uint8_t kElectraAcLightToggleOn
Definition ir_Electra.h:99
const uint8_t kElectraAcTempDelta
Definition ir_Electra.h:84
const uint8_t kElectraAcMinTemp
Definition ir_Electra.h:82
const uint8_t kElectraAcSwingOff
Definition ir_Electra.h:86
const uint8_t kElectraAcLightToggleOff
Definition ir_Electra.h:105
const uint8_t kElectraAcHeat
Definition ir_Electra.h:96
fanspeed_t
Common A/C settings for Fan Speeds.
Definition IRsend.h:61
opmode_t
Common A/C settings for A/C operating modes.
Definition IRsend.h:49
Structure to hold a common A/C state.
Definition IRsend.h:114
Native representation of a Electra A/C message.
Definition ir_Electra.h:35
uint8_t Sum
Definition ir_Electra.h:77
uint8_t SwingV
Definition ir_Electra.h:41
uint8_t Mode
Definition ir_Electra.h:61
uint8_t Quiet
Definition ir_Electra.h:56
uint8_t Fan
Definition ir_Electra.h:52
uint8_t SensorTemp
Definition ir_Electra.h:63
uint8_t Power
Definition ir_Electra.h:70
uint8_t LightToggle
Definition ir_Electra.h:75
uint8_t Clean
Definition ir_Electra.h:68
uint8_t raw[kElectraAcStateLength]
The state of the IR remote.
Definition ir_Electra.h:36
uint8_t SensorUpdate
Definition ir_Electra.h:48
uint8_t IFeel
Definition ir_Electra.h:59
uint8_t SwingH
Definition ir_Electra.h:45
uint8_t Temp
Definition ir_Electra.h:42
uint8_t Turbo
Definition ir_Electra.h:55