bitbank2 / SPI_LCD

A simple C library for directly communicating with SPI-connected LCD displays
GNU General Public License v3.0
112 stars 24 forks source link

HX8357C on Raspberry Pi #4

Closed Thermisto closed 6 years ago

Thermisto commented 6 years ago

I have this display: image image On the back of my display it also says HX8357C. Can the display be used on the Raspberry Pi Zero W with your library? How would you connect the pins to the Raspberry Pi? Where would I have to make modifications to the code to get it running?

Thank you for your help.

bitbank2 commented 6 years ago

I have a similar display that I just tossed in the trash. I couldn't find any documentation (and the screen came in the mail cracked anyway). I'm really not sure if it would work. It obviously has SPI, but it may only be used for the SD card slot (and missing flash memory chip). If the HX8357 is connected correctly on the SPI bus, then my code should work, but I don't see a DATA/COMMAND pin like should be present for SPI connected LCDs.

Thermisto commented 6 years ago

As the price was only $7,39, I could not resist and bought this dispay. I have some documentation: 3.2inch_Arduino_Mega2560_HX8357C_V3.0.zip I found out, that the LCD_RS pin is DATA/COMMAND, but I am not sure, whether SPI is enabled on the display. There are three pins (IM0,IM1,IM2) on the HX8357C which control the mode, see the docs. Unfortunately the pins are not accesible on the display. Here are the connections I made, but the screen stays white, when I run the demo: GPIO11 -> SPI_CLK GPIO8 -> LCD_CS GPIO10 -> SPI_MOSI GPIO24 -> LCD_RST GPIO23 -> LCD_RS I have changed line 78 in main.c like this: rc = spilcdInit(LCD, 0, 0, 46000000, 23, 24, 13); // LCD type, flip 180, SPI Channel, D/C, RST, LED and I use PIGPIO to access it. pi@raspberrypi:~ $ ls /dev/spi* /dev/spidev0.0 /dev/spidev0.1 If I have not made a mistake here, it is probably not configured for SPI mode.

bitbank2 commented 6 years ago

It looks like you're passing the wrong info to my init function. The numbers are header pin numbers, not GPIO numbers. This allows you to not worry about which access method you use because my code translates the pin numbers into the correct numbers for each method. For example, for GPIO24, I think you mean pin 18, so you should pass 18 to the init function for that pin.

Thermisto commented 6 years ago

Wow, I like that. Changed it like this: rc = spilcdInit(LCD, 0, 0, 16000000, 16, 18, 13); The pins I use are: 23 -> SPI_CLK 24 -> LCD_CS 19 -> SPI-MOSI 18 -> LCD_RST 16 -> LCD_RS The program runs, but the display stays white:

pi@raspberrypi:~/SPI_LCD $ sudo ./lcd Full screen updates max out at 9.23 FPS 2000 random rectangles in 1386 ms

I will try to get my hands on an Arduino Mega and see what it does with the UTFT library. It is too bad, that the connection mode can only be set with access to the pins IM0-2.

Thank you for your help.

Thermisto commented 6 years ago

I finally got the display working by using a SPI Interface curcuit from the fbtft wiki. With this interface I can use your code and it is running fine. I can only use it up to about 20 Mhz, but that is fine for my purposes.

sudo ./lcd Full screen updates max out at 11.01 FPS 2000 random rectangles in 1178 ms

I can also use the fbtft kernel driver now like this:

sudo modprobe fbtft_device name=ili9481 gpios=reset:24,dc:23 speed=16000000

I added this here so just in case someone has the same display can get a little help.

bitbank2 commented 6 years ago

great news! - thanks for letting (us) know your results.

boelle commented 5 years ago

i know this is a bit old, but i have the same display and i want to recycle it in a weather station display project. i dont need the sd card reader on the display

a few q's:

1) is there a connection diagram? 2) do i need any extra stuff?

EDIT: i'm ok with modding the display and connect it past the 3 chips on the back side if that helps anything

Thermisto commented 5 years ago

You have to build the Hardware Interface, see the Link above. You have to Connect all Pins of the display to the interface. The interface converts the parallel connection to SPI. Although I managed to get it running, I would Not recommend to use it on the RPi. It ist too much Work and for the price of the parts needed, you can almost get a new display, that has SPI on Board.

boelle commented 5 years ago

does the diaply not have SPI controller onboard that is just connected to the 3 chips on the back side of the board?

but its for a weather station project for my mominlaw and the display unit is made up of a mega and the display and a BME280 module, so now that i think of it it might be better if i just use a pi for the outside unit and transmit to the display

many ways to skin a cat :-D

Thermisto commented 5 years ago

If you have an arduino mega, you can simply plug it in the corresponding connector on the mega. 😃

boelle commented 5 years ago

that will also be the case :-D