From 7bef6977771809259c263cbd0659117fe16a928c Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 7 Oct 2022 15:16:19 -0400 Subject: [PATCH] Fix compatibility with MicroPython --- adafruit_ssd1306.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/adafruit_ssd1306.py b/adafruit_ssd1306.py index f2b4d1d..8e0654a 100644 --- a/adafruit_ssd1306.py +++ b/adafruit_ssd1306.py @@ -17,10 +17,16 @@ from adafruit_bus_device import i2c_device, spi_device try: + # MicroPython framebuf import import framebuf + + _FRAMEBUF_FORMAT = framebuf.MONO_VLSB except ImportError: + # CircuitPython framebuf import import adafruit_framebuf as framebuf + _FRAMEBUF_FORMAT = framebuf.MVLSB + try: # Used only for typing from typing import Optional @@ -67,7 +73,7 @@ def __init__( reset: Optional[digitalio.DigitalInOut], page_addressing: bool ): - super().__init__(buffer, width, height) + super().__init__(buffer, width, height, _FRAMEBUF_FORMAT) self.width = width self.height = height self.external_vcc = external_vcc