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

Reduce flash space used. #1633

Merged
merged 1 commit 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
3 changes: 2 additions & 1 deletion src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ IRTEXT_CONST_STRING(kSwingVToggleStr, D_STR_SWINGVTOGGLE); ///<
///< "Swing(V) Toggle"
IRTEXT_CONST_STRING(kTurboToggleStr, D_STR_TURBOTOGGLE); ///< "Turbo Toggle"

// Separators
// Separators & Punctuation
const char kTimeSep = D_CHR_TIME_SEP; ///< ':'
IRTEXT_CONST_STRING(kSpaceLBraceStr, D_STR_SPACELBRACE); ///< " ("
IRTEXT_CONST_STRING(kCommaSpaceStr, D_STR_COMMASPACE); ///< ", "
IRTEXT_CONST_STRING(kColonSpaceStr, D_STR_COLONSPACE); ///< ": "
IRTEXT_CONST_STRING(kDashStr, D_STR_DASH); ///< "-"

// IRutils
// - Time
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern IRTEXT_CONST_PTR(kComfortStr);
extern IRTEXT_CONST_PTR(kCommandStr);
extern IRTEXT_CONST_PTR(kCommaSpaceStr);
extern IRTEXT_CONST_PTR(kCoolStr);
extern IRTEXT_CONST_PTR(kDashStr);
extern IRTEXT_CONST_PTR(kDaysStr);
extern IRTEXT_CONST_PTR(kDayStr);
extern IRTEXT_CONST_PTR(kDisplayTempStr);
Expand Down
13 changes: 12 additions & 1 deletion src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,18 @@ namespace irutils {
/// @return The resulting String.
String addBoolToString(const bool value, const String label,
const bool precomma) {
return addLabeledString((value ? kOnStr : kOffStr), label, precomma);
return addLabeledString(value ? kOnStr : kOffStr, label, precomma);
}

/// Create a String with a colon separated toggle flag suitable for Humans.
/// e.g. "Light: Toggle", "Light: -"
/// @param[in] toggle The value of the toggle to come after the label.
/// @param[in] label The label to precede the value.
/// @param[in] precomma Should the output string start with ", " or not?
/// @return The resulting String.
String addToggleToString(const bool toggle, const String label,
const bool precomma) {
return addLabeledString(toggle ? kToggleStr : kDashStr, label, precomma);
}

/// Create a String with a colon separated labeled Integer suitable for
Expand Down
2 changes: 2 additions & 0 deletions src/IRutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ float fahrenheitToCelsius(const float deg);
namespace irutils {
String addBoolToString(const bool value, const String label,
const bool precomma = true);
String addToggleToString(const bool toggle, const String label,
const bool precomma = true);
String addIntToString(const uint16_t value, const String label,
const bool precomma = true);
String addSignedIntToString(const int16_t value, const String label,
Expand Down
4 changes: 2 additions & 2 deletions src/ir_Electra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using irutils::addLabeledString;
using irutils::addModeToString;
using irutils::addFanToString;
using irutils::addTempToString;
using irutils::addToggleToString;

#if SEND_ELECTRA_AC
/// Send a Electra A/C formatted message.
Expand Down Expand Up @@ -351,8 +352,7 @@ String IRElectraAc::toString(void) const {
kElectraAcFanMed);
result += addBoolToString(getSwingV(), kSwingVStr);
result += addBoolToString(getSwingH(), kSwingHStr);
result += addLabeledString(getLightToggle() ? String(kToggleStr)
: String("-"), kLightStr);
result += addToggleToString(getLightToggle(), kLightStr);
result += addBoolToString(_.Clean, kCleanStr);
result += addBoolToString(_.Turbo, kTurboStr);
return result;
Expand Down
10 changes: 4 additions & 6 deletions src/ir_Goodweather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using irutils::addLabeledString;
using irutils::addModeToString;
using irutils::addFanToString;
using irutils::addTempToString;
using irutils::addToggleToString;

#if SEND_GOODWEATHER
/// Send a Goodweather HVAC formatted message.
Expand Down Expand Up @@ -347,12 +348,9 @@ String IRGoodweatherAc::toString(void) const {
kGoodweatherFanAuto, kGoodweatherFanAuto,
kGoodweatherFanMed);

result += addLabeledString(_.Turbo ? String(kToggleStr)
: String("-"), kTurboStr);
result += addLabeledString(_.Light ? String(kToggleStr)
: String("-"), kLightStr);
result += addLabeledString(_.Sleep ? String(kToggleStr)
: String("-"), kSleepStr);
result += addToggleToString(_.Turbo, kTurboStr);
result += addToggleToString(_.Light, kLightStr);
result += addToggleToString(_.Sleep, kSleepStr);
result += addIntToString(_.Swing, kSwingStr);
result += kSpaceLBraceStr;
switch (_.Swing) {
Expand Down
9 changes: 3 additions & 6 deletions src/ir_Sharp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ using irutils::addModeToString;
using irutils::addModelToString;
using irutils::addSwingVToString;
using irutils::addTempToString;
using irutils::addToggleToString;
using irutils::minsToString;

// Also used by Denon protocol
Expand Down Expand Up @@ -920,14 +921,10 @@ String IRSharpAc::toString(void) const {
switch (model) {
case sharp_ac_remote_model_t::A705:
case sharp_ac_remote_model_t::A903:
result += addLabeledString(getLightToggle() ? String(kToggleStr)
: String("-"),
kLightStr);
result += addToggleToString(getLightToggle(), kLightStr);
break;
default:
result += addLabeledString(getEconoToggle() ? String(kToggleStr)
: String("-"),
kEconoStr);
result += addToggleToString(getEconoToggle(), kEconoStr);
}
result += addBoolToString(_.Clean, kCleanStr);
if (_.TimerEnabled)
Expand Down
10 changes: 2 additions & 8 deletions src/ir_Transcold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using irutils::addIntToString;
using irutils::addLabeledString;
using irutils::addModeToString;
using irutils::addTempToString;

using irutils::addToggleToString;

#if SEND_TRANSCOLD
/// Send a Transcold message
Expand Down Expand Up @@ -391,13 +391,7 @@ String IRTranscoldAc::toString(void) const {
result += addBoolToString(getPower(), kPowerStr, false);
if (!getPower()) return result; // If it's off, there is no other info.
// Special modes.
if (getSwing()) {
result += kCommaSpaceStr;
result += kSwingStr;
result += kColonSpaceStr;
result += kToggleStr;
return result;
}
if (getSwing()) return result + addToggleToString(true, kSwingStr);
result += addModeToString(getMode(), kTranscoldAuto, kTranscoldCool,
kTranscoldHeat, kTranscoldDry, kTranscoldFan);
result += addIntToString(_.Fan, kFanStr);
Expand Down
3 changes: 3 additions & 0 deletions src/locale/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@
#ifndef D_STR_COLONSPACE
#define D_STR_COLONSPACE ": "
#endif // D_STR_COLONSPACE
#ifndef D_STR_DASH
#define D_STR_DASH "-"
#endif // D_STR_DASH

#ifndef D_STR_DAY
#define D_STR_DAY "Day"
Expand Down