Skip to content

Commit

Permalink
Merge pull request #159 from andrewjswan/2023.9.1-Vertical_scroll_of_…
Browse files Browse the repository at this point in the history
…screen

2023.9.1: Vertical scroll of screen
  • Loading branch information
lubeda authored Nov 20, 2023
2 parents e0ab970 + 251666c commit b9c32ef
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 67 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- `text_screen_progress(text, value, progress, lifetime, screen_time, default_font, value_color_as_progress, r, g, b)`
- Added `set_weekday_accent_on` and `set_weekday_accent_off` Turn on / off small days (accent) of the week when brightness is insufficient.
- Added `icon_prognosis_screen` and `icon_prognosis_screen_rgb` Displays an icon, text, and a prognosis bar consisting of 24 dots of specified colors. https://github.com/lubeda/EspHoMaTriXv2/issues/149
- Added `vertical_scroll` to ehmtxv2 config.

### EspHoMaTriX 2023.9.0
- Added the ability to display graph as defined in the YAML file
Expand Down Expand Up @@ -632,6 +633,7 @@ ehmtxv2:
  time_format: "%H:%M"
  date_format: "%d.%m."
  rtl: false # write vom left to right
vertical_scroll: false
  week_start_monday: true # false equals sunday
  scroll_count: 2 # scroll long text at least two times
  scroll_interval: 80 # milliseconds
Expand Down Expand Up @@ -662,6 +664,8 @@ ehmtxv2:

**rtl** (optional, boolean): if `true` write text (but only the scroll direction, the words and numbers aren't changed!) from right to left (Arabic, Hebrew etc.). Default is `false`

**vertical_scroll** (optional, boolean): If true, the screen change is vertical scrolling. Default is `false`

**matrix_component** (required, ID): ID of the addressable display

**show_dow** (optional, bool): draw the day of week rindicator on the bottom of the clock screen. Disable, e.g., if you want larger fonts, defaults to true.
Expand Down
70 changes: 62 additions & 8 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace esphome
this->set_weekday_color();
this->night_mode = false;
this->weekday_accent = false;
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
this->vertical_scroll = false;
#endif

for (uint8_t i = 0; i < MAXQUEUE; i++)
{
Expand Down Expand Up @@ -219,6 +222,10 @@ namespace esphome
screen->mode = MODE_BITMAP_SCREEN;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process("bitmap", (uint8_t)screen->mode);
Expand Down Expand Up @@ -1015,6 +1022,9 @@ namespace esphome
this->screen_pointer = this->find_last_clock();
this->scroll_step = 0;
this->ticks_ = 0;
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
this->vertical_scroll = false;
#endif

if (this->screen_pointer == MAXQUEUE)
{
Expand Down Expand Up @@ -1339,6 +1349,10 @@ namespace esphome
screen->progress = (progress > 100) ? 100 : (progress < -100) ? -100 : progress;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name, (uint8_t)screen->mode);
Expand Down Expand Up @@ -1418,6 +1432,10 @@ namespace esphome
screen->icon = icon;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name, (uint8_t)screen->mode);
Expand Down Expand Up @@ -1451,6 +1469,10 @@ namespace esphome
screen->icon = icon;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name, (uint8_t)screen->mode);
Expand Down Expand Up @@ -1508,6 +1530,10 @@ namespace esphome
{
screen->screen_time_ = EHMTXv2_CLOCK_INTERVALL * 1000.0 - 2000.0;
}
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
screen->status();
}
Expand All @@ -1521,6 +1547,10 @@ namespace esphome
screen->default_font = default_font;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
screen->status();
}

Expand Down Expand Up @@ -1582,6 +1612,10 @@ namespace esphome
screen->icon = 0;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process("Fire", (uint8_t)screen->mode);
Expand Down Expand Up @@ -1610,6 +1644,10 @@ namespace esphome
screen->icon_name = iconname;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
for (auto *t : on_add_screen_triggers_)
{
t->process(screen->icon_name, (uint8_t)screen->mode);
Expand All @@ -1627,6 +1665,10 @@ namespace esphome
screen->default_font = default_font;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
screen->status();
}

Expand All @@ -1641,6 +1683,10 @@ namespace esphome
screen->default_font = default_font;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif
screen->status();
}

Expand Down Expand Up @@ -1907,6 +1953,10 @@ namespace esphome
screen->icon = MAXICONS;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif

this->graph->set_height(8);
this->graph->set_width(32);
Expand Down Expand Up @@ -1940,6 +1990,10 @@ namespace esphome
screen->icon_name = iconname;
screen->screen_time_ = screen_time * 1000.0;
screen->endtime = this->get_tick() + (lifetime > 0 ? lifetime * 60000.0 : screen->screen_time_);
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
screen->scroll_reset = 32;
#endif

this->graph->set_height(8);
this->graph->set_width(24);
Expand All @@ -1962,7 +2016,7 @@ namespace esphome

#define max3(x,y,z) ( (x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z)) )

void EHMTX::draw_day_of_week(bool small)
void EHMTX::draw_day_of_week(int ypos, bool small)
{
if (this->show_day_of_week)
{
Expand All @@ -1982,33 +2036,33 @@ namespace esphome
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);
this->display->line(2 + i * 4, ypos + 7, i * 4 + 4, ypos + 7, this->today_color);
}
else
{
this->display->line(2 + i * 4, 7, i * 4 + 4, 7, this->weekday_color);
this->display->line(2 + i * 4, ypos + 7, i * 4 + 4, ypos + 7, this->weekday_color);
if (accent_color != esphome::display::COLOR_OFF)
{
this->display->line(i * 4 + 3, 7, i * 4 + 3, 7, accent_color);
this->display->line(i * 4 + 3, ypos + 7, i * 4 + 3, ypos + 7, accent_color);
}
}
}
}
}
else
{
for (uint8_t i = 0; i <= 6; i++)
{
if (((!EHMTXv2_WEEK_START) && (dow == i)) ||
((EHMTXv2_WEEK_START) && ((dow == (i + 1)) || ((dow == 0 && i == 6)))))
{
this->display->line(10 + i * 3, 7, 11 + i * 3 , 7, this->today_color);
this->display->line(10 + i * 3, ypos + 7, 11 + i * 3, ypos + 7, this->today_color);
}
else
{
this->display->line(10 + i * 3, 7, 11 + i * 3 , 7, this->weekday_color);
this->display->line(10 + i * 3, ypos + 7, 11 + i * 3, ypos + 7, this->weekday_color);
if (accent_color != esphome::display::COLOR_OFF)
{
this->display->line( (i < dow ? 11 : 10) + i * 3, 7, (i < dow ? 11 : 10) + i * 3 , 7, accent_color);
this->display->line( (i < dow ? 11 : 10) + i * 3, ypos + 7, (i < dow ? 11 : 10) + i * 3, ypos + 7, accent_color);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ namespace esphome
float next_action_time = 0.0; // when is the next screen change
uint32_t tick_next_action = 0; // when is the next screen change
uint32_t ticks_ = 0; // when is the next screen change
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
bool vertical_scroll = false;
#endif

void remove_expired_queue_element();
uint8_t find_oldest_queue_element();
Expand All @@ -163,7 +166,7 @@ namespace esphome
uint8_t find_icon(std::string name);
uint8_t find_last_clock();
bool string_has_ending(std::string const &fullString, std::string const &ending);
void draw_day_of_week(bool small=false);
void draw_day_of_week(int ypos = 0, bool small=false);
void show_all_icons();
float get_tick();
void tick();
Expand Down
Loading

0 comments on commit b9c32ef

Please sign in to comment.