Skip to content

Commit 3c8c416

Browse files
committed
fix: code formatting
1 parent ebce640 commit 3c8c416

File tree

2 files changed

+65
-57
lines changed

2 files changed

+65
-57
lines changed

src/ir_Electrolux.cpp

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const uint16_t kElectroluxAcBitMark = 752;
1919
const uint16_t kElectroluxAcHdrSpace = 2700;
2020
const uint16_t kElectroluxAcOneSpace = 2149;
2121
const uint16_t kElectroluxAcZeroSpace = 756;
22-
const uint16_t kElectroluxAcFreq = 38000; // Hz.
22+
const uint16_t kElectroluxAcFreq = 38000;
2323
const uint16_t kElectroluxAcOverhead = 3;
2424

2525
#if SEND_ELECTROLUX_AC
@@ -48,10 +48,12 @@ void IRsend::sendElectroluxAc(
4848
send_data >>= 32;
4949
// Footer
5050
mark(kElectroluxAcBitMark);
51-
space(kDefaultMessageGap); // A 100% made up guess of the gap between messages.
51+
52+
// A 100% made up guess of the gap between messages.
53+
space(kDefaultMessageGap);
5254
}
5355
}
54-
#endif // SEND_ELECTROLUX
56+
#endif // SEND_ELECTROLUX
5557

5658
#if DECODE_ELECTROLUX_AC
5759
// Function should be safe up to 64 bits.
@@ -69,8 +71,8 @@ bool IRrecv::decodeElectroluxAc(
6971
const uint16_t nbits,
7072
const bool strict
7173
) {
72-
if (results->rawlen < 2 * nbits + kElectroluxAcOverhead - offset) // rawlen = 68, nbits = 104
73-
return false; // Too short a message to match.
74+
if (results->rawlen < 2 * nbits + kElectroluxAcOverhead - offset)
75+
return false; // Too short a message to match.
7476
if (strict && nbits != kElectroluxAcBits)
7577
return false;
7678

@@ -84,13 +86,15 @@ bool IRrecv::decodeElectroluxAc(
8486

8587
// Data Section #1
8688
// e.g. data_result.data = 0xED000004, nbits = 32
87-
match_result_t data_result = matchData(&(results->rawbuf[offset]), 32,
88-
kElectroluxAcBitMark, kElectroluxAcOneSpace,
89-
kElectroluxAcBitMark, kElectroluxAcZeroSpace);
89+
match_result_t data_result = matchData(
90+
&(results->rawbuf[offset]), 32,
91+
kElectroluxAcBitMark, kElectroluxAcOneSpace,
92+
kElectroluxAcBitMark, kElectroluxAcZeroSpace);
93+
9094
offset += data_result.used;
9195
if (data_result.success == false)
92-
return false; // Fail
93-
data <<= 32; // Make room for the new bits of data.
96+
return false; // Fail
97+
data <<= 32; // Make room for the new bits of data.
9498
data |= data_result.data;
9599

96100
// Footer
@@ -105,7 +109,7 @@ bool IRrecv::decodeElectroluxAc(
105109
results->address = 0;
106110
return true;
107111
}
108-
#endif // DECODE_ELECTROLUX
112+
#endif // DECODE_ELECTROLUX
109113

110114
/// Class constructor
111115
/// @param[in] pin GPIO to be used when sending.
@@ -130,7 +134,7 @@ void IRElectroluxAc::stateReset() { _.raw = 0xF3008005; }
130134
void IRElectroluxAc::send(const uint16_t repeat) {
131135
_irsend.sendElectroluxAc(getRaw(), kElectroluxAcBits, repeat);
132136
}
133-
#endif // SEND_ELECTROLUX_AC
137+
#endif // SEND_ELECTROLUX_AC
134138

135139
/// Set up hardware to be able to send a message.
136140
void IRElectroluxAc::begin() { _irsend.begin(); }
@@ -145,11 +149,15 @@ bool IRElectroluxAc::getPower() const { return _.Power; }
145149

146150
/// Turn on/off the fahrenheit temp mode.
147151
/// @param[in] on The desired setting state.
148-
void IRElectroluxAc::setTempModeFahrenheit(const bool on) { _.TempModeFahrenheit = on; }
152+
void IRElectroluxAc::setTempModeFahrenheit(const bool on) {
153+
_.TempModeFahrenheit = on;
154+
}
149155

150156
/// Get the fahrenheit temp mode set from the internal state.
151157
/// @return A boolean indicating the setting.
152-
bool IRElectroluxAc::getTempModeFahrenheit() const { return _.TempModeFahrenheit; }
158+
bool IRElectroluxAc::getTempModeFahrenheit() const {
159+
return _.TempModeFahrenheit;
160+
}
153161

154162
/// Set the temperature.
155163
/// @param[in] degrees The temperature in celsius or fahrenheit.
@@ -162,7 +170,8 @@ void IRElectroluxAc::setTemp(const uint8_t degrees) {
162170
uint8_t temp = max(kElectroluxAcMinTemp, degrees);
163171
temp = min(kElectroluxAcMaxTemp, temp);
164172
#ifndef UNIT_TEST
165-
temp = map(temp, kElectroluxAcMinTemp, kElectroluxAcMaxTemp, kElectroluxAcMinFTemp, kElectroluxAcMaxFTemp);
173+
temp = map(temp, kElectroluxAcMinTemp, kElectroluxAcMaxTemp,
174+
kElectroluxAcMinFTemp, kElectroluxAcMaxFTemp);
166175
#else
167176
temp = temp * 9 / 5 + 32;
168177
#endif
@@ -177,7 +186,8 @@ uint8_t IRElectroluxAc::getTemp() const {
177186
return _.Temp + kElectroluxAcMinFTemp;
178187
} else {
179188
#ifndef UNIT_TEST
180-
uint8_t temp = map(_.Temp + kElectroluxAcMinFTemp, kElectroluxAcMinFTemp, kElectroluxAcMaxFTemp,
189+
uint8_t temp = map(_.Temp + kElectroluxAcMinFTemp,
190+
kElectroluxAcMinFTemp, kElectroluxAcMaxFTemp,
181191
kElectroluxAcMinTemp, kElectroluxAcMaxTemp);
182192
#else
183193
uint8_t temp = ((_.Temp + kElectroluxAcMinFTemp) - 32) * 5 / 9;
@@ -225,11 +235,11 @@ uint8_t IRElectroluxAc::getMode() const { return _.Mode; }
225235
void IRElectroluxAc::setOnOffTimer(const uint16_t nr_of_mins) {
226236
const uint8_t hours = std::min(
227237
static_cast<uint8_t>(nr_of_mins / 60),
228-
kElectroluxTimerMax
229-
);
238+
kElectroluxTimerMax);
239+
230240
// The time can be changed in sleep mode, but doesn't set the flag.
231241
_.TimerEnabled = hours > 0;
232-
_.Timer = std::max(kElectroluxTimerMin, hours); // Hours
242+
_.Timer = std::max(kElectroluxTimerMin, hours); // Hours
233243
}
234244

235245
/// Get the current On/Off Timer time.
@@ -250,7 +260,7 @@ bool IRElectroluxAc::getQuiet() const { return _.Quiet; }
250260
/// Get a copy of the internal state as a valid code for this protocol.
251261
/// @return A valid code for this protocol based on the current internal state.
252262
uint64_t IRElectroluxAc::getRaw() {
253-
checksum(); // Ensure correct settings before sending.
263+
checksum(); // Ensure correct settings before sending.
254264
return _.raw;
255265
}
256266

@@ -265,10 +275,10 @@ uint8_t IRElectroluxAc::calcChecksum(const uint64_t state) {
265275
uint32_t data = GETBITS64(
266276
state,
267277
kElectroluxAcChecksumSize + kElectroluxAcChecksumOffset,
268-
kElectroluxAcBits - 4
269-
);
278+
kElectroluxAcBits - 4);
279+
270280
uint8_t result = 0;
271-
for (; data; data >>= 4) // Add each nibble together.
281+
for (; data; data >>= 4) // Add each nibble together.
272282
result += GETBITS8(data, 0, 4);
273283
return (result ^ 0xF) & 0xF;
274284
}
@@ -389,45 +399,43 @@ stdAc::state_t IRElectroluxAc::toCommon(const stdAc::state_t *prev) const {
389399
/// @return The current internal state expressed as a human readable String.
390400
String IRElectroluxAc::toString() const {
391401
String result = "";
392-
result.reserve(120); // Reserve some heap for the string to reduce fragging.
402+
result.reserve(120); // Reserve heap for the string to reduce fragging.
403+
393404
result += addBoolToString(
394405
_.Power,
395406
kPowerStr,
396-
false
397-
);
407+
false);
408+
398409
result += addModeToString(
399410
_.Mode,
400411
kElectroluxModeAuto,
401412
kElectroluxModeCool,
402413
0xFF,
403414
kElectroluxModeDry,
404-
kElectroluxModeFan
405-
);
415+
kElectroluxModeFan);
416+
406417
result += addTempToString(
407418
getTemp(),
408-
!getTempModeFahrenheit()
409-
);
419+
!getTempModeFahrenheit());
420+
410421
result += addFanToString(
411422
_.Fan,
412423
kElectroluxFanHigh,
413424
kElectroluxFanLow,
414425
kElectroluxFanAuto,
415426
kElectroluxFanAuto,
416-
kElectroluxFanMedium
417-
);
427+
kElectroluxFanMedium);
418428

419429
result += addBoolToString(getQuiet(), kQuietStr);
420430

421431
if (getPower()) {
422432
result += irutils::addLabeledString(
423433
irutils::minsToString(getOnOffTimer()),
424-
kOffTimerStr
425-
);
434+
kOffTimerStr);
426435
} else {
427436
result += irutils::addLabeledString(
428437
irutils::minsToString(getOnOffTimer()),
429-
kOnTimerStr
430-
);
438+
kOnTimerStr);
431439
}
432440
return result;
433441
}

src/ir_Electrolux.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#endif
2121

2222
union ElectroluxAcProtocol {
23-
uint64_t raw; // The state of the IR remote in native IR code form.
23+
uint64_t raw; // The state of the IR remote in native IR code form.
2424
struct {
2525
uint8_t Sum: 4;
2626
uint8_t : 4;
@@ -39,30 +39,30 @@ union ElectroluxAcProtocol {
3939
};
4040

4141
// Constants
42-
const uint8_t kElectroluxAcMinTemp = 16; // 16C
43-
const uint8_t kElectroluxAcMaxTemp = 32; // 32C
44-
const uint8_t kElectroluxAcMinFTemp = 60; // 60F
45-
const uint8_t kElectroluxAcMaxFTemp = 90; // 90F
46-
const uint8_t kElectroluxTimerMax = 12; // 12H
47-
const uint8_t kElectroluxTimerMin = 1; // 1H
42+
const uint8_t kElectroluxAcMinTemp = 16; // 16C
43+
const uint8_t kElectroluxAcMaxTemp = 32; // 32C
44+
const uint8_t kElectroluxAcMinFTemp = 60; // 60F
45+
const uint8_t kElectroluxAcMaxFTemp = 90; // 90F
46+
const uint8_t kElectroluxTimerMax = 12; // 12H
47+
const uint8_t kElectroluxTimerMin = 1; // 1H
4848
const uint64_t kElectroluxAcKnownGoodState = 0xF3008005;
4949
const uint8_t kElectroluxAcChecksumOffset = 0;
5050
const uint8_t kElectroluxAcChecksumSize = 4;
5151

5252
// Fan
53-
const uint8_t kElectroluxFanLow = 2; // 0b11
54-
const uint8_t kElectroluxFanMedium = 1; // 0b01
55-
const uint8_t kElectroluxFanHigh = 0; // 0b00
56-
const uint8_t kElectroluxFanAuto = 3; // 0b11
53+
const uint8_t kElectroluxFanLow = 2; // 0b11
54+
const uint8_t kElectroluxFanMedium = 1; // 0b01
55+
const uint8_t kElectroluxFanHigh = 0; // 0b00
56+
const uint8_t kElectroluxFanAuto = 3; // 0b11
5757

5858
// Modes
59-
const uint8_t kElectroluxModeCool = 0; // 0b000
60-
const uint8_t kElectroluxModeDry = 1; // 0b001
61-
const uint8_t kElectroluxModeFan = 2; // 0b010
62-
const uint8_t kElectroluxModeAuto = 4; // 0b100
59+
const uint8_t kElectroluxModeCool = 0; // 0b000
60+
const uint8_t kElectroluxModeDry = 1; // 0b001
61+
const uint8_t kElectroluxModeFan = 2; // 0b010
62+
const uint8_t kElectroluxModeAuto = 4; // 0b100
6363

6464
class IRElectroluxAc {
65-
public:
65+
public:
6666
explicit IRElectroluxAc(uint16_t pin, bool inverted = false,
6767
bool use_modulation = true);
6868

@@ -75,7 +75,7 @@ class IRElectroluxAc {
7575
/// @note This will produce a 65ms IR signal pulse at 38kHz.
7676
/// Only ever needs to be run once per object instantiation, if at all.
7777
int8_t calibrate() { return _irsend.calibrate(); }
78-
#endif // SEND_ELECTROLUX_AC
78+
#endif // SEND_ELECTROLUX_AC
7979
void begin();
8080

8181
void on();
@@ -132,16 +132,16 @@ class IRElectroluxAc {
132132

133133
#ifndef UNIT_TEST
134134

135-
private:
136-
IRsend _irsend; ///< Instance of the IR send class
135+
private:
136+
IRsend _irsend; ///< Instance of the IR send class
137137
#else // UNIT_TEST
138138
/// @cond IGNORE
139-
IRsendTest _irsend; ///< Instance of the testing IR send class
139+
IRsendTest _irsend; ///< Instance of the testing IR send class
140140
/// @endcond
141141
#endif // UNIT_TEST
142142
ElectroluxAcProtocol _{};
143143

144144
void checksum();
145145
};
146146

147-
#endif // IR_ELECTROLUX_AC_H_
147+
#endif // IR_ELECTROLUX_AC_H_

0 commit comments

Comments
 (0)