Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HAIER_AC176] Add Turbo and Quiet settings #1634

Merged
merged 3 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/ir_Haier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ stdAc::state_t IRHaierAC::toCommon(void) const {
result.econo = false;
result.light = false;
result.clean = false;
result.beep = false;
result.beep = true;
result.clock = -1;
return result;
}
Expand Down Expand Up @@ -948,6 +948,20 @@ stdAc::swingv_t IRHaierAC176::toCommonSwingV(const uint8_t pos) {
}
}

/// Convert the Turbo setting of the A/C into native turbo setting.
/// @param[in] speed The enum to be converted.
/// @return true, the setting is on. false, the setting is off.
bool IRHaierAC176::toCommonTurbo(const uint8_t speed) {
return speed == kHaierAcYrw02TurboHigh;
}

/// Convert the Turbo setting of the A/C into native quiet setting.
/// @param[in] speed The enum to be converted.
/// @return true, the setting is on. false, the setting is off.
bool IRHaierAC176::toCommonQuiet(const uint8_t speed) {
return speed == kHaierAcYrw02TurboLow;
}

/// Convert the current internal state into its stdAc::state_t equivalent.
/// @return The stdAc equivalent of the native settings.
stdAc::state_t IRHaierAC176::toCommon(void) const {
Expand All @@ -962,14 +976,14 @@ stdAc::state_t IRHaierAC176::toCommon(void) const {
result.swingv = toCommonSwingV(_.Swing);
result.filter = _.Health;
result.sleep = _.Sleep ? 0 : -1;
result.quiet = toCommonQuiet(_.Turbo);
result.turbo = toCommonTurbo(_.Turbo);
// Not supported.
result.swingh = stdAc::swingh_t::kOff;
result.quiet = false;
result.turbo = false;
result.econo = false;
result.light = false;
result.clean = false;
result.beep = false;
result.beep = true;
result.clock = -1;
return result;
}
Expand Down
4 changes: 3 additions & 1 deletion src/ir_Haier.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ union HaierAc176Protocol{
uint8_t Fan :3;
// Byte 6
uint8_t OffTimerMins:6;
uint8_t Turbo:2;
uint8_t Turbo :2;
// Byte 7
uint8_t OnTimerHrs :5;
uint8_t Mode :3;
Expand Down Expand Up @@ -445,6 +445,8 @@ class IRHaierAC176 {
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
static stdAc::swingv_t toCommonSwingV(const uint8_t pos);
static bool toCommonTurbo(const uint8_t speed);
static bool toCommonQuiet(const uint8_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
Expand Down
4 changes: 2 additions & 2 deletions test/ir_Haier_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ TEST(TestHaierACClass, toCommon) {
ASSERT_FALSE(ac.toCommon().quiet);
ASSERT_FALSE(ac.toCommon().econo);
ASSERT_FALSE(ac.toCommon().clean);
ASSERT_FALSE(ac.toCommon().beep);
ASSERT_TRUE(ac.toCommon().beep);
ASSERT_EQ(-1, ac.toCommon().clock);
}

Expand Down Expand Up @@ -1133,7 +1133,7 @@ TEST(TestHaierACYRW02Class, toCommon) {
ASSERT_FALSE(ac.toCommon().quiet);
ASSERT_FALSE(ac.toCommon().econo);
ASSERT_FALSE(ac.toCommon().clean);
ASSERT_FALSE(ac.toCommon().beep);
ASSERT_TRUE(ac.toCommon().beep);
ASSERT_EQ(-1, ac.toCommon().clock);
}

Expand Down