-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for 1.3" ST7789 (240x240) colour LCD driver #80
Conversation
README.rst
Outdated
other functionality to support: | ||
Python library interfacing LCD displays with the PCD8544, ST7735, ST7789, | ||
ST7567, HT1621 and UC1701X driver using SPI on the Raspberry Pi and other | ||
linux-based single-board computers - it provides a Pillow-compatible drawing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capitalize Linux
I've been trying to use this branch to get a ST7789 device working. However, all I seem to get is :-
the python 2 version says :-
I know I'm doing something wrong, so any assistance would be much appreciated. |
Anything on a brach is definitely a work-in-progress I'm afraid. Unfortunately I've been greatly sidetracked by work (and moving house, and building an extension on the new house) this year so I've not been able spend anywhere near as much time as I would've liked on this project or my other GitHub projects. I'm not even sure where my collection of RPi's and small screens are .. they will be in a packing box somewhere... Hopelly come January or February I will be able to start picking things up again |
Co-authored-by: Richard Hull <rm_hull@yahoo.co.uk>
""" | ||
def __init__(self, serial_interface=None, rotate=0, **kwargs): | ||
super(st7789, self).__init__(luma.lcd.const.st7789, serial_interface, **kwargs) | ||
self.capabilities(240, 240, rotate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.capabilities(240, 240, rotate) | |
self.capabilities(240, 240, rotate, mode="RGB") |
self.set_window(0, 0, w, h) | ||
|
||
#packed_image = BitArray().join(BitArray(uint=x & 0x00111111, length=6) for x in image.tobytes()).tobytes() | ||
|
||
#self.data(image.tobytes()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.set_window(0, 0, w, h) | |
#packed_image = BitArray().join(BitArray(uint=x & 0x00111111, length=6) for x in image.tobytes()).tobytes() | |
#self.data(image.tobytes()) | |
self.set_window(0, 0, w, h) | |
image = self.preprocess(image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this code on Jetson Nano and I needed to add spi mode = 3 (look at this pr: rm-hull/luma.core#174 )
example initialization:
from luma.core.interface.serial import spi
from luma.lcd.device import st7789
import Jetson.GPIO as GPIO
GPIO.setmode(GPIO.TEGRA_SOC)
serial = spi(port=0, device=0, gpio=GPIO, gpio_DC='GPIO_PZ0', gpio_RST='GPIO_PE6', bus_speed_hz=16000000, spi_mode = 3)
device = st7789(serial, gpio=GPIO, gpio_LIGHT='LCD_BL_PW', rotate=3)
Please note you have to enable the spi port via dtb ( look at https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fhw_setup_jetson_io.html%23 )
Here one of the samples: https://youtu.be/f7amvsklIw0
We now have a range of boards - Pirate Audio - that use an ST7789 display and would benefit from this support. I'm similarly stacked at the moment, but I'd be happy to lend an extra pair of eyes for testing/feedback where I can. For Pirate Audio I'm running with:
Some observations: I usually run Pirate Audio boards are 80MHz (which probably clamps to the nearest available freq on the Pi) since it's a lot of pixels to push at any reasonable framerate. However it looks like Luma will only let me drive up to 32MHz. Might be worth adding support for 62 (62.5 MHz) and 125MHz. As an aside, since Luma uses runtime asserts the error generated for an "invalid" SPI frequency is a little opaque (The Pi will pick the nearest anyway, not sure about other platforms):
By default the width/height are A purly aesthetic observation is that the code is somewhat opaque- observe these lines: Lines 234 to 303 in 3eb8c40
Yes, this problem is systemic in Luma and my code isn't much better (https://github.com/pimoroni/st7789-python/blob/master/library/ST7789/__init__.py), but it might be handy to normalise using defines or comments to indicate what these commands are actually doing. Sorry, bit of a dump of random things. The code seems to work and successfully drive the ST7789. |
I have rebased this feature branch, implemented the changes kindly suggested by @AlessioMorale and raised a replacement for this PR at #109 |
ok, lets close this PR and focus on #109 |
Not ready for review yet
https://www.aliexpress.com/item/1-3-inch-IPS-HD-TFT-ST7789-Drive-IC-240-240-SPI-Communication-3-3V-Voltage/32880846744.html