1.8 inch SPI TFT ST7735 LCD Serial Port Display Module 128x160 pixels

Well, that was a mouthful, wasn't it.  I have been on a little bit of a mission to get a further / deeper understanding of how to use TFT / LCD screens (of all sizes) from a Raspberry Pi, more specifically from a PICO and currently just using MicroPython.  I shall dip into the world of C at a later stage once it makes a bit more sense.

The good news is, I had a few existing LCD screens knocking around, from what looks like back in 2013 - the bad news is after wasting about 30hours of my life, they are either just dead or they are proprietary and must have been made before standards were adopted.

Whilst I had purchased a waveshare 2.8" Pico-ResTouch-LCD-2.8 (320x240) that allowed you to connect a PICO directly to the back and it had an SD-Card reader onboard, again, it was a little bit locked down - basically I couldn't find any schematics and although I could make a guess at what PINs were doing what, it didn't seem to work for me - that could be down to a lot of factors, so I might come back to that again one-day.

However, I was inspired to purchase one of these for about £22 as it was a 3.5" TFT LCD that is SPI handles 480x320 and uses the ILI9488 interface driver.

At that point in time, I didn't know the difference between an ILI9488 and a ST7735 or ST7739 driver; however, I had found a fwe YouTube videos and a couple of good looking articles that seemed to be pretty clear / simple / easy to get going with.  It also has an SD-card reader on the back too.

Whilst I was adding it to my cart, I noticed this listed in the side-bar, for £7, how could I not just chuck one in - I'm sure it won't be of any use, but it matched the sizes of the one's I was trying earlier that didn't work, so who knows.


Delivery time.  I open both screens up and a noticed the 3.5" screen had a small black box/2-3pixels in size mark on the top of one side of the screen.  For some reason - it may have been due to the fact I still had the breadboard and wires out that I decided to "get the 1.8"" screen working....

As I say, I ended up learning more about ST7735 MicroPython drivers than I ever wanted to.

I'm no expert by any means, however, I reckon I could write my own driver by now!

As I have found, the naming of the Pins on the boards varies a lot and sometimes there is a little bit of guess work involved, it mostly boils down to figuring out what are the SCLK, MOSI, MISO (if it even exists), DC, CS and RESET (RST) Pins - most have a BLK (Backlight) but these are not software controlled and can just be plugged into the 3.3v Pin.

For this board, it had CS, RESET, DC, A0, CLK - okay, we're off to a reasonable start... bit of headscratching later and DC = SDA = MOSI and that means A0 = DC

Then it was a case of checking out the Pins on the PICO and what "could" go where.... incase you are wondering, they are NOT just random, there are sections around the PICO where you can add 4 SPI devices and they have grouped / related pins.

This is a great PIN layout webpage:



I did a lot of reading about SPI:

https://docs.micropython.org/en/latest/library/machine.SPI.html#machine-spi

https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi

The above articles REALLY helped when it came to figuring out what values to use when using the MicroPython to initialise the SPI Display driver - no more "bad SCLK" error messages for me!

(This also piqued my interest that I could have 4 of these screens connected to 1 x PICO... if that was ever required....)

I then hooked up the wires to the breadboard for the TFT LCD screen and got myself a library:


As you can see when calling the machine.SPI() we have to tell the code what the sck and mosi GPIO pins are.

Then when we create the driver itself we tell it what the Rest(rst), CE(CS) and DC GPIO pins are.

Those values seem to do the job:

Testing the SD-Card was a similar config, just telling the machine.SPI() what the GPIO pins were:



You'll note that the display screen had the value : SPI(0, xxxxx) and the sd-card had the value: SPI(1, xxxxx) - that is to indicate the 2 different SPI devices on the bus.  If you waste a minute or two scratching your head as to why your code isn't running, make sure you've not cut&paste'd anything that overwrites the "1" with a "0".. as that would be really stooopid of you, wouldn't it... don't know anyone who might have done that... cough cough....



and there we have it... both the TFT LCD screen is working as it should and the SD-Card can be written to (test.txt) okay and the contents read too.... those are a lit of the 100s of Atari 800 XL ROMs to use in the emulator ;-)

So...there you go, I wasn't setting out to get this screen up & running and working, but I did and it was a nice learning exercise and pretty painless and for £7...I will now just get one of these next time instead fo wasting hours and hours trying to get 10year old screens to work...oh well, you live & learn.


Right...now, where was I? what was I doing? what day of the week is it? where are my clothes? who am I?


-------------------------------------------------------------------------------

I then decided to setup the 3.5" screen using the different ILI9341 driver - now, getting the driver and setting it up was no problem, in fact following article like this one:

https://bytesnbits.co.uk/raspberry-pi-pico-spi-lcd-display/

and this YouTube video really helped:

Unfortunately, no matter what I did, I would just get a couple of shades of grey on the screen.  Therefore, it went back to Amazon Returns..... and I ordered another one!  Well, slightly different, this was £23 and it is a 320x240 sreen, but very similar:

I'll try out the same steps when that arrives and we'll see what happens - if it works, great, if not, then it must be something I am doing wrong...however, I doubt that.

Best driver to use: 

https://github.com/rdagger/micropython-ili9341

-------------------------------------------------------------------------------------------------------------

UPDATE:

As per this diagram from link above:


I wired up the newly received LCD screen (320x240) and lo-and-behold it worked first time:


I have bouncing balls. awesome.  I knew it wasn't me... it was duff/broken hardware.

-------------------------------------------------------------------------------------------------------------







Then....as it has the sd-card reader on the back too.... I might hook up a couple of extra pins for buttons and modify the iopins.h file and attempt to set this up using the PICO and this display:


From what I can see in the C code, it can be done, it's certainly feasible and logically it should work - I just need to find the right combination of configuration settings to get it working and then I can have a PICO emulating an old Atari 800 XL.  The Atari 800 XL had 64K RAM and the PICO has 256K RAM, so it should run okay!






Comments