Skip to content

Commit 3c7ef26

Browse files
committed
Fix linting issue and missed files
1 parent 98554a5 commit 3c7ef26

File tree

8 files changed

+62
-23
lines changed

8 files changed

+62
-23
lines changed

src/IRsend.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ enum argo_ac_remote_model_t {
228228
SAC_WREM3 // (2) ARGO WREM3 remote (touch buttons), bit-len vary by cmd
229229
};
230230

231+
/// Toshiba A/C model numbers
232+
enum toshiba_ac_remote_model_t {
233+
kToshibaGenericRemote_A = 0, // Default from existing codebase
234+
kToshibaGenericRemote_B = 1, // Newly discovered remote control b, applies to
235+
// many remote models such as WA-TH03A, WA-TH04A etc.
236+
};
237+
231238
// Classes
232239

233240
/// Class for sending all basic IR protocols.

src/IRtext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ IRTEXT_CONST_STRING(kDg11j104Str, D_STR_DG11J104); ///< "DG11J104"
295295
IRTEXT_CONST_STRING(kDg11j191Str, D_STR_DG11J191); ///< "DG11J191"
296296
IRTEXT_CONST_STRING(kArgoWrem2Str, D_STR_ARGO_WREM2); ///< "WREM3"
297297
IRTEXT_CONST_STRING(kArgoWrem3Str, D_STR_ARGO_WREM3); ///< "WREM3"
298+
IRTEXT_CONST_STRING(kToshibaGenericRemoteAStr, D_STR_TOSHIBAGENERICREMOTEA);
299+
// "TOSHIBA REMOTE A"
300+
IRTEXT_CONST_STRING(kToshibaGenericRemoteBStr, D_STR_TOSHIBAGENERICREMOTEB);
301+
// "TOSHIBA REMOTE B"
298302

299303
#define D_STR_UNSUPPORTED "?" // Unsupported protocols will be showing as
300304
// a question mark, check for length > 1

src/IRtext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ extern IRTEXT_CONST_PTR(kSetTimerCommandStr);
229229
extern IRTEXT_CONST_PTR(kTimerStr);
230230
extern IRTEXT_CONST_PTR(kToggleStr);
231231
extern IRTEXT_CONST_PTR(kTopStr);
232+
extern IRTEXT_CONST_PTR(kToshibaGenericRemoteAStr);
233+
extern IRTEXT_CONST_PTR(kToshibaGenericRemoteBStr);
232234
extern IRTEXT_CONST_PTR(kTrueStr);
233235
extern IRTEXT_CONST_PTR(kTurboStr);
234236
extern IRTEXT_CONST_PTR(kTurboToggleStr);

src/IRutils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ namespace irutils {
701701
default: return kUnknownStr;
702702
}
703703
break;
704+
case decode_type_t::TOSHIBA_AC:
705+
switch (model) {
706+
case toshiba_ac_remote_model_t::kToshibaGenericRemote_A:
707+
return kToshibaGenericRemoteAStr;
708+
case toshiba_ac_remote_model_t::kToshibaGenericRemote_B:
709+
return kToshibaGenericRemoteBStr;
710+
default:
711+
return kUnknownStr;
712+
}
704713
default: return kUnknownStr;
705714
}
706715
}

src/ir_Toshiba.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using irutils::addModeToString;
4040
using irutils::addTempToString;
4141
using irutils::checkInvertedBytePairs;
4242
using irutils::invertBytePairs;
43+
using irutils::addModelToString;
4344

4445
#if SEND_TOSHIBA_AC
4546
/// Send a Toshiba A/C message.
@@ -463,7 +464,8 @@ stdAc::state_t IRToshibaAC::toCommon(const stdAc::state_t *prev) const {
463464
String IRToshibaAC::toString(void) const {
464465
String result = "";
465466
result.reserve(95);
466-
result += addTempToString(getTemp(), true, false);
467+
result += addModelToString(decode_type_t::TOSHIBA_AC, getModel(), false);
468+
result += addTempToString(getTemp(), true);
467469
switch (getStateLength()) {
468470
case kToshibaACStateLengthShort:
469471
result += addIntToString(getSwing(true), kSwingVStr);
@@ -494,20 +496,26 @@ String IRToshibaAC::toString(void) const {
494496
return result;
495497
}
496498

497-
void IRToshibaAC::setRemoteControl(const uint8_t remote_type) {
498-
switch (remote_type) {
499-
case kToshibaAcRemoteA:
500-
case kToshibaAcRemoteB:
501-
_.Remote = remote_type;
502-
break;
503-
default:
504-
_.Remote = kToshibaAcRemoteA;
505-
break;
499+
/// Get the model information currently known.
500+
/// @return The known model number.
501+
toshiba_ac_remote_model_t IRToshibaAC::getModel(void) const {
502+
switch(_.Model) {
503+
case kToshibaAcRemoteB: return toshiba_ac_remote_model_t::kToshibaGenericRemote_B;
504+
default: return toshiba_ac_remote_model_t::kToshibaGenericRemote_A;
506505
}
507506
}
508507

509-
uint8_t IRToshibaAC::getRemoteControl() const {
510-
return _.Remote;
508+
/// Set the current model for the remote.
509+
/// @param[in] model The model number.
510+
void IRToshibaAC::setModel(const toshiba_ac_remote_model_t model) {
511+
switch(model) {
512+
case toshiba_ac_remote_model_t::kToshibaGenericRemote_B:
513+
_.Model = kToshibaAcRemoteB;
514+
break;
515+
default:
516+
_.Model = kToshibaAcRemoteA;
517+
break;
518+
}
511519
}
512520

513521
#if DECODE_TOSHIBA_AC

src/ir_Toshiba.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ union ToshibaProtocol{
5757
// Toshiba remote type
5858
// 0 - Remote control A
5959
// 1 - Remote control B
60-
uint8_t Remote :4;
60+
uint8_t Model :4;
6161
// Byte[3] - The bit-inverted value of the "length" byte.
6262
uint8_t :8;
6363
// Byte[4]
@@ -147,8 +147,8 @@ class IRToshibaAC {
147147
void begin(void);
148148
void on(void);
149149
void off(void);
150-
void setRemoteControl(const uint8_t remote_type);
151-
uint8_t getRemoteControl() const;
150+
void setModel(const toshiba_ac_remote_model_t model);
151+
toshiba_ac_remote_model_t getModel() const;
152152
void setPower(const bool on);
153153
bool getPower(void) const;
154154
void setTemp(const uint8_t degrees);

src/locale/defaults.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,12 @@ D_STR_INDIRECT " " D_STR_MODE
11201120
#ifndef D_STR_ZEPEAL
11211121
#define D_STR_ZEPEAL "ZEPEAL"
11221122
#endif // D_STR_ZEPEAL
1123+
#ifndef D_STR_TOSHIBAGENERICREMOTEA
1124+
#define D_STR_TOSHIBAGENERICREMOTEA "TOSHIBA REMOTE A"
1125+
#endif // D_STR_TOSHIBAGENERICREMOTEA
1126+
#ifndef D_STR_TOSHIBAGENERICREMOTEB
1127+
#define D_STR_TOSHIBAGENERICREMOTEB "TOSHIBA REMOTE B"
1128+
#endif // D_STR_TOSHIBAGENERICREMOTEB
11231129

11241130
// IRrecvDumpV2+
11251131
#ifndef D_STR_TIMESTAMP

test/ir_Toshiba_test.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,25 @@ TEST(TestToshibaACClass, HumanReadableOutput) {
311311
0x00, 0xC1, 0x00, 0xC0};
312312

313313
ac.setRaw(initial_state);
314-
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, Mode: 0 (Auto), "
315-
"Fan: 0 (Auto), Turbo: Off, Econo: Off, Filter: Off",
314+
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, "
315+
"Mode: 0 (Auto), Fan: 0 (Auto), Turbo: Off, Econo: Off, "
316+
"Filter: Off",
316317
ac.toString());
317318
ac.setRaw(modified_state);
318-
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, Mode: 1 (Cool), "
319-
"Fan: 5 (High), Turbo: Off, Econo: Off, Filter: Off",
319+
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, "
320+
"Mode: 1 (Cool), Fan: 5 (High), Turbo: Off, Econo: Off, "
321+
"Filter: Off",
320322
ac.toString());
321323
ac.setTemp(25);
322324
ac.setFan(3);
323325
ac.setMode(kToshibaAcDry);
324-
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: On, Mode: 2 (Dry), "
325-
"Fan: 3 (Medium), Turbo: Off, Econo: Off, Filter: Off",
326+
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: On, "
327+
"Mode: 2 (Dry), Fan: 3 (Medium), Turbo: Off, Econo: Off, "
328+
"Filter: Off",
326329
ac.toString());
327330
ac.off();
328-
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: Off, Fan: 3 (Medium), "
329-
"Turbo: Off, Econo: Off, Filter: Off",
331+
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: Off, "
332+
"Fan: 3 (Medium), Turbo: Off, Econo: Off, Filter: Off",
330333
ac.toString());
331334
}
332335

0 commit comments

Comments
 (0)