Skip to content

Commit

Permalink
Merge pull request #33 from lubeda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lubeda authored Jun 7, 2023
2 parents b8bb7f1 + bf1f6bc commit 1699686
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 153 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Changelog

## 2023.6.3

- introduced `default_clock_font: true`
- changed *_interval to be set only on compile time
- change scroll_count to be set only on compile time
- change font_offsets to be set only on compile time
- change date/time_format to be set only on compile time
- remove unused frame_interval

## 2023.6.2

- set rtl mode at compile time
- changed clock to default font

## 2023.6.1

Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There are some “RGB-matrices” status displays/clocks out there, the commerci
- [LaMetric](https://lametric.com/en-US/) commercial ~ €199
- [Ulanzi TC001](https://www.aliexpress.com/item/1005005008682055.html) commercial ~ €50
- [AWTRIX](https://awtrixdocs.blueforcer.de/#/) (project has been discontinued after more than 4 years in August 2022)
- [Pixel It](https://docs.bastelbunker.de/pixelit/) (project is under active development)
- [Pixel It](https://pixelit-project.github.io/) (project is under active development)
- [AWTRIX-Light](https://github.com/Blueforcer/awtrix-light) From the developer of AWTRIX, optimized for the Ulanzi TC001 hardware

The solutions have their pros and cons. I tried some and used AWTRIX for a long time. But the cons are so big (in my opinion) that I started an esphome.io variant. Targeted to an optimized Home Assistant integration, without paid blueprints and the need of MQTT or uploading files to the ESP.
Expand All @@ -34,7 +34,7 @@ Based on a 8x32 RGB matrix, it displays a clock, the date and up to 24 other 'sc

### State

After the [old](https://github.com/lubeda/EsphoMaTrix) component became favorite, there were some feature requests, which indicated that my old code was a mess. I reworked the whole code and restructured it, so it is now hopefully more extensible.
After the [old](https://github.com/lubeda/EsphoMaTrix) component became favorite, there were some feature requests, which indicated that my old code was a mess. I reworked the whole code and restructured it, so it is now hopefully more extensible. **This software is still heavily in progress, before updating check the [breaking changes](#breaking-changes)**

### Advice

Expand Down Expand Up @@ -504,7 +504,6 @@ ehmtxv2:
  scroll_count: 2 # scroll long text at least two times
  scroll_interval: 80 # milliseconds
  rainbow_interval: 32 # milliseconds
  frame_interval: 192 # milliseconds
  icons:
  .....
```
Expand Down Expand Up @@ -543,9 +542,9 @@ ehmtxv2:

**week_start_monday** (optional, bool): default Monday is first day of week, false => Sunday

**scroll_interval** (optional, ms): the interval in ms to scroll the text (default=80), should be a multiple of the ```update_interval``` of the [display](https://esphome.io/components/display/addressable_light.html)
**default_clock_font** (optional, boolean): If true, use the default font for clock and date otherwise use the special font. (default = `true`)

**frame_interval** (optional, ms): the interval in ms to display the next animation/icon frame (default = 192), should be a multiple of the [display](https://esphome.io/components/display/addressable_light.html). It can be overwritten per icon/GIF, see [icons](#icons-and-animations) parameter `frame_duration`
**scroll_interval** (optional, ms): the interval in ms to scroll the text (default=80), should be a multiple of the ```update_interval``` of the [display](https://esphome.io/components/display/addressable_light.html)

**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)

Expand Down Expand Up @@ -1066,6 +1065,15 @@ sensor:

## Breaking changes

### 2023.6.3

**Due to this change these values are fixed, e.g. you can not change the date or timeformat during runtime anymore!!**

- changed *_interval to be set only on compile time
- change scroll_count to be set only on compile time
- change font_offsets to be set only on compile time
- change date/time_format to be set only on compile time

### 2023.5.0

- renamed `indicator` to `rindicator` because there is now also a `lindicator`
Expand Down Expand Up @@ -1101,9 +1109,10 @@ THE SOFTWARE IS PROVIDED “AS IS”, use at your own risk!
- **[aptonline](https://github.com/aptonline)** for his work on the Ulanzi hardware
- **[wsbtak](https://github.com/wsbtak)** for the work on the Ulanzi hardware
- **[ofirsnb](https://github.com/ofirsnb)** for his contributions
- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts and user support
- **[darkpoet78](https://github.com/darkpoet78/MatrixClockFonts)** for his work on optimized fonts and user support and work on the wiki
- **[pplucky](https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.GIF)** for his 8x32 GIF animation
- **[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
- **Everybody** who found bugs/issues and reported them!

Expand Down
106 changes: 16 additions & 90 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace esphome
this->display_lindicator = 0;
this->display_alarm = 0;
this->clock_time = 10;
this->clock_interval = 90;
this->hold_time = 10;
this->icon_count = 0;
this->hue_ = 0;
Expand All @@ -35,16 +34,6 @@ namespace esphome
ESP_LOGD(TAG, "Constructor finish");
}

void EHMTX::set_time_format(std::string s)
{
this->time_fmt = s;
}

void EHMTX::set_date_format(std::string s)
{
this->date_fmt = s;
}

void EHMTX::show_rindicator(int r, int g, int b, int size)
{
if (size > 0)
Expand Down Expand Up @@ -352,8 +341,8 @@ namespace esphome
this->bitmap_screen(EHMTX_LOGO, 1, 10);
this->bitmap_small(EHMTX_SLOGO, EHMTX_VERSION, 1, 10);
#endif
this->clock_screen(14 * 24 * 60, this->clock_time, true, C_RED, C_GREEN, C_BLUE);
this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, true, C_RED, C_GREEN, C_BLUE);
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;
}
}
Expand Down Expand Up @@ -409,14 +398,14 @@ namespace esphome
uint8_t EHMTX::find_last_clock()
{
uint8_t hit = MAXQUEUE;
if (this->clock_interval > 0)
if (EHMTXv2_CLOCK_INTERVALL > 0)
{
time_t ts = this->clock->now().timestamp;
for (size_t i = 0; i < MAXQUEUE; i++)
{
if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK))
{
if (ts > (this->queue[i]->last_time + this->clock_interval))
if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVALL))
{
hit = i;
}
Expand Down Expand Up @@ -501,7 +490,7 @@ namespace esphome
{
time_t ts = this->clock->now().timestamp;

if (millis() - this->last_scroll_time >= this->scroll_interval)
if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVALL)
{
this->scroll_step++;
this->last_scroll_time = millis();
Expand Down Expand Up @@ -582,8 +571,8 @@ namespace esphome
this->clock->now().month, this->clock->now().year,
this->clock->now().hour, this->clock->now().minute);
ESP_LOGI(TAG, "status brightness: %d (0..255)", this->brightness_);
ESP_LOGI(TAG, "status date format: %s", this->date_fmt.c_str());
ESP_LOGI(TAG, "status time format: %s", this->time_fmt.c_str());
ESP_LOGI(TAG, "status date format: %s", EHMTXv2_DATE_FORMAT);
ESP_LOGI(TAG, "status time format: %s", EHMTXv2_TIME_FORMAT);
ESP_LOGI(TAG, "status alarm_color: RGB(%d,%d,%d)", this->alarm_color.r, this->alarm_color.g, this->alarm_color.b);
if (this->show_display)
{
Expand Down Expand Up @@ -621,21 +610,6 @@ namespace esphome
this->special_font = font;
}

void EHMTX::set_frame_interval(uint16_t fi)
{
this->frame_interval = fi;
}

void EHMTX::set_scroll_interval(uint16_t si)
{
this->scroll_interval = si;
}

void EHMTX::set_rainbow_interval(uint16_t si)
{
this->rainbow_interval = si;
}

void EHMTX::del_screen(std::string icon_name, int mode)
{
for (uint8_t i = 0; i < MAXQUEUE; i++)
Expand Down Expand Up @@ -665,11 +639,6 @@ namespace esphome
}
}

void EHMTX::set_clock_interval(uint16_t t)
{
this->clock_interval = t;
}

void EHMTX::icon_screen(std::string iconname, std::string text, int lifetime, int screen_time, bool default_font, int r, int g, int b)
{
uint8_t icon = this->find_icon(iconname.c_str());
Expand Down Expand Up @@ -739,13 +708,13 @@ namespace esphome
ESP_LOGD(TAG, "rainbow_clock_screen lifetime: %d screen_time: %d", lifetime, screen_time);
screen->mode = MODE_RAINBOW_CLOCK;
screen->default_font = default_font;
if (this->clock_interval == 0 || (this->clock_interval > screen_time))
if (EHMTXv2_CLOCK_INTERVALL == 0 || (EHMTXv2_CLOCK_INTERVALL > screen_time))
{
screen->screen_time_ = screen_time;
}
else
{
screen->screen_time_ = this->clock_interval - 2;
screen->screen_time_ = EHMTXv2_CLOCK_INTERVALL - 2;
}
screen->endtime = this->clock->now().timestamp + lifetime * 60;
screen->status();
Expand Down Expand Up @@ -896,17 +865,6 @@ namespace esphome
}
}

#ifdef EHMTXv2_USE_RTL
void EHMTX::set_rtl(bool b)
{
this->rtl = b;
if (b)
{
ESP_LOGI(TAG, "show text right to left");
}
}
#endif

void EHMTX::set_show_seconds(bool b)
{
this->show_seconds = b;
Expand All @@ -933,19 +891,6 @@ namespace esphome
}
}

void EHMTX::set_week_start(bool b)
{
this->week_starts_monday = b;
if (b)
{
ESP_LOGI(TAG, "weekstart: monday");
}
else
{
ESP_LOGI(TAG, "weekstart: sunday");
}
}

void EHMTX::set_brightness(int value)
{
if (value < 256)
Expand All @@ -967,11 +912,6 @@ namespace esphome
this->clock_time = t;
}

void EHMTX::set_scroll_count(uint8_t c)
{
this->scroll_count = c;
}

void EHMTX::set_display(addressable_light::AddressableLightDisplay *disp)
{
this->display = disp;
Expand All @@ -992,8 +932,8 @@ namespace esphome
auto dow = this->clock->now().day_of_week - 1; // SUN = 0
for (uint8_t i = 0; i <= 6; i++)
{
if (((!this->week_starts_monday) && (dow == i)) ||
((this->week_starts_monday) && ((dow == (i + 1)) || ((dow == 0 && i == 6)))))
if (((!EHMTXv2_WEEK_START) && (dow == i)) ||
((EHMTXv2_WEEK_START) && ((dow == (i + 1)) || ((dow == 0 && i == 6)))))
{
this->display->line(2 + i * 4, 7, i * 4 + 4, 7, this->today_color);
}
Expand All @@ -1005,28 +945,14 @@ namespace esphome
}
};

void EHMTX::set_default_font_offset(int8_t y, int8_t x)
{
this->default_xoffset = x;
this->default_yoffset = y;
ESP_LOGD(TAG, "set_default_font_offset x: %d y: %d", x, y);
}

void EHMTX::set_special_font_offset(int8_t y, int8_t x)
{
this->special_xoffset = x;
this->special_yoffset = y;
ESP_LOGD(TAG, "set_special_font_offset x: %d y: %d", x, y);
}

void EHMTX::dump_config()
{
ESP_LOGCONFIG(TAG, "EspHoMatriXv2 version: %s", EHMTX_VERSION);
ESP_LOGCONFIG(TAG, "Icons: %d of %d", this->icon_count, MAXICONS);
ESP_LOGCONFIG(TAG, "Clock interval: %d s", this->clock_interval);
ESP_LOGCONFIG(TAG, "Date format: %s", this->date_fmt.c_str());
ESP_LOGCONFIG(TAG, "Time format: %s", this->time_fmt.c_str());
ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d frame: %d", this->scroll_interval, this->frame_interval);
ESP_LOGCONFIG(TAG, "Clock interval: %d s", EHMTXv2_CLOCK_INTERVALL);
ESP_LOGCONFIG(TAG, "Date format: %s", EHMTXv2_DATE_FORMAT);
ESP_LOGCONFIG(TAG, "Time format: %s", EHMTXv2_TIME_FORMAT);
ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d", EHMTXv2_SCROLL_INTERVALL);
if (this->show_day_of_week)
{
ESP_LOGCONFIG(TAG, "show day of week");
Expand All @@ -1038,7 +964,7 @@ namespace esphome
#ifdef EHMTXv2_USE_RTL
ESP_LOGCONFIG(TAG, "RTL activated");
#endif
if (this->week_starts_monday)
if (EHMTXv2_WEEK_START)
{
ESP_LOGCONFIG(TAG, "weekstart: monday");
}
Expand Down
Loading

0 comments on commit 1699686

Please sign in to comment.