adafruit / Adafruit_Blinka_Displayio

Displayio for Blinka
MIT License
14 stars 20 forks source link

Type inconcsistency in FourWire.send / _send #81

Closed yeahnope closed 2 years ago

yeahnope commented 2 years ago

As far as I can tell FourWires send method expects command to be an int:

    def send(
        self, command, data: _typing.ReadableBuffer, *, toggle_every_byte: bool = False
    ) -> None:
[...]
        if not 0 <= command <= 255:
            raise ValueError("Command must be an int between 0 and 255")

and it uses command to call _send:

        self._send(DISPLAY_COMMAND, chip_select, command)

however no int is expected there:

    def _send(self, data_type: int, chip_select: int, data: _typing.ReadableBuffer):

and at least in my tests, using the FourWire class did not work as I would have expected. For my usecase I found that patching the FourWire send method and replacing the _send call with

        self._send(DISPLAY_COMMAND, chip_select, bytes([command]))

worked. Is this a bug? Also as I came across while trying to use an e-ink display: It took me some time to find out that the EPaperDisplay class is not functional. Maybe you could replace the pass statements in not implemented methods with a raise NotImplementedError?

makermelissa commented 2 years ago

It could definitely be a bug. I had to wrap up a lot of that quickly. Also great idea on using the NotImpllementedError.