From c56f4825162f8c716a3f70cb475c241285b8e098 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 7 Nov 2023 21:51:41 +0100 Subject: [PATCH] User embedded color565 conversion --- nspanel_esphome_core.yaml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/nspanel_esphome_core.yaml b/nspanel_esphome_core.yaml index 20b2aed..fed878c 100644 --- a/nspanel_esphome_core.yaml +++ b/nspanel_esphome_core.yaml @@ -1939,20 +1939,12 @@ script: background: int[] then: - lambda: |- - int fg565 = -1; - int bg565 = -1; - // Foreground - if (foreground.size() == 3 and foreground[0] >= 0 and foreground[1] >= 0 and foreground[2] >= 0) fg565 = ((foreground[0] & 0b11111000) << 8) | ((foreground[1] & 0b11111100) << 3) | (foreground[2] >> 3); - else if (foreground.size() == 1) fg565 = foreground[0]; - else fg565 = -1; - if (fg565 >= 0) disp1->set_component_font_color(component.c_str(), fg565); - + if (foreground.size() == 3 and foreground[0] >= 0 and foreground[1] >= 0 and foreground[2] >= 0) disp1->set_component_font_color(component.c_str(), Color(foreground[0], foreground[1], foreground[2])); + else if (foreground.size() == 1 and foreground[0] >= 0) disp1->set_component_font_color(component.c_str(), foreground[0]); // Background - if (background.size() == 3 and background[0] >= 0 and background[1] >= 0 and background[2] >= 0) bg565 = ((background[0] & 0b11111000) << 8) | ((background[1] & 0b11111100) << 3) | (background[2] >> 3); - else if (background.size() == 1) bg565 = background[0]; - else bg565 = -1; - if (bg565 >= 0) disp1->set_component_background_color(component.c_str(), bg565); + if (background.size() == 3 and background[0] >= 0 and background[1] >= 0 and background[2] >= 0) disp1->set_component_background_color(component.c_str(), Color(background[0], background[1], background[2])); + else if (background.size() == 1 and background[0] >= 0) disp1->set_component_background_color(component.c_str(), background[0]); - id: display_wrapped_text mode: queued