Try to search your question here, if you can't find : Ask Any Question Now ?

Micropython inheritance fails

HomeCategory: stackoverflowMicropython inheritance fails
Avatarwillson asked 4 months ago

I’m trying to get connect a PyBoard (I’m not sure about the hardware version, but it’s running uPython 1.9.3) to a SSD1306 based LED display over I2C.

The physical connection works, and I can establish a I2C connection, see the device, and verify that it’s readable on the I2C connection.

However, I’m unable to use the ssd1306 module from the uPython Github. I can import the module fine but the SSD1306 class won’t initialize. The code which fails is this:

class SSD1306(framebuf.FrameBuffer):
    def __init__(self, width, height, external_vcc):
        self.width = width
        self.height = height
        self.external_vcc = external_vcc
        self.pages = self.height // 8
        self.buffer = bytearray(self.pages * self.width)
        super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB)

The error message is always

TypeError: function missing 1 required positional arguments

which seems to be spurious (i’ve definitely made sure to pass in the required width, height, and external_vcc. I’m pretty sure the problem is in the super() call — but its uPython, so print-debugging inside an initializer does not seem to work.

I’ve read in a couple of places that uPython tends to issue bad error messages about missing params when calling a closure, but this is only vaguely similar to that. I tried adding an explicit self to the super().__init__() call just in case, but that didn’t work either. So I’m a bit stuck and would welcome advice on the right next step for debugging.

1 Answers
Best Answer
AvatarMikhail answered 4 months ago
Your Answer

6 + 6 =

Popular Tags

WP Facebook Auto Publish Powered By :