Skip to content

Commit

Permalink
Hitachi344: Attempt to fix swingv operation.
Browse files Browse the repository at this point in the history
For #1134
  • Loading branch information
crankyoldgit committed May 30, 2020
1 parent f720bb8 commit d194594
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ void IRac::hitachi344(IRHitachiAc344 *ac,
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingV(swingv != stdAc::swingv_t::kOff);
ac->setSwingH(ac->convertSwingH(swingh));
ac->setPower(on);
// No Quiet setting available.
Expand All @@ -802,6 +801,10 @@ void IRac::hitachi344(IRHitachiAc344 *ac,
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.

// Do Swing(V) last as it appears that it's the only way to make it respond
// to the SwingV command. i.e. It reliese on the `setButton()` value.
ac->setSwingV(swingv != stdAc::swingv_t::kOff);
ac->send();
}
#endif // SEND_HITACHI_AC344
Expand Down
2 changes: 1 addition & 1 deletion test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ TEST(TestIRac, Hitachi344) {
IRrecv capture(kGpioUnused);
char expected[] =
"Power: On, Mode: 6 (Heat), Temp: 25C, Fan: 6 (Max), "
"Button: 19 (Power/Mode), Swing(V): On, Swing(H): 2 (Right)";
"Button: 129 (Swing(V)), Swing(V): On, Swing(H): 2 (Right)";

ac.begin();
irac.hitachi344(&ac,
Expand Down
29 changes: 27 additions & 2 deletions test/ir_Hitachi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ TEST(TestDecodeHitachiAc344, SyntheticExample) {
IRAcUtils::resultAcToString(&irsend.capture));
}

TEST(TestIRHitachiAc344, ExampleMessages) {
TEST(TestDecodeIRHitachiAc344, ExampleMessages) {
IRHitachiAc344 ac(kGpioUnused);

// On, 17, Hot, Auto
Expand All @@ -1944,7 +1944,7 @@ TEST(TestIRHitachiAc344, ExampleMessages) {
ac.toString());
}

TEST(TestIRHitachiAc344, ReconstructKnownState) {
TEST(TestIRHitachiAc344Class, ReconstructKnownState) {
IRHitachiAc344 ac(kGpioUnused);

// On, 17, Hot, Auto
Expand All @@ -1959,3 +1959,28 @@ TEST(TestIRHitachiAc344, ReconstructKnownState) {
ac.setButton(kHitachiAc344ButtonPowerMode);
EXPECT_STATE_EQ(expected, ac.getRaw(), kHitachiAc344Bits);
}

TEST(TestIRHitachiAc344Class, SwingV) {
IRHitachiAc344 ac(kGpioUnused);
// Ref: https://github.com/crankyoldgit/IRremoteESP8266/issues/1134#issuecomment-635760537

// https://docs.google.com/spreadsheets/d/1LPd8K9V437oyEMZT6JDv5LlPXh61RPmgeoVcHLWWr7k/edit#gid=874235844&range=G4
// aka. On 17 Cool Auto SwingV off SwingH off
const uint8_t start[43] = {
0x01, 0x10, 0x00, 0x40, 0xBF, 0xFF, 0x00, 0xCC, 0x33, 0x92, 0x6D, 0x44,
0xBB, 0x44, 0xBB, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x53, 0xAC, 0xF1, 0x0E, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0x7F, 0x03,
0xFC, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF};
ac.setRaw(start);
EXPECT_FALSE(ac.getSwingV());
const uint8_t turn_on_swingv[43] = {
0x01, 0x10, 0x00, 0x40, 0xBF, 0xFF, 0x00, 0xCC, 0x33, 0x92, 0x6D, 0x81,
0x7E, 0x44, 0xBB, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
0xFF, 0x53, 0xAC, 0xF1, 0x0E, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0x7F, 0x03,
0xFC, 0x20, 0xDF, 0x00, 0xFF, 0x00, 0xFF};
ac.setSwingV(true); // Turn it on.
EXPECT_TRUE(ac.getSwingV());
EXPECT_STATE_EQ(turn_on_swingv, ac.getRaw(), kHitachiAc344Bits);
ac.setSwingV(false);
EXPECT_FALSE(ac.getSwingV());
}

0 comments on commit d194594

Please sign in to comment.