I’m using a SSD1306 128x64 OLED to show temperature data, like so:
display:
- platform: ssd1306_i2c
id: my_oled
update_interval: .5s
contrast: 0.0
brightness: 0.0
model: "SSD1306 128x64"
rotation: 0
address: 0x3C
lambda: |-
if (id(fire).state) {id(ani_fire).next_frame(); it.image(0, 0, id(ani_fire));}
else {it.image(0, 0, id(home_thermometer));}
it.printf(64, 4, id(font2), TextAlign::TOP_CENTER, " %.1f°", id(bedroom_temperature).state * (9.0/5.0) + 32.0);
it.printf(0, 64, id(font3), TextAlign::BASELINE_LEFT, " Set to: %.1f°", id(bedroom_thermostat).target_temperature_low * (9.0/5.0) + 32);
I want the display to remain dark until I press a button, then go out again after a delay. But, even though I have brightness and contrast set to zero, the display is lit. How can I make it stay dark until a switch event?
nickrout
(Nick Rout)
August 6, 2022, 9:36pm
2
Again, docs say
brightness (Optional , percentage): Set display brightness in %. Only can be used with SSD1305. Defaults to 100%
.
You don’t have a ssd1305.
1 Like
I know; thought I’d try it anyway. Take the brightness line out and leave in contrast: 0.0 and the display remains on.
nickrout
(Nick Rout)
August 6, 2022, 10:04pm
4
I’ve never tried to make the display blank, but have you tried to print blanks or empty strings?
EKorneev
(Eugene Korneev)
August 7, 2022, 10:37pm
5
i use (for off)
- lambda: id(my_screen).set_contrast(0.0);
- lambda: id(my_screen).turn_off();
and (for on)
- lambda: id(my_screen).turn_on();
- lambda: id(my_screen).set_contrast(1.0);
2 Likes
Thanks; I’m a little unclear on using the lambda. Could you give an example of a switch that would turn off the oled screen?
EKorneev
(Eugene Korneev)
August 11, 2022, 4:55pm
7
# Example configuration entry
switch:
- platform: template
name: "Template Switch"
lambda: |-
if (......) {
return true;
} else {
return false;
}
turn_on_action:
- lambda: .....
turn_off_action:
- lambda: .....