feat: wordclock works!

This commit is contained in:
Philip Stark 2023-05-09 20:01:36 +02:00
parent 5b0930d616
commit 7f091409cf
8 changed files with 1405 additions and 12 deletions

154
image_test.yaml Normal file
View file

@ -0,0 +1,154 @@
esphome:
name: "display-thing"
esp8266:
board: d1_mini
framework:
version: recommended
external_components:
- source:
type: local
path: components
components: [ wordclock, addressable_light ]
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "${devicename}"
password: !secret ap_password
manual_ip:
static_ip: !secret manualip_static_ip
gateway: !secret manualip_gateway
subnet: !secret manualip_subnet
dns1: 1.1.1.1
dns2: 1.0.0.1
api:
# ota:
# password: "${devicename}"
logger:
# esp8266_store_log_strings_in_flash: false
web_server:
port: 80
light:
- name: NeoPixel Strip 1
id: neopixel_strip_1
platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO3
num_leds: 199
restore_mode: ALWAYS_ON
default_transition_length: 0s
color_correct: [100%, 100%, 100%]
method:
type: esp8266_dma
display:
- platform: addressable_light
id: led_matrix_display
addressable_light_id: neopixel_strip_1
width: 18
height: 11
rotation: 270°
update_interval: 16ms
auto_clear_enabled: false
pixel_mapper: |-
int mapping_even[] = {0, 2, 4, 6,8,10,11,13,15,17, 16,16,16,16, 16,16,16,16};
int mapping_odd[] = {17,15,13,11,9, 7, 6, 4, 2, 0, 16,16,16,16, 16,16,16,16};
if (x > 9) return -1;
if (y % 2 == 0) {
return (y * 18 + mapping_even[x]); // mapping_even[y];
} else {
return (y * 18 + mapping_odd[x]); // mapping_odd[y];
}
# lambda: |-
# it.fill(Color(0));
# it.image(0, 0, id(foo));
# //it.line(0,0,5,5, Color(0x00FF00));
# image:
# - id: foo
# file: ./test.png
# type: RGB24
# resize: 18x11
time:
- platform: sntp
id: current_time
timezone: !secret timezone
wordclock:
time_id: current_time
display_id: led_matrix_display
static_segments: ["IT", "IS"]
segments:
- {name: "IT", line: {x1: 0, x2: 1, y1: 0}}
- {name: "IS", line: {x1: 3, x2: 4, y1: 0}}
- {name: "AM", line: {x1: 7, x2: 8, y1: 0}}
- {name: "PM", line: {x1: 9, x2: 10, y1: 0}}
- {name: "QUARTER", line: {x1: 2, x2: 8, y1: 1}}
- {name: "TWENTY", line: {x1: 0, x2: 5, y1: 2}}
- {name: "FIVE_MINUTES", line: {x1: 6, x2: 9, y1: 2}}
- {name: "HALF", line: {x1: 0, x2: 3, y1: 3}}
- {name: "TEN_MINUTES", line: {x1: 5, x2: 7, y1: 3}}
- {name: "TO", line: {x1: 9, x2: 10, y1: 3}}
- {name: "PAST", line: {x1: 0, x2: 3, y1: 4}}
- {name: "NINE", line: {x1: 7, x2: 10, y1: 4}}
- {name: "ONE", line: {x1: 0, x2: 2, y1: 5}}
- {name: "SIX", line: {x1: 3, x2: 5, y1: 5}}
- {name: "THREE", line: {x1: 6, x2: 10, y1: 5}}
- {name: "FOUR", line: {x1: 0, x2: 3, y1: 6}}
- {name: "FIVE", line: {x1: 4, x2: 7, y1: 6}}
- {name: "TWO", line: {x1: 8, x2: 10, y1: 6}}
- {name: "EIGHT", line: {x1: 0, x2: 4, y1: 7}}
- {name: "ELEVEN", line: {x1: 5, x2: 10, y1: 7}}
- {name: "SEVEN", line: {x1: 0, x2: 4, y1: 8}}
- {name: "TWELVE", line: {x1: 5, x2: 10, y1: 8}}
- {name: "TEN", line: {x1: 0, x2: 2, y1: 9}}
- {name: "OCLOCK", line: {x1: 5, x2: 10, y1: 9}}
minutes:
- {minute: 0, segments: ["OCLOCK"]}
- {minute: 5, segments: ["FIVE_MINUTES", "PAST"]}
- {minute: 10, segments: ["TEN_MINUTES", "PAST"]}
- {minute: 15, segments: ["QUARTER", "PAST"]}
- {minute: 20, segments: ["TWENTY", "PAST"]}
- {minute: 25, segments: ["TWENTY", "FIVE_MINUTES", "PAST"]}
- {minute: 30, segments: ["HALF", "PAST"]}
- {minute: 35, segments: ["TWENTY", "FIVE_MINUTES", "TO"]}
- {minute: 40, segments: ["TWENTY", "TO"]}
- {minute: 45, segments: ["QUARTER", "TO"]}
- {minute: 50, segments: ["TEN_MINUTES", "TO"]}
- {minute: 55, segments: ["FIVE_MINUTES", "TO"]}
hours:
- {hour: 0, segments: ["TWELVE", "AM"]}
- {hour: 1, segments: ["ONE", "AM"]}
- {hour: 2, segments: ["TWO", "AM"]}
- {hour: 3, segments: ["THREE", "AM"]}
- {hour: 4, segments: ["FOUR", "AM"]}
- {hour: 5, segments: ["FIVE", "AM"]}
- {hour: 6, segments: ["SIX", "AM"]}
- {hour: 7, segments: ["SEVEN", "AM"]}
- {hour: 8, segments: ["EIGHT", "AM"]}
- {hour: 9, segments: ["NINE", "AM"]}
- {hour: 10, segments: ["TEN", "AM"]}
- {hour: 11, segments: ["ELEVEN", "AM"]}
- {hour: 12, segments: ["TWELVE", "PM"]}
- {hour: 13, segments: ["ONE", "PM"]}
- {hour: 14, segments: ["TWO", "PM"]}
- {hour: 15, segments: ["THREE", "PM"]}
- {hour: 16, segments: ["FOUR", "PM"]}
- {hour: 17, segments: ["FIVE", "PM"]}
- {hour: 18, segments: ["SIX", "PM"]}
- {hour: 19, segments: ["SEVEN", "PM"]}
- {hour: 20, segments: ["EIGHT", "PM"]}
- {hour: 21, segments: ["NINE", "PM"]}
- {hour: 22, segments: ["TEN", "PM"]}
- {hour: 23, segments: ["ELEVEN", "PM"]}