Breakout Garden Pi400

May be a dumb question but I wanted to know if/how I can have cpu/system stats shown on the display (0.96 LCD SPI breakout) iv ran a few examples from the recourses provided but I’m new to this and unsure how to do anything beyond those examples!. Any help is very appreciated!

Thanks,
Kyle

I’ve been playing around with a fair bit of the Breakout Garden stuff. I have the Mini SPI, i2c and mini i2c Breakout Gardens. Several of those 0.96 color LCD’s, BME280’s, UV and ambient light sensors etc.
I’m mostly running modified Enviro+ code on them. I have one setup with three displays, one shows a graph of the temperature, one a humidity graph, and the third graphs pressure. It’s what the Enviro+ is shown displaying on its product page. My python skills are average at best so I start with what is already working and modify it to suit my needs.
Long story short, first I’d figure out how to get your stats, and just use a print statement to display them on screen in thony or what ever IDE you want to use.
Once you get that working then try to figure out how to display them on the Breakout garden screen. The weather-and-light example does something similar to what you want to do. I’m running it right now on my Breakout Garden. It shows the values for temperature, humidity and pressure etc in numerical values and some changing icons. You’d just swap out air temperature for say CPU temperature, as an example.
Anyway, you just have to start small and work up to what you want as a finished product.

1 Like

The python examples work for you?
I have a similar set-up : pi400, breakout garden and the 1.3 SPI Colour LCD, which has a fork of the python library for the 0.96 SPI LCD.
The python library seemed to install per the instructions, but the examples don’t work.
I think this is because the module it installs is for python 2.7, but that isn’t available on my pi, so the python interpreter can’t find it when it runs.

If you haven’t already try
sudo pip3 install st7789
and
sudo apt-get install python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
I think you will get an error for one of the items in that second command. My 1.3 display worked anyway from python 3. I don’t have the Pi400 Breakout Garden, just the i2c, SPI Mini hooked up to a Pi Zero.
I believe this is the config I used. It may be different for the Pi400 Breakout Garden.

# Create ST7789 LCD display class
st7789 = ST7789.ST7789(
    port=0,
    cs=1, 
    dc=9,
    backlight=19, 
    rotation=90,
    spi_speed_hz=10000000
)

(With apologies to the original poster for taking over their thread)

Thank you alphanumeric. The first command fixed that problem at least. I think I learned how to persuade python to install modules in v3 now.

The second command all worked too - if I run it again now I’m told that everything is up to date and nothing new is installed.

python3-numpy is already the newest version (1:1.16.2-1).
python3-pil is already the newest version (5.4.1-2+deb10u2).
python3-pip is already the newest version (18.1-5+rpt1).
python3-rpi.gpio is already the newest version (0.7.0-0.1~bpo10+4).
python3-spidev is already the newest version (20190221~182651-1).
0 upgraded, 0 newly installed, 0 to remove and 186 not upgraded.

However, I’m still getting errors from the examples, - I suspect it’s another noob mistake, but I haven’t been able to diagnose it. Here’s what I tried:

Running gif.py from Thonny, it prints out a message saying to use it from the command line. So it seems fine from there, just inappropriately called.

Running from the command line I get this:

pi@raspberrypi:~/Pimoroni/240x240screen $ ./gif.py deployrainbows.gif
from: can’t read /var/mail/PIL
./gif.py: line 22: import: command not found
./gif.py: line 23: import: command not found
./gif.py: line 24: import: command not found
./gif.py: line 29: syntax error near unexpected token $'"""\ngif.py - Display a gif on the LCD.\n\nIf you\'re using Breakout Garden, plug the 1.3"'' ./gif.py: line 29: If you’re using Breakout Garden, plug the 1.3" LCD (SPI)’

I don’t know what the /var/mail/PIL thing is about - there isn’t anything in /var/mail anyway.
I also don’t know what the unexpected token is about. To get the demos, I copy-pasted them from the git webpage, so I might have corrupted them - but it’s not obvious to me how, and it might be a red herring.

The scrolling-text.py demo gives different errors from the command-line vs Thonny.

Thonny reports:

Python 3.7.3 (/usr/bin/python3)
>>> %Run scrolling-text.py
Traceback (most recent call last):
  File "/home/pi/Pimoroni/240x240screen/scrolling-text.py", line 17, in <module>
    spi_speed_hz=80 * 1000 * 1000
  File "/usr/local/lib/python3.7/dist-packages/ST7789/__init__.py", line 124, in __init__
    self._spi = spidev.SpiDev(port, cs)
FileNotFoundError: [Errno 2] No such file or directory

I think that’s the SPI module balking at the display initialisation object.

From the command-line I get this instead:

pi@raspberrypi:~/Pimoroni/240x240screen $ ./scrolling-text.py
from: can’t read /var/mail/PIL
from: can’t read /var/mail/PIL
from: can’t read /var/mail/PIL
./scrolling-text.py: line 4: import: command not found
./scrolling-text.py: line 6: import: command not found
./scrolling-text.py: line 9: MESSAGE: command not found
./scrolling-text.py: line 12: syntax error near unexpected token (' ./scrolling-text.py: line 12: disp = ST7789.ST7789(’

Which is essentially a reprise of the other demo’s errors.

Any advice would be welcome.

 ./gif.py deployrainbows.gif 
from: can't read /var/mail/PIL ./gif.py: 
line 22: import: command not found

As far as I can tell it can’t tell what it’s supposed to be opening gif.py with, try:

python3 gif.py deployrainbows.gif

1 Like

Double check that SPI is enabled. I’ve gotten “file not found” messages for SPI and i2c when I have forgotten to enable them.

1 Like

Both of these are very good suggestions, and both fixed a problem - I didn’t have SPI enabled (had no idea it needed it, hadn’t seen a mention of it before), and also apparently there isn’t a route to automatically figure out how to run python3 files built-in to linux.
So now the demos seem to run fine.
But they still don’t actually display anything, which is rather disappointing.
I can see that the backlight is on when the pi is on, although it’s still ‘dark’. And when I run one of the demos, this goes off for a moment. But it’s not showing an image.

The pi400 version of the breakout garden only has one SPI slot, and the code has references to front and back slots (which other versions of the board have). So I thought I’d try changing the code to reference the back slot. This didn’t work, although I did see that changing the backlight value to the back slot value stops the momentary dim at start, - so I think I’ve confirmed it’s trying to address the right SPI slot.

The framerate reporter seems to be able to interrogate …whatever it needs to talk to:

pi@raspberrypi:~/Pimoroni/240x240screen $ python3 framerate.py

framerate.py - Test LCD framerate.

If you're using Breakout Garden, plug the 1.3" LCD (SPI)
breakout into the front slot.

Running at: 80MHz

Time:    3.990,      Frames:    120,      FPS:   30.077
Time:    7.977,      Frames:    240,      FPS:   30.086
Time:   11.964,      Frames:    360,      FPS:   30.091
Time:   15.953,      Frames:    480,      FPS:   30.088
Time:   19.948,      Frames:    600,      FPS:   30.078
Time:   24.030,      Frames:    720,      FPS:   29.962

Honestly I’m rather at a loss, now.

I have the Breakout Garden Mini i2c SPI. It’s SPI slot is wired up the same as the front slot on the full sized hat that has two SPI slots. The way it works is both slots are wired to SPI0 which equates to port=0. The front slot (and mine) use chip select 1 which equates to cs=1. I can just enter cs=1 in my screen config. The back slot on the hat uses chip select 0 which is cs=0. You could try cs=0 and see it it is wired to chip select 0? You can just remark out the backlight line if you have no idea what pin it uses. I have done this and it didn’t stop my display from working. As far as I can tell it’s only used to turn the backlight off.

# Create ST7789 LCD display class
st7789 = ST7789.ST7789(
    port=0, 
    cs=0,   
    dc=9,  
    # backlight=19, 
    rotation=90,
    spi_speed_hz=10000000
)

SPI0
GPIO 7, Pin 26, CE1
GPIO 8, Pin 24, CE0
GPIO 9, Pin 21, MISO
GPIO 10, Pin 19, MOSI
GPIO 11, Pin 23, SCLK

SCLK - Serial ClocK
CE - Chip Enable (often called Chip Select)
MOSI - Master Out Slave In
MISO - Master In Slave Out
MOMI - Master Out Master In