Skip to content

CircuitPython Parsec

The CircuitPython Parsec is a weekly video hosted by John Park of Adafruit. Each video offers a quick tip with CircuitPython and is generally around 2 minutes or less in length.

Here's the complete youtube playlist

Individual CircuitPython Parsec videos with descriptions

Some tips on finding out which board type and version of Circuit Python you're running, more at : https://github.com/todbot/circuitpython-tricks

import os
print (os.uname().machine)
print (os.uname().version)   # NOTE: this only prints the version for CircuitPython on embeded devices
print (os.uname())

import board
board.[tab]  # press tab for auto-completion - similar to auto-complete on bash

https://circup.readthedocs.io/en/latest/ https://github.com/adafruit/circup https://learn.adafruit.com/keep-your-circuitpython-libraries-on-devices-up-to-date-with-circup/

python3 -m venv ~/.virtualenvs/circup
. ~/.virtualenvs/circup/bin/activate

(circup) jliu@JEFFREYs-MBP ~/Downloads/CircuitPython/circuitpython-class % python --version
Python 3.8.2

pip install circup


(circup) jliu@JEFFREYs-MBP /Volumes/CIRCUITPY/lib % circup bundle-show
adafruit/Adafruit_CircuitPython_Bundle
 https://github.com/adafruit/Adafruit_CircuitPython_Bundle
 version = 20210921
adafruit/CircuitPython_Community_Bundle
 https://github.com/adafruit/CircuitPython_Community_Bundle
 version = 20210921
circuitpython/CircuitPython_Org_Bundle
 https://github.com/circuitpython/CircuitPython_Org_Bundle
 version = 0.0.3



cd /Volumes/CIRCUITPY/lib

circup install adafruit_debouncer

circup uninstall adafruit_debouncer

(circup) jliu@JEFFREYs-MBP ~/Downloads/CircuitPython/circuitpython-class % ls -lrt ~/Library/Application\ Support/circup
total 34080
-rw-r--r-- 1 jliu staff 6901917 Sep 20 12:21 adafruit-circuitpython-bundle-py.zip
-rw-r--r-- 1 jliu staff 4426830 Sep 20 12:21 adafruit-circuitpython-bundle-6mpy.zip
-rw-r--r-- 1 jliu staff 3468520 Sep 20 12:21 adafruit-circuitpython-bundle-7mpy.zip
-rw-r--r-- 1 jliu staff 1247376 Sep 20 12:21 circuitpython-community-bundle-py.zip
-rw-r--r-- 1 jliu staff  766679 Sep 20 12:21 circuitpython-community-bundle-6mpy.zip
-rw-r--r-- 1 jliu staff  593322 Sep 20 12:21 circuitpython-community-bundle-7mpy.zip
drwxr-xr-x 8 jliu staff 256 Sep 20 12:21 adafruit
-rw-r--r-- 1 jliu staff 11320 Sep 20 12:21 circuitpython-org-bundle-py.zip
-rw-r--r-- 1 jliu staff  5506 Sep 20 12:21 circuitpython-org-bundle-6mpy.zip
-rw-r--r-- 1 jliu staff  4992 Sep 20 12:21 circuitpython-org-bundle-7mpy.zip
drwxr-xr-x 5 jliu staff 160 Sep 20 12:21 circuitpython
-rw-r--r-- 1 jliu staff 160 Sep 20 12:21 circup.json

(circup) jliu@JEFFREYs-MBP ~/Downloads/CircuitPython/circuitpython-class % du -sh ~/Library/Application\ Support/circup
49M  /Users/jliu/Library/Application Support/circup




(circup) jliu@JEFFREYs-MBP /Volumes/CIRCUITPY/lib % circup freeze > ../requirements.txt



(circup) jliu@JEFFREYs-MBP /Volumes/CIRCUITPY/lib % circup uninstall adafruit_debouncer
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.3.0.
A newer version of CircuitPython (7.0.0) is available.
Get it here: https://circuitpython.org/downloads
Uninstalled 'adafruit_debouncer'.


(circup) jliu@JEFFREYs-MBP /Volumes/CIRCUITPY/lib % circup install -r ../requirements.txt
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.3.0.
A newer version of CircuitPython (7.0.0) is available.
Get it here: https://circuitpython.org/downloads
Searching for dependencies for: ['a newer version of circuitpython (7.0.0) is available.', 'adafruit_debouncer', 'found device at /volumes/circuitpy, running circuitpython 6.3.0.', 'get it here: https://circuitpython.org/downloads']
WARNING:
    a newer version of circuitpython (7.0.0) is available. is not a known CircuitPython library.
WARNING:
    found device at /volumes/circuitpy, running circuitpython 6.3.0. is not a known CircuitPython library.
WARNING:
    get it here: https://circuitpython.org/downloads is not a known CircuitPython library.
Ready to install: ['adafruit_debouncer']


Installed 'adafruit_debouncer'.

https://github.com/adafruit/circup/pull/110 Support for community bundle and future bundles NOTE: by default the DATA_DIR/circup directory on Mac is ~/Library/Application\ Support/circup

find ~ -name circup.json
/Users/jliu/Library/Application Support/circup/circup.json


(circup) jliu@JEFFREYs-MBP ~  % cd Library/Application\ Support/circup 

(circup) jliu@JEFFREYs-MBP ~/Library/Application Support/circup  % ls -lrt
total 35752
-rw-r--r--  1 jliu  staff  11320 Sep 21 11:55 circuitpython-org-bundle-py.zip
-rw-r--r--  1 jliu  staff   5506 Sep 21 11:55 circuitpython-org-bundle-6mpy.zip
-rw-r--r--  1 jliu  staff   4992 Sep 21 11:55 circuitpython-org-bundle-7mpy.zip
drwxr-xr-x  5 jliu  staff  160 Sep 21 11:55 circuitpython
-rw-r--r--  1 jliu  staff  4531939 Dec  5 10:25 adafruit-circuitpython-bundle-6mpy.zip
-rw-r--r--  1 jliu  staff  1398845 Dec  5 10:25 circuitpython-community-bundle-py.zip
-rw-r--r--  1 jliu  staff   866768 Dec  5 10:25 circuitpython-community-bundle-6mpy.zip
-rw-r--r--  1 jliu  staff   655732 Dec  5 10:25 circuitpython-community-bundle-7mpy.zip
-rw-r--r--  1 jliu  staff  7197908 Jan  1 19:44 adafruit-circuitpython-bundle-py.zip
-rw-r--r--  1 jliu  staff  3607698 Jan  1 19:44 adafruit-circuitpython-bundle-7mpy.zip
drwxr-xr-x  8 jliu  staff  256 Jan  1 19:44 adafruit
-rw-r--r--  1 jliu  staff  160 Jan  1 19:44 circup.json

(circup) jliu@JEFFREYs-MBP ~/Library/Application Support/circup  % du -sh .
 51M   .
- [ ] minipip: a tool for installing distribution packages for MicroPython and CircuitPython #CircuitPython #MicroPython  https://blog.adafruit.com/2021/05/26/minipip-a-tool-for-installing-distribution-packages-for-micropython-and-circuitpython-circuitpython-amicropython-aivarannamaa/

- [ ] pipkin - successor to minipip, included with Thonny 4

https://pypi.org/project/pipkin/ https://forums.adafruit.com/viewtopic.php?f=60&t=189621 https://blog.adafruit.com/2022/03/25/thonny-python-editor-gets-4-0-0-beta-release-python-micropython/

  • Servo Animation List (9/24/2021)
  • Servo Easing (10/1/2021) Use this simple technique to ease the motion of your servo motors and avoid sudden, jerky halting!
  • CPU Temperature (10/8/2021)
  • boot.py (10/14/2021) Use the boot.py file to prevent the CIRCUITPY drive from showing up when you don’t want it to! https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/circuitpy-midi-serial
  • Random Delay (10/25/2021)
  • Dual NeoPixel Rings (10/29/2021)
  • Sine Wave Tones (11/8/2021) Debouncer and PWM audio example for CircuitPython Bluefruit
  • Free Memory (11/15/2021) Check your board’s free memory with the Garbage Collector. Example from the REPL:
import gc
dir(gc)
['__class__', '__name__', 'collect', 'disable', 'enable', 'isenabled', 'mem_alloc', 'mem_free']

print(gc.mem_free())
142288

from adafruit_led_animation.color import *
print(gc.mem_free())
139472

## NOTE: so there is no difference if you just import individual colors
from adafruit_led_animation.color import CYAN
print(gc.mem_free())
139472
  • Keyword Arguments (11/19/2021)
  • Print w/o Newline Improve your serial output by printing without newline! (12/6/2021) (also see 8/12/2022)
  • Pixel Patterns Create patterns of NeoPixels using for loops and the range() command. (12/13/2021)
  • Fake Ground Pin (12/17/2021)
  • Linear Interpolation (1/7/2022) lerp() is a simple function to do linear interpolation between two values, for example RGB color mixing.
  • Capacitive Touch Sensing (1/14/2022) Learn to use capacitive touch pins in CircuitPython for simple touch sensing!
  • User Input (1/22/2022) You can employ typed user input from the USB serial REPL in your CircuitPython code.
  • WiFi Sniffing (1/31/2022) You can sniff for WiFi networks in CircuitPython on ESP-32 S2 with just a tiny bit of code!
  • Dictionaries (2/7/2022) Use dictionaries in CircuitPython to organize and access your data!
  • Wav Audio Crossfader (2/14/2022) Crossfade looping audio files with the audio mixer in CircuitPython.
  • DisplayIO Fill (2/18/2022) Use this simple trick to display shapes on TFT and OLED displays using displayio and fill.
  • DisplayIO Movement (2/25/2022) How to move screen shapes with DisplayIO.
  • DisplayIO Text (3/7/2022) How to use Text Labels with DisplayIO
  • DisplayIO Rotation (3/12/2022) Use display.rotation() to re-orient your screen.
  • DisplayIO Palette Swap (3/20/2022) Swap out each color in an bitmap palette for a cool image effect.
  • VectorIO Circle and Rectangle (3/28/2022) VectorIO is a lightweight 2D shapes library for DisplayIO
  • VectorIO polygonal shapes (4/1/2022) Introducing vectorIO polygonal shapes — VectorIO is a lightweight, 2D shape drawing library for displayio in CircuitPython.
  • Touchscreen (4/8/2022) How to use a touchscreen in CircuitPython.
  • Transparent Sprites (4/15/2022)
  • Mouse Cursor (5/6/2022) https://learn.adafruit.com/cursor-for-circuitpython https://learn.adafruit.com/creating-your-first-tilemap-game-with-circuitpython
  • Cursor Control (5/13/2022) It’s simple to made cool disco light patterns for NeoPixels using random integers for color component values.
  • Bi-color LED Matrix (5/20/2022)
  • NTP time server (5/27/2022) Learn to set your board's RTC (real time clock) with the NTP time server using CircuitPython. ESP32-S2 TFT Feather: https://www.adafruit.com/product/5300 Base template found here: https://docs.circuitpython.org/projects/ntp/en/latest/examples.html
  • Random Range Tones (6/2/2022) https://blog.adafruit.com/2022/06/02/john-parks-circuitpython-parsec-random-range-tones-adafruit-johnedgarpark-adafruit-circuitpython/ You can play back “computery/roboty” bleeps with random.randomrange() and random.uniform() to define pitch and duration in CircuitPython.
  • Pixelmap (6/17/2022) Use the PixelMap feature of the led_animation library to create multiple logical strips from a single physical NeoPixel strip, grid, or ring!
  • TileGrid Sprite Sheet (6/24/2022) Create dynamic user interface elements using TileGrid Sprite Sheets.
  • SVG to VectorIO (7/1/2022) Convert SVG graphics to VectorIO shapes for use with CircuitPython. Thanks to Todbot for this cool method! Use PathToPoints to format the SVG into CircuitPython code.
  • Pixel Framebuf (7/8/2022) Easily display shapes, pixels, and lines on a DotStar or NeoPixel grid using pixel_framebuf in CircuitPython.
  • List parsing (7/17/2022) Learn how to use the 'sort()' command to sort lists into alphabetical-, reverse-, size- and other useful orders.
  • tio - a simple serial device I/O tool (7/22/2022) Check out ‘tio’ the Serial IO tool for any operating system that makes it painless to debug your microcontroller, even when resetting or power cycling your board. https://github.com/tio/tio To make a simpler serial device tool for talking with serial TTY devices with less focus on classic terminal/modem features and more focus on the needs of embedded developers and hackers. tio was originally created to replace screen for connecting to serial devices when used in combination with tmux.
  • discotool (8/1/2022) Use discotool to make your CircuitPython REPL adventures much friendlier!
    https://github.com/Neradoc/discotool If you have multiple devices connected, it will display friendly names and allows you to connect via them. Seems to be based off tio.
    Can also call subcommands for circup update etc.
  • Carriage Return (8/12/2022) Use 'end='\r'' carriage return to prevent newlines in your print statements. (also see 12/6/2021)
  • Mode Select (8/22/2022) Create a mode select in your CircuitPython code that runs at the start of the program, allowing users to choose settings.
  • Range (9/2/2022) Adjust the step size of loop iteration with range(start, stop, step)
  • Progress Bars (9/9/2022) Create horizontal progress bars in CircuitPython. It's easy, fun, and low calorie.
  • Bitmap Snow (9/16/2022) Draw randomized pixels in a bitmap object to create multicolored "snow" using CircuitPython.
  • Bitmap Line Drawing (9/26/2022) Make a DIY line drawing function for bitmap pixels in CircuitPython.
  • USB Brightness Control (9/30/2022) Build a custom brightness controller for your computer or mobile device using CircuitPython.
  • Boot_Out.txt (10/10/2022) That mysterious 'boot_out.txt' file on your CircuitPython board isn't so mysterious after all!
  • Deep Sleep (10/16/2022) Use the alarm library to send your microcontroller into deep sleep and then wake up later.
  • Bluetooth Naming (10/22/2022) Give your Bluetooth Low Energy object descriptive advertised name in CircuitPython.
ble.name = "BLE Midid Fader"
  • numpy LED Fades (10/28/2022) Speed up LED fades with numpy!
  • File Glider iOS App (11/18/2022) Code your BLE CircuitPython device right from your mobile device with the Adafruit File Glider app for iOS and Android! https://learn.adafruit.com/how-to-transfer-files-to-a-circuit-playground-bluefruit-using-the-fileglider-app
  • Incremental Iteration (11/28/2022) How iterate incrementally with a loop within a loop.
  • Blink Without Delay (12/5/2022) How to use timing intervals in CircuitPython without blocking your code.
  • Timing with Ticks (12/8/2022)
  • I2C Scanning (12/26/2022) Scan the I2C bus for device addresses in CircuitPython.
import board

i2c = board.I2C() # or busio.I2C(pin_scl,pin_sda)

while not i2c.try_lock():
    pass

print("I2C addresses found: ", [hex(device_address) for device_address in i2c.scan()])

i2c.unlock()
  • Using SNES Controllers (1/2/2023) How to use Super Nintendo controllers in CircuitPython with the keypad library.

  • Long vs Short Press (1/6/2023) You can use a single button to mean two different things depending on how long you press it! Learn how to use a short duration vs. a long duration button press in CircuitPython (adafruit_debouncer library).

  • Multi Clicks (1/13/2023) Enable single-click/double-click button functions in CircuitPython!

  • I2S Audio Pins (1/20/2023) Use CircuitPython to determine valid sets of pins on your microcontroller to use with I2S audio. Code is here: https://learn.adafruit.com/mp3-playback-rp2040#circuitpython-mp3-capable-pins-3101440

  • List Filtering (1/27/2023) Get more (less?) out of lists with List Filtering!

  • Iterate Up and Down (2/3/2023) Iterate up and down in your for loops to count up & down and cycle behaviors.

-Noise (2/10/2023) Use the Noise library's noise function to smoothly flow through values. This simplex noise (based on Ken Perlin's 2D noise function) is great for creating undulating LED values and more. Implemented by Tod @todbot Kurt, noise is available in the CircuitPython Community Bundle, and can be installed with 'circup install noise'

-Supervisor Reload (2/19/2023) Use the Supervisor to change CircuitPython’s autoreload behavior.

-Unpacking Tuples (2/24/2023) Learn how to unpack the multiple values in a tuple and use the ones you want.

  • Rainbowio Colorwheel (3/4/2023) Easily change hue values on NeoPixels with Rainbowio Colorwheel!

  • ANSI Escape Codes (3/13/1023) Use ANSI escape codes in CircuitPython color text in your REPL terminal and help with debugging.

  • One Liners (3/20/2023) Use multiple command copy/paste one-liners for quick debugging and testing. Sample one liners here: https://github.com/todbot/circuitpython-tricks#use-repl-fast-with-copy-paste-multi-one-liners

  • DotStar LEDs (3/27/2023) How to use DotStar RGB LEDs in CircuitPython

  • Integer Divide (4/7/2023) How to use use integer divide // to get whole numbers in CircuitPython

  • Wiichuck uDraw Tablet (4/15/2023) Use a Nintendo uDraw tablet in CircuitPython to control NeoPixels, MIDI, motors, and anything else! The wiichuck library from the Community Bundle makes it simple.

  • Touchscreen Calibration (4/28/2023) How to calibrate a touchscreen in CircuitPython using adafruit_touchscreen library and Cedar Grove Maker’s calibration program.

  • LCD Character Displays (5/12/2023) How to use an LCD character display in CircuitPython

  • Enumerate (5/19/2023) How to use the enumerate command in CircuitPython

  • S3 Builds of CircuitPython (5/29/2023) How to get the latest builds of CircuitPython from the S3 server.

  • Color Gradients with NeoPixels (6/2/2023) Create RGB color gradients for NeoPixels in CircuitPython

  • Absolute Wave Rectifier (6/19/2023) Rectify a sine wave with the absolute function in CircuitPython.

  • Function Lists (6/24/2023) Make and call lists of functions in CircuitPython.

  • Circuit Playground LED/Switch (7/7/2023) Use the Circuit Playground library on the CPX and CPB boards to light the LED and use the switch.

  • Circuit Playground Tap Detection (7/14/2023) Use the Circuit Playground library on the CPX and CPB boards to detect single and double taps with the on-board accelerometer.

  • Circuit Playground NeoPixels (7/28/2023) Use the Circuit Playground library on the CPX and CPB boards to easily control on-board NeoPixels.

  • Circuit Playground Light Detection (8/4/2023) Use the on-board light detector on Circuit Playground boards!

  • Circuit Playground Buttons (8/11/2023) Use the built-in buttons on Circuit Playground boards!

  • Circuit Playground Temperature (8/21/2023) Use the built-in temperature sensor on Circuit Playground boards!

  • Circuit Playground Touch Sensing (9/8/2023) How to use the capacitive touch pads on the Circuit Playground Express/Bluefruit boards with Circuit Playground in CircuitPython.

  • Circuit Playground Tones (9/15/2023) Play simple music with the Tones command on Circuit Playground Express/Bluefruit boards with Circuit Playground in CircuitPython.

  • Circuit Playground Play Files (9/22/2023) Play audio .wav files with the cp.play_file() command on Circuit Playground Express/Bluefruit boards with Circuit Playground in CircuitPython.

  • Circuit Playground Sound Detection (9/29/2023) Use the built-in mic on Circuit Playground Bluefruit to sense sound levels and detect loud sounds to trigger events.

  • Bitmap Label Highlighting (10/6/2023) Highlight display text with bitmap label colors.

  • Debouncer Timer (10/13/2023) Use the Debouncer library to create a simple event timer in CircuitPython

  • Print Debugger (10/27/2023) Use a special print function to simplify debugging.

  • WiFi Web Workflow (11/3/2023) Code your ESP32 boards in CircuitPython over WiFi! Right in the browser!! https://learn.adafruit.com/getting-started-with-web-workflow-using-the-code-editor

  • Set Next Code File (11/10/2023) Create a code file that allows you to launch other code files in CircuitPython! code example here: https://github.com/jedgarpark/parsec/blob/main/2023-11-09/code.py

  • Non-Volatile Memory (11/17/2023) You can save data between power cycles in non-volatile memory with this one simple trick in CircuitPython! code example here: https://github.com/jedgarpark/parsec/blob/main/2023-11-16/code.py

  • For Statements with Enumeration (12/8/2023) Simplify and clarify your 'for' statements with enumeration. code example here: https://github.com/jedgarpark/parsec/blob/main/2023-11-29/code.py

  • asyncio (12/15/2023) Do multiple things at once with asyncio! code example here: https://github.com/jedgarpark/parsec/blob/main/2023-12-15/asyncio_code.py

  • Split Strings (1/5/2024) Split Strings code example here: https://github.com/jedgarpark/parsec/blob/main/2024-01-04/code.py

  • List Comparison (1/12/2024) List Comparison

  • IP Ping (1/19/2024) Ping an IP address from your microcontroller to check ping time. code example here: https://github.com/jedgarpark/parsec/blob/main/2024_01_18/code.py

  • Get Sorted (1/6/2024) Used the 'sorted()' command to create a new list in sorted order. Or reverse it! code example here: https://github.com/jedgarpark/parsec/blob/main/2024_01_25/code.py

Additional References

This page was last updated on 2024-01-27 11:25:07 -0500.s