fix: static text lvobj NULL access
This commit is contained in:
committed by
Raphael Coeffic
parent
f8b8232d07
commit
f6598a11e4
+6
-7
@@ -54,7 +54,7 @@ void StaticText::setText(std::string value)
|
|||||||
{
|
{
|
||||||
if (text != value) {
|
if (text != value) {
|
||||||
text = std::move(value);
|
text = std::move(value);
|
||||||
lv_label_set_text(lvobj, text.c_str());
|
if (lvobj) lv_label_set_text(lvobj, text.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,10 +66,9 @@ const std::string& StaticText::getText() const
|
|||||||
void StaticText::setBackgroundColor(LcdFlags color)
|
void StaticText::setBackgroundColor(LcdFlags color)
|
||||||
{
|
{
|
||||||
bgColor = color;
|
bgColor = color;
|
||||||
auto actualColor = COLOR_VAL(bgColor);
|
|
||||||
lv_obj_set_style_bg_color(
|
if (!lvobj) return;
|
||||||
lvobj,
|
|
||||||
lv_color_make(GET_RED(actualColor), GET_GREEN(actualColor),
|
lv_color_t c = makeLvColor(bgColor);
|
||||||
GET_BLUE(actualColor)),
|
lv_obj_set_style_bg_color(lvobj, c, LV_PART_MAIN);
|
||||||
LV_PART_MAIN);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user