Some background:
In MicroPython there is a class called Pin which controls I/O pins. In CircuitPython a similar class is called DigitalInOut. So for compatibility I wrote this simple class. Unfortunately, something goes wrong with my implementation. after calling:
drv_enn = PinC(board.D0, PinC.OUT)
drv_enn.on()
the pin doesn't go into 3.3V, but rather into 3.51V, which seem to be the uninitialized value. but this code does work, taking the pin into 3.3V:
drv_enn = DigitalInOut(board.D0)
drv_enn.direction = Direction.OUTPUT
drv_enn.value = True
so when I implemented a class without inheritance, it worked ok. My conclusion is that calling super().__init__(pin) did not work well. Did I do something wrong?
BTW I don't think that it is relevant, but my hardware is Seeed XIAO RP2040
my problematic implementation:
class PinC(DigitalInOut):
    OUT = Direction.OUTPUT
    def __init__(self, pin, mode=Direction.OUTPUT):
        super().__init__(pin)
        self.direction = mode
    def on(self):
        self.value = True
    def off(self):
        self.value = False
    def read(self):
        return self.value
This class works as expected - without inheritance:
class PinC:
    OUT = Direction.OUTPUT
    def __init__(self, pin, mode=Direction.OUTPUT):
        self.dio = DigitalInOut(pin)
        self.dio.direction = mode
    def on(self):
        self.dio.value = True
    def off(self):
        self.dio.value = False
    def read(self):
        return self.dio.value
I'd be glad to find out what is the root cause for this!
