sh1106 compatability
Closed this issue · 3 comments
pacmac commented
Hi Peter;
https://github.com/robert-hh/SH1106
Am trying to use the writer with the sh1106 but I get:
ValueError: Device must be derived from FrameBuffer.
But it looks like this is derived from framebuffer ??
import sh1106
>>> ssd = sh1106.SH1106_I2C(128, 64, gpio.i2c)
>>> dir(ssd)
['__class__', '__dict__', '__init__', '__module__', '__qualname__', 'addr', 'blit', 'buffer', 'fill', 'fill_rect', 'framebuf', 'hline', 'invert', 'line', 'pixel', 'rect', 'reset', 'scroll', 'sleep', 'text', 'vline', 'res', 'init_display', 'poweroff', 'poweron', 'contrast', 'show', 'width', 'height', 'external_vcc', 'pages', 'write_cmd', 'write_data', 'i2c', 'temp', 'rotate', 'hw_write_data', 'sw_write_data']
peterhinch commented
If you look at the driver code you'll see that the framebuf
results from composition rather than inheritance. I guess it was written before the facility to inherit from framebuf
was developed.
pacmac commented
I managed to successfully convert the driver to inheritance:
https://github.com/pacmac/micropython-share/blob/master/sh1106_i2c.py
peterhinch commented
I suggest you submit a PR: I'm sure Robert will appreciate it. Subclassing framebuf
offers the benefit of providing the framebuf
graphics primitives at zero cost.