dasfreak
Posts: 4
Joined: Sat May 07, 2016 11:03 am

Trying to get 128x128 TFT display working. Am I close? (Pi3)

Sun Sep 10, 2017 8:58 am

On a whim I purchased a cheap 128x138 TFT-LCD display from my local retailer. It's primarily for Arduino but I Googled the chip type and it seems it should work on a Pi

The display in question uses a ST7735 chipset and supports SPI. Info sheet here (https://www.techbrands.com/dbdocument/4 ... _24906.pdf - PDF) and data sheet on the chip is here (http://www.displayfuture.com/Display/da ... ST7735.pdf - PDF)

That sheet is actually wrong of course and the pin outs are as follows
VCC
GND
GND
NC
NC
LED
CLK
SDI
RS
RST
CS

From some Googling, it looked like the correct pins for the Pi are:

Code: Select all

VCC -> 5V
GND -> GND
LED -> 3.3V
CLK -> GPIO11 (SCLK)
SDI -> GPIO10 (MOSI)
RS -> GPIO 24
RST _> GPIO 25
CS -> GPIO8 (CE0)
I then inserted the fbtft_device module. I used the sainsmart18 driver as it uses the same chipset adjusting the the width/height

Code: Select all

sudo modprobe fbtft_device name=sainsmart18 gpios=reset:25,dc:24 width=128 height=128
I can see that /dev/fb1 is created.

Finally I used a sample pygame script to display the time

Code: Select all

import os
import sys
import time
import pygame

time_stamp_prev=0

os.environ["SDL_FBDEV"] = "/dev/fb1"
os.environ['SDL_VIDEODRIVER']="fbcon"

def displaytext(text,size,line,color,clearscreen):
    if clearscreen:
        screen.fill((0,0,0))

    font = pygame.font.Font(None,size)
    text = font.render(text,0,color)
    rotated = pygame.transform.rotate(text,90)
    textpos = rotated.get_rect()
    textpos.centery = 80
    if line == 1:
        textpos.centerx = 99
        screen.blit(rotated,textpos)
    elif line == 2:
        textpos.centerx = 61
        screen.blit(rotated,textpos)
    elif line == 3:
        textpos.centerx = 25
        screen.blit(rotated,textpos)

def main():
    global screen

    pygame.init()
    pygame.mouse.set_visible(0)
    size = width,height = 128,128
    screen = pygame.display.set_mode(size)

    while True:
        displaytext(time.strftime("%d.%m.%Y",time.gmtime()),40,1,(255,255,255),True)
        displaytext(time.strftime("%H:%M:%S",time.gmtime()),40,2,(255,255,255),False)
        pygame.display.flip()
        time.sleep(1)

if __name__ == '__main__':
    main()
Couple observations
  1. The screen comes on vivid white and stays that way
  2. If I remove the VCC pin so the LED power is running, I can see the screen flicker every 1 second as per the time.sleep() call so something is getting through
Not entirely sure where I've gone astray but any pointers would be very gratefully received.

drgeoff
Posts: 7443
Joined: Wed Jan 25, 2012 6:39 pm

Re: Trying to get 128x128 TFT display working. Am I close? (Pi3)

Sun Sep 10, 2017 3:22 pm

Do not use the 5 volt rail on the RPi GPIO header. RPi GPIO use 3.3 volt logic. Use the 3.3 volt pin to power the display module.

I don't say this will be enough to get the display working but it will reduce the chances of a dead RPi.

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: Trying to get 128x128 TFT display working. Am I close? (Pi3)

Sat Oct 07, 2017 2:36 am

Any further luck with this display on the Pi?

RexRoper
Posts: 64
Joined: Wed Oct 31, 2012 4:45 pm
Location: South Florida
Contact: Website

Re: Trying to get 128x128 TFT display working. Am I close? (Pi3)

Sun Oct 15, 2017 12:19 am

I recently ran across my 1.8" SPI - TFT that I purchased from Texy back he first sold these units. I was able to get mine working at that time, but I have lost my early Raspberry Pi images that contained my very first Raspberry Pi projects. I had the TFT display running on Wheezy. I am now trying to get the display working again on either a Jessie image or a Stretch image and have not been successful. I found useful instructions that seen like what I am looking for and listed them below, but I too only get a white screen on the TFT. Does anyone have step-by-step to get 1.8" SPI TFT display working on the newer Jessie or Stretch operating systems?

http://harizanov.com/2013/02/1-8-tft-lc ... pberry-pi/

http://harizanov.com/2013/08/raspberry- ... t-support/

Any assistance will be greatly appreciated.
Rex Roper

User avatar
ab1jx
Posts: 402
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Trying to get 128x128 TFT display working. Am I close? (Pi3)

Wed Oct 18, 2017 1:21 am

I'd look at SPI, there's a loadable kernel module spidev.ko that's a driver. It only needs 4 pins, SCLK and MOSI are 2 of them. I have an old PiTFT from Adafruit I've tried to get working and being useful. I'm not sure if spidev works through the GPU or not. Using the CPU to run it at a default frame rate uses up 17% CPU on a Zero, I'm trying to fight that. And mirroring the normal framebuffer to a tiny display is useless anyway. As a dedicated output device you can probably write to it when you have something to write and it'll stay on the screen.

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 10 guests