From 47b5d935298560f2b420e8d0667688594e69736f Mon Sep 17 00:00:00 2001 From: Mateusz Bronk Date: Sun, 4 Dec 2022 23:43:15 +0100 Subject: [PATCH] Added extra "mid" option for Fan & SwingV to IRac Signed-off-by: Mateusz Bronk --- src/IRac.cpp | 36 +++++++++++++++++++++--------------- src/IRsend.h | 18 ++++++++++-------- src/IRtext.cpp | 1 + src/IRtext.h | 1 + src/ir_Argo.cpp | 14 ++++++++------ src/locale/defaults.h | 3 +++ test/IRac_test.cpp | 5 +++++ test/ir_Argo_test.cpp | 2 +- 8 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/IRac.cpp b/src/IRac.cpp index 160b6d5ff..9c591f8f6 100644 --- a/src/IRac.cpp +++ b/src/IRac.cpp @@ -3672,6 +3672,8 @@ stdAc::fanspeed_t IRac::strToFanspeed(const char *str, !STRCASECMP(str, kMaximumStr) || !STRCASECMP(str, kHighestStr)) return stdAc::fanspeed_t::kMax; + else if (!STRCASECMP(str, kMedHighStr)) + return stdAc::fanspeed_t::kMediumHigh; else return def; } @@ -3704,6 +3706,8 @@ stdAc::swingv_t IRac::strToSwingV(const char *str, !STRCASECMP(str, kMediumStr) || !STRCASECMP(str, kCentreStr)) return stdAc::swingv_t::kMiddle; + else if (!STRCASECMP(str, kUpperMiddleStr)) + return stdAc::swingv_t::kUpperMiddle; else if (!STRCASECMP(str, kHighStr) || !STRCASECMP(str, kHiStr)) return stdAc::swingv_t::kHigh; @@ -3920,13 +3924,14 @@ String IRac::opmodeToString(const stdAc::opmode_t mode, const bool ha) { /// @return The equivalent String for the locale. String IRac::fanspeedToString(const stdAc::fanspeed_t speed) { switch (speed) { - case stdAc::fanspeed_t::kAuto: return kAutoStr; - case stdAc::fanspeed_t::kMax: return kMaxStr; - case stdAc::fanspeed_t::kHigh: return kHighStr; - case stdAc::fanspeed_t::kMedium: return kMediumStr; - case stdAc::fanspeed_t::kLow: return kLowStr; - case stdAc::fanspeed_t::kMin: return kMinStr; - default: return kUnknownStr; + case stdAc::fanspeed_t::kAuto: return kAutoStr; + case stdAc::fanspeed_t::kMax: return kMaxStr; + case stdAc::fanspeed_t::kHigh: return kHighStr; + case stdAc::fanspeed_t::kMedium: return kMediumStr; + case stdAc::fanspeed_t::kMediumHigh: return kMedHighStr; + case stdAc::fanspeed_t::kLow: return kLowStr; + case stdAc::fanspeed_t::kMin: return kMinStr; + default: return kUnknownStr; } } @@ -3935,14 +3940,15 @@ String IRac::fanspeedToString(const stdAc::fanspeed_t speed) { /// @return The equivalent String for the locale. String IRac::swingvToString(const stdAc::swingv_t swingv) { switch (swingv) { - case stdAc::swingv_t::kOff: return kOffStr; - case stdAc::swingv_t::kAuto: return kAutoStr; - case stdAc::swingv_t::kHighest: return kHighestStr; - case stdAc::swingv_t::kHigh: return kHighStr; - case stdAc::swingv_t::kMiddle: return kMiddleStr; - case stdAc::swingv_t::kLow: return kLowStr; - case stdAc::swingv_t::kLowest: return kLowestStr; - default: return kUnknownStr; + case stdAc::swingv_t::kOff: return kOffStr; + case stdAc::swingv_t::kAuto: return kAutoStr; + case stdAc::swingv_t::kHighest: return kHighestStr; + case stdAc::swingv_t::kHigh: return kHighStr; + case stdAc::swingv_t::kMiddle: return kMiddleStr; + case stdAc::swingv_t::kUpperMiddle: return kUpperMiddleStr; + case stdAc::swingv_t::kLow: return kLowStr; + case stdAc::swingv_t::kLowest: return kLowestStr; + default: return kUnknownStr; } } diff --git a/src/IRsend.h b/src/IRsend.h index c90d7a483..8d0336146 100644 --- a/src/IRsend.h +++ b/src/IRsend.h @@ -56,14 +56,15 @@ enum class opmode_t { /// Common A/C settings for Fan Speeds. enum class fanspeed_t { - kAuto = 0, - kMin = 1, - kLow = 2, - kMedium = 3, - kHigh = 4, - kMax = 5, + kAuto = 0, + kMin = 1, + kLow = 2, + kMedium = 3, + kHigh = 4, + kMax = 5, + kMediumHigh = 6, // Add new entries before this one, and update it to point to the last entry - kLastFanspeedEnum = kMax, + kLastFanspeedEnum = kMediumHigh, }; /// Common A/C settings for Vertical Swing. @@ -75,8 +76,9 @@ enum class swingv_t { kMiddle = 3, kLow = 4, kLowest = 5, + kUpperMiddle = 6, // Add new entries before this one, and update it to point to the last entry - kLastSwingvEnum = kLowest, + kLastSwingvEnum = kUpperMiddle, }; /// @brief Tyoe of A/C command (if the remote uses different codes for each) diff --git a/src/IRtext.cpp b/src/IRtext.cpp index 9af6e381c..8ae921fab 100644 --- a/src/IRtext.cpp +++ b/src/IRtext.cpp @@ -126,6 +126,7 @@ IRTEXT_CONST_STRING(kOutsideStr, D_STR_OUTSIDE); ///< "Outside" IRTEXT_CONST_STRING(kLoudStr, D_STR_LOUD); ///< "Loud" IRTEXT_CONST_STRING(kLowerStr, D_STR_LOWER); ///< "Lower" IRTEXT_CONST_STRING(kUpperStr, D_STR_UPPER); ///< "Upper" +IRTEXT_CONST_STRING(kUpperMiddleStr, D_STR_UPPER_MIDDLE); ///< "Upper-Middle" IRTEXT_CONST_STRING(kBreezeStr, D_STR_BREEZE); ///< "Breeze" IRTEXT_CONST_STRING(kCirculateStr, D_STR_CIRCULATE); ///< "Circulate" IRTEXT_CONST_STRING(kCeilingStr, D_STR_CEILING); ///< "Ceiling" diff --git a/src/IRtext.h b/src/IRtext.h index c99081ab2..15d2690b7 100644 --- a/src/IRtext.h +++ b/src/IRtext.h @@ -236,6 +236,7 @@ extern IRTEXT_CONST_PTR(kTypeStr); extern IRTEXT_CONST_PTR(kUnknownStr); extern IRTEXT_CONST_PTR(kUpStr); extern IRTEXT_CONST_PTR(kUpperStr); +extern IRTEXT_CONST_PTR(kUpperMiddleStr); extern IRTEXT_CONST_PTR(kValueStr); extern IRTEXT_CONST_PTR(kV9014557AStr); extern IRTEXT_CONST_PTR(kV9014557BStr); diff --git a/src/ir_Argo.cpp b/src/ir_Argo.cpp index c55819def..99b73caec 100644 --- a/src/ir_Argo.cpp +++ b/src/ir_Argo.cpp @@ -1095,7 +1095,8 @@ argoFan_t IRArgoACBase::convertFan(const stdAc::fanspeed_t speed) { return argoFan_t::FAN_LOWER; case stdAc::fanspeed_t::kMedium: return argoFan_t::FAN_LOW; - // No 'MEDIUM-HIGH' in common, hence skipping the "actual" medium + case stdAc::fanspeed_t::kMediumHigh: + return argoFan_t::FAN_MEDIUM; case stdAc::fanspeed_t::kHigh: return argoFan_t::FAN_HIGH; case stdAc::fanspeed_t::kMax: @@ -1115,7 +1116,8 @@ argoFlap_t IRArgoACBase::convertSwingV(const stdAc::swingv_t position) { return argoFlap_t::FLAP_1; case stdAc::swingv_t::kHigh: return argoFlap_t::FLAP_2; - // Skipping "flap3" -> no UPPER-MIDDLE in common + case stdAc::swingv_t::kUpperMiddle: + return argoFlap_t::FLAP_3; case stdAc::swingv_t::kMiddle: return argoFlap_t::FLAP_4; case stdAc::swingv_t::kLow: @@ -1175,7 +1177,8 @@ stdAc::swingv_t IRArgoACBase::toCommonSwingV( return stdAc::swingv_t::kHighest; case argoFlap_t::FLAP_5: return stdAc::swingv_t::kHigh; - case argoFlap_t::FLAP_4: // Upper-middle collapsed to "middle" + case argoFlap_t::FLAP_4: + return stdAc::swingv_t::kUpperMiddle; case argoFlap_t::FLAP_3: return stdAc::swingv_t::kMiddle; case argoFlap_t::FLAP_2: @@ -1232,9 +1235,8 @@ stdAc::fanspeed_t IRArgoACBase::toCommonFanSpeed(const argoFan_t speed) { case argoFan_t::FAN_AUTO: return stdAc::fanspeed_t::kAuto; case argoFan_t::FAN_HIGHEST: return stdAc::fanspeed_t::kMax; case argoFan_t::FAN_HIGH: return stdAc::fanspeed_t::kHigh; - case argoFan_t::FAN_MEDIUM: // No "Medium-High" support in common - case argoFan_t::FAN_LOW: - return stdAc::fanspeed_t::kMedium; + case argoFan_t::FAN_MEDIUM: return stdAc::fanspeed_t::kMediumHigh; + case argoFan_t::FAN_LOW: return stdAc::fanspeed_t::kMedium; case argoFan_t::FAN_LOWER: return stdAc::fanspeed_t::kLow; case argoFan_t::FAN_LOWEST: return stdAc::fanspeed_t::kMin; default: return stdAc::fanspeed_t::kAuto; diff --git a/src/locale/defaults.h b/src/locale/defaults.h index a5f6aee8d..5a54baeff 100644 --- a/src/locale/defaults.h +++ b/src/locale/defaults.h @@ -451,6 +451,9 @@ D_STR_INDIRECT " " D_STR_MODE #ifndef D_STR_BOTTOM #define D_STR_BOTTOM "Bottom" #endif // D_STR_BOTTOM +#ifndef D_STR_UPPER_MIDDLE +#define D_STR_UPPER_MIDDLE D_STR_UPPER "-" D_STR_MIDDLE +#endif // D_STR_UPPER_MIDDLE #ifndef D_STR_CONFIG #define D_STR_CONFIG "Config" #endif // D_STR_CONFIG diff --git a/test/IRac_test.cpp b/test/IRac_test.cpp index c3732cb66..8d22bf241 100644 --- a/test/IRac_test.cpp +++ b/test/IRac_test.cpp @@ -2679,6 +2679,7 @@ TEST(TestIRac, strToFanspeed) { EXPECT_EQ(stdAc::fanspeed_t::kMin, IRac::strToFanspeed("MIN")); EXPECT_EQ(stdAc::fanspeed_t::kLow, IRac::strToFanspeed("LOW")); EXPECT_EQ(stdAc::fanspeed_t::kMedium, IRac::strToFanspeed("MEDIUM")); + EXPECT_EQ(stdAc::fanspeed_t::kMediumHigh, IRac::strToFanspeed("MED-HIGH")); EXPECT_EQ(stdAc::fanspeed_t::kHigh, IRac::strToFanspeed("HIGH")); EXPECT_EQ(stdAc::fanspeed_t::kMax, IRac::strToFanspeed("MAX")); EXPECT_EQ(stdAc::fanspeed_t::kAuto, IRac::strToFanspeed("FOOBAR")); @@ -2691,6 +2692,7 @@ TEST(TestIRac, strToSwingV) { EXPECT_EQ(stdAc::swingv_t::kLowest, IRac::strToSwingV("LOWEST")); EXPECT_EQ(stdAc::swingv_t::kLow, IRac::strToSwingV("LOW")); EXPECT_EQ(stdAc::swingv_t::kMiddle, IRac::strToSwingV("MIDDLE")); + EXPECT_EQ(stdAc::swingv_t::kUpperMiddle, IRac::strToSwingV("UPPER-MIDDLE")); EXPECT_EQ(stdAc::swingv_t::kHigh, IRac::strToSwingV("HIGH")); EXPECT_EQ(stdAc::swingv_t::kHighest, IRac::strToSwingV("HIGHEST")); EXPECT_EQ(stdAc::swingv_t::kOff, IRac::strToSwingV("OFF")); @@ -2771,6 +2773,7 @@ TEST(TestIRac, opmodeToString) { TEST(TestIRac, fanspeedToString) { EXPECT_EQ("Low", IRac::fanspeedToString(stdAc::fanspeed_t::kLow)); EXPECT_EQ("Auto", IRac::fanspeedToString(stdAc::fanspeed_t::kAuto)); + EXPECT_EQ("Med-High", IRac::fanspeedToString(stdAc::fanspeed_t::kMediumHigh)); EXPECT_EQ("UNKNOWN", IRac::fanspeedToString((stdAc::fanspeed_t)500)); } @@ -2778,6 +2781,8 @@ TEST(TestIRac, swingvToString) { EXPECT_EQ("Off", IRac::swingvToString(stdAc::swingv_t::kOff)); EXPECT_EQ("Low", IRac::swingvToString(stdAc::swingv_t::kLow)); EXPECT_EQ("Auto", IRac::swingvToString(stdAc::swingv_t::kAuto)); + EXPECT_EQ("Upper-Middle", IRac::swingvToString( + stdAc::swingv_t::kUpperMiddle)); EXPECT_EQ("UNKNOWN", IRac::swingvToString((stdAc::swingv_t)500)); } diff --git a/test/ir_Argo_test.cpp b/test/ir_Argo_test.cpp index b18f1e808..436ffb9dd 100644 --- a/test/ir_Argo_test.cpp +++ b/test/ir_Argo_test.cpp @@ -75,7 +75,7 @@ TEST(TestArgoAC_WREM3Class, toCommon) { ASSERT_EQ(stdAc::fanspeed_t::kMax, ac.toCommon().fanspeed); ASSERT_TRUE(ac.toCommon().turbo); ASSERT_TRUE(ac.toCommon().quiet); // Night - ASSERT_EQ(stdAc::swingv_t::kMiddle, ac.toCommon().swingv); + ASSERT_EQ(stdAc::swingv_t::kUpperMiddle, ac.toCommon().swingv); ASSERT_TRUE(ac.toCommon().econo); ASSERT_TRUE(ac.toCommon().light); ASSERT_TRUE(ac.toCommon().filter);