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

Move some strings to IRtext.cpp & locale/default.h #1637

Merged
merged 2 commits into from
Oct 13, 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
102 changes: 50 additions & 52 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
#define STRCASECMP(LHS, RHS) strcasecmp(LHS, RHS)
#endif // ESP8266
#endif // STRCASECMP
#ifndef PSTR
#define PSTR
#endif

/// Class constructor
/// @param[in] pin Gpio pin to use when transmitting IR messages.
Expand Down Expand Up @@ -3124,14 +3121,14 @@ stdAc::opmode_t IRac::strToOpmode(const char *str,
!STRCASECMP(str, kStopStr))
return stdAc::opmode_t::kOff;
else if (!STRCASECMP(str, kCoolStr) ||
!STRCASECMP(str, PSTR("COOLING")))
!STRCASECMP(str, kCoolingStr))
return stdAc::opmode_t::kCool;
else if (!STRCASECMP(str, kHeatStr) ||
!STRCASECMP(str, PSTR("HEATING")))
!STRCASECMP(str, kHeatingStr))
return stdAc::opmode_t::kHeat;
else if (!STRCASECMP(str, kDryStr) ||
!STRCASECMP(str, PSTR("DRYING")) ||
!STRCASECMP(str, PSTR("DEHUMIDIFY")))
!STRCASECMP(str, kDryingStr) ||
!STRCASECMP(str, kDehumidifyStr))
return stdAc::opmode_t::kDry;
else if (!STRCASECMP(str, kFanStr) ||
// The following Fans strings with "only" are required to help with
Expand Down Expand Up @@ -3232,9 +3229,9 @@ stdAc::swingh_t IRac::strToSwingH(const char *str,
else if (!STRCASECMP(str, kOffStr) ||
!STRCASECMP(str, kStopStr))
return stdAc::swingh_t::kOff;
else if (!STRCASECMP(str, kLeftMaxStr) || // "LeftMax"
!STRCASECMP(str, PSTR(D_STR_LEFT " " D_STR_MAX)) || // "Left Max"
!STRCASECMP(str, PSTR(D_STR_MAX D_STR_LEFT)) || // "MaxLeft"
else if (!STRCASECMP(str, kLeftMaxNoSpaceStr) || // "LeftMax"
!STRCASECMP(str, kLeftMaxStr) || // "Left Max"
!STRCASECMP(str, kMaxLeftNoSpaceStr) || // "MaxLeft"
!STRCASECMP(str, kMaxLeftStr)) // "Max Left"
return stdAc::swingh_t::kLeftMax;
else if (!STRCASECMP(str, kLeftStr))
Expand All @@ -3247,9 +3244,9 @@ stdAc::swingh_t IRac::strToSwingH(const char *str,
return stdAc::swingh_t::kMiddle;
else if (!STRCASECMP(str, kRightStr))
return stdAc::swingh_t::kRight;
else if (!STRCASECMP(str, kRightMaxStr) || // "RightMax"
!STRCASECMP(str, PSTR(D_STR_RIGHT " " D_STR_MAX)) || // "Right Max"
!STRCASECMP(str, PSTR(D_STR_MAX D_STR_RIGHT)) || // "MaxRight"
else if (!STRCASECMP(str, kRightMaxNoSpaceStr) || // "RightMax"
!STRCASECMP(str, kRightMaxStr) || // "Right Max"
!STRCASECMP(str, kMaxRightNoSpaceStr) || // "MaxRight"
!STRCASECMP(str, kMaxRightStr)) // "Max Right"
return stdAc::swingh_t::kRightMax;
else if (!STRCASECMP(str, kWideStr))
Expand All @@ -3265,77 +3262,78 @@ stdAc::swingh_t IRac::strToSwingH(const char *str,
/// @return The equivalent enum.
int16_t IRac::strToModel(const char *str, const int16_t def) {
// Gree
if (!STRCASECMP(str, PSTR("YAW1F"))) {
if (!STRCASECMP(str, kYaw1fStr)) {
return gree_ac_remote_model_t::YAW1F;
} else if (!STRCASECMP(str, PSTR("YBOFB"))) {
} else if (!STRCASECMP(str, kYbofbStr)) {
return gree_ac_remote_model_t::YBOFB;
// HitachiAc1 models
} else if (!STRCASECMP(str, PSTR("R-LT0541-HTA-A"))) {
} else if (!STRCASECMP(str, kRlt0541htaaStr)) {
return hitachi_ac1_remote_model_t::R_LT0541_HTA_A;
} else if (!STRCASECMP(str, PSTR("R-LT0541-HTA-B"))) {
} else if (!STRCASECMP(str, kRlt0541htabStr)) {
return hitachi_ac1_remote_model_t::R_LT0541_HTA_B;
// Fujitsu A/C models
} else if (!STRCASECMP(str, PSTR("ARRAH2E"))) {
} else if (!STRCASECMP(str, kArrah2eStr)) {
return fujitsu_ac_remote_model_t::ARRAH2E;
} else if (!STRCASECMP(str, PSTR("ARDB1"))) {
} else if (!STRCASECMP(str, kArdb1Str)) {
return fujitsu_ac_remote_model_t::ARDB1;
} else if (!STRCASECMP(str, PSTR("ARREB1E"))) {
} else if (!STRCASECMP(str, kArreb1eStr)) {
return fujitsu_ac_remote_model_t::ARREB1E;
} else if (!STRCASECMP(str, PSTR("ARJW2"))) {
} else if (!STRCASECMP(str, kArjw2Str)) {
return fujitsu_ac_remote_model_t::ARJW2;
} else if (!STRCASECMP(str, PSTR("ARRY4"))) {
} else if (!STRCASECMP(str, kArry4Str)) {
return fujitsu_ac_remote_model_t::ARRY4;
} else if (!STRCASECMP(str, kArrew4eStr)) {
return fujitsu_ac_remote_model_t::ARREW4E;
// LG A/C models
} else if (!STRCASECMP(str, PSTR("GE6711AR2853M"))) {
} else if (!STRCASECMP(str, kGe6711ar2853mStr)) {
return lg_ac_remote_model_t::GE6711AR2853M;
} else if (!STRCASECMP(str, PSTR("AKB75215403"))) {
} else if (!STRCASECMP(str, kAkb75215403Str)) {
return lg_ac_remote_model_t::AKB75215403;
} else if (!STRCASECMP(str, PSTR("AKB74955603"))) {
} else if (!STRCASECMP(str, kAkb74955603Str)) {
return lg_ac_remote_model_t::AKB74955603;
} else if (!STRCASECMP(str, PSTR("AKB73757604"))) {
} else if (!STRCASECMP(str, kAkb73757604Str)) {
return lg_ac_remote_model_t::AKB73757604;
// Panasonic A/C families
} else if (!STRCASECMP(str, PSTR("LKE")) ||
!STRCASECMP(str, PSTR("PANASONICLKE"))) {
} else if (!STRCASECMP(str, kLkeStr) ||
!STRCASECMP(str, kPanasonicLkeStr)) {
return panasonic_ac_remote_model_t::kPanasonicLke;
} else if (!STRCASECMP(str, PSTR("NKE")) ||
!STRCASECMP(str, PSTR("PANASONICNKE"))) {
} else if (!STRCASECMP(str, kNkeStr) ||
!STRCASECMP(str, kPanasonicNkeStr)) {
return panasonic_ac_remote_model_t::kPanasonicNke;
} else if (!STRCASECMP(str, PSTR("DKE")) ||
!STRCASECMP(str, PSTR("PANASONICDKE")) ||
!STRCASECMP(str, PSTR("PKR")) ||
!STRCASECMP(str, PSTR("PANASONICPKR"))) {
} else if (!STRCASECMP(str, kDkeStr) ||
!STRCASECMP(str, kPanasonicDkeStr) ||
!STRCASECMP(str, kPkrStr) ||
!STRCASECMP(str, kPanasonicPkrStr)) {
return panasonic_ac_remote_model_t::kPanasonicDke;
} else if (!STRCASECMP(str, PSTR("JKE")) ||
!STRCASECMP(str, PSTR("PANASONICJKE"))) {
} else if (!STRCASECMP(str, kJkeStr) ||
!STRCASECMP(str, kPanasonicJkeStr)) {
return panasonic_ac_remote_model_t::kPanasonicJke;
} else if (!STRCASECMP(str, PSTR("CKP")) ||
!STRCASECMP(str, PSTR("PANASONICCKP"))) {
} else if (!STRCASECMP(str, kCkpStr) ||
!STRCASECMP(str, kPanasonicCkpStr)) {
return panasonic_ac_remote_model_t::kPanasonicCkp;
} else if (!STRCASECMP(str, PSTR("RKR")) ||
!STRCASECMP(str, PSTR("PANASONICRKR"))) {
} else if (!STRCASECMP(str, kRkrStr) ||
!STRCASECMP(str, kPanasonicRkrStr)) {
return panasonic_ac_remote_model_t::kPanasonicRkr;
// Sharp A/C Models
} else if (!STRCASECMP(str, PSTR("A907"))) {
} else if (!STRCASECMP(str, kA907Str)) {
return sharp_ac_remote_model_t::A907;
} else if (!STRCASECMP(str, PSTR("A705"))) {
} else if (!STRCASECMP(str, kA705Str)) {
return sharp_ac_remote_model_t::A705;
} else if (!STRCASECMP(str, PSTR("A903"))) {
} else if (!STRCASECMP(str, kA903Str)) {
return sharp_ac_remote_model_t::A903;
// TCL A/C Models
} else if (!STRCASECMP(str, PSTR("TAC09CHSD"))) {
} else if (!STRCASECMP(str, kTac09chsdStr)) {
return tcl_ac_remote_model_t::TAC09CHSD;
} else if (!STRCASECMP(str, PSTR("GZ055BE1"))) {
} else if (!STRCASECMP(str, kGz055be1Str)) {
return tcl_ac_remote_model_t::GZ055BE1;
// Voltas A/C models
} else if (!STRCASECMP(str, PSTR("122LZF"))) {
} else if (!STRCASECMP(str, k122lzfStr)) {
return voltas_ac_remote_model_t::kVoltas122LZF;
// Whirlpool A/C models
} else if (!STRCASECMP(str, PSTR("DG11J13A")) ||
!STRCASECMP(str, PSTR("DG11J104")) ||
!STRCASECMP(str, PSTR("DG11J1-04"))) {
} else if (!STRCASECMP(str, kDg11j13aStr) ||
!STRCASECMP(str, kDg11j104Str)) {
crankyoldgit marked this conversation as resolved.
Show resolved Hide resolved
return whirlpool_ac_remote_model_t::DG11J13A;
} else if (!STRCASECMP(str, PSTR("DG11J191"))) {
} else if (!STRCASECMP(str, kDg11j191Str)) {
return whirlpool_ac_remote_model_t::DG11J191;
} else {
int16_t number = atoi(str);
Expand All @@ -3352,12 +3350,12 @@ int16_t IRac::strToModel(const char *str, const int16_t def) {
/// @return The equivalent boolean value.
bool IRac::strToBool(const char *str, const bool def) {
if (!STRCASECMP(str, kOnStr) ||
!STRCASECMP(str, PSTR("1")) ||
!STRCASECMP(str, k1Str) ||
!STRCASECMP(str, kYesStr) ||
!STRCASECMP(str, kTrueStr))
return true;
else if (!STRCASECMP(str, kOffStr) ||
!STRCASECMP(str, PSTR("0")) ||
!STRCASECMP(str, k0Str) ||
!STRCASECMP(str, kNoStr) ||
!STRCASECMP(str, kFalseStr))
return false;
Expand Down
56 changes: 54 additions & 2 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ IRTEXT_CONST_STRING(kProtocolStr, D_STR_PROTOCOL); ///< "Protocol"
IRTEXT_CONST_STRING(kPowerStr, D_STR_POWER); ///< "Power"
IRTEXT_CONST_STRING(kOnStr, D_STR_ON); ///< "On"
IRTEXT_CONST_STRING(kOffStr, D_STR_OFF); ///< "Off"
IRTEXT_CONST_STRING(k1Str, D_STR_1); ///< "1"
IRTEXT_CONST_STRING(k0Str, D_STR_0); ///< "0"
IRTEXT_CONST_STRING(kModeStr, D_STR_MODE); ///< "Mode"
IRTEXT_CONST_STRING(kToggleStr, D_STR_TOGGLE); ///< "Toggle"
IRTEXT_CONST_STRING(kTurboStr, D_STR_TURBO); ///< "Turbo"
Expand Down Expand Up @@ -126,8 +128,12 @@ IRTEXT_CONST_STRING(kAutoStr, D_STR_AUTO); ///< "Auto"
IRTEXT_CONST_STRING(kAutomaticStr, D_STR_AUTOMATIC); ///< "Automatic"
IRTEXT_CONST_STRING(kManualStr, D_STR_MANUAL); ///< "Manual"
IRTEXT_CONST_STRING(kCoolStr, D_STR_COOL); ///< "Cool"
IRTEXT_CONST_STRING(kCoolingStr, D_STR_COOLING); ///< "Cooling"
IRTEXT_CONST_STRING(kHeatStr, D_STR_HEAT); ///< "Heat"
IRTEXT_CONST_STRING(kHeatingStr, D_STR_HEATING); ///< "Heating"
IRTEXT_CONST_STRING(kDryStr, D_STR_DRY); ///< "Dry"
IRTEXT_CONST_STRING(kDryingStr, D_STR_DRYING); ///< "Drying"
IRTEXT_CONST_STRING(kDehumidifyStr, D_STR_DEHUMIDIFY); ///< "Dehumidify"
IRTEXT_CONST_STRING(kFanStr, D_STR_FAN); ///< "Fan"
// The following Fans strings with "only" are required to help with
// HomeAssistant & Google Home Climate integration. For compatibility only.
Expand Down Expand Up @@ -155,11 +161,17 @@ IRTEXT_CONST_STRING(kLowStr, D_STR_LOW); ///< "Low"
IRTEXT_CONST_STRING(kLoStr, D_STR_LO); ///< "Lo"
IRTEXT_CONST_STRING(kLowestStr, D_STR_LOWEST); ///< "Lowest"
IRTEXT_CONST_STRING(kMaxRightStr, D_STR_MAXRIGHT); ///< "Max Right"
IRTEXT_CONST_STRING(kRightMaxStr, D_STR_RIGHTMAX_NOSPACE); ///< "RightMax"
IRTEXT_CONST_STRING(kMaxRightNoSpaceStr, D_STR_MAXRIGHT_NOSPACE); ///<
///< "MaxRight"
IRTEXT_CONST_STRING(kRightMaxStr, D_STR_RIGHTMAX); ///< "Right Max"
IRTEXT_CONST_STRING(kRightMaxNoSpaceStr, D_STR_RIGHTMAX_NOSPACE); ///<
///< "RightMax"
IRTEXT_CONST_STRING(kRightStr, D_STR_RIGHT); ///< "Right"
IRTEXT_CONST_STRING(kLeftStr, D_STR_LEFT); ///< "Left"
IRTEXT_CONST_STRING(kMaxLeftStr, D_STR_MAXLEFT); ///< "Max Left"
IRTEXT_CONST_STRING(kLeftMaxStr, D_STR_LEFTMAX_NOSPACE); ///< "LeftMax"
IRTEXT_CONST_STRING(kMaxLeftNoSpaceStr, D_STR_MAXLEFT_NOSPACE); ///< "MaxLeft"
IRTEXT_CONST_STRING(kLeftMaxStr, D_STR_LEFTMAX); ///< "Left Max"
IRTEXT_CONST_STRING(kLeftMaxNoSpaceStr, D_STR_LEFTMAX_NOSPACE); ///< "LeftMax"
IRTEXT_CONST_STRING(kWideStr, D_STR_WIDE); ///< "Wide"
IRTEXT_CONST_STRING(kCentreStr, D_STR_CENTRE); ///< "Centre"
IRTEXT_CONST_STRING(kTopStr, D_STR_TOP); ///< "Top"
Expand Down Expand Up @@ -212,6 +224,46 @@ IRTEXT_CONST_STRING(kRepeatStr, D_STR_REPEAT); ///< "Repeat"
IRTEXT_CONST_STRING(kCodeStr, D_STR_CODE); ///< "Code"
IRTEXT_CONST_STRING(kBitsStr, D_STR_BITS); ///< "Bits"

// Model Names
IRTEXT_CONST_STRING(kYaw1fStr, D_STR_YAW1F); ///< "YAW1F"
IRTEXT_CONST_STRING(kYbofbStr, D_STR_YBOFB); ///< "YBOFB"
IRTEXT_CONST_STRING(kRlt0541htaaStr, D_STR_RLT0541HTA_A); ///< "R-LT0541-HTA-A"
IRTEXT_CONST_STRING(kRlt0541htabStr, D_STR_RLT0541HTA_B); ///< "R-LT0541-HTA-B"
IRTEXT_CONST_STRING(kArrah2eStr, D_STR_ARRAH2E); ///< "ARRAH2E"
IRTEXT_CONST_STRING(kArdb1Str, D_STR_ARDB1); ///< "ARDB1"
IRTEXT_CONST_STRING(kArreb1eStr, D_STR_ARREB1E); ///< "ARREB1E"
IRTEXT_CONST_STRING(kArjw2Str, D_STR_ARJW2); ///< "ARJW2"
IRTEXT_CONST_STRING(kArry4Str, D_STR_ARRY4); ///< "ARRY4"
IRTEXT_CONST_STRING(kArrew4eStr, D_STR_ARREW4E); ///< "ARREW4E"
IRTEXT_CONST_STRING(kGe6711ar2853mStr, D_STR_GE6711AR2853M); ///<
///< "GE6711AR2853M"
IRTEXT_CONST_STRING(kAkb75215403Str, D_STR_AKB75215403); ///< "AKB75215403"
IRTEXT_CONST_STRING(kAkb74955603Str, D_STR_AKB74955603); ///< "AKB74955603"
IRTEXT_CONST_STRING(kAkb73757604Str, D_STR_AKB73757604); ///< "AKB73757604"
IRTEXT_CONST_STRING(kLkeStr, D_STR_LKE); ///< "LKE"
IRTEXT_CONST_STRING(kNkeStr, D_STR_NKE); ///< "NKE"
IRTEXT_CONST_STRING(kDkeStr, D_STR_DKE); ///< "DKE"
IRTEXT_CONST_STRING(kPkrStr, D_STR_PKR); ///< "PKR"
IRTEXT_CONST_STRING(kJkeStr, D_STR_JKE); ///< "JKE"
IRTEXT_CONST_STRING(kCkpStr, D_STR_CKP); ///< "CKP"
IRTEXT_CONST_STRING(kRkrStr, D_STR_RKR); ///< "RKR"
IRTEXT_CONST_STRING(kPanasonicLkeStr, D_STR_PANASONICLKE); ///< "PANASONICLKE"
IRTEXT_CONST_STRING(kPanasonicNkeStr, D_STR_PANASONICNKE); ///< "PANASONICNKE"
IRTEXT_CONST_STRING(kPanasonicDkeStr, D_STR_PANASONICDKE); ///< "PANASONICDKE"
IRTEXT_CONST_STRING(kPanasonicPkrStr, D_STR_PANASONICPKR); ///< "PANASONICPKR"
IRTEXT_CONST_STRING(kPanasonicJkeStr, D_STR_PANASONICJKE); ///< "PANASONICJKE"
IRTEXT_CONST_STRING(kPanasonicCkpStr, D_STR_PANASONICCKP); ///< "PANASONICCKP"
IRTEXT_CONST_STRING(kPanasonicRkrStr, D_STR_PANASONICRKR); ///< "PANASONICRKR"
IRTEXT_CONST_STRING(kA907Str, D_STR_A907); ///< "A907"
IRTEXT_CONST_STRING(kA705Str, D_STR_A705); ///< "A705"
IRTEXT_CONST_STRING(kA903Str, D_STR_A903); ///< "A903"
IRTEXT_CONST_STRING(kTac09chsdStr, D_STR_TAC09CHSD); ///< "TAC09CHSD"
IRTEXT_CONST_STRING(kGz055be1Str, D_STR_GZ055BE1); ///< "GZ055BE1"
IRTEXT_CONST_STRING(k122lzfStr, D_STR_122LZF); ///< "122LZF"
IRTEXT_CONST_STRING(kDg11j13aStr, D_STR_DG11J13A); ///< "DG11J13A"
IRTEXT_CONST_STRING(kDg11j104Str, D_STR_DG11J104); ///< "DG11J104"
IRTEXT_CONST_STRING(kDg11j191Str, D_STR_DG11J191); ///< "DG11J191"

// Protocol Names
// Needs to be in decode_type_t order.
IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
Expand Down
Loading