BBB Python3 ST7735r issue

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
BobNJ
 
Posts: 4
Joined: Wed Jul 27, 2022 2:45 pm

BBB Python3 ST7735r issue

Post by BobNJ »

I've been trying to get the Adafruit 358 module working over SPI on Beaglebone Black.
I know the display itself is good because it works with a Duo.
I've checked the wiring multiple times and it's good.
It seems like the issue is with the initialization library itself.
The script runs, I can clock and data activity but nothing shows on the display.
I'm using examples for from Adafruit for text, images etc.
Any suggestions?

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: BBB Python3 ST7735r issue

Post by mikeysklar »

Can you post a photo of how you have the display wired to the BBB?

One difference between this and the DUO would be the BBB needs to be wired for 3v3 as the input pins are not 5v tolerant.

This should be the closest wiring example based on the Raspberry Pi with 1.8" display (scroll down).

https://learn.adafruit.com/1-8-tft-disp ... ys-3042525
Screen Shot 2022-07-28 at 10.21.13 AM.png
Screen Shot 2022-07-28 at 10.21.13 AM.png (223.16 KiB) Viewed 2246 times

User avatar
BobNJ
 
Posts: 4
Joined: Wed Jul 27, 2022 2:45 pm

Re: BBB Python3 ST7735r issue

Post by BobNJ »

BBB wiring.jpg
BBB wiring.jpg (28.39 KiB) Viewed 2243 times
Sorry the picture isn't very clear.
Wiring is as follows:
backlight P9_14 (pwm) Brown
MISO P9_21 Orange
SCK P9_22 Yellow
MOSI P9_18 Green
TFT_CS P9_17 Blue
Card CS P9_23 Violet (set Low in script)
D/CX P9_15 Grey
RST P9_12 White
VCC from P9_4 Red
GND from P9_1 Black

"One difference between this and the DUO would be the BBB needs to be wired for 3v3 as the input pins are not 5v tolerant."

I'm not quite following what you are saying about the BBB not tolerating 5v at the pins?
Are you saying the display will try to put 5 volts onto the pins of the BBB?

Or are you saying I need a level shifter between the BBB and the module?
With 5 volts on the module side and 3.3 volts on the BBB side?
I was under the impression that the Adafruit 358 would work on both 5v and 3.3 volt. Is that incorrect?

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: BBB Python3 ST7735r issue

Post by mikeysklar »

Do not feed the display 5v when using the BBB as you want to keep everything 3v3.

Make sure that your Vin and Lite pins on the display are 3v3 just like the Pi wiring instructions.

The display does support 5v or 3v3 devices, but when you are using a 3v3 device like the BBB you need to keep it all 3v3.

If you are able to post some more close up photos of the wiring on each side I might be able to review the pinouts with you.

User avatar
BobNJ
 
Posts: 4
Joined: Wed Jul 27, 2022 2:45 pm

Re: BBB Python3 ST7735r issue

Post by BobNJ »

I was able to get something on the display using PIL.
However, the text is slanted, so I suspect it is an issue with the device being an ST7735R and PIL module only works with ST7735.
At least now I know that the SPI does work.

the following did make the display color.
draw.rectangle((0, 0, width, height), fill=(0, 90, 132))
display.image(image)

this did not draw a smaller purple rectangle.
# Draw a smaller inner purple rectangle
draw.rectangle(
(BORDER, BORDER, width - BORDER - 1, height - BORDER - 1), fill=(170, 0, 136)
)

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: BBB Python3 ST7735r issue

Post by mikeysklar »

That looks like great progress.

Did you have another question or is this resolved for you?

User avatar
BobNJ
 
Posts: 4
Joined: Wed Jul 27, 2022 2:45 pm

Re: BBB Python3 ST7735r issue

Post by BobNJ »

Well, I would still like to understand why it doesn't work using Adafruit modules.
It seems like the display is not being initialized by the adafruit_st7735r.py module.
I don't get any error message when I run the examples, I just don't get anything on the display.
If I have to continue to use PIL, I need to find out why I'm not getting the display to show properly.
Text is slanted.
None of the examples for PIL behave as expected.

Is it possible this is due to the device being an ST7735R while PIL only supports the ST7735?
Again, I have the Adafruit 358 which is supposed to have the ST7735R version of the chip.

User avatar
mikeysklar
 
Posts: 13823
Joined: Mon Aug 01, 2016 8:10 pm

Re: BBB Python3 ST7735r issue

Post by mikeysklar »

Let's go over the adafruit_st7735r.py code and see how you have modified the code for your BBB setup and the 1.8" display.

Is this the example code you have been using?

https://learn.adafruit.com/1-8-tft-disp ... ge-3042435

Code: Select all

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

"""
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)!

Author(s): Melissa LeBlanc-Williams for Adafruit Industries
"""

import digitalio
import board
from PIL import Image, ImageDraw
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,                 # 0.96" MiniTFT ST7735R
# 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)

image = Image.open("blinka.jpg")

# Scale the image to the smaller screen dimension
image_ratio = image.width / image.height
screen_ratio = width / height
if screen_ratio < image_ratio:
    scaled_width = image.width * height // image.height
    scaled_height = height
else:
    scaled_width = width
    scaled_height = image.height * width // image.width
image = image.resize((scaled_width, scaled_height), Image.Resampling.BICUBIC)

# Crop and center the image
x = scaled_width // 2 - width // 2
y = scaled_height // 2 - height // 2
image = image.crop((x, y, x + width, y + height))

# Display image.
disp.image(image)

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

Return to “Beagle Bone & Adafruit Beagle Bone products”