Install CircuitPython on Raspberry Pi Zero 2 W

Steps to install CircuitPython 9.0.0-beta.0 on Raspberry Pi Zero 2 W.


Prepare CircuitPython Firmware

Visit https://circuitpython.org/downloads, search "Zero 2 W" by Raspberry Pi.
Download CircuitPython 9.0.0-beta.0 > DOWNLOAD .DISK.IMG.ZIP NOW

Write to microSD

Write to microSD using Raspberry Pi Imager:
- Raspberry Pi Device: Raspberry Pi Zero 2 W
- Operating System: Use custom, select the downloaded zip file (no need un-zip)
- and select Storage
- Next
Follow other steps as writing SD for normal Raspberry Pi.

Power on Raspberry Pi 2 W in CircuitPython

- Remove and insert the microSD into Raspberry Pi Zero 2 W
- Connect HDMI monitor
- Power on HDMI monitor
- Connect Host USB to the USB port marked USB
- Raspberry Pi 2 W appear as USB driver named CIRCUITPY.

Run

Then Run Thonny Python IDE on host computer to test it.
> Run > Configure interpreter...
> Select interpreter of CircuitPython and Port
> OK

Raspberry Pi Zero 2 W is running CircuitPython.

Code

Try my exercise, cpy_Zero2W_turtle.py, CircuitPython script to draw something on display using CircuitPython Turtle Graphics.
(Actually, it is copied from my former exercise of Turtle Graphics on ESP32-S3-EYE/CircuitPython)

Library need:
- adafruit_turtle.mpy

cpy_Zero2W_turtle.py
# Turtle Exercise
# ref: https://learn.adafruit.com/circuitpython-turtle-graphics

import board
from adafruit_turtle import Color, turtle
import os, sys

display = board.DISPLAY
turtle = turtle(board.DISPLAY)

info = os.uname()[4] + "\n" + \
       sys.implementation[0] + " " + os.uname()[3] + "\n" + \
       "board.DISPLAY: " + str(display.width) + "x" + str(display.height)
print("=======================================")
print(info)
print("=======================================")
print("Turtle Exercise")

def drawSquare(t,size,angle):
    t.left(angle)
    halfsize = size * .5
    t.pu()
    t.setpos(0,0)
    t.backward(halfsize)
    t.left(90)
    t.backward(halfsize)
    t.right(90)
    t.pd()

    for i in range(0,4):
        t.fd(size)
        t.left(90)

def drawSquarePattern(t):
    t.pencolor(Color.WHITE)
    drawSquare(t,240,0)
    for i in range(0,20):
        size = 240 * pow(1/1.2,i+1)
        drawSquare(t,size,12.5)
    t.ht()

drawSquarePattern(turtle)
print("~ bye ~")


ref:

Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.