regulate brightness (contrast) of ssd1306 display
Hi This is my time posting a question on github so hopefully I am doing this correctly.
First, I would like to thank all of the contributors in generating the Luma display package. I am a newbie to working with RPIs and based on the documentation I was able to get the code working wonderfully for my application.
Background: I am using a ssd1306 OLED 128 x 64 display running on a RPI 3B+ linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15;58 GMT 2020 armv7l GNU/Linux
Objective: Vary brightness (contrast) of 1.54" ssd1306 OLED display. Display is embedded in prototype chassis and is working appropriately so I would prefer to not have to change display. However I did not realize how bright these displays are, so now I would like to add code to vary brightness(contrast)
Problem: Running the simple program below over a range of contrast values ( 1-255) has no affect on display brightness. I have tested code on various other ssd1306 oled displays including i2c and spi versions from 3 other vendors and likewise see no change in brightness when changing Contrast value. However, changing contrast value on sh1106 oled display works fine (from dim to very bright).
Question: What am I doing wrong? Alternatively, is there additional code required for varying the contrast of ssd1306 driven displays? According to postings on forums where others have used ssd1306 displays (arduino code) and varied the brightness it is necessary to vary the pre charge time. Is this feasible using the luma oled code? If so, I would greatly appreciate your suggestions (for a relatively coding newbie) on how to implement.
Thanks
Simple test program:
from luma.core.interface .serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
serial =spi(device=0, port=0)
Contrast =10 #range 0-255
device.contrast(Contrast)
try:
while True:
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((30,10), "Hello World", fill= "white")''
finally:
device.cleanup()
setting contrast as you have done should work, if you try and run the https://github.com/rm-hull/luma.examples/blob/master/examples/demo.py that should regulate the brightness output - does that work for you?
It would be useful if you can provide a link to the OLED breakout board you are using also