Skip to content

Commit

Permalink
cleanup and changed on empty queue behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeda committed May 1, 2024
1 parent d6f6a4f commit 5a546ac
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wiki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish wiki
on:
push:
branches:
- 2023.9.1
- 2024.5.0
- 2024.1.0-prerelease
paths:
- wiki/**
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2024.5.0
- changed on_empty_queue behavior (triggered every 15 sec after first occurance)

## 2024.1.0

- cleaned up docu
Expand Down
30 changes: 14 additions & 16 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace esphome
{
EHMTX::EHMTX() : PollingComponent(POLLINGINTERVAL)
{
ESP_LOGD(TAG, "Constructor start");
this->show_display = true;
this->display_gauge = false;
this->display_rindicator = 0;
Expand Down Expand Up @@ -71,7 +70,6 @@ namespace esphome
this->set_adv_clock_color();
#endif

ESP_LOGD(TAG, "Constructor finish");
}

void EHMTX::show_rindicator(int r, int g, int b, int size)
Expand Down Expand Up @@ -1023,7 +1021,7 @@ namespace esphome
}
else
{
ESP_LOGD(TAG, "oldest queue element not found");
// Queue is empty
}
this->queue[hit]->status();

Expand All @@ -1033,7 +1031,7 @@ namespace esphome
uint8_t EHMTX::find_last_clock()
{
uint8_t hit = MAXQUEUE;
if (EHMTXv2_CLOCK_INTERVALL > 0)
if (EHMTXv2_CLOCK_INTERVAL > 0)
{
float ts = this->get_tick();
for (size_t i = 0; i < MAXQUEUE; i++)
Expand All @@ -1056,7 +1054,7 @@ namespace esphome

if ((this->queue[i]->mode == MODE_CLOCK) || (this->queue[i]->mode == MODE_RAINBOW_CLOCK) || (this->queue[i]->mode == MODE_ICON_CLOCK))
{
if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVALL * 1000.0))
if (ts > (this->queue[i]->last_time + EHMTXv2_CLOCK_INTERVAL * 1000.0))
{
hit = i;
}
Expand All @@ -1076,7 +1074,7 @@ namespace esphome
if (this->clock->now().is_valid())
{
std::string infotext;
float ts = this->get_tick() + static_cast<float>(EHMTXv2_SCROLL_INTERVALL); // Force remove expired queue element
float ts = this->get_tick() + static_cast<float>(EHMTXv2_SCROLL_INTERVAL); // Force remove expired queue element

for (size_t i = 0; i < MAXQUEUE; i++)
{
Expand Down Expand Up @@ -1218,7 +1216,7 @@ namespace esphome

void EHMTX::tick()
{
if (millis() - this->last_rainbow_time >= EHMTXv2_RAINBOW_INTERVALL)
if (millis() - this->last_rainbow_time >= EHMTXv2_RAINBOW_INTERVAL)
{
this->hue_++;
this->rainbow_color = esphome::light::ESPHSVColor(this->hue_, 255, 240).to_rgb();
Expand All @@ -1229,7 +1227,7 @@ namespace esphome
{
float ts = this->get_tick();

if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVALL)
if (millis() - this->last_scroll_time >= EHMTXv2_SCROLL_INTERVAL)
{
this->scroll_step++;
this->last_scroll_time = millis();
Expand Down Expand Up @@ -1352,12 +1350,12 @@ namespace esphome
}
else
{
this->next_action_time = ts;
this->next_action_time = ts + 15000 ; // come back in 15 Seconds
for (auto *t : on_empty_queue_triggers_)
{
ESP_LOGD(TAG, "on_empty_queue trigger");
t->process();
}
ESP_LOGD(TAG, "on_empty_queue trigger");
t->process();
}
}
}

Expand Down Expand Up @@ -1941,13 +1939,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 (EHMTXv2_CLOCK_INTERVALL == 0 || (EHMTXv2_CLOCK_INTERVALL * 1000.0 > screen_time * 1000.0))
if (EHMTXv2_CLOCK_INTERVAL == 0 || (EHMTXv2_CLOCK_INTERVAL * 1000.0 > screen_time * 1000.0))
{
screen->screen_time_ = screen_time * 1000.0;
}
else
{
screen->screen_time_ = EHMTXv2_CLOCK_INTERVALL * 1000.0 - 2000.0;
screen->screen_time_ = EHMTXv2_CLOCK_INTERVAL * 1000.0 - 2000.0;
}
#ifdef EHMTXv2_USE_VERTICAL_SCROLL
screen->pixels_ = 0;
Expand Down Expand Up @@ -2817,10 +2815,10 @@ namespace esphome
{
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", EHMTXv2_CLOCK_INTERVALL);
ESP_LOGCONFIG(TAG, "Clock interval: %d s", EHMTXv2_CLOCK_INTERVAL);
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);
ESP_LOGCONFIG(TAG, "Interval (ms) scroll: %d", EHMTXv2_SCROLL_INTERVAL);
if (this->show_day_of_week)
{
ESP_LOGCONFIG(TAG, "Show day of week");
Expand Down
2 changes: 1 addition & 1 deletion components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const uint8_t TEXTSCROLLSTART = 8;
const uint8_t TEXTSTARTOFFSET = (32 - 8);

const uint16_t POLLINGINTERVAL = 250;
static const char *const EHMTX_VERSION = "2024.3.0";
static const char *const EHMTX_VERSION = "2024.5.0";
static const char *const TAG = "EHMTXv2";

enum show_mode : uint8_t
Expand Down
24 changes: 12 additions & 12 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace esphome
#endif

default:
ESP_LOGD(TAG, "queue: UPPS");
// Queue not initialized
break;
}
}
Expand Down Expand Up @@ -284,7 +284,7 @@ namespace esphome
{
uint8_t reverse_steps = round(((static_cast<float>(width) - 8 * static_cast<float>(this->icon)) / static_cast<float>(this->icon + 1)) + 8);

if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > reverse_steps)
if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > reverse_steps)
{
result = (item + 1 == this->icon) ? width - this->config_->scroll_step : -8 + this->config_->scroll_step;
if (item == 0 && (item_pos == 32767 || item_pos < target))
Expand Down Expand Up @@ -324,7 +324,7 @@ namespace esphome
{
uint8_t reverse_steps = round(((static_cast<float>(width) - 8 * static_cast<float>(this->icon)) / static_cast<float>(this->icon + 1)) * this->icon + 8 * (this->icon + 1)) + 8;

if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > reverse_steps)
if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > reverse_steps)
{
if (item_pos > target)
{
Expand Down Expand Up @@ -354,7 +354,7 @@ namespace esphome

uint8_t height = 8;

if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > height)
if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > height)
{
if (this->config_->vertical_scroll)
{
Expand All @@ -363,7 +363,7 @@ namespace esphome
this->config_->vertical_scroll = this->config_->scroll_step >= height;
return this->config_->scroll_step - height;
}
return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL);
return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL);
#else
return 0;
#endif
Expand All @@ -375,7 +375,7 @@ namespace esphome

if ((this->progress == 1) && (this->icon == 1 || (this->icon == 3 && item == 1)))
{
if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL) > height)
if (ceil((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL) > height)
{
if (this->default_font)
{
Expand All @@ -384,7 +384,7 @@ namespace esphome
this->default_font = this->config_->scroll_step >= height;
return this->config_->scroll_step - height;
}
return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVALL);
return height - round((this->config_->next_action_time - this->config_->get_tick()) / EHMTXv2_SCROLL_INTERVAL);
}

return 0;
Expand Down Expand Up @@ -1243,7 +1243,7 @@ namespace esphome
case MODE_RAINBOW_TEXT:
#ifdef EHMTXv2_SCROLL_SMALL_TEXT
max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_;
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVALL);
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVAL);
this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time;
#else
if (this->pixels_ < 32)
Expand All @@ -1253,7 +1253,7 @@ namespace esphome
else
{
max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_;
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVALL);
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVAL);
this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time;
}
#endif
Expand All @@ -1274,7 +1274,7 @@ namespace esphome
else
{
max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_;
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVALL);
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVAL);
this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time;
}
break;
Expand All @@ -1287,7 +1287,7 @@ namespace esphome
else
{
max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_;
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVALL);
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVAL);
this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time;
}
break;
Expand Down Expand Up @@ -1320,7 +1320,7 @@ namespace esphome
else
{
max_steps = EHMTXv2_SCROLL_COUNT * (width - startx) + EHMTXv2_SCROLL_COUNT * this->pixels_;
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVALL);
display_duration = static_cast<float>(max_steps * EHMTXv2_SCROLL_INTERVAL);
this->screen_time_ = (display_duration > requested_time) ? display_duration : requested_time;
}

Expand Down
9 changes: 4 additions & 5 deletions components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
SVG_END = "</svg>"

logging.warning(f"")
logging.warning(f"!!!! This version (2024.4.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 Expand Up @@ -566,10 +565,10 @@ def thumbnails(frames):
if config[CONF_REPLACE_TIME_DATE_FROM]:
logging.warning(f"replace_time_date_from: defined but no replace_time_date_to:! (not using replacements)\n\r")

cg.add_define("EHMTXv2_SCROLL_INTERVALL",config[CONF_SCROLLINTERVAL])
cg.add_define("EHMTXv2_RAINBOW_INTERVALL",config[CONF_RAINBOWINTERVAL])
cg.add_define("EHMTXv2_FRAME_INTERVALL",config[CONF_FRAMEINTERVAL])
cg.add_define("EHMTXv2_CLOCK_INTERVALL",config[CONF_CLOCKINTERVAL])
cg.add_define("EHMTXv2_SCROLL_INTERVAL",config[CONF_SCROLLINTERVAL])
cg.add_define("EHMTXv2_RAINBOW_INTERVAL",config[CONF_RAINBOWINTERVAL])
cg.add_define("EHMTXv2_FRAME_INTERVAL",config[CONF_FRAMEINTERVAL])
cg.add_define("EHMTXv2_CLOCK_INTERVAL",config[CONF_CLOCKINTERVAL])
cg.add_define("EHMTXv2_SCROLL_COUNT",config[CONF_SCROLLCOUNT])
cg.add_define("EHMTXv2_WEEK_START",config[CONF_WEEK_START_MONDAY])
cg.add_define("EHMTXv2_DEFAULT_FONT_OFFSET_X",config[CONF_DEFAULT_FONT_XOFFSET])
Expand Down
6 changes: 3 additions & 3 deletions install/ulanzi-easy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ external_components:
- source:
type: git
url: https://github.com/lubeda/EspHoMaTriXv2
ref: "2024.1.0"
ref: "2024.5.0"
refresh: 600s
components: [ ehmtxv2 ]

Expand All @@ -67,7 +67,7 @@ esphome:
name: $devicename
project:
name: "Ulanzi.EHMTXv2"
version: "2024.1.0"
version: "2024.5.0"
on_boot:
then:
- ds1307.read_time:
Expand Down Expand Up @@ -103,7 +103,7 @@ binary_sensor:
name: "Right button"

logger:
level: DEBUG
level: INFO

api:

Expand Down
2 changes: 1 addition & 1 deletion wiki/using-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To use graphs on your display you have to add a graph to your yaml, only this gr

```yaml
logger:
level: DEBUG
level: INFO
logs:
graph: error

Expand Down

0 comments on commit 5a546ac

Please sign in to comment.