Raspberry Pi + SPI + ST7789Vi
Hello,
I have NHD-2.4-240320CF-BSXV-F - SPI interface, ST7789Vi controller, that I want to connect to Raspberry Pi.
But I fail to make it work - backlight is working, so I assume the whole screen is working, but nothing is painted on screen. I guess driver problem.
Does anybody has any experience with ST7789Vi ? Some source-code to share?
Thank you
Arturas
-
Hi Arturas,
Here is a link to some example code for the NHD-2.4-240320CF-BSXV-F that is written for the Arduino Uno.
https://github.com/NewhavenDisplay/NHD-2.4-240320CF-BSXV_Example
Here is the link to the ST7789Vi TFT controller IC for your reference:https://support.newhavendisplay.com/hc/en-us/articles/4414907838487-ST7789V
A quick internet search for "ST7789Vi driver library" will provide links to some resources that may be of interest to get you started.
Regards,0 -
Thank you!
0 -
Hello again,
I have implemented Arduino sample (https://github.com/NewhavenDisplay/NHD-2.4-240320CF-BSXV_Example) in Python. The display does not work. I attach this implementation in case somebody finds it interesting (hardcoded to 4-wire serial).
I have also found a controller for ST7789V (https://github.com/Zeroji/st7789v) - the display does not work with this one also.
I have the following PIN connections:Screen PIN Raspberry PIN 1 - GND PIN6 - ground 6, 7 - VDD, IOVDD PIN1 - +3.3V 8 - MOSI PIN19, GPIO10 - MOSI 9 - MISO <not connected> 10 - SCLK PIN23, GPIO11 - SCLK 11 - D/C PIN22, GPIO25 12 - CS PIN24, GPIO8 - CE0 13 - RES PIN13, GPIO27 14 - IM0 PIN6 - ground 15 - IM1 PIN1 - +3.3V 16-19 - LED-Kx PIN6 - ground 20 - LED-A PIN1 - +3.3V
Any ideas? Any comments?
Perhaps the display is broken? There is white background when powered, so at least power part is working for sure.Python code used for testing:
#!/usr/bin/python
# almost direct copy of https://www.newhavendisplay.com/resources_dataFiles/excode/txt/Arduino/NHD-2.4-240320CF-BSXV-F_Official.txt
# some python structures are sub-optimal - as I wanted to keep as much original Arduino code as possible
# IMs are hardcoded -> IM0 - PIN6 (ground); IM1 - PIN1 (+3.3V)
from gpiozero import DigitalOutputDevice
from time import sleep
class GPIO:
# GPIO numbers are here, not physical pins
MOSI = DigitalOutputDevice(10)
SCLK = DigitalOutputDevice(11)
DC = DigitalOutputDevice(25)
CS = DigitalOutputDevice(8)
RST = DigitalOutputDevice(27)
global pin
pin = GPIO()
def debug(F, msg):
ignore = ('real_send', 'data_out')
if F not in ignore:
print('%s> %s' % (F, msg))
def delay(time):
sleep(time / 1000.0)
def real_send(data):
global pin
debug('real_send', 'received %s to send' % data)
for i in range(8):
if ( (data & 0x80) == 0x80):
debug('real_send', 'sending 1')
pin.MOSI.on()
else:
debug('real_send', 'sending 0')
pin.MOSI.off()
data = data << 1
pin.SCLK.off()
pin.SCLK.on()
pin.SCLK.off()
debug('real_send', 'sent ok')
def comm_out(data):
global pin
debug('comm_out', 'received %s to send' % data)
pin.DC.off()
real_send(data)
def data_out(data):
global pin
debug('data_out', 'received %s to send' % data)
pin.DC.on()
real_send(data)
def all_red():
debug('all_red', 'starting')
comm_out(0x2C)
for i in range(38400):
data_out(0x00)
data_out(0x1F)
data_out(0x00)
data_out(0x1F)
debug('all_red', 'end')
def setup():
debug('setup', 'starting')
pin.CS.off()
pin.RST.off()
delay(250)
pin.RST.on()
delay(250)
comm_out(0x28); # display off
comm_out(0x11); # exit SLEEP mode
delay(100);
comm_out(0x36); # MADCTL: memory data access control
data_out(0x88);
comm_out(0x3A); # COLMOD: Interface Pixel format *** 65K-colors in 16bit/pixel (5-6-5) format when using 16-bit interface to allow 1-byte per pixel
data_out(0x55);
comm_out(0xB2); # PORCTRK: Porch setting
data_out(0x0C);
data_out(0x0C);
data_out(0x00);
data_out(0x33);
data_out(0x33);
comm_out(0xB7); # GCTRL: Gate Control
data_out(0x35);
comm_out(0xBB); # VCOMS: VCOM setting
data_out(0x2B);
comm_out(0xC0); # LCMCTRL: LCM Control
data_out(0x2C);
comm_out(0xC2); # VDVVRHEN: VDV and VRH Command Enable
data_out(0x01);
data_out(0xFF);
comm_out(0xC3); # VRHS: VRH Set
data_out(0x11);
comm_out(0xC4); # VDVS: VDV Set
data_out(0x20);
comm_out(0xC6); # FRCTRL2: Frame Rate control in normal mode
data_out(0x0F);
comm_out(0xD0); # PWCTRL1: Power Control 1
data_out(0xA4);
data_out(0xA1);
comm_out(0xE0); # PVGAMCTRL: Positive Voltage Gamma control
data_out(0xD0);
data_out(0x00);
data_out(0x05);
data_out(0x0E);
data_out(0x15);
data_out(0x0D);
data_out(0x37);
data_out(0x43);
data_out(0x47);
data_out(0x09);
data_out(0x15);
data_out(0x12);
data_out(0x16);
data_out(0x19);
comm_out(0xE1); # NVGAMCTRL: Negative Voltage Gamma control
data_out(0xD0);
data_out(0x00);
data_out(0x05);
data_out(0x0D);
data_out(0x0C);
data_out(0x06);
data_out(0x2D);
data_out(0x44);
data_out(0x40);
data_out(0x0E);
data_out(0x1C);
data_out(0x18);
data_out(0x16);
data_out(0x19);
comm_out(0x2A); # X address set
data_out(0x00);
data_out(0x00);
data_out(0x00);
data_out(0xEF);
comm_out(0x2B); # Y address set
data_out(0x00);
data_out(0x00);
data_out(0x01);
data_out(0x3F);
delay(10);
comm_out(0x29); # display ON
delay(10)
debug('setup', 'end')
print('start')
setup()
print('all red')
all_red()
sleep(3)
print('end')Thank you,
Arturas0 -
Did you ever solve this? I am in the same boat. The Waveshare SPI display works fine, but I'd like to use the NHD-2.4-240320AF-CSXP instead. I have tried the Waveshare driver and python code to replicate the NHD bit banging arduino code. Thanks!
0
Please sign in to leave a comment.
Comments
4 comments