From 9f99a26f1fd0200c60765a2486d21678ec5209f2 Mon Sep 17 00:00:00 2001 From: crankyoldgit Date: Tue, 12 Oct 2021 22:32:24 +1000 Subject: [PATCH 1/2] Move all String literals from IRac.cpp to IRtext.cpp & locale --- src/IRac.cpp | 100 +++++++++++++++--------------- src/IRtext.cpp | 55 ++++++++++++++++- src/IRtext.h | 46 ++++++++++++++ src/locale/defaults.h | 140 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 287 insertions(+), 54 deletions(-) diff --git a/src/IRac.cpp b/src/IRac.cpp index 843227e9c..f5673da1c 100644 --- a/src/IRac.cpp +++ b/src/IRac.cpp @@ -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. @@ -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 @@ -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)) @@ -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)) @@ -3265,77 +3262,76 @@ 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; // 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)) { 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); @@ -3352,12 +3348,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; diff --git a/src/IRtext.cpp b/src/IRtext.cpp index 21d91b302..86376fd96 100644 --- a/src/IRtext.cpp +++ b/src/IRtext.cpp @@ -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" @@ -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. @@ -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" @@ -212,6 +224,45 @@ 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(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) { diff --git a/src/IRtext.h b/src/IRtext.h index 8de825189..73a22f511 100644 --- a/src/IRtext.h +++ b/src/IRtext.h @@ -23,11 +23,25 @@ class __FlashStringHelper; #endif // ESP8266 extern const char kTimeSep; +extern IRTEXT_CONST_PTR(k0Str); extern IRTEXT_CONST_PTR(k10CHeatStr); +extern IRTEXT_CONST_PTR(k122lzfStr); +extern IRTEXT_CONST_PTR(k1Str); extern IRTEXT_CONST_PTR(k3DStr); extern IRTEXT_CONST_PTR(k6thSenseStr); extern IRTEXT_CONST_PTR(k8CHeatStr); +extern IRTEXT_CONST_PTR(kA705Str); +extern IRTEXT_CONST_PTR(kA903Str); +extern IRTEXT_CONST_PTR(kA907Str); extern IRTEXT_CONST_PTR(kAirFlowStr); +extern IRTEXT_CONST_PTR(kAkb73757604Str); +extern IRTEXT_CONST_PTR(kAkb74955603Str); +extern IRTEXT_CONST_PTR(kAkb75215403Str); +extern IRTEXT_CONST_PTR(kArdb1Str); +extern IRTEXT_CONST_PTR(kArjw2Str); +extern IRTEXT_CONST_PTR(kArrah2eStr); +extern IRTEXT_CONST_PTR(kArreb1eStr); +extern IRTEXT_CONST_PTR(kArry4Str); extern IRTEXT_CONST_PTR(kAutomaticStr); extern IRTEXT_CONST_PTR(kAutoStr); extern IRTEXT_CONST_PTR(kBeepStr); @@ -42,6 +56,7 @@ extern IRTEXT_CONST_PTR(kCelsiusStr); extern IRTEXT_CONST_PTR(kCentreStr); extern IRTEXT_CONST_PTR(kChangeStr); extern IRTEXT_CONST_PTR(kCirculateStr); +extern IRTEXT_CONST_PTR(kCkpStr); extern IRTEXT_CONST_PTR(kCleanStr); extern IRTEXT_CONST_PTR(kClockStr); extern IRTEXT_CONST_PTR(kCodeStr); @@ -49,12 +64,19 @@ extern IRTEXT_CONST_PTR(kColonSpaceStr); extern IRTEXT_CONST_PTR(kComfortStr); extern IRTEXT_CONST_PTR(kCommandStr); extern IRTEXT_CONST_PTR(kCommaSpaceStr); +extern IRTEXT_CONST_PTR(kCoolingStr); extern IRTEXT_CONST_PTR(kCoolStr); extern IRTEXT_CONST_PTR(kDashStr); extern IRTEXT_CONST_PTR(kDaysStr); extern IRTEXT_CONST_PTR(kDayStr); +extern IRTEXT_CONST_PTR(kDehumidifyStr); +extern IRTEXT_CONST_PTR(kDg11j104Str); +extern IRTEXT_CONST_PTR(kDg11j13aStr); +extern IRTEXT_CONST_PTR(kDg11j191Str); extern IRTEXT_CONST_PTR(kDisplayTempStr); +extern IRTEXT_CONST_PTR(kDkeStr); extern IRTEXT_CONST_PTR(kDownStr); +extern IRTEXT_CONST_PTR(kDryingStr); extern IRTEXT_CONST_PTR(kDryStr); extern IRTEXT_CONST_PTR(kEconoStr); extern IRTEXT_CONST_PTR(kEconoToggleStr); @@ -71,7 +93,10 @@ extern IRTEXT_CONST_PTR(kFilterStr); extern IRTEXT_CONST_PTR(kFixedStr); extern IRTEXT_CONST_PTR(kFollowStr); extern IRTEXT_CONST_PTR(kFreshStr); +extern IRTEXT_CONST_PTR(kGe6711ar2853mStr); +extern IRTEXT_CONST_PTR(kGz055be1Str); extern IRTEXT_CONST_PTR(kHealthStr); +extern IRTEXT_CONST_PTR(kHeatingStr); extern IRTEXT_CONST_PTR(kHeatStr); extern IRTEXT_CONST_PTR(kHighestStr); extern IRTEXT_CONST_PTR(kHighStr); @@ -84,11 +109,14 @@ extern IRTEXT_CONST_PTR(kIdStr); extern IRTEXT_CONST_PTR(kIFeelStr); extern IRTEXT_CONST_PTR(kInsideStr); extern IRTEXT_CONST_PTR(kIonStr); +extern IRTEXT_CONST_PTR(kJkeStr); extern IRTEXT_CONST_PTR(kLastStr); +extern IRTEXT_CONST_PTR(kLeftMaxNoSpaceStr); extern IRTEXT_CONST_PTR(kLeftMaxStr); extern IRTEXT_CONST_PTR(kLeftStr); extern IRTEXT_CONST_PTR(kLightStr); extern IRTEXT_CONST_PTR(kLightToggleStr); +extern IRTEXT_CONST_PTR(kLkeStr); extern IRTEXT_CONST_PTR(kLoStr); extern IRTEXT_CONST_PTR(kLoudStr); extern IRTEXT_CONST_PTR(kLowerStr); @@ -96,7 +124,9 @@ extern IRTEXT_CONST_PTR(kLowestStr); extern IRTEXT_CONST_PTR(kLowStr); extern IRTEXT_CONST_PTR(kManualStr); extern IRTEXT_CONST_PTR(kMaximumStr); +extern IRTEXT_CONST_PTR(kMaxLeftNoSpaceStr); extern IRTEXT_CONST_PTR(kMaxLeftStr); +extern IRTEXT_CONST_PTR(kMaxRightNoSpaceStr); extern IRTEXT_CONST_PTR(kMaxRightStr); extern IRTEXT_CONST_PTR(kMaxStr); extern IRTEXT_CONST_PTR(kMediumStr); @@ -113,6 +143,7 @@ extern IRTEXT_CONST_PTR(kMouldStr); extern IRTEXT_CONST_PTR(kMoveStr); extern IRTEXT_CONST_PTR(kNAStr); extern IRTEXT_CONST_PTR(kNightStr); +extern IRTEXT_CONST_PTR(kNkeStr); extern IRTEXT_CONST_PTR(kNoStr); extern IRTEXT_CONST_PTR(kNowStr); extern IRTEXT_CONST_PTR(kOffStr); @@ -121,6 +152,14 @@ extern IRTEXT_CONST_PTR(kOnStr); extern IRTEXT_CONST_PTR(kOnTimerStr); extern IRTEXT_CONST_PTR(kOutsideQuietStr); extern IRTEXT_CONST_PTR(kOutsideStr); +extern IRTEXT_CONST_PTR(kPanasonicCkpStr); +extern IRTEXT_CONST_PTR(kPanasonicDkeStr); +extern IRTEXT_CONST_PTR(kPanasonicJkeStr); +extern IRTEXT_CONST_PTR(kPanasonicLkeStr); +extern IRTEXT_CONST_PTR(kPanasonicNkeStr); +extern IRTEXT_CONST_PTR(kPanasonicPkrStr); +extern IRTEXT_CONST_PTR(kPanasonicRkrStr); +extern IRTEXT_CONST_PTR(kPkrStr); extern IRTEXT_CONST_PTR(kPowerButtonStr); extern IRTEXT_CONST_PTR(kPowerfulStr); extern IRTEXT_CONST_PTR(kPowerStr); @@ -131,8 +170,12 @@ extern IRTEXT_CONST_PTR(kPurifyStr); extern IRTEXT_CONST_PTR(kQuietStr); extern IRTEXT_CONST_PTR(kRecycleStr); extern IRTEXT_CONST_PTR(kRepeatStr); +extern IRTEXT_CONST_PTR(kRightMaxNoSpaceStr); extern IRTEXT_CONST_PTR(kRightMaxStr); extern IRTEXT_CONST_PTR(kRightStr); +extern IRTEXT_CONST_PTR(kRkrStr); +extern IRTEXT_CONST_PTR(kRlt0541htaaStr); +extern IRTEXT_CONST_PTR(kRlt0541htabStr); extern IRTEXT_CONST_PTR(kRoomStr); extern IRTEXT_CONST_PTR(kSaveStr); extern IRTEXT_CONST_PTR(kSecondsStr); @@ -155,6 +198,7 @@ extern IRTEXT_CONST_PTR(kSwingStr); extern IRTEXT_CONST_PTR(kSwingVModeStr); extern IRTEXT_CONST_PTR(kSwingVStr); extern IRTEXT_CONST_PTR(kSwingVToggleStr); +extern IRTEXT_CONST_PTR(kTac09chsdStr); extern IRTEXT_CONST_PTR(kTempDownStr); extern IRTEXT_CONST_PTR(kTempStr); extern IRTEXT_CONST_PTR(kTempUpStr); @@ -176,6 +220,8 @@ extern IRTEXT_CONST_PTR(kWeeklyTimerStr); extern IRTEXT_CONST_PTR(kWideStr); extern IRTEXT_CONST_PTR(kWifiStr); extern IRTEXT_CONST_PTR(kXFanStr); +extern IRTEXT_CONST_PTR(kYaw1fStr); +extern IRTEXT_CONST_PTR(kYbofbStr); extern IRTEXT_CONST_PTR(kYesStr); extern IRTEXT_CONST_PTR(kZoneFollowStr); extern IRTEXT_CONST_PTR(kAllProtocolNamesStr); diff --git a/src/locale/defaults.h b/src/locale/defaults.h index 61ba6fc5d..cde1b4c9d 100644 --- a/src/locale/defaults.h +++ b/src/locale/defaults.h @@ -30,9 +30,15 @@ #ifndef D_STR_ON #define D_STR_ON "On" #endif // D_STR_ON +#ifndef D_STR_1 +#define D_STR_1 "1" +#endif // D_STR_1 #ifndef D_STR_OFF #define D_STR_OFF "Off" #endif // D_STR_OFF +#ifndef D_STR_0 +#define D_STR_0 "0" +#endif // D_STR_0 #ifndef D_STR_MODE #define D_STR_MODE "Mode" #endif // D_STR_MODE @@ -298,9 +304,15 @@ #ifndef D_STR_COOL #define D_STR_COOL "Cool" #endif // D_STR_COOL +#ifndef D_STR_COOLING +#define D_STR_COOLING "Cooling" +#endif // D_STR_COOLING #ifndef D_STR_HEAT #define D_STR_HEAT "Heat" #endif // D_STR_HEAT +#ifndef D_STR_HEATING +#define D_STR_HEATING "Heating" +#endif // D_STR_HEATING #ifndef D_STR_FAN #define D_STR_FAN "Fan" #endif // D_STR_FAN @@ -322,6 +334,12 @@ #ifndef D_STR_DRY #define D_STR_DRY "Dry" #endif // D_STR_DRY +#ifndef D_STR_DRYING +#define D_STR_DRYING "Drying" +#endif // D_STR_DRYING +#ifndef D_STR_DEHUMIDIFY +#define D_STR_DEHUMIDIFY "Dehumidify" +#endif // D_STR_DEHUMIDIFY #ifndef D_STR_MAX #define D_STR_MAX "Max" @@ -372,6 +390,12 @@ #ifndef D_STR_MAXRIGHT #define D_STR_MAXRIGHT D_STR_MAX " " D_STR_RIGHT // Set `D_STR_MAX` first! #endif // D_STR_MAXRIGHT +#ifndef D_STR_MAXRIGHT_NOSPACE +#define D_STR_MAXRIGHT_NOSPACE D_STR_MAX D_STR_RIGHT // Set `D_STR_MAX` first! +#endif // D_STR_MAXRIGHT_NOSPACE +#ifndef D_STR_RIGHTMAX +#define D_STR_RIGHTMAX D_STR_RIGHT " " D_STR_MAX // Set `D_STR_MAX` first! +#endif // D_STR_RIGHTMAX #ifndef D_STR_RIGHTMAX_NOSPACE #define D_STR_RIGHTMAX_NOSPACE D_STR_RIGHT D_STR_MAX // Set `D_STR_MAX` first! #endif // D_STR_RIGHTMAX_NOSPACE @@ -381,6 +405,12 @@ #ifndef D_STR_MAXLEFT #define D_STR_MAXLEFT D_STR_MAX " " D_STR_LEFT // Set `D_STR_MAX` first! #endif // D_STR_MAXLEFT +#ifndef D_STR_MAXLEFT_NOSPACE +#define D_STR_MAXLEFT_NOSPACE D_STR_MAX D_STR_LEFT // Set `D_STR_MAX` first! +#endif // D_STR_MAXLEFT_NOSPACE +#ifndef D_STR_LEFTMAX +#define D_STR_LEFTMAX D_STR_LEFT " " D_STR_MAX // Set `D_STR_MAX` first! +#endif // D_STR_LEFTMAX #ifndef D_STR_LEFTMAX_NOSPACE #define D_STR_LEFTMAX_NOSPACE D_STR_LEFT D_STR_MAX // Set `D_STR_MAX` first! #endif // D_STR_LEFTMAX_NOSPACE @@ -510,6 +540,116 @@ #define D_STR_BITS "Bits" #endif // D_STR_BITS +// Model Names +#ifndef D_STR_YAW1F +#define D_STR_YAW1F "YAW1F" +#endif // D_STR_YAW1F +#ifndef D_STR_YBOFB +#define D_STR_YBOFB "YBOFB" +#endif // D_STR_YBOFB +#ifndef D_STR_RLT0541HTA_A +#define D_STR_RLT0541HTA_A "R-LT0541-HTA-A" +#endif // D_STR_RLT0541HTA_A +#ifndef D_STR_RLT0541HTA_B +#define D_STR_RLT0541HTA_B "R-LT0541-HTA-B" +#endif // D_STR_RLT0541HTA_B +#ifndef D_STR_ARRAH2E +#define D_STR_ARRAH2E "ARRAH2E" +#endif // D_STR_ARRAH2E +#ifndef D_STR_ARDB1 +#define D_STR_ARDB1 "ARDB1" +#endif // D_STR_ARDB1 +#ifndef D_STR_ARREB1E +#define D_STR_ARREB1E "ARREB1E" +#endif // D_STR_ARREB1E +#ifndef D_STR_ARJW2 +#define D_STR_ARJW2 "ARJW2" +#endif // D_STR_ARJW2 +#ifndef D_STR_ARRY4 +#define D_STR_ARRY4 "ARRY4" +#endif // D_STR_ARRY4 +#ifndef D_STR_GE6711AR2853M +#define D_STR_GE6711AR2853M "GE6711AR2853M" +#endif // D_STR_GE6711AR2853M +#ifndef D_STR_AKB75215403 +#define D_STR_AKB75215403 "AKB75215403" +#endif // D_STR_AKB75215403 +#ifndef D_STR_AKB74955603 +#define D_STR_AKB74955603 "AKB74955603" +#endif // D_STR_AKB74955603 +#ifndef D_STR_AKB73757604 +#define D_STR_AKB73757604 "AKB73757604" +#endif // D_STR_AKB73757604 +#ifndef D_STR_LKE +#define D_STR_LKE "LKE" +#endif // D_STR_LKE +#ifndef D_STR_NKE +#define D_STR_NKE "NKE" +#endif // D_STR_NKE +#ifndef D_STR_DKE +#define D_STR_DKE "DKE" +#endif // D_STR_DKE +#ifndef D_STR_PKR +#define D_STR_PKR "PKR" +#endif // D_STR_PKR +#ifndef D_STR_JKE +#define D_STR_JKE "JKE" +#endif // D_STR_JKE +#ifndef D_STR_CKP +#define D_STR_CKP "CKP" +#endif // D_STR_CKP +#ifndef D_STR_RKR +#define D_STR_RKR "RKR" +#endif // D_STR_RKR +#ifndef D_STR_PANASONICLKE +#define D_STR_PANASONICLKE "PANASONICLKE" +#endif // D_STR_PANASONICLKE +#ifndef D_STR_PANASONICNKE +#define D_STR_PANASONICNKE "PANASONICNKE" +#endif // D_STR_PANASONICNKE +#ifndef D_STR_PANASONICDKE +#define D_STR_PANASONICDKE "PANASONICDKE" +#endif // D_STR_PANASONICDKE +#ifndef D_STR_PANASONICPKR +#define D_STR_PANASONICPKR "PANASONICPKR" +#endif // D_STR_PANASONICPKR +#ifndef D_STR_PANASONICJKE +#define D_STR_PANASONICJKE "PANASONICJKE" +#endif // D_STR_PANASONICJKE +#ifndef D_STR_PANASONICCKP +#define D_STR_PANASONICCKP "PANASONICCKP" +#endif // D_STR_PANASONICCKP +#ifndef D_STR_PANASONICRKR +#define D_STR_PANASONICRKR "PANASONICRKR" +#endif // D_STR_PANASONICRKR +#ifndef D_STR_A907 +#define D_STR_A907 "A907" +#endif // D_STR_A907 +#ifndef D_STR_A705 +#define D_STR_A705 "A705" +#endif // D_STR_A705 +#ifndef D_STR_A903 +#define D_STR_A903 "A903" +#endif // D_STR_A903 +#ifndef D_STR_TAC09CHSD +#define D_STR_TAC09CHSD "TAC09CHSD" +#endif // D_STR_TAC09CHSD +#ifndef D_STR_GZ055BE1 +#define D_STR_GZ055BE1 "GZ055BE1" +#endif // D_STR_GZ055BE1 +#ifndef D_STR_122LZF +#define D_STR_122LZF "122LZF" +#endif // D_STR_122LZF +#ifndef D_STR_DG11J13A +#define D_STR_DG11J13A "DG11J13A" +#endif // D_STR_DG11J13A +#ifndef D_STR_DG11J104 +#define D_STR_DG11J104 "DG11J104" +#endif // D_STR_DG11J104 +#ifndef D_STR_DG11J191 +#define D_STR_DG11J191 "DG11J191" +#endif // D_STR_DG11J191 + // Protocols Names #ifndef D_STR_AIRWELL #define D_STR_AIRWELL "AIRWELL" From c55223806ae7c40a0e15b099c997b44468205a75 Mon Sep 17 00:00:00 2001 From: crankyoldgit Date: Tue, 12 Oct 2021 23:20:17 +1000 Subject: [PATCH 2/2] Move some strings out of IRutils.cpp * Move out some strings/reuse flash strings. * Add missing `ARREW4E` to `strToModel()` * Minor code sttyle/formating changes. --- src/IRac.cpp | 2 ++ src/IRtext.cpp | 1 + src/IRtext.h | 1 + src/IRutils.cpp | 83 ++++++++++++++++++++++--------------------- src/locale/defaults.h | 3 ++ 5 files changed, 49 insertions(+), 41 deletions(-) diff --git a/src/IRac.cpp b/src/IRac.cpp index f5673da1c..4a456d846 100644 --- a/src/IRac.cpp +++ b/src/IRac.cpp @@ -3282,6 +3282,8 @@ int16_t IRac::strToModel(const char *str, const int16_t def) { return fujitsu_ac_remote_model_t::ARJW2; } 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, kGe6711ar2853mStr)) { return lg_ac_remote_model_t::GE6711AR2853M; diff --git a/src/IRtext.cpp b/src/IRtext.cpp index 86376fd96..7866b47f9 100644 --- a/src/IRtext.cpp +++ b/src/IRtext.cpp @@ -234,6 +234,7 @@ 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" diff --git a/src/IRtext.h b/src/IRtext.h index 73a22f511..f8a3be4ed 100644 --- a/src/IRtext.h +++ b/src/IRtext.h @@ -41,6 +41,7 @@ extern IRTEXT_CONST_PTR(kArdb1Str); extern IRTEXT_CONST_PTR(kArjw2Str); extern IRTEXT_CONST_PTR(kArrah2eStr); extern IRTEXT_CONST_PTR(kArreb1eStr); +extern IRTEXT_CONST_PTR(kArrew4eStr); extern IRTEXT_CONST_PTR(kArry4Str); extern IRTEXT_CONST_PTR(kAutomaticStr); extern IRTEXT_CONST_PTR(kAutoStr); diff --git a/src/IRutils.cpp b/src/IRutils.cpp index 1f0954a9b..003dfe4eb 100644 --- a/src/IRutils.cpp +++ b/src/IRutils.cpp @@ -95,7 +95,7 @@ String uint64ToString(uint64_t input, uint8_t base) { /// @returns A String representation of the integer. String int64ToString(int64_t input, uint8_t base) { if (input < 0) { - return "-" + uint64ToString(-input, base); + return kDashStr + uint64ToString(-input, base); } return uint64ToString(input, base); } @@ -343,7 +343,7 @@ String resultToTimingInfo(const decode_results * const results) { for (uint16_t i = 1; i < results->rawlen; i++) { if (i % 2 == 0) - output += '-'; // even + output += kDashStr; // even else output += F(" +"); // odd value = uint64ToString(results->rawbuf[i] * kRawTick); @@ -587,78 +587,79 @@ namespace irutils { switch (protocol) { case decode_type_t::FUJITSU_AC: switch (model) { - case fujitsu_ac_remote_model_t::ARRAH2E: return F("ARRAH2E"); - case fujitsu_ac_remote_model_t::ARDB1: return F("ARDB1"); - case fujitsu_ac_remote_model_t::ARREB1E: return F("ARREB1E"); - case fujitsu_ac_remote_model_t::ARJW2: return F("ARJW2"); - case fujitsu_ac_remote_model_t::ARRY4: return F("ARRY4"); - case fujitsu_ac_remote_model_t::ARREW4E: return F("ARREW4E"); - default: return kUnknownStr; + case fujitsu_ac_remote_model_t::ARRAH2E: return kArrah2eStr; + case fujitsu_ac_remote_model_t::ARDB1: return kArdb1Str; + case fujitsu_ac_remote_model_t::ARREB1E: return kArreb1eStr; + case fujitsu_ac_remote_model_t::ARJW2: return kArjw2Str; + case fujitsu_ac_remote_model_t::ARRY4: return kArry4Str; + case fujitsu_ac_remote_model_t::ARREW4E: return kArrew4eStr; + default: return kUnknownStr; } break; case decode_type_t::GREE: switch (model) { - case gree_ac_remote_model_t::YAW1F: return F("YAW1F"); - case gree_ac_remote_model_t::YBOFB: return F("YBOFB"); - default: return kUnknownStr; + case gree_ac_remote_model_t::YAW1F: return kYaw1fStr; + case gree_ac_remote_model_t::YBOFB: return kYbofbStr; + default: return kUnknownStr; } break; case decode_type_t::HITACHI_AC1: switch (model) { case hitachi_ac1_remote_model_t::R_LT0541_HTA_A: - return F("R-LT0541-HTA-A"); + return kRlt0541htaaStr; case hitachi_ac1_remote_model_t::R_LT0541_HTA_B: - return F("R-LT0541-HTA-B"); - default: return kUnknownStr; + return kRlt0541htabStr; + default: + return kUnknownStr; } break; case decode_type_t::LG: case decode_type_t::LG2: switch (model) { - case lg_ac_remote_model_t::GE6711AR2853M: return F("GE6711AR2853M"); - case lg_ac_remote_model_t::AKB75215403: return F("AKB75215403"); - case lg_ac_remote_model_t::AKB74955603: return F("AKB74955603"); - case lg_ac_remote_model_t::AKB73757604: return F("AKB73757604"); - default: return kUnknownStr; + case lg_ac_remote_model_t::GE6711AR2853M: return kGe6711ar2853mStr; + case lg_ac_remote_model_t::AKB75215403: return kAkb75215403Str; + case lg_ac_remote_model_t::AKB74955603: return kAkb74955603Str; + case lg_ac_remote_model_t::AKB73757604: return kAkb73757604Str; + default: return kUnknownStr; } break; case decode_type_t::PANASONIC_AC: switch (model) { - case panasonic_ac_remote_model_t::kPanasonicLke: return F("LKE"); - case panasonic_ac_remote_model_t::kPanasonicNke: return F("NKE"); - case panasonic_ac_remote_model_t::kPanasonicDke: return F("DKE"); - case panasonic_ac_remote_model_t::kPanasonicJke: return F("JKE"); - case panasonic_ac_remote_model_t::kPanasonicCkp: return F("CKP"); - case panasonic_ac_remote_model_t::kPanasonicRkr: return F("RKR"); - default: return kUnknownStr; + case panasonic_ac_remote_model_t::kPanasonicLke: return kLkeStr; + case panasonic_ac_remote_model_t::kPanasonicNke: return kNkeStr; + case panasonic_ac_remote_model_t::kPanasonicDke: return kDkeStr; + case panasonic_ac_remote_model_t::kPanasonicJke: return kJkeStr; + case panasonic_ac_remote_model_t::kPanasonicCkp: return kCkpStr; + case panasonic_ac_remote_model_t::kPanasonicRkr: return kRkrStr; + default: return kUnknownStr; } break; case decode_type_t::SHARP_AC: switch (model) { - case sharp_ac_remote_model_t::A907: return F("A907"); - case sharp_ac_remote_model_t::A705: return F("A705"); - case sharp_ac_remote_model_t::A903: return F("A903"); - default: return kUnknownStr; + case sharp_ac_remote_model_t::A907: return kA907Str; + case sharp_ac_remote_model_t::A705: return kA705Str; + case sharp_ac_remote_model_t::A903: return kA903Str; + default: return kUnknownStr; } break; case decode_type_t::TCL112AC: switch (model) { - case tcl_ac_remote_model_t::TAC09CHSD: return F("TAC09CHSD"); - case tcl_ac_remote_model_t::GZ055BE1: return F("GZ055BE1"); - default: return kUnknownStr; + case tcl_ac_remote_model_t::TAC09CHSD: return kTac09chsdStr; + case tcl_ac_remote_model_t::GZ055BE1: return kGz055be1Str; + default: return kUnknownStr; } break; case decode_type_t::VOLTAS: switch (model) { - case voltas_ac_remote_model_t::kVoltas122LZF: return F("122LZF"); - default: return kUnknownStr; + case voltas_ac_remote_model_t::kVoltas122LZF: return k122lzfStr; + default: return kUnknownStr; } break; case decode_type_t::WHIRLPOOL_AC: switch (model) { - case whirlpool_ac_remote_model_t::DG11J13A: return F("DG11J13A"); - case whirlpool_ac_remote_model_t::DG11J191: return F("DG11J191"); - default: return kUnknownStr; + case whirlpool_ac_remote_model_t::DG11J13A: return kDg11j13aStr; + case whirlpool_ac_remote_model_t::DG11J191: return kDg11j191Str; + default: return kUnknownStr; } break; default: return kUnknownStr; @@ -733,8 +734,8 @@ namespace irutils { if (mode == automatic) result += kAutoStr; else if (mode == cool) result += kCoolStr; else if (mode == heat) result += kHeatStr; - else if (mode == dry) result += kDryStr; - else if (mode == fan) result += kFanStr; + else if (mode == dry) result += kDryStr; + else if (mode == fan) result += kFanStr; else result += kUnknownStr; return result + ')'; diff --git a/src/locale/defaults.h b/src/locale/defaults.h index cde1b4c9d..2e9c58139 100644 --- a/src/locale/defaults.h +++ b/src/locale/defaults.h @@ -568,6 +568,9 @@ #ifndef D_STR_ARRY4 #define D_STR_ARRY4 "ARRY4" #endif // D_STR_ARRY4 +#ifndef D_STR_ARREW4E +#define D_STR_ARREW4E "ARREW4E" +#endif // D_STR_ARREW4E #ifndef D_STR_GE6711AR2853M #define D_STR_GE6711AR2853M "GE6711AR2853M" #endif // D_STR_GE6711AR2853M