Skip to content

Commit

Permalink
Panasonic AC - Fix Low and High fan speeds (#1515)
Browse files Browse the repository at this point in the history
* Add Fan low and high speeds to setFan
* Adjust unit tests accordingly.
* Fixes a regression introduced in #934 

Co-authored-by: David Conran <[email protected]>
  • Loading branch information
ajaypala and crankyoldgit authored Jul 4, 2021
1 parent 7102d8f commit 3c1862f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
20 changes: 11 additions & 9 deletions src/ir_Panasonic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ void IRPanasonicAc::setSwingHorizontal(const uint8_t desired_direction) {
void IRPanasonicAc::setFan(const uint8_t speed) {
switch (speed) {
case kPanasonicAcFanMin:
case kPanasonicAcFanLow:
case kPanasonicAcFanMed:
case kPanasonicAcFanHigh:
case kPanasonicAcFanMax:
case kPanasonicAcFanAuto:
setBits(&remote_state[16], kHighNibble, kNibbleSize,
Expand Down Expand Up @@ -668,9 +670,9 @@ uint8_t IRPanasonicAc::convertMode(const stdAc::opmode_t mode) {
uint8_t IRPanasonicAc::convertFan(const stdAc::fanspeed_t speed) {
switch (speed) {
case stdAc::fanspeed_t::kMin: return kPanasonicAcFanMin;
case stdAc::fanspeed_t::kLow: return kPanasonicAcFanMin + 1;
case stdAc::fanspeed_t::kMedium: return kPanasonicAcFanMin + 2;
case stdAc::fanspeed_t::kHigh: return kPanasonicAcFanMin + 3;
case stdAc::fanspeed_t::kLow: return kPanasonicAcFanLow;
case stdAc::fanspeed_t::kMedium: return kPanasonicAcFanMed;
case stdAc::fanspeed_t::kHigh: return kPanasonicAcFanHigh;
case stdAc::fanspeed_t::kMax: return kPanasonicAcFanMax;
default: return kPanasonicAcFanAuto;
}
Expand Down Expand Up @@ -723,9 +725,9 @@ stdAc::opmode_t IRPanasonicAc::toCommonMode(const uint8_t mode) {
stdAc::fanspeed_t IRPanasonicAc::toCommonFanSpeed(const uint8_t spd) {
switch (spd) {
case kPanasonicAcFanMax: return stdAc::fanspeed_t::kMax;
case kPanasonicAcFanMin + 3: return stdAc::fanspeed_t::kHigh;
case kPanasonicAcFanMin + 2: return stdAc::fanspeed_t::kMedium;
case kPanasonicAcFanMin + 1: return stdAc::fanspeed_t::kLow;
case kPanasonicAcFanHigh: return stdAc::fanspeed_t::kHigh;
case kPanasonicAcFanMed: return stdAc::fanspeed_t::kMedium;
case kPanasonicAcFanLow: return stdAc::fanspeed_t::kLow;
case kPanasonicAcFanMin: return stdAc::fanspeed_t::kMin;
default: return stdAc::fanspeed_t::kAuto;
}
Expand Down Expand Up @@ -791,9 +793,9 @@ String IRPanasonicAc::toString(void) {
result += addModeToString(getMode(), kPanasonicAcAuto, kPanasonicAcCool,
kPanasonicAcHeat, kPanasonicAcDry, kPanasonicAcFan);
result += addTempToString(getTemp());
result += addFanToString(getFan(), kPanasonicAcFanMax, kPanasonicAcFanMin,
kPanasonicAcFanAuto, kPanasonicAcFanAuto,
kPanasonicAcFanMed);
result += addFanToString(getFan(), kPanasonicAcFanHigh, kPanasonicAcFanLow,
kPanasonicAcFanAuto, kPanasonicAcFanMin,
kPanasonicAcFanMed, kPanasonicAcFanMax);
result += addSwingVToString(getSwingVertical(), kPanasonicAcSwingVAuto,
kPanasonicAcSwingVHighest,
kPanasonicAcSwingVHigh,
Expand Down
2 changes: 2 additions & 0 deletions src/ir_Panasonic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const uint8_t kPanasonicAcCool = 3; // 0b011
const uint8_t kPanasonicAcHeat = 4; // 0b010
const uint8_t kPanasonicAcFan = 6; // 0b110
const uint8_t kPanasonicAcFanMin = 0;
const uint8_t kPanasonicAcFanLow = 1;
const uint8_t kPanasonicAcFanMed = 2;
const uint8_t kPanasonicAcFanHigh = 3;
const uint8_t kPanasonicAcFanMax = 4;
const uint8_t kPanasonicAcFanAuto = 7;
const uint8_t kPanasonicAcFanDelta = 3;
Expand Down
2 changes: 1 addition & 1 deletion test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ TEST(TestIRac, Panasonic) {
ASSERT_TRUE(IRAcUtils::decodeToState(&ac._irsend.capture, &r, &p));

char expected_dke[] =
"Model: 3 (DKE), Power: On, Mode: 3 (Cool), Temp: 18C, Fan: 4 (High), "
"Model: 3 (DKE), Power: On, Mode: 3 (Cool), Temp: 18C, Fan: 4 (Maximum), "
"Swing(V): 2 (High), Swing(H): 6 (Middle), "
"Quiet: Off, Powerful: On, Ion: On, "
"Clock: 19:17, On Timer: Off, Off Timer: Off";
Expand Down
14 changes: 7 additions & 7 deletions test/ir_Panasonic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,16 @@ TEST(TestIRPanasonicAcClass, SetAndGetFan) {
EXPECT_EQ(kPanasonicAcFanMin, ac.getFan());
ac.setFan(kPanasonicAcFanMin - 1);
EXPECT_EQ(kPanasonicAcFanAuto, ac.getFan());
ac.setFan(kPanasonicAcFanLow);
EXPECT_EQ(kPanasonicAcFanLow, ac.getFan());
ac.setFan(kPanasonicAcFanMed);
EXPECT_EQ(kPanasonicAcFanMed, ac.getFan());
ac.setFan(kPanasonicAcFanMin + 1);
EXPECT_EQ(kPanasonicAcFanAuto, ac.getFan());
ac.setFan(kPanasonicAcFanHigh);
EXPECT_EQ(kPanasonicAcFanHigh, ac.getFan());
ac.setFan(kPanasonicAcFanMax);
EXPECT_EQ(kPanasonicAcFanMax, ac.getFan());
ac.setFan(kPanasonicAcFanMax + 1);
EXPECT_EQ(kPanasonicAcFanAuto, ac.getFan());
ac.setFan(kPanasonicAcFanMax - 1);
EXPECT_EQ(kPanasonicAcFanAuto, ac.getFan());
}

TEST(TestIRPanasonicAcClass, SetAndGetSwings) {
Expand Down Expand Up @@ -788,22 +788,22 @@ TEST(TestIRPanasonicAcClass, HumanReadable) {
ac.setPowerful(true);
EXPECT_EQ(
"Model: 4 (JKE), Power: On, Mode: 4 (Heat), Temp: 30C, "
"Fan: 4 (High), Swing(V): 15 (Auto), Quiet: Off, "
"Fan: 4 (Maximum), Swing(V): 15 (Auto), Quiet: Off, "
"Powerful: On, Clock: 00:00, On Timer: Off, Off Timer: Off",
ac.toString());
ac.setQuiet(true);
ac.setModel(kPanasonicLke);
EXPECT_EQ(
"Model: 1 (LKE), Power: Off, Mode: 4 (Heat), Temp: 30C, "
"Fan: 4 (High), Swing(V): 15 (Auto), "
"Fan: 4 (Maximum), Swing(V): 15 (Auto), "
"Swing(H): 6 (Middle), Quiet: On, Powerful: Off, "
"Clock: 00:00, On Timer: 00:00, Off Timer: Off",
ac.toString());
ac.setModel(kPanasonicDke);
ac.setSwingHorizontal(kPanasonicAcSwingHRight);
EXPECT_EQ(
"Model: 3 (DKE), Power: Off, Mode: 4 (Heat), Temp: 30C, "
"Fan: 4 (High), Swing(V): 15 (Auto), "
"Fan: 4 (Maximum), Swing(V): 15 (Auto), "
"Swing(H): 11 (Right), Quiet: On, Powerful: Off, Ion: Off, "
"Clock: 00:00, On Timer: Off, Off Timer: Off",
ac.toString());
Expand Down

0 comments on commit 3c1862f

Please sign in to comment.