Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: display
- friendly_name: Display
- comment: Testing st7735 color display
- esp32:
- board: esp32-c3-devkitm-1
- framework:
- type: arduino
- <<: !include common/comset.yaml
- captive_portal:
- time:
- - platform: homeassistant
- id: esptime
- sensor:
- - platform: homeassistant
- id: u_temp
- entity_id: sensor.ute_temperatur
- internal: true
- - platform: homeassistant
- id: i_temp
- entity_id: sensor.kontor_temperatur
- internal: true
- - platform: homeassistant
- id: baro
- entity_id: sensor.barometer
- internal: true
- binary_sensor:
- - platform: homeassistant
- id: g_door
- entity_id: binary_sensor.garage_door
- internal: true
- # Display stuff
- spi:
- clk_pin: 3
- mosi_pin: 4
- display:
- - platform: ili9xxx
- model: ST7735
- invert_colors: false
- reset_pin: 5
- cs_pin: 2
- dc_pin: 0
- rotation: 0
- color_order: bgr
- dimensions:
- height: 128
- width: 128
- offset_width: 2
- offset_height: 1
- update_interval: 1s
- lambda: |-
- // Klokke med sekunder - align center
- it.strftime(64, 16, id(my_font30), id(c_red), TextAlign::CENTER, "%H:%M:%S", id(esptime).now());
- // Dato - align center
- it.strftime(64, 40, id(my_font20), id(c_blue), TextAlign::CENTER, "%d-%m-%Y", id(esptime).now());
- // Ute temperatur - align left (normal) med 8 px buffer - vises kun om data er tilgjenglig
- if (id(u_temp).has_state()) {
- it.printf(8, 50, id(my_font20), id(c_green), "U: %.1f°", id(u_temp).state);
- }
- // Kontor temp ... align right med 8px buffer
- if (id(i_temp).has_state()) {
- it.printf(120, 50, id(my_font20), id(c_green), TextAlign::RIGHT, "I: %.1f°", id(i_temp).state);
- }
- it.printf(64, 75, id(my_font20), id(c_green), TextAlign::CENTER, "B: %.1f", id(baro).state); // Barometer
- // eksperiment: viser open/closed basert på binær sensor
- //if ( id(g_door).state ) { it.print( 0, 90, my_font20, id(c_red), "Open" ); }
- //else { it.print( 0, 90, my_font20, id(c_green), "Closed" ); };
- // samme som ovenfor bare med ikon i stedet
- if ( !id(g_door).state ) {
- //it.print( 98, 98, icons_50, id(c_green), "\U0000e714" );
- it.image(0, 88, id(i_garage), id(c_green));
- }
- else {
- //it.print( 98, 98, icons_50, id(c_red), "\U0000e714" );
- it.image(0, 88, id(i_garage_o) , id(c_red));
- }
- // MDI Testing
- //it.image(0, 88, id(c_green), id(i_garage));
- image:
- - file: mdi:garage
- id: i_garage
- resize: 40x40
- - file: mdi:garage-open
- id: i_garage_o
- resize: 40x40
- font:
- - file: "gfonts://Roboto"
- id: my_font20
- size: 16
- - file: "gfonts://Roboto"
- id: my_font30
- size: 31
- glyphs: [ 1,2,3,4,5,6,7,8,9,0,"\u003a", ]
- - file: "gfonts://Material+Symbols+Outlined"
- id: icons_50
- size: 30
- glyphs: ["\U0000e714"] # Garage door
- color:
- - id: c_red
- red: 100%
- green: 0%
- blue: 0%
- white: 0%
- - id: c_blue
- red: 0%
- green: 0%
- blue: 100%
- white: 0%
- - id: c_green
- red: 0%
- green: 100%
- blue: 0%
- white: 0%
Advertisement