Skip to content

Commit 7bef697

Browse files
committed
Fix compatibility with MicroPython
1 parent 82d48a8 commit 7bef697

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

adafruit_ssd1306.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
from adafruit_bus_device import i2c_device, spi_device
1818

1919
try:
20+
# MicroPython framebuf import
2021
import framebuf
22+
23+
_FRAMEBUF_FORMAT = framebuf.MONO_VLSB
2124
except ImportError:
25+
# CircuitPython framebuf import
2226
import adafruit_framebuf as framebuf
2327

28+
_FRAMEBUF_FORMAT = framebuf.MVLSB
29+
2430
try:
2531
# Used only for typing
2632
from typing import Optional
@@ -67,7 +73,7 @@ def __init__(
6773
reset: Optional[digitalio.DigitalInOut],
6874
page_addressing: bool
6975
):
70-
super().__init__(buffer, width, height)
76+
super().__init__(buffer, width, height, _FRAMEBUF_FORMAT)
7177
self.width = width
7278
self.height = height
7379
self.external_vcc = external_vcc

0 commit comments

Comments
 (0)