rm-hull / luma.oled

Python module to drive a SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SH1106 OLED
https://luma-oled.readthedocs.io
MIT License
813 stars 164 forks source link

Incremental screen updates with Luma and SH1106? #386

Open zapta opened 11 months ago

zapta commented 11 months ago

Expected behaviour

If only a small area of the screen got changed, write only that area rather than the entire screen. E.g. find a writeable bounding box of the modified pixels and update just that portion onthe screen.

Actual behaviour

I wrote a small program that updates a numeric field on a SH1106 OLED and it works well (thanks). I did observed though that even ifI change only a small area of the screen, the entire screen is written on each update.

My question is, does Luma support incremental updates? And if not, please add it to your feature request list.

My drawing code:

i = 0
while True:
    with canvas(oled) as draw:
        print(f"Drawing {i}", flush=True)
        # draw.rectangle(oled.bounding_box, outline="white", fill="black")
        # draw.text((19, 15), f"Hello  I2C Adapter", fill="white")
        draw.text((47, 42), f"{i:05d}", fill="white")
    i += 1
    time.sleep(1.0)

Full program at https://github.com/zapta/i2c_adapter/blob/main/examples/oled_demo.py

zapta commented 11 months ago

... I found the discussion below but it deals with the rendering side rather than the screen update (i2c in that case). From my experience, the I2C communication is the bottleneck of the screen refresh process with SH1106 in I2C mode.

https://stackoverflow.com/questions/64189757/add-element-to-oled-display-via-pil-python-without-erasing-rest