rm-hull / luma.lcd

Python module to drive PCD8544, HT1621, ST7735, ST7567 and UC1701X-based LCDs
https://luma-lcd.readthedocs.io
MIT License
156 stars 56 forks source link

Add width and height parameters to ST7789 device #155

Closed Frederic98 closed 2 years ago

Frederic98 commented 2 years ago

This pull request adds support for more ST7789 based screens with resolutions other than 240x240.

As in #142, passing the width and height to set_window() didn't directly work. This is because the arguments to the RASET and CASET commands are sent as command bytes. They should, however, be sent as data bytes. This also applies to all other commands with arguments, like those called to initialize the screen.
The reason that the screen went blank in #142 was because 320px translates to 0x01 0x3F, where the command 0x01 is mapped to software reset in the LCD driver.

To solve this, I add the command(self, cmd, *args) function in st7789 where it calls super.command(self, cmd) and self.data(args) to send the arguments as data bytes.

rm-hull commented 2 years ago

Lgtm. If the tests run ok and code coverage is about the same I will merge and make a release.

Thanks for taking the time to investigate and provide a fix. Could you add yourself to the contributors list too please?