fix: static text lvobj NULL access

This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent f8b8232d07
commit f6598a11e4
+6 -7
View File
@@ -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);
} }