Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

[changed] ST7735S support
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

[changed] ST7735S support

by mitsuperboy12 on Sun Jul 12, 2020 9:44 am

Hi

Im new to CP and not a good progamer but why is all the CP libaries .mpy and .py are corrupted form CP Website because nothing work on the Metro M0 Express The Code and the Board works but nothing happens i look at All of the libaries and the are the like, "[][][]{}{}{}{}???///" to me the is Gooly goog. Im running the Lastest Windows 10

image.png
image.png (118.73 KiB) Viewed 32 times


can any one help

Tim

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: circuitpython libraries corrupted

by danhalbert on Sun Jul 12, 2020 9:50 am

The .mpy libraries are compiled versions of the .py libraries, so they are not human-readable. They are not corrupted: you are just looking at binary data.

Please give more details about "but nothing happens".

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: circuitpython libraries corrupted

by mitsuperboy12 on Sun Jul 12, 2020 10:38 am

oh ok, write the code then check it, no errors put it in to the Mtero M0 Expess, the Metro M0 running the code like normal but it does drive any components

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: circuitpython libraries corrupted

by danhalbert on Sun Jul 12, 2020 10:48 am

Please supply more details. I assume you mean "does NOT drive any components". Please post your code, say which versions you are using, and describe your wiring. A picture or several can be extremely helpful. Did it ever work?

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: circuitpython libraries corrupted

by mitsuperboy12 on Sun Jul 12, 2020 11:49 am

I have a Metro M0 Express and a 1.8 inch Display - https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1
I have wired it up as per the instructions sent from the Seller on Amazon, and also following some of the instructions on the Adafruit website. I have tried the Display on an Arduino Uno and it works perfectly with the Test Hello World software, but it does not do anything except light up white on the Metro.


C_20200712_155825 (1).jpg
Screen Pins
C_20200712_155825 (1).jpg (90.17 KiB) Viewed 27 times

C_20200712_155856 (1).jpg
Pin on Metro M0 Express
C_20200712_155856 (1).jpg (195.09 KiB) Viewed 27 times


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

Code: Select all | TOGGLE FULL SIZE
import digitalio
import board
from PIL import Image, ImageDraw
import adafruit_rgb_display.st7735 as st7735

# Configuration for CS and DC pins
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()

disp = st7735.ST7735R(spi, rotation=90,
cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)

# 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.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))

disp.image(image)
Attachments
C_20200712_155904 (1).jpg
C_20200712_155904 (1).jpg (148.4 KiB) Viewed 27 times

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: circuitpython libraries corrupted

by danhalbert on Sun Jul 12, 2020 12:44 pm

I edited your post to make it more readable, by selecting the code and enclosing it in [ CODE ] tags (see the buttons above the editing box).

It looks like you are mixing regular Python code, such as you might use on a Raspberry Pi code, with CircuitPython. PIL is not available in CircuitPython. I see that the repo doesn't make this clear. I will file an issue about that, sorry.

In addition the mfr documentation says this is an ST7735S display, and you are using the ST7735R driver.

Try this simple example, but change the pins as needed, and change the drive to the ST7735S driver:
https://github.com/adafruit/Adafruit_Ci ... pletest.py

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: circuitpython libraries corrupted

by danhalbert on Sun Jul 12, 2020 12:51 pm

Alternatively see this driver and its examples: https://github.com/adafruit/Adafruit_Ci ... on_ST7735R, though I'm not sure about its ST7735S support.

I'm going to point someone who's more expert on this to this thread.

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: [changed] ST7735S support

by danhalbert on Sun Jul 12, 2020 12:55 pm

The fact that PIL is not working, and other errors, would show up in the text output when you tried to run the program. Check out this guide: https://learn.adafruit.com/welcome-to-c ... al-console for information about how to see the error messages.

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: [changed] ST7735S support

by MakerMelissa on Sun Jul 12, 2020 1:16 pm

I have noticed on a lot of the non-Adafruit displays, the backlight is often off by default. Maybe check if the "BLK" connection is for backlight and hook it up to +3v or possible vcc.

MakerMelissa
 
Posts: 154
Joined: Wed Jun 05, 2013 2:10 am

Re: [changed] ST7735S support

by mitsuperboy12 on Sat Jul 18, 2020 10:03 am

Thank you for your reply regarding the backlight I can confirm that there is no connection to the display on the BLK pin. So as soon as the metro board is powered up the backlight comes on.

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: [changed] ST7735S support

by mitsuperboy12 on Sat Jul 18, 2020 10:09 am

Hi thanks for you help, unfortunately the display still does not work on the Metro M0 I modified the code that you suggested for the st7735S as below.
if you can offer more help, that would l be most appreciated.

Code: Select all | TOGGLE FULL SIZE
# Quick test of TFT FeatherWing (ST7789) with Feather M0 or M4
# This will work even on a device running displayio
# Will fill the TFT black and put a red pixel in the center, wait 2 seconds,
# then fill the screen blue (with no pixel), wait 2 seconds, and repeat.
import time
import random
import digitalio
import board

from adafruit_rgb_display.rgb import color565
import adafruit_rgb_display.st7735S as st7735S

# Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4):
cs_pin = digitalio.DigitalInOut(board.D5)
dc_pin = digitalio.DigitalInOut(board.D6)
reset_pin = digitalio.DigitalInOut(board.D9)

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

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

# Create the ST7789 display:
display = st7735S.st7735S(spi, cs=cs_pin,
dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)

# Main loop:
while True:
    # Fill the screen red, green, blue, then black:
    for color in ((255, 0, 0), (0, 255, 0), (0, 0, 255)):
        display.fill(color565(color))
    # Clear the display
    display.fill(0)
    # Draw a red pixel in the center.
    display.pixel(display.width // 2, display.height // 2, color565(255, 0, 0))
    # Pause 2 seconds.
    time.sleep(2)
    # Clear the screen a random color
    display.fill(
        color565(random.randint(0, 255),
        random.randint(0, 255), random.randint(0, 255))
    )
    # Pause 2 seconds.
    time.sleep(2)

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: [changed] ST7735S support

by mitsuperboy12 on Sun Jul 19, 2020 10:23 am

Thank you for your help so far with this.
I have retraced my steps, and wired the Display back to an Arduino UNO, and it works fine with a piece of demo Software.
The Arduino Demo Software used the following as part of it's setup ( I have note shown the rest of the code for simplicity);

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

// For the breakout, you can use any (4 or) 5 pins
//#define sclk 4
//#define mosi 5
//#define cs   6
//#define dc   7
//#define rst  8  // you can also connect this to the Arduino reset

//Use these pins for the shield!
#define sclk 13
#define mosi 11
#define cs   10
#define dc   8
#define rst  5  // you can also connect this to the Arduino reset


I am a little confused over what are the SCLK and MOSI pins, as the Display has SDA and SLK pins.
But I have used them both in different combinations with no luck on getting anything on the Display.
Except the Backlight lights up when the Metro Board is powered up, even with nothing connected to the BLK pin on the Display.
I also tried 3.3V which appears to be slightly dimmer than 5V

Also I was unsure what to connect to the Metro Board, as there are SCL and SDA pins on that immediately next to the Reset Button.
Plus also reading elsewhere there is a MOSI pin 11 and a MISO pin 12
Both of these I have tried too, but I get the same lit up blank white screen.

I am totally new to the world of Microcontrollers, and so I have no idea whether the problem that I have is software, hardware or drivers?
I had hoped that this would be a great introduction into programming with CircuitPython, as I have successfully managed to read Switches and turn on LEDs using it.
Where as the code for Arduino is something that have just struggled with?

Any help to get me over this first step would be greatly appreciated as it looks to be so much fun, and I don't wish to get frustrated and give up.

Kind regards

mitsuperboy12
 
Posts: 7
Joined: Sun Jul 12, 2020 9:29 am

Re: [changed] ST7735S support

by MakerMelissa on Sun Jul 19, 2020 1:33 pm

Hi,

I just realized you said it's a Metro M0 and not a Metro 328. For the Metro M0 and M4 boards, you are required to use the pins in the 2x3 ICSP header rather than pins 13 and 11. If you google image search for "icsp header pinout", you should see plenty of diagrams.

As a side note, SCLK is the same as the SCK on your board and MOSI is the same as SDA on your board. Also, if the backlight is turning on without it being wired up, then you don't need to wire it up.

Hope that helps.

Melissa

MakerMelissa
 
Posts: 154
Joined: Wed Jun 05, 2013 2:10 am

Please be positive and constructive with your questions and comments.