2.4 TFT LCD No Display with Sample Code

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
yukunc_phoenix
 
Posts: 5
Joined: Wed Mar 01, 2023 2:16 pm

2.4 TFT LCD No Display with Sample Code

Post by yukunc_phoenix »

Hi, I followed every step in https://learn.adafruit.com/adafruit-2-8 ... -and-setup, and the sample codes ran without any error. I'm using Raspberry Pi Zero as a microcomputer to control it. The screen has a bright light when it gets powered (as the attached photo shows). And when I run the sample codes, it blinks once, but nothing is displayed. I didn't connect the Lite pin.
Attachments
Adafruit Screen.jpg
Adafruit Screen.jpg (83 KiB) Viewed 108 times

User avatar
adafruit_support_carter
 
Posts: 29159
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by adafruit_support_carter »

Which specific example code are you running?

User avatar
yukunc_phoenix
 
Posts: 5
Joined: Wed Mar 01, 2023 2:16 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by yukunc_phoenix »

https://learn.adafruit.com/adafruit-2-8 ... on-3042505

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
This will show some Linux Statistics on the attached display. Be sure to adjust
to the display you have connected. Be sure to check the learn guides for more
usage information.

This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!
"""

import time
import subprocess
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
from adafruit_rgb_display import ili9341
from adafruit_rgb_display import st7789  # pylint: disable=unused-import
from adafruit_rgb_display import hx8357  # pylint: disable=unused-import
from adafruit_rgb_display import st7735  # pylint: disable=unused-import
from adafruit_rgb_display import ssd1351  # pylint: disable=unused-import
from adafruit_rgb_display import ssd1331  # pylint: disable=unused-import

# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)

# Config for display baudrate (default max is 24mhz):
BAUDRATE = 24000000

# Setup SPI bus using hardware SPI:
spi = board.SPI()

# pylint: disable=line-too-long
# Create the display:
# disp = st7789.ST7789(spi, rotation=90,                            # 2.0" ST7789
# disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180,  # 1.3", 1.54" ST7789
# disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789
# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789
# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789
# disp = hx8357.HX8357(spi, rotation=180,                           # 3.5" HX8357
# disp = st7735.ST7735R(spi, rotation=90,                           # 1.8" ST7735R
# disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3,   # 1.44" ST7735R
# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80,       # 0.96" MiniTFT Rev A ST7735R
# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80,    # 0.96" MiniTFT Rev B ST7735R
# x_offset=26, y_offset=1,
# disp = ssd1351.SSD1351(spi, rotation=180,                         # 1.5" SSD1351
# disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351
# disp = ssd1331.SSD1331(spi, rotation=180,                         # 0.96" SSD1331
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE,
)
# pylint: enable=line-too-long

# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
if disp.rotation % 180 == 90:
    height = disp.width  # we swap height/width to rotate it to landscape!
    width = disp.height
else:
    width = disp.width  # we swap height/width to rotate it to landscape!
    height = disp.height

image = Image.new("RGB", (width, height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
disp.image(image)

# First define some constants to allow easy positioning of text.
padding = -2
x = 0

# Load a TTF font.  Make sure the .ttf font file is in the
# same directory as the python script!
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 24)

while True:
    # Draw a black filled box to clear the image.
    draw.rectangle((0, 0, width, height), outline=0, fill=0)

    # Shell scripts for system monitoring from here:
    # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
    cmd = "hostname -I | cut -d' ' -f1"
    IP = "IP: " + subprocess.check_output(cmd, shell=True).decode("utf-8")
    cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
    CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
    cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB  %.2f%%\", $3,$2,$3*100/$2 }'"
    MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
    cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB  %s", $3,$2,$5}\''
    Disk = subprocess.check_output(cmd, shell=True).decode("utf-8")
    cmd = "cat /sys/class/thermal/thermal_zone0/temp |  awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'"  # pylint: disable=line-too-long
    Temp = subprocess.check_output(cmd, shell=True).decode("utf-8")

    # Write four lines of text.
    y = padding
    draw.text((x, y), IP, font=font, fill="#FFFFFF")
    y += font.getsize(IP)[1]
    draw.text((x, y), CPU, font=font, fill="#FFFF00")
    y += font.getsize(CPU)[1]
    draw.text((x, y), MemUsage, font=font, fill="#00FF00")
    y += font.getsize(MemUsage)[1]
    draw.text((x, y), Disk, font=font, fill="#0000FF")
    y += font.getsize(Disk)[1]
    draw.text((x, y), Temp, font=font, fill="#FF00FF")

    # Display image.
    disp.image(image)
    time.sleep(0.1)
 
Last edited by adafruit_support_carter on Wed Mar 01, 2023 8:19 pm, edited 1 time in total.
Reason: added [code] tags

User avatar
adafruit_support_carter
 
Posts: 29159
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by adafruit_support_carter »

Are you seeing any error messages when running the code? Or it runs without errors, just nothing on TFT?

User avatar
yukunc_phoenix
 
Posts: 5
Joined: Wed Mar 01, 2023 2:16 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by yukunc_phoenix »

Without any error. The screen just blinked once then displays nothing only the backlight

User avatar
yukunc_phoenix
 
Posts: 5
Joined: Wed Mar 01, 2023 2:16 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by yukunc_phoenix »

Is Raspberry Pi Zero able to run this code? Which Raspberry Pi model do the tutorials linked below support?
I followed every step in the tutorials, copied the code to Raspberry Pi Zero, and used "python3 code.py" to run that code. I can tell the code runs without errors, but there is no display on the TFT.

https://learn.adafruit.com/adafruit-2-8 ... -and-setup
https://learn.adafruit.com/circuitpytho ... rypi-linux

User avatar
adafruit_support_carter
 
Posts: 29159
Joined: Tue Nov 29, 2016 2:45 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by adafruit_support_carter »

A Pi Zero should be fine.

FYI - There's a separate guide for the 2.4" TFT you have here:
https://learn.adafruit.com/adafruit-2-4 ... t/overview
(different than 2.8"/3.2" TFT guide)

And just remembered that the 2.4" TFT has jumpers that need to be set for SPI mode:
https://learn.adafruit.com/adafruit-2-4 ... iring-test

Has that been done?

User avatar
yukunc_phoenix
 
Posts: 5
Joined: Wed Mar 01, 2023 2:16 pm

Re: 2.4 TFT LCD No Display with Sample Code

Post by yukunc_phoenix »

Sorry for the late reply but I got it resolved. There was a wiring issue. Thank you for the support!

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”