From dd630ae4a9dc7f6a0ac1f474421d80b4f33b9f50 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 6 Jan 2024 15:18:49 +0200 Subject: [PATCH] 2024.1.0: Small improvements in reading source code --- README.md | 18 +++------ components/ehmtxv2/EHMTX.cpp | 74 +++++++++++++++++----------------- components/ehmtxv2/__init__.py | 2 +- 3 files changed, 43 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index dea4b2fd..412bc3ff 100644 --- a/README.md +++ b/README.md @@ -930,12 +930,12 @@ boot_logo (optional, string, only on ESP32): Mask defined as rgb565 array used t **boot_logo_mode** (optional, integer, only on ESP32, Default: 3) Mode of displaying boot logo, can take value from 0 to 3: -0 - Display the boot_logo with the defined colors (default) -1 - Display the boot_logo with the defined colors, the mask appears from the center to the sides. -2 - Display boot_logo in white color -3 - Display boot_logo in white color, the mask appears from the center to the sides. -4 - Display boot_logo with rainbow color -5 - Display boot_logo in rainbow color, the mask appears from the center to the sides +- 0 - Display the boot_logo with the defined colors (default) +- 1 - Display the boot_logo with the defined colors, the logo appears from the center to the sides. +- 2 - Display boot_logo in white color +- 3 - Display boot_logo in white color, the mask appears from the center to the sides. +- 4 - Display boot_logo with rainbow color +- 5 - Display boot_logo in rainbow color, the mask appears from the center to the sides Mode 3 is best used with the option @@ -950,12 +950,6 @@ After startup, to save memory, you can clear the array with the boot logo by cal id(rgb8x32)->set_boot_logo(""); ``` -**boot_logo** (optional, string , only on ESP32): Display a full screen logo defined as rgb565 array. - -```yaml - boot_logo: "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]" -``` - **night_mode_screens** (optional, screen array, default [2, 3, 16]): List of screens displayed in [night mode](#night-mode). **icon_indicator_screens** (optional, screen array, default [15, 18]): List of screens on which the [icon indicator](#icon-indicator) will be displayed. diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index fea8b39a..21401796 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -45,9 +45,9 @@ namespace esphome #endif #ifdef USE_ESP32 -#ifdef EHMTXv2_ADV_BOOT + #ifdef EHMTXv2_ADV_BOOT this->boot_logo = nullptr; -#endif + #endif #endif for (uint8_t i = 0; i < MAXQUEUE; i++) @@ -251,7 +251,7 @@ namespace esphome } #ifdef USE_ESP32 -#ifdef EHMTXv2_ADV_BOOT + #ifdef EHMTXv2_ADV_BOOT void EHMTX::set_boot_logo(std::string logo) { if (logo == "") @@ -263,11 +263,11 @@ namespace esphome if (this->boot_logo == NULL) { -#if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_1 + #if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_1 this->boot_logo = new Color[256]; -#else + #else this->boot_logo = new uint8_t[256]; -#endif + #endif } const size_t CAPACITY = JSON_ARRAY_SIZE(256); @@ -280,21 +280,20 @@ namespace esphome { uint16_t buf = v.as(); + #if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_1 unsigned char b = (((buf) & 0x001F) << 3); unsigned char g = (((buf) & 0x07E0) >> 3); // Fixed: shift >> 5 and << 2 unsigned char r = (((buf) & 0xF800) >> 8); // shift >> 11 and << 3 -#if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_1 this->boot_logo[i++] = Color(r, g, b); -#else - this->boot_logo[i++] = (r + g + b == C_BLACK) ? 0 : 1; -#endif + #else + this->boot_logo[i++] = (buf == 0) ? 0 : 1; + #endif } } -#endif + #endif #endif #ifndef USE_ESP8266 - void EHMTX::bitmap_screen(std::string text, int lifetime, int screen_time) { std::string ic = get_icon_name(text); @@ -1346,33 +1345,32 @@ namespace esphome else { #ifdef USE_ESP32 -#ifdef EHMTXv2_ADV_BOOT - + #ifdef EHMTXv2_ADV_BOOT if (this->boot_logo != NULL) { -#if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_2 || defined EHMTXv2_ADV_BOOT_MODE_4 + #if defined EHMTXv2_ADV_BOOT_MODE_0 || defined EHMTXv2_ADV_BOOT_MODE_2 || defined EHMTXv2_ADV_BOOT_MODE_4 for (uint8_t x = 0; x < 32; x++) { for (uint8_t y = 0; y < 8; y++) { -#ifdef EHMTXv2_ADV_BOOT_MODE_0 + #ifdef EHMTXv2_ADV_BOOT_MODE_0 this->display->draw_pixel_at(x, y, this->boot_logo[x + y * 32]); -#else -#if defined EHMTXv2_ADV_BOOT_MODE_2 || defined EHMTXv2_ADV_BOOT_MODE_4 + #else + #if defined EHMTXv2_ADV_BOOT_MODE_2 || defined EHMTXv2_ADV_BOOT_MODE_4 if (this->boot_logo[x + y * 32] == 1) { -#ifdef EHMTXv2_ADV_BOOT_MODE_2 + #ifdef EHMTXv2_ADV_BOOT_MODE_2 this->display->draw_pixel_at(x, y, Color(C_RED, C_GREEN, C_BLUE)); -#else + #else this->display->draw_pixel_at(x, y, this->rainbow_color); -#endif + #endif } -#endif -#endif + #endif + #endif } } -#endif -#if defined EHMTXv2_ADV_BOOT_MODE_1 || defined EHMTXv2_ADV_BOOT_MODE_3 || defined EHMTXv2_ADV_BOOT_MODE_5 + #endif + #if defined EHMTXv2_ADV_BOOT_MODE_1 || defined EHMTXv2_ADV_BOOT_MODE_3 || defined EHMTXv2_ADV_BOOT_MODE_5 if (this->boot_anim % 8 == 0 ) { uint8_t w = (2 + (uint8_t)(32 / 16) * (this->boot_anim * 2 / 16)) % 32; @@ -1380,35 +1378,35 @@ namespace esphome uint8_t r = 15 + w / 2; for (uint8_t y = 0; y < 8; y++) { -#if defined EHMTXv2_ADV_BOOT_MODE_3 || defined EHMTXv2_ADV_BOOT_MODE_5 + #if defined EHMTXv2_ADV_BOOT_MODE_3 || defined EHMTXv2_ADV_BOOT_MODE_5 if (this->boot_logo[l + y * 32] == 1) { -#ifdef EHMTXv2_ADV_BOOT_MODE_3 + #ifdef EHMTXv2_ADV_BOOT_MODE_3 this->display->draw_pixel_at(l, y, Color(C_RED, C_GREEN, C_BLUE)); -#else + #else this->display->draw_pixel_at(l, y, this->rainbow_color); -#endif + #endif } if (this->boot_logo[r + y * 32] == 1) { -#ifdef EHMTXv2_ADV_BOOT_MODE_3 + #ifdef EHMTXv2_ADV_BOOT_MODE_3 this->display->draw_pixel_at(r, y, Color(C_RED, C_GREEN, C_BLUE)); -#else + #else this->display->draw_pixel_at(r, y, this->rainbow_color); -#endif + #endif } -#endif -#ifdef EHMTXv2_ADV_BOOT_MODE_1 + #endif + #ifdef EHMTXv2_ADV_BOOT_MODE_1 this->display->draw_pixel_at(l, y, this->boot_logo[l + y * 32]); this->display->draw_pixel_at(r, y, this->boot_logo[r + y * 32]); -#endif + #endif } } -#endif + #endif } - -#endif + #endif #endif + #ifndef EHMTXv2_ADV_BOOT { uint8_t w = 2 + ((uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index e5b971de..9acc3249 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -31,7 +31,7 @@ SVG_END = "" logging.warning(f"") -logging.warning(f"!!!!This version (2023.9.1) has breaking changes!!!!") +logging.warning(f"!!!!This version (2024.1.0) has breaking changes!!!!") logging.warning(f"Please check the documentation and wiki https://github.com/lubeda/EspHoMaTriXv2") logging.warning(f"This will only work with esphome >= 2023.7.0") logging.warning(f"")