joukos / PaperTTY

PaperTTY - Python module to render a TTY or VNC on e-ink
942 stars 101 forks source link

vcom command line argument for IT8951 #108

Closed mcarr823 closed 10 months ago

mcarr823 commented 11 months ago

This PR adds a new command line argument, --vcom, to allow people to adjust the VCOM value of the IT8951 driver without manually editing the code.

VCOM is currently hard-coded to -2.0V. However, ideally it should be set to the value found on the panel's tag. The reason for this is explained in the waveshare wiki: https://www.waveshare.com/wiki/7.8inch_e-Paper_HAT#Use_Correct_VCOM_Value

Unfortunately, this value may differ from panel to panel, even if two panels are exactly the same model. eg. https://www.waveshare.com/wiki/7.8inch_e-Paper_HAT#/media/File:6inch-HD-e-Paper-HAT-Manual-06.png From waveshare's wiki, those are two of the same 6" panel, both with different VCOM values (-1.5V, -1.78V) so we can't infer the value from the model name. So while a command line argument isn't ideal, it seems better than needing to manually edit the driver file.

joukos commented 10 months ago

Thanks :+1:

mcarr823 commented 10 months ago

@joukos It's a bit late for this PR, but I've just tested it again after the suggested changes and found a problem (not caused by them).

self.VCOM = kwargs.get('vcom', self.VCOM)

The problem is that self.vcom in papertty.py is initialized as None by default, so it gets passed through as None to the above command if it isn't specified. This could be prevented by making the default value in papertty.py 2000, but then we'd have the default value specified in both the driver and in papertty. I'd suggest instead changing the above line to:

    vcom = kwargs.get('vcom', None)
    if vcom:
        self.VCOM = vcom

which I've just tested both with and without --vcom being specified.