Skip to content

Commit

Permalink
Merge pull request #194 from andrewjswan/2024.1.0-Small_improvements_…
Browse files Browse the repository at this point in the history
…in_reading_source_code

2024.1.0: Small improvements in reading source code
  • Loading branch information
lubeda authored Jan 6, 2024
2 parents ee45df0 + dd630ae commit 253bcb8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 51 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
74 changes: 36 additions & 38 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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 == "")
Expand All @@ -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);
Expand All @@ -280,21 +280,20 @@ namespace esphome
{
uint16_t buf = v.as<int>();

#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);
Expand Down Expand Up @@ -1346,69 +1345,68 @@ 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;
uint8_t l = 16 - w / 2;
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;
Expand Down
2 changes: 1 addition & 1 deletion components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
SVG_END = "</svg>"

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"")
Expand Down

0 comments on commit 253bcb8

Please sign in to comment.