6
6
// Brand: Electrolux, Model: Electrolux EACM EZ/N3
7
7
8
8
#include " ir_Electrolux.h"
9
+ #include < Arduino.h>
9
10
#include < algorithm>
10
11
#include " IRac.h"
11
12
#include " IRrecv.h"
@@ -124,11 +125,11 @@ void IRElectroluxAc::begin(void) { _irsend.begin(); }
124
125
125
126
// / Turn on/off the Power Airwell setting.
126
127
// / @param[in] on The desired setting state.
127
- void IRElectroluxAc::setPowerToggle (const bool on) { _.PowerToggle = on; }
128
+ void IRElectroluxAc::setPower (const bool on) { _.Power = on; }
128
129
129
130
// / Get the power toggle setting from the internal state.
130
131
// / @return A boolean indicating the setting.
131
- bool IRElectroluxAc::getPowerToggle (void ) const { return _.PowerToggle ; }
132
+ bool IRElectroluxAc::getPower (void ) const { return _.Power ; }
132
133
133
134
// / Turn on/off the fahrenheit temp mode.
134
135
// / @param[in] on The desired setting state.
@@ -142,14 +143,15 @@ bool IRElectroluxAc::getTempModeFahrenheit(void) const { return _.TempModeFahren
142
143
// / @param[in] degrees The temperature in celsius or fahrenheit.
143
144
void IRElectroluxAc::setTemp (const uint8_t degrees) {
144
145
if (getTempModeFahrenheit ()) {
145
- uint8_t temp = std:: max (kElectroluxAcMaxFTemp , degrees);
146
- temp = std:: min (kElectroluxAcMinFTemp , temp);
146
+ uint8_t temp = max (kElectroluxAcMinFTemp , degrees);
147
+ temp = min (kElectroluxAcMaxFTemp , temp);
147
148
_.Temp = (temp - kElectroluxAcMinFTemp );
148
149
}
149
150
else {
150
- uint8_t temp = std::max (kElectroluxAcMaxTemp , degrees);
151
- temp = std::min (kElectroluxAcMinTemp , temp);
152
- _.Temp = ((temp - kElectroluxAcMinTemp ) * 1.8 ); // TODO: fix accuracy
151
+ uint8_t temp = max (kElectroluxAcMinTemp , degrees);
152
+ temp = min (kElectroluxAcMaxTemp , temp);
153
+ temp = map (temp, kElectroluxAcMinTemp , kElectroluxAcMaxTemp , kElectroluxAcMinFTemp , kElectroluxAcMaxFTemp );
154
+ _.Temp = temp - kElectroluxAcMinFTemp ;
153
155
}
154
156
}
155
157
@@ -160,7 +162,8 @@ uint8_t IRElectroluxAc::getTemp(void) const {
160
162
return _.Temp + kElectroluxAcMinFTemp ;
161
163
}
162
164
else {
163
- return (_.Temp / 1.8 ) + kElectroluxAcMinTemp ; // TODO: fix accuracy
165
+ uint8_t temp = map (_.Temp + kElectroluxAcMinFTemp , kElectroluxAcMinFTemp , kElectroluxAcMaxFTemp , kElectroluxAcMinTemp , kElectroluxAcMaxTemp );
166
+ return temp;
164
167
}
165
168
}
166
169
@@ -239,10 +242,10 @@ void IRElectroluxAc::setRaw(const uint64_t state) { _.raw = state; }
239
242
// / @param[in] state The value to calc the checksum of.
240
243
// / @return The 4-bit checksum stored in a uint_8.
241
244
uint8_t IRElectroluxAc::calcChecksum (const uint64_t state) {
242
- uint32_t data = GETBITS32 (state, 0 , kElectroluxAcBits - 4 );
245
+ uint32_t data = GETBITS64 (state, kElectroluxAcChecksumSize + kElectroluxAcChecksumOffset , kElectroluxAcBits - 4 );
243
246
uint8_t result = 0 ;
244
247
for (; data; data >>= 4 ) // Add each nibble together.
245
- result += GETBITS32 (data, 0 , 4 );
248
+ result += GETBITS8 (data, 0 , 4 );
246
249
return (result ^ 0xF ) & 0xF ;
247
250
}
248
251
@@ -325,7 +328,7 @@ stdAc::state_t IRElectroluxAc::toCommon(const stdAc::state_t *prev) const {
325
328
result.power = false ;
326
329
}
327
330
result.protocol = decode_type_t ::ELETROLUX_AC;
328
- result.power = _.PowerToggle ;
331
+ result.power = _.Power ;
329
332
result.mode = toCommonMode (_.Mode );
330
333
result.celsius = !getTempModeFahrenheit ();
331
334
result.degrees = getTemp ();
@@ -351,17 +354,17 @@ stdAc::state_t IRElectroluxAc::toCommon(const stdAc::state_t *prev) const {
351
354
String IRElectroluxAc::toString (void ) const {
352
355
String result = " " ;
353
356
result.reserve (120 ); // Reserve some heap for the string to reduce fragging.
354
- result += addBoolToString (_.PowerToggle , kPowerStr , false );
357
+ result += addBoolToString (_.Power , kPowerStr , false );
355
358
result += addModeToString (_.Mode , kElectroluxModeAuto , kElectroluxModeCool ,
356
359
0xFF , kElectroluxModeDry , kElectroluxModeFan );
357
- result += addTempToString (getTemp ());
360
+ result += addTempToString (getTemp (), ! getTempModeFahrenheit () );
358
361
result += addFanToString (_.Fan , kElectroluxFanHigh , kElectroluxFanLow ,
359
362
kElectroluxFanAuto , kElectroluxFanAuto ,
360
363
kElectroluxFanMedium );
361
364
362
365
result += addBoolToString (getQuiet (), kQuietStr );
363
366
364
- if (getPowerToggle ()) {
367
+ if (getPower ()) {
365
368
result += irutils::addLabeledString (irutils::minsToString (getOnOffTimer ()), kOffTimerStr );
366
369
}
367
370
else {
@@ -373,4 +376,10 @@ String IRElectroluxAc::toString(void) const {
373
376
// / Calculate and set the checksum values for the internal state.
374
377
void IRElectroluxAc::checksum (void ) {
375
378
_.Sum = calcChecksum (_.raw );
376
- }
379
+ }
380
+
381
+ // / Set the requested power state of the A/C to on.
382
+ void IRElectroluxAc::on (void ) { setPower (true ); }
383
+
384
+ // / Set the requested power state of the A/C to off.
385
+ void IRElectroluxAc::off (void ) { setPower (false ); }
0 commit comments