Closed CrackXT closed 2 years ago
It looks like this library uses the DisplayIO implementation of the hardware. If I'm understanding correctly, the equivalent command for contrast()
in Adafruit_CircuitPython_SSD1306 here would be setting the object's brightness
:
For Adafruit_CircuitPython_SSD1306:
display.contrast(51) # 0 - 255, so this is 20%
For Adafruit_CircuitPython_DisplayIO_SSD1306:
dislpay.brightness = 0.2 # 0.0 - 1.0, so this is also 20%
Not sure if one should be renamed to match the other, but that seems to be the same functionality.
Updated to correct example values
Thank you for your feedback, I already had this idea. However, brightness is not defined in the library and so the line is only processed as an error.
Oh weird, I wonder if that's a bug or that functionality needs to be added, I don't really know the displayio module that well... The register for brightness is in the code at least so it's weird it doesn't use it:
Out of curiosity, what's the error text you get, and with what code? I'd love to try and fix this.
On Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Feather M4 Express with samd51j19
with OLED FeatherWing, it sort of works, but I only get 3 visually distinct levels of brightness:
import time
import board
import displayio
import adafruit_displayio_ssd1306
i2c = board.I2C()
displayio.release_displays()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
splash = displayio.Group()
background_bitmap = displayio.Bitmap(display.width, display.height, 1)
background_palette = displayio.Palette(1)
background_palette[0] = 0xFFFFFF
background = displayio.TileGrid(background_bitmap, pixel_shader=background_palette)
splash.append(background)
display.show(splash)
while True:
for contrast in (0, 1, 0.1):
display.brightness = contrast
time.sleep(1)
But I think implementing the proper contrast control to register 0x81 will give better performance. I don't get a CircuitPython exception.
I didn't dive deeply enough into the core to see what it actually does. I'm surprised it works at all if it's not using the contrast register.
It is using the 0x81 command. There is probably a problem with how the value is converted.
I suppose it's a safe assumption for now that any I2C display will support that register. Transfer this issue to circuitpython?
I'll add this to the core then, thanks everyone!
Please also integrate the command for "display.contrast ()" for brightness control in the library.
This is contained in the "Adafruit_CircuitPython_SSD1306", isn't it here?