Skip to content

Commit

Permalink
Merge pull request #65 from lubeda/develop
Browse files Browse the repository at this point in the history
Develop to main for release
  • Loading branch information
lubeda authored Jul 21, 2023
2 parents 781198d + ce349d2 commit 5f337a2
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 60 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
- file: tests/ehtmxv2-special.yaml
name: EHMTX template 8266
manifest_filename: ehtmxv2-special-template-manifest.json
devfirmware:
- file: tests/ulanzi-easy.yaml
name: Ulanzi-Easy
manifest_filename: ulanzi-easy-manifest.json
fail-fast: false
steps:
- name: Checkout source code
Expand All @@ -34,3 +38,9 @@ jobs:
with:
yaml_file: ${{ matrix.firmware.file }}
version: latest
# - name: Build firmware with beta
# uses: esphome/[email protected]
# id: esphome-build-beta
# with:
# yaml_file: ${{ matrix.firmware.file }}
# version: beta
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 2023.7.0

- added always_show_rl_indicators boolean
- added on_start_running trigger to allow for additional configuration when
matrix starts display
- icontype rgb565 array as string
- fixed scroll small text
- introduced mateine.ttf and mateineThin.ttf from @dbuezas [samples](https://github.com/lubeda/EspHoMaTriXv2/issues/63)
- fixed hold_screen [issue](https://github.com/lubeda/EspHoMaTriXv2/issues/58)

## 2023.6.5

- introduced `blend_steps: 16`
Expand Down
60 changes: 53 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# EspHoMaTriX version 2 (EHMTXv2)

## Warning
[donation-badge]:https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white
[donation-url]: https://www.paypal.com/donate/?hosted_button_id=FZDKSLQ46HJTU

Sorry but there this modules is highly dependend from the esphome releases. You can expect that some breaking changes in esphome breaks my code. So This version of EspHoMaTriX is working from esphome **2023.7.0** upwards (hopefully).
![Home Assistant](https://img.shields.io/badge/home%20assistant-%2341BDF5.svg?style=for-the-badge&logo=home-assistant&logoColor=white)
![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)
[![Donate][donation-badge]][donation-url]

## Attention

Some updates of esphome will interfere with EspHoMaTriXv2, like the update of esphome to 2023.7.0. It made a change to all YAML files neccessary.

You have to add this to your YAML

```yaml
image:
- file: 1pixel.gif
id: breaking20237

animation:
- file: 1pixel.gif
id: breaking20237
```
You have also to copy the file 1pixel.gif from the copy2esphome folder to the directory with your yaml.
Also there might be [breaking changes](#breaking-changes) due to a redesign of EspHoMaTriXv2.
## Important information
Expand Down Expand Up @@ -56,7 +79,7 @@ In easy mode you'll have a clock with auto brightness control and after step 3 y
Copy these files from the source folder `copy2esphome`:

- ulanzi-simple.yaml
- EHMTXv2.ttf
- mateine.ttf

to your esphome directory (usually /config/esphome). In your esphome dashboard, you will find a new device named `ulanzi-easy`.

Expand Down Expand Up @@ -426,11 +449,11 @@ You can configure two fonts if you like.

Trip5 is also providing special fonts for 8x32 matrices in his [repo](https://github.com/trip5/MatrixClockFonts)

For Europeans starters, you can use the font EHMTXv2.ttf of the copy2esphome folder.
dbuezas has also contributed tow optimized fonts with umlauts for this kind of display `mateine.ttf` and `mateineThin.ttf`. They are included in the copy2esphome folder

```yaml
font:
  - file: EHMTXv2.ttf
  - file: mateine.ttf
    id: default_font
    size: 16
    glyphs:  |
Expand Down Expand Up @@ -557,8 +580,18 @@ ehmtxv2:

**clock_interval** (optional, s): the interval in seconds to force the clock display. By default, the clock screen, if any, will be displayed according to the position in the queue. **If you set the clock_interval close to the screen_time of the clock, you will only see the clock!** (default=0)

**boot_logo** (optional, string , only on ESP32): Display a fullscreen 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]"
```

If defined you can use the services `display_boot_logo` and `display_version` to display the defined logo or the version of ehmtx.

**icons2html** (optional, boolean): If true, generate the HTML-file (*filename*.html) to show all included icons.  (default = `false`)

**always_show_rl_indicators** (optional, boolean): If true, always show the r/l indicators on all screens. Default is to not show either on clock, date, full, and bitmap screens, left on icon, or if display gauge displayed. (default = `false`)

***Example output:***
![icon preview](./images/icons_preview.png)

Expand Down Expand Up @@ -602,7 +635,6 @@ Numerous features are accessible with services from home assistant and lambdas t
|`show_gauge"`|"percent", "r", "g", "b"|set the height of the gauge according to the percentage in the given color|
|`show_alarm`|"r", "g", "b", "size"|shows the color with the given size in the upper-right corner|
|`show_rindicator`|"r", "g", "b", "size"|shows the color with the given size in the lower-right corner|
|`set_clock_color`|"r", "g", "b"|set the default color for the clock/date display|
|`set_today_color`|"r", "g", "b"|set the special color for today in the day of week line|
|`set_weekday_color`|"r", "g", "b"|set the default color in the day of week line|
|`del_screen`|"icon_name", “mode”|deletes the specified icon screen from the queue, the [mode](#modes) is a filter|
Expand Down Expand Up @@ -700,6 +732,10 @@ ehmtxv2:
            - mode
```

#### on_start_running

The trigger ```on_start_running``` is triggered when the display starts. It is triggered when time sync is done, and initial clock / date / version screens are loaded. This is to allow you to customize the default screens (for instance set colours for the clock).

#### on_icon_error

The trigger ```on_icon_error``` is triggered if you try to add a screen with a non defined icon. In lambda's you can use one local string variable:
Expand Down Expand Up @@ -822,6 +858,8 @@ For example, if you have multiple icons named weather_sunny, weather_rain & weat
|MODE_RAINBOW_TEXT|8|
|MODE_RAINBOW_CLOCK| 9|
|MODE_RAINBOW_DATE| 10|
|MODE_BITMAP_SCREEN| 11|
|MODE_BITMAP_SMALL| 12|

**(D)** Service **display_on** / **display_off**

Expand Down Expand Up @@ -866,7 +904,7 @@ binary_sensor:

Service **hold_screen**

Displays the current screen for a configured amount (see **hold_time**) (default=30) seconds longer.
Displays the current screen for a configured amount (default=30) seconds longer.

e.g., on the Ulanzi TC001

Expand Down Expand Up @@ -1074,6 +1112,11 @@ sensor:

## Breaking changes

### 2023.7.0

- removed automatic boot logo display
- removed set_clock_color since clock_screen and date_screen will set color anyway

### 2023.6.3

**Due to this change these values are fixed, e.g. you can not change the date or timeformat during runtime anymore!!**
Expand Down Expand Up @@ -1113,6 +1156,8 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk!
## Thanks

- **[blakadder](https://github.com/blakadder)** for his contribution (cleanup README.md, fixed sample)
- **[dbuezas](https://github.com/dbuezas)** for his fonts [infos](https://github.com/lubeda/EspHoMaTriXv2/issues/63)
- **[jfurtner](https://github.com/jfurtner)** for his the on_start_running trigger and a new parameter
- **[andrew-codechimp](https://github.com/andrew-codechimp)** for his contribution (display on/off & del_screen "*" & show_clock with 0) and improved blueprint slelection
- **[jd1](https://github.com/jd1)** for his contributions
- **[aptonline](https://github.com/aptonline)** for his work on the Ulanzi hardware
Expand All @@ -1123,6 +1168,7 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk!
- **[dennisse](https://github.com/dennisse)** Auto brightness for the Ulanzi
- **[hco](https://github.com/hco)** fixing documentation
- **[geekofweek](https://github.com/geekofweek)** fixed sample YAML, cleanup documentation
- **[joncar](https://github.com/joncar)** fixed scroll small text
- **Everybody** who found bugs/issues and reported them!

## Special thanks to all sponsors
71 changes: 48 additions & 23 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ namespace esphome
this->display_lindicator = 0;
this->display_alarm = 0;
this->clock_time = 10;
this->hold_time = 10;
this->icon_count = 0;
this->hue_ = 0;
this->text_color = Color(C_RED, C_GREEN, C_BLUE);
this->today_color = Color(C_RED, C_GREEN, C_BLUE);
this->weekday_color = Color(CD_RED, CD_GREEN, CD_BLUE);
this->clock_color = Color(C_RED, C_GREEN, C_BLUE);
this->rainbow_color = Color(CA_RED, CA_GREEN, CA_BLUE);
this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE);
this->next_action_time = 0;
Expand Down Expand Up @@ -96,12 +94,6 @@ namespace esphome
ESP_LOGD(TAG, "default weekday color: %d g: %d b: %d", r, g, b);
}

void EHMTX::set_clock_color(int r, int g, int b)
{
this->clock_color = Color((uint8_t)r & 248, (uint8_t)g & 252, (uint8_t)b & 248);
ESP_LOGD(TAG, "default clock color r: %d g: %d b: %d", r, g, b);
}

bool EHMTX::string_has_ending(std::string const &fullString, std::string const &ending)
{
if (fullString.length() >= ending.length())
Expand Down Expand Up @@ -329,7 +321,6 @@ namespace esphome
register_service(&EHMTX::show_rindicator, "show_rindicator", {"r", "g", "b", "size"});
register_service(&EHMTX::show_lindicator, "show_lindicator", {"r", "g", "b", "size"});

register_service(&EHMTX::set_clock_color, "set_clock_color", {"r", "g", "b"});
register_service(&EHMTX::set_today_color, "set_today_color", {"r", "g", "b"});
register_service(&EHMTX::set_weekday_color, "set_weekday_color", {"r", "g", "b"});

Expand All @@ -354,6 +345,10 @@ namespace esphome

register_service(&EHMTX::set_brightness, "brightness", {"value"});
#ifndef USE_ESP8266
#ifdef EHMTXv2_BOOTLOGO
register_service(&EHMTX::display_boot_logo, "display_boot_logo");
register_service(&EHMTX::display_version, "display_version");
#endif
register_service(&EHMTX::color_gauge, "color_gauge", {"colors"});
register_service(&EHMTX::bitmap_screen, "bitmap_screen", {"icon", "lifetime", "screen_time"});
register_service(&EHMTX::bitmap_small, "bitmap_small", {"icon", "text", "lifetime", "screen_time", "default_font", "r", "g", "b"});
Expand All @@ -376,6 +371,18 @@ namespace esphome
}
}

#ifndef USE_ESP8266
#ifdef EHMTXv2_BOOTLOGO
void EHMTX::display_boot_logo() {
this->bitmap_screen(EHMTXv2_BOOTLOGO, 1, 10);
}
void EHMTX::display_version() {
this->bitmap_small("[2016,0,0,0,2016,0,0,0,2016,0,0,0,2016,0,0,0,2016,0,0,0,2016,0,0,0,0,2016,0,2016,0,31,31,0,0,0,2016,0,31,0,0,31,0,0,0,0,0,0,31,0,0,0,0,0,0,31,0,0,0,0,0,0,31,31,31,31]", EHMTX_VERSION, 1, 10);
}

#endif
#endif

void EHMTX::hide_alarm()
{
this->display_alarm = 0;
Expand All @@ -398,12 +405,18 @@ namespace esphome
{
ESP_LOGD(TAG, "time sync => start running");
#ifndef USE_ESP8266
this->bitmap_screen(EHMTX_LOGO, 1, 10);
this->bitmap_small(EHMTX_SLOGO, EHMTX_VERSION, 1, 10);
#ifdef EHMTXv2_BOOTLOGO
this->bitmap_screen(EHMTXv2_BOOTLOGO, 1, 10);
#endif
#endif
this->clock_screen(14 * 24 * 60, this->clock_time, EHMTXv2_DEFAULT_CLOCK_FONT, C_RED, C_GREEN, C_BLUE);
this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, EHMTXv2_DEFAULT_CLOCK_FONT, C_RED, C_GREEN, C_BLUE);
this->is_running = true;
for (auto *t : on_start_running_triggers_)
{
ESP_LOGD(TAG, "on_start_running_triggers");
t->process();
}
}
}
else
Expand Down Expand Up @@ -545,7 +558,7 @@ namespace esphome
float red, green, blue;
esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue);
this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue));

if (this->is_running && this->clock->now().is_valid())
{
time_t ts = this->clock->now().timestamp;
Expand Down Expand Up @@ -608,16 +621,16 @@ namespace esphome
}
}
// blend handling

#ifdef EHMTXv2_BLEND_STEPS
if (this->ticks_ <= EHMTXv2_BLEND_STEPS)
if ((this->ticks_ <= EHMTXv2_BLEND_STEPS))
{
uint8_t b = this->brightness_;
float br = lerp((float)this->ticks_ / EHMTXv2_BLEND_STEPS, 0, (float)b / 255);
this->display->get_light()->set_correction(br, br, br);
uint8_t b = this->brightness_;
float br = lerp((float)this->ticks_ / EHMTXv2_BLEND_STEPS, 0, (float)b / 255);
this->display->get_light()->set_correction(br, br, br);
}
#endif
this->ticks_++;
this->ticks_++;
}
else
{
Expand All @@ -634,8 +647,7 @@ namespace esphome

void EHMTX::hold_screen(int time)
{
this->next_action_time += this->hold_time;
this->hold_time = time;
this->next_action_time = this->clock->now().timestamp + time;
}

void EHMTX::get_status()
Expand Down Expand Up @@ -877,7 +889,6 @@ namespace esphome
void EHMTX::clock_screen(int lifetime, int screen_time, bool default_font, int r, int g, int b)
{
EHMTX_queue *screen = this->find_free_queue_element();

screen->text_color = Color(r, g, b);
ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b);
screen->mode = MODE_CLOCK;
Expand Down Expand Up @@ -1046,6 +1057,9 @@ namespace esphome
}
#ifdef EHMTXv2_USE_RTL
ESP_LOGCONFIG(TAG, "RTL activated");
#endif
#ifdef EHMTXv2_BLEND_STEPS
ESP_LOGCONFIG(TAG, "Fade in activated: %d steps",EHMTXv2_BLEND_STEPS);
#endif
if (EHMTXv2_WEEK_START)
{
Expand Down Expand Up @@ -1128,19 +1142,30 @@ namespace esphome
{
this->draw_gauge();
}
if (this->queue[this->screen_pointer]->mode != MODE_CLOCK && this->queue[this->screen_pointer]->mode != MODE_DATE && this->queue[this->screen_pointer]->mode != MODE_FULL_SCREEN && this->queue[this->screen_pointer]->mode != MODE_BITMAP_SCREEN)
{
#ifndef EHMTXv2_ALWAYS_SHOW_RLINDICATORS
if (this->queue[this->screen_pointer]->mode != MODE_CLOCK && this->queue[this->screen_pointer]->mode != MODE_DATE && this->queue[this->screen_pointer]->mode != MODE_FULL_SCREEN && this->queue[this->screen_pointer]->mode != MODE_BITMAP_SCREEN)
{
#endif

this->draw_rindicator();
#ifndef EHMTXv2_ALWAYS_SHOW_RLINDICATORS
if (this->queue[this->screen_pointer]->mode != MODE_ICON_SCREEN && this->queue[this->screen_pointer]->mode != MODE_RAINBOW_ICON && !this->display_gauge)
{
#endif
this->draw_lindicator();
#ifndef EHMTXv2_ALWAYS_SHOW_RLINDICATORS
}
}
#endif
this->draw_alarm();
}
}

void EHMTXStartRunningTrigger::process()
{
this->trigger();
}

void EHMTXNextScreenTrigger::process(std::string iconname, std::string text)
{
this->trigger(iconname, text);
Expand Down
Loading

0 comments on commit 5f337a2

Please sign in to comment.