feat(color): Change global variables layout to better match other pages (#3116)

* Change global variables layout to better match other pages.

* Move internal classes for global variable page from .h to .cpp file. Convert header text in edit page to StaticText object and remove 'paint' function.

* Fix build error.

* chore: Formatting
This commit is contained in:
philmoz
2023-01-28 12:28:18 +10:00
committed by GitHub
parent e9b8a23ba4
commit 7a1231753a
4 changed files with 397 additions and 439 deletions
+19
View File
@@ -908,6 +908,25 @@ char *getSourceCustomValueString(source_t source, int32_t val, LcdFlags flags)
return getSourceCustomValueString(tmpHelpersString, source, val, flags);
}
std::string getValueWithUnit(int val, uint8_t unit, LcdFlags flags)
{
if ((flags & NO_UNIT) || unit == UNIT_RAW)
return formatNumberAsString(val, flags & (~NO_UNIT));
return formatNumberAsString(val, flags & (~NO_UNIT), 0, nullptr,
STR_VTELEMUNIT[unit]);
}
std::string getGVarValue(uint8_t gvar, gvar_t value, LcdFlags flags)
{
uint8_t prec = g_model.gvars[gvar].prec;
if (prec > 0) {
flags |= (prec == 1 ? PREC1 : PREC2);
}
return getValueWithUnit(
value, g_model.gvars[gvar].unit ? UNIT_PERCENT : UNIT_RAW, flags);
}
#endif // defined(LIBOPENUI)
#endif // !defined(BOOT)