pimoroni / inky

Combined library for V2/V3 Inky pHAT and Inky wHAT.
https://shop.pimoroni.com/?q=inky
MIT License
578 stars 121 forks source link

Optimizing clear and clean program for 7Color #134

Closed InsomniakD closed 1 year ago

InsomniakD commented 2 years ago

I made a picture frame with the 7 color inky screen and added thanks to the button a way to clean the screen but it was taking to much time so i create 3 pictures white red and black as it is shown in the example which make the cleaning way faster. Every 5 cycles because some time there is ghosts on the screen my program call the clear program but the color is strange (a kind of grey) and i can't use to find it in the code can anyone know which one it is because the for loop that replace pixels one after one is taking to long and i don't know if this grey is better for cleaning or not. Thanks in advance.

Gadgetoid commented 2 years ago

The "grey" you refer to is actually called "clear" or CLEAN in our library, and exists specifically for clearing the display.

A "P" format PIL image filled with colour 7 should, in theory, clear the screen to this grey. You can then create that image once and then set it every time you need to clear, rather than setting individual pixels. Something like:

clear = Image.new("P", (inky.width, inky.height), 7)

while True:
    # your code

    # when you need to clear:
    inky.set_image(clear)
    inky.show()