Skip to content

Instantly share code, notes, and snippets.

@dacoffey
Created Sep 20, 2022
Embed
What would you like to do?
ESPHOME: AdaFruit LED Backpack Integration: ht16k33
#include <Adafruit_LEDBackpack.h>
Adafruit_7segment LEDSEG;
esphome::time::ESPTime DTNOW;
char DTSTR[17];
time_t DT;
logger:
level: WARN
esphome:
name: test
platform: ESP32
board: esp32dev
includes: CLOCK.h
libraries:
- "SPI"
- "Wire"
- "Adafruit BusIO"
- "Adafruit GFX Library"
- "Adafruit LED Backpack Library"
on_boot:
then:
- lambda: !lambda |-
DTNOW = id(DTHA).now();
id(LEDSEGCOLON) = true;
LEDSEG = Adafruit_7segment();
LEDSEG.begin(0x70);
LEDSEG.setBrightness(15);
LEDSEG.blinkRate(HT16K33_BLINK_OFF);
globals:
- id: LEDSEGCOLON
type: bool
restore_value: no
<<: !include CONFIG_WIFI.yaml
time:
- platform: homeassistant
id: DTHA
i2c:
scl: 22
sda: 21
frequency: 50000
scan: true
sensor:
- platform: template
name: "T_DT"
update_interval: 100ms
lambda: |-
DTNOW = id(DTHA).now();
DT = DTNOW.timestamp;
strftime(DTSTR, sizeof(DTSTR), "%I%M", localtime(&DT));
return DT;
- platform: template
name: "T_LEDSEG"
update_interval: 750ms
lambda: |-
LEDSEG.print(strtoul(DTSTR,NULL,10));
LEDSEG.drawColon(id(LEDSEGCOLON) = !id(LEDSEGCOLON));
LEDSEG.writeDisplay();
return id(LEDSEGCOLON);
@dacoffey
Copy link
Author

dacoffey commented Sep 20, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment