2024-01-12 22:49:50 +01:00
|
|
|
esphome:
|
|
|
|
name: esphome-clock
|
|
|
|
friendly_name: ESPHome Clock
|
|
|
|
|
|
|
|
esp32:
|
|
|
|
board: esp32dev
|
|
|
|
framework:
|
|
|
|
type: arduino
|
|
|
|
|
|
|
|
# Enable logging
|
|
|
|
logger:
|
|
|
|
logs:
|
|
|
|
sensor: INFO
|
|
|
|
|
|
|
|
# Enable Home Assistant API
|
|
|
|
api:
|
2024-01-14 02:33:50 +01:00
|
|
|
reboot_timeout: 0s
|
2024-01-12 22:49:50 +01:00
|
|
|
encryption:
|
|
|
|
key: ""
|
|
|
|
|
|
|
|
ota:
|
|
|
|
|
|
|
|
|
|
|
|
wifi:
|
|
|
|
ssid: !secret wifi_ssid
|
|
|
|
password: !secret wifi_password
|
|
|
|
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
|
|
ap:
|
|
|
|
ssid: "ESP32Clock"
|
|
|
|
password: "fallBackPass"
|
|
|
|
|
|
|
|
captive_portal:
|
|
|
|
|
2024-01-14 01:55:46 +01:00
|
|
|
web_server:
|
|
|
|
local: true
|
|
|
|
|
2024-01-12 22:49:50 +01:00
|
|
|
external_components:
|
|
|
|
- source:
|
|
|
|
type: local
|
|
|
|
path: components
|
|
|
|
|
|
|
|
time:
|
|
|
|
- platform: sntp
|
|
|
|
id: sntp_time
|
|
|
|
timezone: Europe/Berlin
|
|
|
|
on_time:
|
2024-01-14 03:14:03 +01:00
|
|
|
- seconds: /10
|
2024-01-12 22:49:50 +01:00
|
|
|
then:
|
|
|
|
- logger.log:
|
|
|
|
level: INFO
|
2024-01-14 01:55:46 +01:00
|
|
|
format: "%2d %2d %2d %2d"
|
2024-01-14 03:14:03 +01:00
|
|
|
args:
|
|
|
|
- 'int(id(runtime).state/3600) - int(id(runtime).state/86400)*86400'
|
|
|
|
- 'int(id(runtime).state/60) - int(id(runtime).state/3600)*3600'
|
|
|
|
- 'int(id(runtime).state) - int(id(runtime).state/60)*60'
|
|
|
|
- 'int((id(runtime).state - int(id(runtime).state))*25)'
|
2024-01-12 22:49:50 +01:00
|
|
|
|
|
|
|
spi:
|
|
|
|
clk_pin: GPIO18
|
|
|
|
mosi_pin: GPIO19
|
2024-01-14 01:45:22 +01:00
|
|
|
|
2024-01-12 22:49:50 +01:00
|
|
|
sensor:
|
|
|
|
- platform: uptime
|
|
|
|
id: runtime
|
|
|
|
update_interval: 100ms
|
|
|
|
|
|
|
|
display:
|
|
|
|
- platform: spi_74hc595_display
|
|
|
|
cs_pin: GPIO5
|
|
|
|
data_rate: 5MHz
|
|
|
|
num_chips: 3
|
|
|
|
update_interval: 40ms
|
|
|
|
lambda: |-
|
|
|
|
static int clock_frames=0;
|
|
|
|
static int old_clock=0;
|
|
|
|
|
|
|
|
if(id(sntp_time).now().second!=old_clock){
|
|
|
|
clock_frames=0;
|
|
|
|
old_clock=id(sntp_time).now().second;
|
|
|
|
} else {
|
|
|
|
clock_frames++;
|
|
|
|
}
|
|
|
|
|
2024-01-14 03:14:03 +01:00
|
|
|
it.printf(0, ".*-_'`,0");
|
|
|
|
/*it.strftime(0, "%H%M%s", id(sntp_time).now());*/
|
|
|
|
/*it.printf(6, "%2d", clock_frames);*/
|
|
|
|
|
|
|
|
it.strftime(8, "%H%M%s", id(sntp_time).now());
|
|
|
|
it.printf(14, "%2d", clock_frames);
|
2024-01-12 22:49:50 +01:00
|
|
|
/*it.strftime(8, "%H%M%s", id(sntp_time).now());*/
|
2024-01-14 03:14:03 +01:00
|
|
|
/*it.printf(14, "%1d", 0)*/
|
|
|
|
|
|
|
|
it.printf(16, "%2d%2d%2d%2d",
|
|
|
|
int(id(runtime).state/3600) - int(id(runtime).state/86400)*86400,
|
|
|
|
int(id(runtime).state/60) - int(id(runtime).state/3600)*3600,
|
|
|
|
int(id(runtime).state) - int(id(runtime).state/60)*60,
|
|
|
|
int((id(runtime).state - int(id(runtime).state))*25) );
|
2024-01-12 22:49:50 +01:00
|
|
|
|
2024-01-14 03:14:03 +01:00
|
|
|
# the first display should display a test string to figure out the digit and segment map:
|
2024-01-14 01:45:22 +01:00
|
|
|
# digit 0: >.< character (dot segment on)
|
|
|
|
# digit 1: >*< character (upper segment on)
|
|
|
|
# digit 2: >-< character (middle segment on)
|
|
|
|
# digit 3: >_< character (lower segment on)
|
|
|
|
# digit 4: >'< character (upper left segment on)
|
|
|
|
# digit 5: >`< character (upper right segment on)
|
|
|
|
# digit 6: >,< character (lower right segment on)
|
|
|
|
# digit 7: >9< character (all on, except lower left segment)
|