pimoroni / badger2040

Examples and firmware for Badger 2040 and Badger 2040 W
MIT License
165 stars 52 forks source link

accessing the framebuffer? #58

Open air-eat opened 1 year ago

air-eat commented 1 year ago

i wanted to see if i can somehow get the framebuffer of the badger's display (mainly to create a function that inverts a small section of the display)

there is a set_framebuffer function that works with a bytearray, e.g.

import badger2040
display = badger2040.Badger2040()

fb = bytearray(4736) # (4736 = number of pixels on badger (296*128 = 37888) divided by 8)
display.set_framebuffer(fb) # fills the screen with black since the bytearray is full of 0x00s

display.update()

and picographics does seem to have a get_framebuffer function that is omitted from from the badger (was this deliberate?)

i feel like reading and modifying the framebuffer directly could have some uses, like creating interesting effects or being able to draw patterns faster (the example above is faster than setting the pen to 0 and clearing the screen, albeit by only 9 milliseconds)