From 08ce3aaae601ddbc41037fb84dde9f1551aff5ef Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Sat, 6 Jan 2024 18:19:32 +0200 Subject: [PATCH] 2024.1.0: Add Boot logo mode 6 and 7 - pseudo animation aka `True starship astronavigator modes` Each element of the image mask array can take values from 0 to 255 (if the value is greater than 255, it is automatically reset to 255). Each pixel is output depending on the bit that is set in its value byte, for example: - `1` - `10000000` - Will be displayed at every 1 cycle of the boot logo image output. - `4` - `00100000` - Will be displayed at every 3 cycle of the boot logo image output. - `255` - `11111111` - Will be displayed at each cycle of the boot logo image output. --- README.md | 10 ++++++++++ components/ehmtxv2/EHMTX.cpp | 25 ++++++++++++++++++++++++- components/ehmtxv2/__init__.py | 6 +++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5750669..1376e6f2 100644 --- a/README.md +++ b/README.md @@ -936,6 +936,8 @@ boot_logo (optional, string, only on ESP32): Mask defined as rgb565 array used t - 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 +- 6 - Display boot_logo in white color, in pseudo-animation mode, this mode for true starship astronavigators. +- 7 - Display boot_logo in rainbow color, in pseudo-animation mode, this mode for true starship astronavigators. Mode 3 is best used with the option @@ -950,6 +952,14 @@ After startup, to save memory, you can clear the array with the boot logo by cal id(rgb8x32)->set_boot_logo(""); ``` +`Mode 6,7` - True starship astronavigator modes. +Each element of the image mask array can take values from 0 to 255 (if the value is greater than 255, it is automatically reset to 255). +Each pixel is output depending on the bit that is set in its value byte, for example: + +- `1` - `10000000` - Will be displayed at every 1 cycle of the boot logo image output. +- `4` - `00100000` - Will be displayed at every 3 cycle of the boot logo image output. +- `255` - `11111111` - Will be displayed at each cycle of the boot logo image output. + **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 21401796..cef2f368 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -9,6 +9,14 @@ // #define EHMTXv2_ADV_BOOT // #define EHMTXv2_ADV_BOOT_MODE_0 +#ifdef USE_ESP32 + #ifdef EHMTXv2_ADV_BOOT + #if defined EHMTXv2_ADV_BOOT_MODE_6 || defined EHMTXv2_ADV_BOOT_MODE_7 + #define CHECK_BIT(var, pos) (var & (1 << pos)) + #endif + #endif +#endif + namespace esphome { EHMTX::EHMTX() : PollingComponent(POLLINGINTERVAL) @@ -285,6 +293,8 @@ namespace esphome unsigned char g = (((buf) & 0x07E0) >> 3); // Fixed: shift >> 5 and << 2 unsigned char r = (((buf) & 0xF800) >> 8); // shift >> 11 and << 3 this->boot_logo[i++] = Color(r, g, b); + #elif defined EHMTXv2_ADV_BOOT_MODE_6 || defined EHMTXv2_ADV_BOOT_MODE_7 + this->boot_logo[i++] = (buf > 255) ? 255 : buf; #else this->boot_logo[i++] = (buf == 0) ? 0 : 1; #endif @@ -1348,7 +1358,10 @@ namespace esphome #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 || defined EHMTXv2_ADV_BOOT_MODE_6 || defined EHMTXv2_ADV_BOOT_MODE_7 + #if defined EHMTXv2_ADV_BOOT_MODE_6 || defined EHMTXv2_ADV_BOOT_MODE_7 + if (this->boot_anim % 8 == 0 ) + #endif for (uint8_t x = 0; x < 32; x++) { for (uint8_t y = 0; y < 8; y++) @@ -1366,6 +1379,16 @@ namespace esphome #endif } #endif + #if defined EHMTXv2_ADV_BOOT_MODE_6 || defined EHMTXv2_ADV_BOOT_MODE_7 + if (CHECK_BIT(this->boot_logo[x + y * 32], ((this->boot_anim % 64) / 8))) + { + #ifdef EHMTXv2_ADV_BOOT_MODE_6 + this->display->draw_pixel_at(x, y, Color(C_RED, C_GREEN, C_BLUE)); + #else + this->display->draw_pixel_at(x, y, this->rainbow_color); + #endif + } + #endif #endif } } diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index 9acc3249..084ac959 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -176,7 +176,7 @@ def rgb565_888(v565): ): cv.string, cv.Optional( CONF_BOOTLOGOMODE, default="0" - ): cv.templatable(cv.int_range(min=0, max=5)), + ): cv.templatable(cv.int_range(min=0, max=7)), cv.Optional( CONF_SHOW_SECONDS, default=False ): cv.boolean, @@ -607,6 +607,10 @@ def thumbnails(frames): cg.add_define("EHMTXv2_ADV_BOOT_MODE_4") if config[CONF_BOOTLOGOMODE] == 5: cg.add_define("EHMTXv2_ADV_BOOT_MODE_5") + if config[CONF_BOOTLOGOMODE] == 6: + cg.add_define("EHMTXv2_ADV_BOOT_MODE_6") + if config[CONF_BOOTLOGOMODE] == 7: + cg.add_define("EHMTXv2_ADV_BOOT_MODE_7") if config[CONF_NIGHT_MODE_SCREENS]: cg.add_define("EHMTXv2_CONF_NIGHT_MODE_SCREENS",config[CONF_NIGHT_MODE_SCREENS])