Hi!
I’m trying to ungerstand this code. It’s work fine:
esphome:
name: test
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Test Fallback Hotspot"
password: !secret ap_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret api_password
ota:
password: !secret ota_password
# Time from Home Assistant
time:
- platform: homeassistant
id: homeassistant_time
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: D0
address: 0x3C
lambda: |-
// Displaying the clock with a blinking dot
static int i = 0;
i++;
if ((i % 2) == 0)
it.strftime(2, 0, id(sfdigital), "%H:%M", id(homeassistant_time).now());
else
it.strftime(2, 0, id(sfdigital), "%H %M", id(homeassistant_time).now());
// Displaying the day of the week
it.strftime(15, 25, id(sfdigital1), "%A", id(homeassistant_time).now());
// Date Display
it.strftime(10, 37, id(sfdigital1), "%d-%m-%Y", id(homeassistant_time).now());
font:
- file: "SFDigitalReadout.ttf"
id: sfdigital
size: 36
- file: "SFDigitalReadout.ttf"
id: sfdigital1
size: 15
I can’t understand the code with a blinking dot: why does “i++” happen exactly once a second? The display refresh interval is not spelled out anywhere in the code …