framebuf.FrameBuffer lacks attr for width and height #17549
Unanswered
gvdl
asked this question in
Libraries & Drivers
Replies: 2 comments
-
Subclass with same name is probably the easiest way. #!/micropython
# -*- coding: UTF-8 -*-
# vim: fileencoding=utf-8: ts=4: sw=4: expandtab:
import framebuf
class FrameBuffer(framebuf.FrameBuffer):
def __init__(self, buffer, width, height, format, *args):
self.__w = width
self.__h = height
super().__init__(buffer, width, height, format, *args)
@property
def width(self):
return self.__w
@property
def height(self):
return self.__h
W,H = 16,8
buf = bytearray(W//8 * H)
fb = FrameBuffer(buf, W, H, framebuf.MONO_VLSB, W)
print(fb.width, fb.height) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also see pending pull request #17328 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've had a look at the underlying C code and it appears that width and height attributes are not implemented.
I'm thinking a class wrapper for FrameBuffer might let me locally cache these attributes before handing off to the C implementation. But python isn't really my first language and that sort of jiggery, pokery is beyond my present skills. Does anybody have any ideas?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions