Closed chertvl closed 10 months ago
Doesn't find the clock screen when the alert screen has been removed. https://github.com/lubeda/EspHoMaTriXv2/blob/2023.9.1/components/ehmtxv2/EHMTX.cpp#L798 The reason is:
this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_;
Showed the clock screen in 20:01:32:
[20:01:32][D][EHMTXv2:122]: queue: icon clock: "day#1" for: 10.0 sec
[20:01:32][D][EHMTXv2:1018]: on_next_screen trigger
this->queue[this->screen_pointer]->last_time = 20:01:42; Showed an alert screen and deleted it in 20:01:38:
[20:01:38][D][EHMTXv2:851]: remove expired queue element: slot 1: mode: 16 icon_name: spotify text: Song name - Artist name
And we didn’t find the clock screen because the condition is not met:
if ((this->queue[i]->endtime > this->get_tick()) && (this->queue[i]->last_time < last_time))
Ie:
There are constant skipping cycles until the above condition is met (in 20:01:42), and then we start showing the screens:
[20:01:42][D][EHMTXv2:790]: oldest queue element is: 0/1
[20:01:42][D][EHMTXv2:122]: queue: icon clock: "day#1" for: 10.0 sec
[20:01:42][D][EHMTXv2:1018]: on_next_screen trigger
I propose a solution: If we haven’t found any old screens, but our queue is not empty, return the first one from the queue to display. https://github.com/lubeda/EspHoMaTriXv2/blob/2023.9.1/components/ehmtxv2/EHMTX.cpp#L804-L807 Change to:
uint8_t queue_count = this->queue_count();
if (hit != MAXQUEUE)
{
ESP_LOGD(TAG, "oldest queue element is: %d/%d", hit, queue_count);
}
else if (queue_count > 0)
{
hit = 0;
ESP_LOGD(TAG, "oldest queue element is first: %d/%d", hit, queue_count);
}
Or the solution is even simpler, we simply indicate the fact that the screen is displayed. https://github.com/lubeda/EspHoMaTriXv2/blob/2023.9.1/components/ehmtxv2/EHMTX.cpp#L1006 Change to:
this->queue[this->screen_pointer]->last_time = ts;
I have transferred the https://github.com/lubeda/EspHoMaTriXv2/pull/153 to a draft for now, if the https://github.com/lubeda/EspHoMaTriXv2/pull/154 does not help or produces unwanted artifacts, then we will try it.
@chertvl Can you check: first: https://github.com/andrewjswan/EspHoMaTriXv2/tree/2023.9.1-152-last_time_-_actual_time if not help, then: https://github.com/andrewjswan/EspHoMaTriXv2/tree/2023.9.1-152-find_oldest_queue_element_fix
2023.9.1-152-lasttime-_actual_time 2023.9.1-152-find_oldest_queue_element_fix
Both looks good! I cant catch log issues anymore. Thanks! Which one is better and optimal? ;P
@lubeda Both changes work equally well, whichever one you like better and whichever one fits more into the concept, that PR and merge, the second one will be closed then.
PS: Read below
Although you can infuse these two changes, it will certainly not be worse, and reliability will add ....
Bug report
Describe the bug
For example, I have only one clock screen with lifetime 1440, screentime 10. I called Alert Screen service with some parameters. After Alert is showed it must auto-deleted from queue, and after auto-delete screen I have very huge log storm with strange symbols for 3-4 seconds (many times per second). Somewhy my clock screen dissapears from queue and its empty now, on_empty_queue is trying to add a clock screen again but cant do it few seconds.
On Ulanzi display I see last frame of screen wich must be deleted, it freeze for 1-2 sec, then screen and logs both back to normal.
Additional information
Configuration
Logs