Skip to content

Commit

Permalink
2024.1.0: Add Boot logo mode 6 and 7 - pseudo animation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewjswan committed Jan 6, 2024
1 parent f9b4870 commit 08ce3aa
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
25 changes: 24 additions & 1 deletion components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand All @@ -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
}
}
Expand Down
6 changes: 5 additions & 1 deletion components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 08ce3aa

Please sign in to comment.