I used an SSD1306 OLED screen
I took the liberty of using your solution, my code looks as follows:
- id: page9
lambda: |-
// Print next four collection
char *strFam = strdup(id(cal_garbage).state.c_str());
char delim[] = "~";
char *nxtStrFam = strtok(strFam, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(4, 0, id(font3), TextAlign::TOP_LEFT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(128, 0, id(font3), TextAlign::TOP_RIGHT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(0, 17, id(font3), TextAlign::TOP_LEFT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(128, 17, id(font3), TextAlign::TOP_RIGHT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(0, 34, id(font3), TextAlign::TOP_LEFT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(128, 34, id(font3), TextAlign::TOP_RIGHT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(0, 63, id(font3), TextAlign::BASELINE_LEFT, "%s", nxtStrFam);
}
nxtStrFam = strtok(NULL, delim);
if (nxtStrFam != NULL && strlen(nxtStrFam) > 0) {
it.printf(128, 63, id(font3), TextAlign::BASELINE_RIGHT, "%s", nxtStrFam);
}
this is one of ten screens that shows/renders every 93 seconds.
Unfortunately, the problem I have with it is that this code overflows the RAM memory and the ESP32 restarts approximately every 3 hours and 20 minutes.
Does this code generate some variable that fills the RAM memory and should be removed during the next rendering cycle?
My configuration.yaml.:
- trigger:
- platform: time_pattern
# This will update every hour
hours: "/6"
sensor:
- name: Garbage Data
icon: mdi:calendar
state: "OK"
attributes:
cal_garbage: >-
{% set items = state_attr('sensor.garbage_scheduled_events', 'scheduled_events') | sort(attribute='start') %}
{%- for item in items -%}
{% set delta = (item.start) | as_datetime | as_local - today_at() %}
{%- if delta.days == 0 -%}
{% set start = "Dzisiaj " %}
{%- elif delta.days == 1 -%}
{% set start = "Jutro " %}
{%- elif delta.days == 2 -%}
{% set start = "Pojutrze " %}
{%- else -%}
{% set start = as_timestamp(item.start) | timestamp_custom('%d %b ', default=0) %}
{%- endif -%}
{{start + '~'}}
{{item.summary + '~' }}
{% endfor %}
Have you ever had a problem with RAM overflowing?