Skip to content

Commit

Permalink
Merge pull request #229 from andrewjswan/2024.4.1-Specifying_the_brig…
Browse files Browse the repository at this point in the history
…htness_for_the_BITMAP_screen

2024.4.1: Specifying the brightness for the BITMAP screen
  • Loading branch information
lubeda authored May 1, 2024
2 parents 7a1648e + b7791d8 commit d6f6a4f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,12 @@ ehmtxv2:
advanced_bitmap: true
```
It is also possible to specify the required brightness when displaying a given Bitmap screen (MODE_BITMAP_SCREEN).
```
icon: [....]|screen_id# - Brightness 240 (Default)
icon: [....]|screen_id#200 - Brightness 200
```
### Select for Expand Icon to 9
```
Expand Down
10 changes: 10 additions & 0 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,16 @@ namespace esphome
}
}

#ifdef EHMTXv2_ADV_BITMAP
void EHMTX::set_brightness_silent(int value)
{
if (value < 256)
{
this->target_brightness_ = value;
}
}
#endif

uint8_t EHMTX::get_brightness()
{
return this->brightness_;
Expand Down
3 changes: 3 additions & 0 deletions components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ namespace esphome
void set_show_day_of_week(bool b=true);
void set_show_seconds(bool b=false);
void set_brightness(int b);
#ifdef EHMTXv2_ADV_BITMAP
void set_brightness_silent(int b);
#endif
void set_display_on();
void set_display_off();
void set_night_mode_off();
Expand Down
18 changes: 18 additions & 0 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,24 @@ namespace esphome
#ifdef EHMTXv2_ADV_BITMAP
if (this->bitmap != NULL)
{
std::size_t pos = icon_name.find("#");
if (pos != std::string::npos)
{
uint8_t bri;
std::string str_mode = icon_name.substr(pos + 1);
if (str_mode.length())
{
bri = static_cast<uint8_t>(std::stoi(str_mode));
}
else
{
bri = C_BLUE;
}
if (bri > this->config_->get_brightness())
{
this->config_->set_brightness_silent(bri);
}
}
#endif
for (uint8_t x = 0; x < 32; x++)
{
Expand Down

0 comments on commit d6f6a4f

Please sign in to comment.