esp32_clock/esp32-clock-template.yaml

117 lines
2.9 KiB
YAML
Raw Normal View History

2024-01-12 22:49:50 +01:00
esphome:
name: esphome-clock
friendly_name: ESPHome Clock
esp32:
board: esp32dev
framework:
2024-01-28 02:08:08 +01:00
type: esp-idf
2024-01-12 22:49:50 +01:00
# 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-28 02:08:08 +01:00
format: "%02d:%02d:%02d.%02d"
2024-01-14 03:14:03 +01:00
args:
2024-01-14 17:32:25 +01:00
- 'uint32_t(id(runtime).state/3600) - uint32_t(id(runtime).state/86400)*1440'
- 'uint32_t(id(runtime).state/60) - uint32_t(id(runtime).state/3600)*60'
2024-01-14 05:50:07 +01:00
- 'uint32_t(id(runtime).state) - uint32_t(id(runtime).state/60)*60'
- 'uint32_t((id(runtime).state - uint32_t(id(runtime).state))*25)'
2024-01-12 22:49:50 +01:00
spi:
2024-01-28 02:08:08 +01:00
- id: quad_spi_bus
interface: spi3
clk_pin: 18
data_pins:
- 23
- 19
- 22
- 21
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:
2024-01-28 02:08:08 +01:00
- platform: qspi_74hc595_4x_display
2024-01-12 22:49:50 +01:00
cs_pin: GPIO5
data_rate: 10MHz
2024-01-23 22:40:01 +01:00
update_interval: 10ms
2024-01-28 02:08:08 +01:00
spi_id: quad_spi_bus
2024-01-12 22:49:50 +01:00
lambda: |-
2024-01-14 05:50:07 +01:00
static uint32_t clock_frames=0;
static uint32_t old_clock=0;
2024-01-12 22:49:50 +01:00
if(id(sntp_time).now().second!=old_clock){
clock_frames=0;
old_clock=id(sntp_time).now().second;
} else {
clock_frames++;
}
2024-01-23 22:40:01 +01:00
//it.printf(0, ".*`,_+'-");
//it.printf(0, "88888888");
2024-01-23 22:40:01 +01:00
it.strftime(0, "%H%M%S", id(sntp_time).now());
it.printf(6, "%02d", clock_frames%100);
2024-01-14 03:14:03 +01:00
2024-01-23 22:40:01 +01:00
//it.strftime(8, "%H%M%S", id(sntp_time).now());
2024-01-21 20:39:32 +01:00
//it.printf(14, "%2d", clock_frames);
2024-01-23 22:40:01 +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)*/
2024-01-21 20:39:32 +01:00
/*it.printf(16, "%02d%02d%02d%02d",
2024-01-14 17:32:25 +01:00
uint32_t(id(runtime).state/3600) - uint32_t(id(runtime).state/86400)*1440,
uint32_t(id(runtime).state/60) - uint32_t(id(runtime).state/3600)*60,
2024-01-14 05:50:07 +01:00
uint32_t(id(runtime).state) - uint32_t(id(runtime).state/60)*60,
uint32_t((id(runtime).state - uint32_t(id(runtime).state))*25) );
2024-01-21 20:39:32 +01:00
*/
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)
2024-01-20 02:24:56 +01:00
# digit 1: >*< character (A upper segment on)
# digit 2: >`< character (B upper right segment on)
# digit 3: >,< character (C lower right segment on)
# digit 4: >_< character (D lower segment on)
# digit 5: >+< character (E lower left segment on)
# digit 6: >'< character (F upper left segment on)
# digit 7: >-< character (G middle segment on)