pimoroni / pxt-inkybit

pxt-microbit package for the Pimoroni inky:bit - a three-colour e-ink display for your micro:bit.
MIT License
6 stars 8 forks source link

Clearing smaller areas #1

Closed microbit-giles closed 3 years ago

microbit-giles commented 3 years ago

Will it be possible to clear and/or update a rectangle? I made a temperature logger that updates the display every few minutes and noticed the digits get scrambled without clearing, so I wonder if it may be possible to clear only a portion of the display, or would it be best to draw a filled rectangle in the area of the digits?

helgibbons commented 3 years ago

I'm getting the same @Gadgetoid - it seems as if the display buffer might not be getting cleared properly on an inkybit.show()?

I couldn't figure out a way of clearing it in makecode - I tried adding inkybit.clear() into the Python code but that gets "can't find called function "inkybit.clear" and "module 'inkybit' has no attribute 'clear'"...

PXL_20201221_160259230

clairedean commented 3 years ago

Hi, I'm having the same problem. I'm trying to change the text with different inputs but it's just layering up on the screen and I can only clear it by pressing reset. Calling clear() in the javascript on MakeCode doesn't work and show() isn't clearing the screen.

Gadgetoid commented 3 years ago

Sorry for the delay getting back to you on this one. I've made a silly, silly oversight in not including clear and I'll get that fixed today.

Gadgetoid commented 3 years ago

I've added clear in #2 but I'm thinking that rectangle might be a little verbose for clearing update regions, even though this would normally be the canonical way to do it.

Something like clearRegion or clearRectangle that only accepts x/y and w/h would probably be handy for your purposes @microbit-giles

To clarify show() will not clear the buffer for you, you must call clear() (once this change is merged and published).

microbit-giles commented 3 years ago

Thank you - yes clearRegion or clearRectangle would be very nice features if it would offer a speed advantage or if an updateRegion were possible. If you still have to update the whole screen I guess you might as well clear the whole display and reshow?

Gadgetoid commented 3 years ago

Unfortunately there's no regional update support on these displays as far as I'm aware. Being able to clear a region wouldn't offer much other than some way of simplifying your code- IE: you can draw all the common stuff just once.

Gadgetoid commented 3 years ago

pxt bump'd to 0.0.2 with clear() and clearRectangle()

microbit-giles commented 3 years ago

you can draw all the common stuff just once.

Ah, yes, that's worth having - often you want to draw labels but only update numbers, so this is worthwhile.

microbit-giles commented 3 years ago

Clear rectangle working for me now: https://makecode.microbit.org/_KMfM1uE0u1qc IMG_1611

Gadgetoid commented 3 years ago

Whew! Awesome. Thank you.