IRremoteESP8266
ir_Whirlpool.h
Go to the documentation of this file.
1 // Copyright 2018 David Conran
2 
10 
11 // Supports:
12 // Brand: Whirlpool, Model: DG11J1-3A remote
13 // Brand: Whirlpool, Model: DG11J1-04 remote
14 // Brand: Whirlpool, Model: DG11J1-91 remote
15 // Brand: Whirlpool, Model: SPIS409L A/C
16 // Brand: Whirlpool, Model: SPIS412L A/C
17 // Brand: Whirlpool, Model: SPIW409L A/C
18 // Brand: Whirlpool, Model: SPIW412L A/C
19 // Brand: Whirlpool, Model: SPIW418L A/C
20 
21 #ifndef IR_WHIRLPOOL_H_
22 #define IR_WHIRLPOOL_H_
23 
24 #define __STDC_LIMIT_MACROS
25 #include <stdint.h>
26 #ifndef UNIT_TEST
27 #include <Arduino.h>
28 #endif
29 #include "IRremoteESP8266.h"
30 #include "IRsend.h"
31 #ifdef UNIT_TEST
32 #include "IRsend_test.h"
33 #endif
34 
38  struct {
39  // Byte 0~1
40  uint8_t pad0[2];
41  // Byte 2
42  uint8_t Fan :2;
43  uint8_t Power :1;
44  uint8_t Sleep :1;
45  uint8_t :3;
46  uint8_t Swing1 :1;
47  // Byte 3
48  uint8_t Mode :3;
49  uint8_t :1;
50  uint8_t Temp :4;
51  // Byte 4
52  uint8_t :8;
53  // Byte 5
54  uint8_t :4;
55  uint8_t Super1 :1;
56  uint8_t :2;
57  uint8_t Super2 :1;
58  // Byte 6
59  uint8_t ClockHours :5;
60  uint8_t LightOff :1;
61  uint8_t :2;
62  // Byte 7
63  uint8_t ClockMins :6;
64  uint8_t :1;
65  uint8_t OffTimerEnabled :1;
66  // Byte 8
67  uint8_t OffHours :5;
68  uint8_t :1;
69  uint8_t Swing2 :1;
70  uint8_t :1;
71  // Byte 9
72  uint8_t OffMins :6;
73  uint8_t :1;
74  uint8_t OnTimerEnabled :1;
75  // Byte 10
76  uint8_t OnHours :5;
77  uint8_t :3;
78  // Byte 11
79  uint8_t OnMins :6;
80  uint8_t :2;
81  // Byte 12
82  uint8_t :8;
83  // Byte 13
84  uint8_t Sum1 :8;
85  // Byte 14
86  uint8_t :8;
87  // Byte 15
88  uint8_t Cmd :8;
89  // Byte 16~17
90  uint8_t pad1[2];
91  // Byte 18
92  uint8_t :3;
93  uint8_t J191 :1;
94  uint8_t :4;
95  // Byte 19
96  uint8_t :8;
97  // Byte 20
98  uint8_t Sum2 :8;
99  };
100 };
101 
102 // Constants
103 const uint8_t kWhirlpoolAcChecksumByte1 = 13;
105 const uint8_t kWhirlpoolAcHeat = 0;
106 const uint8_t kWhirlpoolAcAuto = 1;
107 const uint8_t kWhirlpoolAcCool = 2;
108 const uint8_t kWhirlpoolAcDry = 3;
109 const uint8_t kWhirlpoolAcFan = 4;
110 const uint8_t kWhirlpoolAcFanAuto = 0;
111 const uint8_t kWhirlpoolAcFanHigh = 1;
112 const uint8_t kWhirlpoolAcFanMedium = 2;
113 const uint8_t kWhirlpoolAcFanLow = 3;
114 const uint8_t kWhirlpoolAcMinTemp = 18; // 18C (DG11J1-3A), 16C (DG11J1-91)
115 const uint8_t kWhirlpoolAcMaxTemp = 32; // 32C (DG11J1-3A), 30C (DG11J1-91)
116 const uint8_t kWhirlpoolAcAutoTemp = 23; // 23C
117 const uint8_t kWhirlpoolAcCommandLight = 0x00;
118 const uint8_t kWhirlpoolAcCommandPower = 0x01;
119 const uint8_t kWhirlpoolAcCommandTemp = 0x02;
120 const uint8_t kWhirlpoolAcCommandSleep = 0x03;
121 const uint8_t kWhirlpoolAcCommandSuper = 0x04;
122 const uint8_t kWhirlpoolAcCommandOnTimer = 0x05;
123 const uint8_t kWhirlpoolAcCommandMode = 0x06;
124 const uint8_t kWhirlpoolAcCommandSwing = 0x07;
125 const uint8_t kWhirlpoolAcCommandIFeel = 0x0D;
126 const uint8_t kWhirlpoolAcCommandFanSpeed = 0x11;
127 const uint8_t kWhirlpoolAcCommand6thSense = 0x17;
128 const uint8_t kWhirlpoolAcCommandOffTimer = 0x1D;
129 
130 // Classes
133  public:
134  explicit IRWhirlpoolAc(const uint16_t pin, const bool inverted = false,
135  const bool use_modulation = true);
136  void stateReset(void);
137 #if SEND_WHIRLPOOL_AC
138  void send(const uint16_t repeat = kWhirlpoolAcDefaultRepeat,
139  const bool calcchecksum = true);
144  int8_t calibrate(void) { return _irsend.calibrate(); }
145 #endif // SEND_WHIRLPOOL_AC
146  void begin(void);
147  void setPowerToggle(const bool on);
148  bool getPowerToggle(void) const;
149  void setSleep(const bool on);
150  bool getSleep(void) const;
151  void setSuper(const bool on);
152  bool getSuper(void) const;
153  void setTemp(const uint8_t temp);
154  uint8_t getTemp(void) const;
155  void setFan(const uint8_t speed);
156  uint8_t getFan(void) const;
157  void setMode(const uint8_t mode);
158  uint8_t getMode(void) const;
159  void setSwing(const bool on);
160  bool getSwing(void) const;
161  void setLight(const bool on);
162  bool getLight(void) const;
163  uint16_t getClock(void) const;
164  void setClock(const uint16_t minspastmidnight);
165  uint16_t getOnTimer(void) const;
166  void setOnTimer(const uint16_t minspastmidnight);
167  void enableOnTimer(const bool on);
168  bool isOnTimerEnabled(void) const;
169  uint16_t getOffTimer(void) const;
170  void setOffTimer(const uint16_t minspastmidnight);
171  void enableOffTimer(const bool on);
172  bool isOffTimerEnabled(void) const;
173  void setCommand(const uint8_t code);
174  uint8_t getCommand(void) const;
176  void setModel(const whirlpool_ac_remote_model_t model);
177  uint8_t* getRaw(const bool calcchecksum = true);
178  void setRaw(const uint8_t new_code[],
179  const uint16_t length = kWhirlpoolAcStateLength);
180  static bool validChecksum(const uint8_t state[],
181  const uint16_t length = kWhirlpoolAcStateLength);
182  static uint8_t convertMode(const stdAc::opmode_t mode);
183  static uint8_t convertFan(const stdAc::fanspeed_t speed);
184  static stdAc::opmode_t toCommonMode(const uint8_t mode);
185  static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
186  stdAc::state_t toCommon(const stdAc::state_t *prev = NULL) const;
187  String toString(void) const;
188 #ifndef UNIT_TEST
189 
190  private:
192 #else // UNIT_TEST
193  IRsendTest _irsend;
195 #endif // UNIT_TEST
198  uint8_t _desiredtemp;
199  void checksum(const uint16_t length = kWhirlpoolAcStateLength);
200  void _setTemp(const uint8_t temp, const bool remember = true);
201  void _setMode(const uint8_t mode);
202  int8_t getTempOffset(void) const;
203 };
204 
205 #endif // IR_WHIRLPOOL_H_
IRWhirlpoolAc::getClock
uint16_t getClock(void) const
Get the clock time in nr. of minutes past midnight.
Definition: ir_Whirlpool.cpp:314
IRWhirlpoolAc::send
void send(const uint16_t repeat=kWhirlpoolAcDefaultRepeat, const bool calcchecksum=true)
Send the current internal state as an IR message.
Definition: ir_Whirlpool.cpp:142
IRWhirlpoolAc::stateReset
void stateReset(void)
Reset the state of the remote to a known good state/sequence.
Definition: ir_Whirlpool.cpp:94
WhirlpoolProtocol::raw
uint8_t raw[kWhirlpoolAcStateLength]
The state in IR code form.
Definition: ir_Whirlpool.h:37
IRWhirlpoolAc::getSwing
bool getSwing(void) const
Get the (vertical) swing setting of the A/C.
Definition: ir_Whirlpool.cpp:289
IRWhirlpoolAc::getFan
uint8_t getFan(void) const
Get the current fan speed setting.
Definition: ir_Whirlpool.cpp:275
WhirlpoolProtocol::Swing1
uint8_t Swing1
Definition: ir_Whirlpool.h:46
kWhirlpoolAcCommandSuper
const uint8_t kWhirlpoolAcCommandSuper
Definition: ir_Whirlpool.h:121
WhirlpoolProtocol::Swing2
uint8_t Swing2
Definition: ir_Whirlpool.h:69
IRWhirlpoolAc::calibrate
int8_t calibrate(void)
Run the calibration to calculate uSec timing offsets for this platform.
Definition: ir_Whirlpool.h:144
IRWhirlpoolAc::convertMode
static uint8_t convertMode(const stdAc::opmode_t mode)
Convert a stdAc::opmode_t enum into its native mode.
Definition: ir_Whirlpool.cpp:441
IRWhirlpoolAc::getCommand
uint8_t getCommand(void) const
Get the Command (Button) setting of the A/C.
Definition: ir_Whirlpool.cpp:384
IRWhirlpoolAc::_setTemp
void _setTemp(const uint8_t temp, const bool remember=true)
Set the temperature.
Definition: ir_Whirlpool.cpp:200
stdAc::fanspeed_t
fanspeed_t
Common A/C settings for Fan Speeds.
Definition: IRsend.h:61
IRWhirlpoolAc::getMode
uint8_t getMode(void) const
Get the operating mode setting of the A/C.
Definition: ir_Whirlpool.cpp:254
whirlpool_ac_remote_model_t
whirlpool_ac_remote_model_t
Whirlpool A/C model numbers.
Definition: IRsend.h:211
kWhirlpoolAcAutoTemp
const uint8_t kWhirlpoolAcAutoTemp
Definition: ir_Whirlpool.h:116
WhirlpoolProtocol::OnMins
uint8_t OnMins
Definition: ir_Whirlpool.h:79
kWhirlpoolAcFanHigh
const uint8_t kWhirlpoolAcFanHigh
Definition: ir_Whirlpool.h:111
IRWhirlpoolAc::toCommon
stdAc::state_t toCommon(const stdAc::state_t *prev=NULL) const
Convert the current internal state into its stdAc::state_t equivalent.
Definition: ir_Whirlpool.cpp:495
kWhirlpoolAcMaxTemp
const uint8_t kWhirlpoolAcMaxTemp
Definition: ir_Whirlpool.h:115
kWhirlpoolAcAuto
const uint8_t kWhirlpoolAcAuto
Definition: ir_Whirlpool.h:106
IRWhirlpoolAc::convertFan
static uint8_t convertFan(const stdAc::fanspeed_t speed)
Convert a stdAc::fanspeed_t enum into it's native speed.
Definition: ir_Whirlpool.cpp:456
IRWhirlpoolAc::toCommonFanSpeed
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed)
Convert a native fan speed into its stdAc equivalent.
Definition: ir_Whirlpool.cpp:483
IRWhirlpoolAc::getOffTimer
uint16_t getOffTimer(void) const
Get the Off Timer time..
Definition: ir_Whirlpool.cpp:326
IRWhirlpoolAc::getSleep
bool getSleep(void) const
Get the Sleep setting of the A/C.
Definition: ir_Whirlpool.cpp:398
IRWhirlpoolAc::IRWhirlpoolAc
IRWhirlpoolAc(const uint16_t pin, const bool inverted=false, const bool use_modulation=true)
Class constructor.
Definition: ir_Whirlpool.cpp:89
IRWhirlpoolAc::toString
String toString(void) const
Convert the current internal state into a human readable string.
Definition: ir_Whirlpool.cpp:530
kWhirlpoolAcCommandOnTimer
const uint8_t kWhirlpoolAcCommandOnTimer
Definition: ir_Whirlpool.h:122
IRsend.h
IRWhirlpoolAc::setTemp
void setTemp(const uint8_t temp)
Set the temperature.
Definition: ir_Whirlpool.cpp:210
kWhirlpoolAcCommandIFeel
const uint8_t kWhirlpoolAcCommandIFeel
Definition: ir_Whirlpool.h:125
IRWhirlpoolAc::getModel
whirlpool_ac_remote_model_t getModel(void) const
Get/Detect the model of the A/C.
Definition: ir_Whirlpool.cpp:165
IRWhirlpoolAc::setClock
void setClock(const uint16_t minspastmidnight)
Set the clock time in nr. of minutes past midnight.
Definition: ir_Whirlpool.cpp:308
IRWhirlpoolAc::getTempOffset
int8_t getTempOffset(void) const
Calculate the temp. offset in deg C for the current model.
Definition: ir_Whirlpool.cpp:189
IRsend
Class for sending all basic IR protocols.
Definition: IRsend.h:237
WhirlpoolProtocol::Super1
uint8_t Super1
Definition: ir_Whirlpool.h:55
IRsend::calibrate
int8_t calibrate(uint16_t hz=38000U)
Calculate & set any offsets to account for execution times during sending.
Definition: IRsend.cpp:207
kWhirlpoolAcChecksumByte1
const uint8_t kWhirlpoolAcChecksumByte1
Definition: ir_Whirlpool.h:103
IRWhirlpoolAc
Class for handling detailed Whirlpool A/C messages.
Definition: ir_Whirlpool.h:132
String
std::string String
Definition: IRremoteESP8266.h:1521
kWhirlpoolAcCommandMode
const uint8_t kWhirlpoolAcCommandMode
Definition: ir_Whirlpool.h:123
IRWhirlpoolAc::getTemp
uint8_t getTemp(void) const
Get the current temperature setting.
Definition: ir_Whirlpool.cpp:218
IRWhirlpoolAc::isOffTimerEnabled
bool isOffTimerEnabled(void) const
Is the Off timer enabled?
Definition: ir_Whirlpool.cpp:332
WhirlpoolProtocol::pad1
uint8_t pad1[2]
Definition: ir_Whirlpool.h:90
kWhirlpoolAcCool
const uint8_t kWhirlpoolAcCool
Definition: ir_Whirlpool.h:107
kWhirlpoolAcCommandOffTimer
const uint8_t kWhirlpoolAcCommandOffTimer
Definition: ir_Whirlpool.h:128
IRremoteESP8266.h
IRWhirlpoolAc::getPowerToggle
bool getPowerToggle(void) const
Get the value of the current power toggle setting.
Definition: ir_Whirlpool.cpp:378
kWhirlpoolAcCommandSwing
const uint8_t kWhirlpoolAcCommandSwing
Definition: ir_Whirlpool.h:124
WhirlpoolProtocol::OffHours
uint8_t OffHours
Definition: ir_Whirlpool.h:67
WhirlpoolProtocol
Native representation of a Whirlpool A/C message.
Definition: ir_Whirlpool.h:36
IRWhirlpoolAc::_
WhirlpoolProtocol _
Definition: ir_Whirlpool.h:197
IRWhirlpoolAc::validChecksum
static bool validChecksum(const uint8_t state[], const uint16_t length=kWhirlpoolAcStateLength)
Verify the checksum is valid for a given state.
Definition: ir_Whirlpool.cpp:109
kWhirlpoolAcFanMedium
const uint8_t kWhirlpoolAcFanMedium
Definition: ir_Whirlpool.h:112
kWhirlpoolAcDry
const uint8_t kWhirlpoolAcDry
Definition: ir_Whirlpool.h:108
IRWhirlpoolAc::setPowerToggle
void setPowerToggle(const bool on)
Change the power toggle setting.
Definition: ir_Whirlpool.cpp:370
IRWhirlpoolAc::setOffTimer
void setOffTimer(const uint16_t minspastmidnight)
Set the Off Timer time.
Definition: ir_Whirlpool.cpp:320
WhirlpoolProtocol::Sleep
uint8_t Sleep
Definition: ir_Whirlpool.h:44
kWhirlpoolAcCommandLight
const uint8_t kWhirlpoolAcCommandLight
Definition: ir_Whirlpool.h:117
IRWhirlpoolAc::_setMode
void _setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Whirlpool.cpp:225
WhirlpoolProtocol::ClockMins
uint8_t ClockMins
Definition: ir_Whirlpool.h:63
kWhirlpoolAcFanLow
const uint8_t kWhirlpoolAcFanLow
Definition: ir_Whirlpool.h:113
kWhirlpoolAcDefaultRepeat
const uint16_t kWhirlpoolAcDefaultRepeat
Definition: IRremoteESP8266.h:1418
IRWhirlpoolAc::setModel
void setModel(const whirlpool_ac_remote_model_t model)
Set the model of the A/C to emulate.
Definition: ir_Whirlpool.cpp:174
IRWhirlpoolAc::setSuper
void setSuper(const bool on)
Set the Super (Turbo/Jet) setting of the A/C.
Definition: ir_Whirlpool.cpp:404
WhirlpoolProtocol::Power
uint8_t Power
Definition: ir_Whirlpool.h:43
kWhirlpoolAcChecksumByte2
const uint8_t kWhirlpoolAcChecksumByte2
Definition: ir_Whirlpool.h:104
kWhirlpoolAcFan
const uint8_t kWhirlpoolAcFan
Definition: ir_Whirlpool.h:109
WhirlpoolProtocol::OffMins
uint8_t OffMins
Definition: ir_Whirlpool.h:72
kWhirlpoolAcCommandFanSpeed
const uint8_t kWhirlpoolAcCommandFanSpeed
Definition: ir_Whirlpool.h:126
IRWhirlpoolAc::setCommand
void setCommand(const uint8_t code)
Set the Command (Button) setting of the A/C.
Definition: ir_Whirlpool.cpp:434
kWhirlpoolAcStateLength
const uint16_t kWhirlpoolAcStateLength
Definition: IRremoteESP8266.h:1416
WhirlpoolProtocol::Cmd
uint8_t Cmd
Definition: ir_Whirlpool.h:88
IRWhirlpoolAc::setRaw
void setRaw(const uint8_t new_code[], const uint16_t length=kWhirlpoolAcStateLength)
Set the internal state from a valid code for this protocol.
Definition: ir_Whirlpool.cpp:159
kWhirlpoolAcMinTemp
const uint8_t kWhirlpoolAcMinTemp
Definition: ir_Whirlpool.h:114
IRWhirlpoolAc::setSleep
void setSleep(const bool on)
Set the Sleep setting of the A/C.
Definition: ir_Whirlpool.cpp:390
IRWhirlpoolAc::setMode
void setMode(const uint8_t mode)
Set the operating mode of the A/C.
Definition: ir_Whirlpool.cpp:247
WhirlpoolProtocol::OnTimerEnabled
uint8_t OnTimerEnabled
Definition: ir_Whirlpool.h:74
kWhirlpoolAcHeat
const uint8_t kWhirlpoolAcHeat
Definition: ir_Whirlpool.h:105
IRWhirlpoolAc::checksum
void checksum(const uint16_t length=kWhirlpoolAcStateLength)
Calculate & set the checksum for the current internal state of the remote.
Definition: ir_Whirlpool.cpp:130
IRWhirlpoolAc::isOnTimerEnabled
bool isOnTimerEnabled(void) const
Is the On timer enabled?
Definition: ir_Whirlpool.cpp:357
IRWhirlpoolAc::enableOffTimer
void enableOffTimer(const bool on)
Enable the Off Timer.
Definition: ir_Whirlpool.cpp:338
kWhirlpoolAcCommandPower
const uint8_t kWhirlpoolAcCommandPower
Definition: ir_Whirlpool.h:118
IRWhirlpoolAc::enableOnTimer
void enableOnTimer(const bool on)
Enable the On Timer.
Definition: ir_Whirlpool.cpp:363
IRWhirlpoolAc::_irsend
IRsend _irsend
Instance of the IR send class.
Definition: ir_Whirlpool.h:191
IRWhirlpoolAc::setOnTimer
void setOnTimer(const uint16_t minspastmidnight)
Set the On Timer time.
Definition: ir_Whirlpool.cpp:345
IRWhirlpoolAc::_desiredtemp
uint8_t _desiredtemp
The last user explicitly set temperature.
Definition: ir_Whirlpool.h:198
WhirlpoolProtocol::LightOff
uint8_t LightOff
Definition: ir_Whirlpool.h:60
WhirlpoolProtocol::OnHours
uint8_t OnHours
Definition: ir_Whirlpool.h:76
WhirlpoolProtocol::Fan
uint8_t Fan
Definition: ir_Whirlpool.h:42
WhirlpoolProtocol::OffTimerEnabled
uint8_t OffTimerEnabled
Definition: ir_Whirlpool.h:65
kWhirlpoolAcCommandTemp
const uint8_t kWhirlpoolAcCommandTemp
Definition: ir_Whirlpool.h:119
WhirlpoolProtocol::Super2
uint8_t Super2
Definition: ir_Whirlpool.h:57
kWhirlpoolAcCommand6thSense
const uint8_t kWhirlpoolAcCommand6thSense
Definition: ir_Whirlpool.h:127
kWhirlpoolAcCommandSleep
const uint8_t kWhirlpoolAcCommandSleep
Definition: ir_Whirlpool.h:120
WhirlpoolProtocol::Sum1
uint8_t Sum1
Definition: ir_Whirlpool.h:84
WhirlpoolProtocol::Sum2
uint8_t Sum2
Definition: ir_Whirlpool.h:98
WhirlpoolProtocol::J191
uint8_t J191
Definition: ir_Whirlpool.h:93
WhirlpoolProtocol::ClockHours
uint8_t ClockHours
Definition: ir_Whirlpool.h:59
IRWhirlpoolAc::begin
void begin(void)
Set up hardware to be able to send a message.
Definition: ir_Whirlpool.cpp:103
IRWhirlpoolAc::getLight
bool getLight(void) const
Get the Light (Display/LED) setting of the A/C.
Definition: ir_Whirlpool.cpp:302
WhirlpoolProtocol::pad0
uint8_t pad0[2]
Definition: ir_Whirlpool.h:40
IRWhirlpoolAc::getOnTimer
uint16_t getOnTimer(void) const
Get the On Timer time..
Definition: ir_Whirlpool.cpp:351
stdAc::state_t
Structure to hold a common A/C state.
Definition: IRsend.h:114
IRWhirlpoolAc::setFan
void setFan(const uint8_t speed)
Set the speed of the fan.
Definition: ir_Whirlpool.cpp:260
IRWhirlpoolAc::setLight
void setLight(const bool on)
Set the Light (Display/LED) setting of the A/C.
Definition: ir_Whirlpool.cpp:295
WhirlpoolProtocol::Mode
uint8_t Mode
Definition: ir_Whirlpool.h:48
IRWhirlpoolAc::setSwing
void setSwing(const bool on)
Set the (vertical) swing setting of the A/C.
Definition: ir_Whirlpool.cpp:281
WhirlpoolProtocol::Temp
uint8_t Temp
Definition: ir_Whirlpool.h:50
IRWhirlpoolAc::toCommonMode
static stdAc::opmode_t toCommonMode(const uint8_t mode)
Convert a native mode into its stdAc equivalent.
Definition: ir_Whirlpool.cpp:470
IRWhirlpoolAc::getSuper
bool getSuper(void) const
Get the Super (Turbo/Jet) setting of the A/C.
Definition: ir_Whirlpool.cpp:428
kWhirlpoolAcFanAuto
const uint8_t kWhirlpoolAcFanAuto
Definition: ir_Whirlpool.h:110
IRWhirlpoolAc::getRaw
uint8_t * getRaw(const bool calcchecksum=true)
Get a copy of the internal state/code for this protocol.
Definition: ir_Whirlpool.cpp:151
stdAc::opmode_t
opmode_t
Common A/C settings for A/C operating modes.
Definition: IRsend.h:49