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

Added extra "mid" option for Fan & SwingV to IRac #1929

Merged
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
36 changes: 21 additions & 15 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions src/ir_Argo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ argoFan_t IRArgoACBase<T>::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:
Expand All @@ -1115,7 +1116,8 @@ argoFlap_t IRArgoACBase<T>::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:
Expand Down Expand Up @@ -1175,7 +1177,8 @@ stdAc::swingv_t IRArgoACBase<ArgoProtocolWREM3>::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:
Expand Down Expand Up @@ -1232,9 +1235,8 @@ stdAc::fanspeed_t IRArgoACBase<T>::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;
Expand Down
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand Down Expand Up @@ -2771,13 +2773,16 @@ 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));
}

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));
}

Expand Down
2 changes: 1 addition & 1 deletion test/ir_Argo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down