IRremoteIDF
Infrared send & receive for ESP-IDF
Loading...
Searching...
No Matches
ir_Samsung.h
Go to the documentation of this file.
1// Copyright 2018-2021 David Conran
11
12// Supports:
13// Brand: Samsung, Model: UA55H6300 TV (SAMSUNG)
14// Brand: Samsung, Model: BN59-01178B TV remote (SAMSUNG)
15// Brand: Samsung, Model: UE40K5510AUXRU TV (SAMSUNG)
16// Brand: Samsung, Model: DB63-03556X003 remote
17// Brand: Samsung, Model: DB93-16761C remote
18// Brand: Samsung, Model: IEC-R03 remote
19// Brand: Samsung, Model: AK59-00167A Bluray remote (SAMSUNG36)
20// Brand: Samsung, Model: AH59-02692E Soundbar remote (SAMSUNG36)
21// Brand: Samsung, Model: HW-J551 Soundbar (SAMSUNG36)
22// Brand: Samsung, Model: AR09FSSDAWKNFA A/C (SAMSUNG_AC)
23// Brand: Samsung, Model: AR09HSFSBWKN A/C (SAMSUNG_AC)
24// Brand: Samsung, Model: AR12KSFPEWQNET A/C (SAMSUNG_AC)
25// Brand: Samsung, Model: AR12HSSDBWKNEU A/C (SAMSUNG_AC)
26// Brand: Samsung, Model: AR12NXCXAWKXEU A/C (SAMSUNG_AC)
27// Brand: Samsung, Model: AR12TXEAAWKNEU A/C (SAMSUNG_AC)
28// Brand: Samsung, Model: DB93-14195A remote (SAMSUNG_AC)
29// Brand: Samsung, Model: DB96-24901C remote (SAMSUNG_AC)
30
31#ifndef IR_SAMSUNG_H_
32#define IR_SAMSUNG_H_
33
34#define __STDC_LIMIT_MACROS
35#include <stdint.h>
36#include "IRplatform.h"
37#include "IRremoteESP8266.h"
38#include "IRsend.h"
39#ifdef UNIT_TEST
40#include "IRsend_test.h"
41#endif
42
46 struct { // Standard message map
47 // Byte 0
48 uint8_t :8;
49 // Byte 1
50 uint8_t :4;
51 uint8_t :4; // Sum1Lower
52 // Byte 2
53 uint8_t :4; // Sum1Upper
54 uint8_t :4;
55 // Byte 3
56 uint8_t :8;
57 // Byte 4
58 uint8_t :8;
59 // Byte 5
60 uint8_t :4;
61 uint8_t Sleep5 :1;
62 uint8_t Quiet :1;
63 uint8_t :2;
64 // Byte 6
65 uint8_t :4;
66 uint8_t Power1 :2;
67 uint8_t :2;
68 // Byte 7
69 uint8_t :8;
70 // Byte 8
71 uint8_t :4;
72 uint8_t :4; // Sum2Lower
73 // Byte 9
74 uint8_t :4; // Sum1Upper
75 uint8_t Swing :3;
76 uint8_t :1;
77 // Byte 10
78 uint8_t :1;
79 uint8_t FanSpecial :3; // Powerful, Breeze/WindFree, Econo
80 uint8_t Display :1;
81 uint8_t :2;
82 uint8_t CleanToggle10 :1;
83 // Byte 11
84 uint8_t Ion :1;
85 uint8_t CleanToggle11 :1;
86 uint8_t :2;
87 uint8_t Temp :4;
88 // Byte 12
89 uint8_t :1;
90 uint8_t Fan :3;
91 uint8_t Mode :3;
92 uint8_t :1;
93 // Byte 13
94 uint8_t :2;
95 uint8_t BeepToggle :1;
96 uint8_t :1;
97 uint8_t Power2 :2;
98 uint8_t :2;
99 };
100 struct { // Extended message map
101 // 1st Section
102 // Byte 0
103 uint8_t :8;
104 // Byte 1
105 uint8_t :4;
106 uint8_t Sum1Lower :4;
107 // Byte 2
108 uint8_t Sum1Upper :4;
109 uint8_t :4;
110 // Byte 3
111 uint8_t :8;
112 // Byte 4
113 uint8_t :8;
114 // Byte 5
115 uint8_t :8;
116 // Byte 6
117 uint8_t :8;
118 // 2nd Section
119 // Byte 7
120 uint8_t :8;
121 // Byte 8
122 uint8_t :4;
123 uint8_t Sum2Lower :4;
124 // Byte 9
125 uint8_t Sum2Upper :4;
126 uint8_t OffTimeMins :3; // In units of 10's of mins
127 uint8_t OffTimeHrs1 :1; // LSB of the number of hours.
128 // Byte 10
129 uint8_t OffTimeHrs2 :4; // MSBs of the number of hours.
130 uint8_t OnTimeMins :3; // In units of 10's of mins
131 uint8_t OnTimeHrs1 :1; // LSB of the number of hours.
132 // Byte 11
133 uint8_t OnTimeHrs2 :4; // MSBs of the number of hours.
134 uint8_t :4;
135 // Byte 12
136 uint8_t OffTimeDay :1;
137 uint8_t OnTimerEnable :1;
138 uint8_t OffTimerEnable :1;
139 uint8_t Sleep12 :1;
140 uint8_t OnTimeDay :1;
141 uint8_t :3;
142 // Byte 13
143 uint8_t :8;
144 // 3rd Section
145 // Byte 14
146 uint8_t :8;
147 // Byte 15
148 uint8_t :4;
149 uint8_t Sum3Lower :4;
150 // Byte 16
151 uint8_t Sum3Upper :4;
152 uint8_t :4;
153 // Byte 17
154 uint8_t :8;
155 // Byte 18
156 uint8_t :8;
157 // Byte 19
158 uint8_t :8;
159 // Byte 20
160 uint8_t :8;
161 };
162};
163
164// Constants
165const uint8_t kSamsungAcMinTemp = 16; // C Mask 0b11110000
166const uint8_t kSamsungAcMaxTemp = 30; // C Mask 0b11110000
167const uint8_t kSamsungAcAutoTemp = 25; // C Mask 0b11110000
168const uint8_t kSamsungAcAuto = 0;
169const uint8_t kSamsungAcCool = 1;
170const uint8_t kSamsungAcDry = 2;
171const uint8_t kSamsungAcFan = 3;
172const uint8_t kSamsungAcHeat = 4;
173const uint8_t kSamsungAcFanAuto = 0;
174const uint8_t kSamsungAcFanLow = 2;
175const uint8_t kSamsungAcFanMed = 4;
176const uint8_t kSamsungAcFanHigh = 5;
177const uint8_t kSamsungAcFanAuto2 = 6;
178const uint8_t kSamsungAcFanTurbo = 7;
179const uint16_t kSamsungAcSectionLength = 7;
180const uint64_t kSamsungAcPowerSection = 0x1D20F00000000;
181
182// Classes
185 public:
186 explicit IRSamsungAc(const uint16_t pin, const bool inverted = false,
187 const bool use_modulation = true);
188 void stateReset(const bool extended = true, const bool initialPower = true);
189#if SEND_SAMSUNG_AC
190 void send(const uint16_t repeat = kSamsungAcDefaultRepeat);
191 void sendExtended(const uint16_t repeat = kSamsungAcDefaultRepeat);
192 void sendOn(const uint16_t repeat = kSamsungAcDefaultRepeat);
193 void sendOff(const uint16_t repeat = kSamsungAcDefaultRepeat);
198 int8_t calibrate(void) { return _irsend.calibrate(); }
199#endif // SEND_SAMSUNG_AC
200 void begin(void);
201 void on(void);
202 void off(void);
203 void setPower(const bool on);
204 bool getPower(void) const;
205 void setTemp(const uint8_t temp);
206 uint8_t getTemp(void) const;
207 void setFan(const uint8_t speed);
208 uint8_t getFan(void) const;
209 void setMode(const uint8_t mode);
210 uint8_t getMode(void) const;
211 void setSwing(const bool on);
212 bool getSwing(void) const;
213 void setSwingH(const bool on);
214 bool getSwingH(void) const;
215 void setBeep(const bool on);
216 bool getBeep(void) const;
217 void setClean(const bool on);
218 bool getClean(void) const;
219 void setQuiet(const bool on);
220 bool getQuiet(void) const;
221 void setPowerful(const bool on);
222 bool getPowerful(void) const;
223 void setBreeze(const bool on);
224 bool getBreeze(void) const;
225 void setEcono(const bool on);
226 bool getEcono(void) const;
227 void setDisplay(const bool on);
228 bool getDisplay(void) const;
229 void setIon(const bool on);
230 bool getIon(void) const;
231 uint16_t getOnTimer(void) const;
232 void setOnTimer(const uint16_t nr_of_mins);
233 uint16_t getOffTimer(void) const;
234 void setOffTimer(const uint16_t nr_of_mins);
235 uint16_t getSleepTimer(void) const;
236 void setSleepTimer(const uint16_t nr_of_mins);
237 uint8_t* getRaw(void);
238 void setRaw(const uint8_t new_code[],
239 const uint16_t length = kSamsungAcStateLength);
240 static uint8_t calcSectionChecksum(const uint8_t *section);
241 static uint8_t getSectionChecksum(const uint8_t *section);
242 static bool validChecksum(const uint8_t state[],
243 const uint16_t length = kSamsungAcStateLength);
244 static uint8_t convertMode(const stdAc::opmode_t mode);
245 static uint8_t convertFan(const stdAc::fanspeed_t speed);
246 static stdAc::opmode_t toCommonMode(const uint8_t mode);
247 static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
248 stdAc::state_t toCommon(void) const;
249 String toString(void) const;
250#ifndef UNIT_TEST
251
252 private:
254#else // UNIT_TEST
256 IRsendTest _irsend;
258#endif // UNIT_TEST
264 bool _Sleep;
266 uint16_t _OnTimer;
267 uint16_t _OffTimer;
268 uint16_t _lastOnTimer;
270 void checksum(void);
271 uint16_t _getOnTimer(void) const;
272 uint16_t _getOffTimer(void) const;
273 void _setOnTimer(void);
274 void _setOffTimer(void);
275 void _setSleepTimer(void);
276};
277
278#endif // IR_SAMSUNG_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 kSamsungAcExtendedStateLength
Definition IRremoteESP8266.h:1387
const uint16_t kSamsungAcStateLength
Definition IRremoteESP8266.h:1385
const uint16_t kSamsungAcDefaultRepeat
Definition IRremoteESP8266.h:1389
Class for handling detailed Samsung A/C messages.
Definition ir_Samsung.h:184
void setOffTimer(const uint16_t nr_of_mins)
Set the Off Timer value of the A/C.
Definition ir_Samsung.cpp:795
bool getDisplay(void) const
Get the Display (Light/LED) setting of the A/C.
Definition ir_Samsung.cpp:695
bool _OffTimerEnable
Definition ir_Samsung.h:263
void setBeep(const bool on)
Set the Beep toggle setting of the A/C.
Definition ir_Samsung.cpp:601
bool _Sleep
Definition ir_Samsung.h:264
bool getBeep(void) const
Get the Beep toggle setting of the A/C.
Definition ir_Samsung.cpp:597
uint8_t getTemp(void) const
Get the current temperature setting.
Definition ir_Samsung.cpp:495
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition ir_Samsung.cpp:857
void setEcono(const bool on)
Set the current Economy (Eco) setting of the A/C.
Definition ir_Samsung.cpp:682
void setBreeze(const bool on)
Closes the vanes over the fan outlet, to stop direct wind. Aka. WindFree.
Definition ir_Samsung.cpp:662
void off(void)
Set the requested power state of the A/C to off.
Definition ir_Samsung.cpp:471
void setOnTimer(const uint16_t nr_of_mins)
Set the On Timer value of the A/C.
Definition ir_Samsung.cpp:784
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition ir_Samsung.cpp:844
bool getQuiet(void) const
Get the Quiet setting of the A/C.
Definition ir_Samsung.cpp:618
stdAc::state_t toCommon(void) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition ir_Samsung.cpp:869
void setPower(const bool on)
Change the power setting.
Definition ir_Samsung.cpp:475
bool getIon(void) const
Get the Ion (Filter) setting of the A/C.
Definition ir_Samsung.cpp:703
bool _forceextended
Flag to know when we need to send an extended mesg.
Definition ir_Samsung.h:260
static bool validChecksum(const uint8_t state[], const uint16_t length=kSamsungAcStateLength)
Verify the checksum is valid for a given state.
Definition ir_Samsung.cpp:344
bool getSwingH(void) const
Get the horizontal swing setting of the A/C.
Definition ir_Samsung.cpp:574
bool getSwing(void) const
Get the vertical swing setting of the A/C.
Definition ir_Samsung.cpp:551
IRsend _irsend
Instance of the IR send class.
Definition ir_Samsung.h:253
void setSleepTimer(const uint16_t nr_of_mins)
Set the Sleep Timer value of the A/C.
Definition ir_Samsung.cpp:806
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition ir_Samsung.h:198
uint16_t _lastOffTimer
Definition ir_Samsung.h:269
bool getEcono(void) const
Get the current Economy (Eco) setting of the A/C.
Definition ir_Samsung.cpp:675
void on(void)
Set the requested power state of the A/C to on.
Definition ir_Samsung.cpp:468
void setQuiet(const bool on)
Set the Quiet setting of the A/C.
Definition ir_Samsung.cpp:622
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition ir_Samsung.cpp:830
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition ir_Samsung.cpp:525
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition ir_Samsung.cpp:501
void send(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the current internal state as an IR message.
Definition ir_Samsung.cpp:375
void sendExtended(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the extended current internal state as an IR message.
Definition ir_Samsung.cpp:389
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition ir_Samsung.cpp:817
void _setSleepTimer(void)
Definition ir_Samsung.cpp:752
SamsungProtocol _
Definition ir_Samsung.h:259
uint16_t getOffTimer(void) const
Get the Off Timer setting of the A/C.
Definition ir_Samsung.cpp:766
void sendOn(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the special extended "On" message as the library can't seem to reproduce this message automatica...
Definition ir_Samsung.cpp:419
uint16_t _OffTimer
Definition ir_Samsung.h:267
bool _lastSleep
Definition ir_Samsung.h:265
void checksum(void)
Update the checksum for the internal state.
Definition ir_Samsung.cpp:358
bool getClean(void) const
Get the Clean toggle setting of the A/C.
Definition ir_Samsung.cpp:605
void begin(void)
Set up hardware to be able to send a message.
Definition ir_Samsung.cpp:311
void _setOffTimer(void)
Set the current Off Timer value of the A/C into the raw extended state.
Definition ir_Samsung.cpp:738
void setClean(const bool on)
Set the Clean toggle setting of the A/C.
Definition ir_Samsung.cpp:611
uint8_t getFan(void) const
Get the current fan speed setting.
Definition ir_Samsung.cpp:545
void setTemp(const uint8_t temp)
Set the temperature.
Definition ir_Samsung.cpp:487
void setRaw(const uint8_t new_code[], const uint16_t length=kSamsungAcStateLength)
Set the internal state from a valid code for this protocol.
Definition ir_Samsung.cpp:452
uint8_t * getRaw(void)
Get a PTR to the internal state/code for this protocol.
Definition ir_Samsung.cpp:444
void sendOff(const uint16_t repeat=kSamsungAcDefaultRepeat)
Send the special extended "Off" message as the library can't seem to reproduce this message automatic...
Definition ir_Samsung.cpp:432
uint16_t getSleepTimer(void) const
Get the Sleep Timer setting of the A/C.
Definition ir_Samsung.cpp:773
uint16_t _lastOnTimer
Definition ir_Samsung.h:268
String toString(void) const
Convert the current internal state into a human readable string.
Definition ir_Samsung.cpp:895
void _setOnTimer(void)
Set the current On Timer value of the A/C into the raw extended state.
Definition ir_Samsung.cpp:717
void setSwing(const bool on)
Set the vertical swing setting of the A/C.
Definition ir_Samsung.cpp:561
void setPowerful(const bool on)
Set the Powerful (Turbo) setting of the A/C.
Definition ir_Samsung.cpp:640
void stateReset(const bool extended=true, const bool initialPower=true)
Reset the internal state of the emulation.
Definition ir_Samsung.cpp:295
uint16_t _OnTimer
Definition ir_Samsung.h:266
bool getPowerful(void) const
Get the Powerful (Turbo) setting of the A/C.
Definition ir_Samsung.cpp:633
void setDisplay(const bool on)
Set the Display (Light/LED) setting of the A/C.
Definition ir_Samsung.cpp:699
uint16_t _getOnTimer(void) const
Get the On Timer setting of the A/C from a raw extended state.
Definition ir_Samsung.cpp:711
void setSwingH(const bool on)
Set the horizontal swing setting of the A/C.
Definition ir_Samsung.cpp:584
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition ir_Samsung.cpp:519
uint16_t getOnTimer(void) const
Get the On Timer setting of the A/C.
Definition ir_Samsung.cpp:761
bool getBreeze(void) const
Are the vanes closed over the fan outlet, to stop direct wind? Aka. WindFree.
Definition ir_Samsung.cpp:654
bool _OnTimerEnable
Definition ir_Samsung.h:262
bool getPower(void) const
Get the value of the current power setting.
Definition ir_Samsung.cpp:481
void setIon(const bool on)
Set the Ion (Filter) setting of the A/C.
Definition ir_Samsung.cpp:707
bool _lastsentpowerstate
Definition ir_Samsung.h:261
uint16_t _getOffTimer(void) const
Get the Off Timer setting of the A/C from a raw extended state.
Definition ir_Samsung.cpp:732
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 kSamsungAcMaxTemp
Definition ir_Samsung.h:166
const uint8_t kSamsungAcAuto
Definition ir_Samsung.h:168
const uint8_t kSamsungAcCool
Definition ir_Samsung.h:169
const uint8_t kSamsungAcFanAuto
Definition ir_Samsung.h:173
const uint8_t kSamsungAcHeat
Definition ir_Samsung.h:172
const uint8_t kSamsungAcFanHigh
Definition ir_Samsung.h:176
const uint8_t kSamsungAcFan
Definition ir_Samsung.h:171
const uint8_t kSamsungAcDry
Definition ir_Samsung.h:170
const uint8_t kSamsungAcFanLow
Definition ir_Samsung.h:174
const uint8_t kSamsungAcFanMed
Definition ir_Samsung.h:175
const uint8_t kSamsungAcAutoTemp
Definition ir_Samsung.h:167
const uint64_t kSamsungAcPowerSection
Definition ir_Samsung.h:180
const uint8_t kSamsungAcFanAuto2
Definition ir_Samsung.h:177
const uint16_t kSamsungAcSectionLength
Definition ir_Samsung.h:179
const uint8_t kSamsungAcMinTemp
Definition ir_Samsung.h:165
const uint8_t kSamsungAcFanTurbo
Definition ir_Samsung.h:178
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 Samsung A/C message.
Definition ir_Samsung.h:44
uint8_t OffTimeHrs2
Definition ir_Samsung.h:129
uint8_t OffTimerEnable
Definition ir_Samsung.h:138
uint8_t BeepToggle
Definition ir_Samsung.h:95
uint8_t OnTimeDay
Definition ir_Samsung.h:140
uint8_t FanSpecial
Definition ir_Samsung.h:79
uint8_t OffTimeMins
Definition ir_Samsung.h:126
uint8_t OnTimerEnable
Definition ir_Samsung.h:137
uint8_t OffTimeHrs1
Definition ir_Samsung.h:127
uint8_t Mode
Definition ir_Samsung.h:91
uint8_t OnTimeMins
Definition ir_Samsung.h:130
uint8_t Quiet
Definition ir_Samsung.h:62
uint8_t Sum3Lower
Definition ir_Samsung.h:149
uint8_t OnTimeHrs2
Definition ir_Samsung.h:133
uint8_t Fan
Definition ir_Samsung.h:90
uint8_t Sum2Lower
Definition ir_Samsung.h:123
uint8_t Sum1Lower
Definition ir_Samsung.h:106
uint8_t Power2
Definition ir_Samsung.h:97
uint8_t Sleep12
Definition ir_Samsung.h:139
uint8_t Ion
Definition ir_Samsung.h:84
uint8_t CleanToggle10
Definition ir_Samsung.h:82
uint8_t OffTimeDay
Definition ir_Samsung.h:136
uint8_t Sleep5
Definition ir_Samsung.h:61
uint8_t Sum1Upper
Definition ir_Samsung.h:108
uint8_t Display
Definition ir_Samsung.h:80
uint8_t raw[kSamsungAcExtendedStateLength]
State in code form.
Definition ir_Samsung.h:45
uint8_t Sum2Upper
Definition ir_Samsung.h:125
uint8_t Swing
Definition ir_Samsung.h:75
uint8_t Sum3Upper
Definition ir_Samsung.h:151
uint8_t CleanToggle11
Definition ir_Samsung.h:85
uint8_t Temp
Definition ir_Samsung.h:87
uint8_t OnTimeHrs1
Definition ir_Samsung.h:131
uint8_t Power1
Definition ir_Samsung.h:66