Skip to content

Commit

Permalink
Fix linting issue and missed files
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysze committed May 13, 2024
1 parent 98554a5 commit 3c7ef26
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 23 deletions.
7 changes: 7 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ enum argo_ac_remote_model_t {
SAC_WREM3 // (2) ARGO WREM3 remote (touch buttons), bit-len vary by cmd
};

/// Toshiba A/C model numbers
enum toshiba_ac_remote_model_t {
kToshibaGenericRemote_A = 0, // Default from existing codebase
kToshibaGenericRemote_B = 1, // Newly discovered remote control b, applies to
// many remote models such as WA-TH03A, WA-TH04A etc.
};

// Classes

/// Class for sending all basic IR protocols.
Expand Down
4 changes: 4 additions & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ IRTEXT_CONST_STRING(kDg11j104Str, D_STR_DG11J104); ///< "DG11J104"
IRTEXT_CONST_STRING(kDg11j191Str, D_STR_DG11J191); ///< "DG11J191"
IRTEXT_CONST_STRING(kArgoWrem2Str, D_STR_ARGO_WREM2); ///< "WREM3"
IRTEXT_CONST_STRING(kArgoWrem3Str, D_STR_ARGO_WREM3); ///< "WREM3"
IRTEXT_CONST_STRING(kToshibaGenericRemoteAStr, D_STR_TOSHIBAGENERICREMOTEA);
// "TOSHIBA REMOTE A"
IRTEXT_CONST_STRING(kToshibaGenericRemoteBStr, D_STR_TOSHIBAGENERICREMOTEB);
// "TOSHIBA REMOTE B"

#define D_STR_UNSUPPORTED "?" // Unsupported protocols will be showing as
// a question mark, check for length > 1
Expand Down
2 changes: 2 additions & 0 deletions src/IRtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ extern IRTEXT_CONST_PTR(kSetTimerCommandStr);
extern IRTEXT_CONST_PTR(kTimerStr);
extern IRTEXT_CONST_PTR(kToggleStr);
extern IRTEXT_CONST_PTR(kTopStr);
extern IRTEXT_CONST_PTR(kToshibaGenericRemoteAStr);
extern IRTEXT_CONST_PTR(kToshibaGenericRemoteBStr);
extern IRTEXT_CONST_PTR(kTrueStr);
extern IRTEXT_CONST_PTR(kTurboStr);
extern IRTEXT_CONST_PTR(kTurboToggleStr);
Expand Down
9 changes: 9 additions & 0 deletions src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,15 @@ namespace irutils {
default: return kUnknownStr;
}
break;
case decode_type_t::TOSHIBA_AC:
switch (model) {
case toshiba_ac_remote_model_t::kToshibaGenericRemote_A:
return kToshibaGenericRemoteAStr;
case toshiba_ac_remote_model_t::kToshibaGenericRemote_B:
return kToshibaGenericRemoteBStr;
default:
return kUnknownStr;
}
default: return kUnknownStr;
}
}
Expand Down
32 changes: 20 additions & 12 deletions src/ir_Toshiba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ using irutils::addModeToString;
using irutils::addTempToString;
using irutils::checkInvertedBytePairs;
using irutils::invertBytePairs;
using irutils::addModelToString;

#if SEND_TOSHIBA_AC
/// Send a Toshiba A/C message.
Expand Down Expand Up @@ -463,7 +464,8 @@ stdAc::state_t IRToshibaAC::toCommon(const stdAc::state_t *prev) const {
String IRToshibaAC::toString(void) const {
String result = "";
result.reserve(95);
result += addTempToString(getTemp(), true, false);
result += addModelToString(decode_type_t::TOSHIBA_AC, getModel(), false);
result += addTempToString(getTemp(), true);
switch (getStateLength()) {
case kToshibaACStateLengthShort:
result += addIntToString(getSwing(true), kSwingVStr);
Expand Down Expand Up @@ -494,20 +496,26 @@ String IRToshibaAC::toString(void) const {
return result;
}

void IRToshibaAC::setRemoteControl(const uint8_t remote_type) {
switch (remote_type) {
case kToshibaAcRemoteA:
case kToshibaAcRemoteB:
_.Remote = remote_type;
break;
default:
_.Remote = kToshibaAcRemoteA;
break;
/// Get the model information currently known.
/// @return The known model number.
toshiba_ac_remote_model_t IRToshibaAC::getModel(void) const {
switch(_.Model) {
case kToshibaAcRemoteB: return toshiba_ac_remote_model_t::kToshibaGenericRemote_B;
default: return toshiba_ac_remote_model_t::kToshibaGenericRemote_A;
}
}

uint8_t IRToshibaAC::getRemoteControl() const {
return _.Remote;
/// Set the current model for the remote.
/// @param[in] model The model number.
void IRToshibaAC::setModel(const toshiba_ac_remote_model_t model) {
switch(model) {
case toshiba_ac_remote_model_t::kToshibaGenericRemote_B:
_.Model = kToshibaAcRemoteB;
break;
default:
_.Model = kToshibaAcRemoteA;
break;
}
}

#if DECODE_TOSHIBA_AC
Expand Down
6 changes: 3 additions & 3 deletions src/ir_Toshiba.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ union ToshibaProtocol{
// Toshiba remote type
// 0 - Remote control A
// 1 - Remote control B
uint8_t Remote :4;
uint8_t Model :4;
// Byte[3] - The bit-inverted value of the "length" byte.
uint8_t :8;
// Byte[4]
Expand Down Expand Up @@ -147,8 +147,8 @@ class IRToshibaAC {
void begin(void);
void on(void);
void off(void);
void setRemoteControl(const uint8_t remote_type);
uint8_t getRemoteControl() const;
void setModel(const toshiba_ac_remote_model_t model);
toshiba_ac_remote_model_t getModel() const;
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t degrees);
Expand Down
6 changes: 6 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,12 @@ D_STR_INDIRECT " " D_STR_MODE
#ifndef D_STR_ZEPEAL
#define D_STR_ZEPEAL "ZEPEAL"
#endif // D_STR_ZEPEAL
#ifndef D_STR_TOSHIBAGENERICREMOTEA
#define D_STR_TOSHIBAGENERICREMOTEA "TOSHIBA REMOTE A"
#endif // D_STR_TOSHIBAGENERICREMOTEA
#ifndef D_STR_TOSHIBAGENERICREMOTEB
#define D_STR_TOSHIBAGENERICREMOTEB "TOSHIBA REMOTE B"
#endif // D_STR_TOSHIBAGENERICREMOTEB

// IRrecvDumpV2+
#ifndef D_STR_TIMESTAMP
Expand Down
19 changes: 11 additions & 8 deletions test/ir_Toshiba_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,25 @@ TEST(TestToshibaACClass, HumanReadableOutput) {
0x00, 0xC1, 0x00, 0xC0};

ac.setRaw(initial_state);
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, Mode: 0 (Auto), "
"Fan: 0 (Auto), Turbo: Off, Econo: Off, Filter: Off",
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, "
"Mode: 0 (Auto), Fan: 0 (Auto), Turbo: Off, Econo: Off, "
"Filter: Off",
ac.toString());
ac.setRaw(modified_state);
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, Mode: 1 (Cool), "
"Fan: 5 (High), Turbo: Off, Econo: Off, Filter: Off",
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 17C, Power: On, "
"Mode: 1 (Cool), Fan: 5 (High), Turbo: Off, Econo: Off, "
"Filter: Off",
ac.toString());
ac.setTemp(25);
ac.setFan(3);
ac.setMode(kToshibaAcDry);
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: On, Mode: 2 (Dry), "
"Fan: 3 (Medium), Turbo: Off, Econo: Off, Filter: Off",
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: On, "
"Mode: 2 (Dry), Fan: 3 (Medium), Turbo: Off, Econo: Off, "
"Filter: Off",
ac.toString());
ac.off();
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: Off, Fan: 3 (Medium), "
"Turbo: Off, Econo: Off, Filter: Off",
EXPECT_EQ("Model: 0 (TOSHIBA REMOTE A), Temp: 25C, Power: Off, "
"Fan: 3 (Medium), Turbo: Off, Econo: Off, Filter: Off",
ac.toString());
}

Expand Down

0 comments on commit 3c7ef26

Please sign in to comment.