https://www.instructables.com/Lazy-Mini-Grid/
font 3x5: https://fontstruct.com/fontstructors/1441974/vyznev
Přepsal jsem pixel_mapper aby souřadnice odpovídaly ESPHome a šly použít fonty
Definice 103LED (fyzicky 90) a matice 17x6 (fyzicky 17x5 viditelných, resp.18x5) je schválně - jinak zůstanou svítit LED mezi 85-90.
Osobně to použiji asi jako hodiny, možná s nějakými warningy z HA.
Při použití ESP32 namísto 8266 zakomentovat řádek "method" u light:
Kód: Vybrat vše
time:
- platform: homeassistant
id: hatime
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO3
method: esp8266_dma
num_leds: 103
name: "NeoPixel Light"
id: led_matrix_17x5
default_transition_length:
milliseconds: 80
# color_correct: [100%, 100%, 100%]
color_correct: [50%, 50%, 50%]
restore_mode: ALWAYS_ON
binary_sensor:
- platform: gpio
pin:
number: D1
mode:
input: True
pullup: True
inverted: True
id: sw
on_click:
then:
- light.toggle: led_matrix_17x5
font:
# - file: "fonts/5x5.ttf"
# id: fnt5
# size: 5
# - file: "fonts/cg-pixel-4x5.ttf"
# id: fnt4
# size: 5
- file: "fonts/cg-pixel-3x5.ttf"
id: fnt3
size: 5
display:
- platform: addressable_light
id: led_matrix_17x5_display
addressable_light_id: led_matrix_17x5
width: 17
height: 6
# pixel_mapper: |-
# if (x % 2 == 0) {
# return (x / 2 + y * 18);
# }
# return (18 - x + x / 2 + y * 18);
pixel_mapper: |-
if (x % 2 == 0) {
return (2*y+1)*9-1-x/2;
}
return (2*y+1)*9+(x+1)/2;
rotation: 0°
update_interval: 160ms
lambda: |-
auto red = Color(255, 0, 0);
auto green = Color(0, 255, 0);
auto blue = Color(0, 0, 255);
auto white = Color(255, 255, 255);
auto orange = Color(255, 165, 0);
auto magenta = Color(255, 0, 255);
auto black = Color(0, 0, 0);
//it.strftime(0, 0, id(fnt3), red, TextAlign::TOP_LEFT, "%H:%M", id(hatime).now());
it.strftime(0, 0, id(fnt3), Color::random_color(), TextAlign::TOP_LEFT, "%H:%M", id(hatime).now());
//led_matrix_17x5
//it.filled_rectangle(0, 0, 17, 5, black);
//it.line(0, 0, 16, 0, red);
//it.line(0, 1, 16, 1, green);
//it.line(0, 2, 16, 2, blue);
//it.line(0, 3, 16, 3, orange);
//it.line(0, 4, 16, 4, magenta);
//it.rectangle(0,0,17,5,red);
//it.rectangle(1,1,16,4,green);
//it.rectangle(2,2,15,3,blue);
//it.rectangle(3,3,14,2,orange);
//it.rectangle(4,4,13,1,magenta);
//it.rectangle(0,0,17,5,red);
//it.rectangle(1,1,15,3,green);
//it.rectangle(2,2,13,1,blue);
//it.print(0, 0, id(fnt3), "2O:14");
/* it.draw_pixel_at(0,0,red);
it.draw_pixel_at(1,0,green);
it.draw_pixel_at(2,0,blue);
it.draw_pixel_at(0,1,red);
it.draw_pixel_at(1,1,green);
it.draw_pixel_at(2,1,blue); */