Utils

August 14, 2026 · View on GitHub

Optional extensions in lib/utils/. Not required for basic display and event use. API docs: Utils Reference.

MCU / host helpers that used to live here (byteswap, viper_tools, mip, micropython shim, keypins, wifi, frame_recorder) are in pydevices utils/. packages/utils.json depends on that tree; a sibling checkout is on sys.path via path.py.

Install

import mip
mip.install("github:PyDevices/pydevices-examples/packages/utils.json", target="./utils")

Path setup

Preferred: set PYTHONPATH (CPython/CircuitPython) or MICROPYPATH (MicroPython) to .:lib:utils and run from lib/ — no import needed.

When environment variables are unavailable or not set as recommended (for example, a bare device REPL, or boot.py/main.py), put lib/ and utils/ on sys.path explicitly:

import utils.path

Or copy the utils modules into lib/ on your device.

Notable modules

ModulePurpose
framebuf.pyframebuf API on CPython/CircuitPython
displaybuf.pyPeter Hinch DisplayBuffer API
console.pyTerminal-style console widget
lv_encoder_emu.pyDesktop-only soft encoder UI on a secondary surface (stand-in for MCU machine.Encoder / rotaryio); see examples/lv_multi_display.py
pdwidgets/Moved to pdwidgetsuser guide
palettes/Moved to palettesuser guide
tft_text.py, tft_write.pyrusshughes font rendering
png.pyPNG support (experimental)

Third-party trees copied locally (not in utils.json):

PathPurpose
gui/Peter Hinch GUIs — install via fetch_ph_gui; gitignored; one of nano / micro / touch at a time

Many examples in lib/examples/ depend on utils. They are excluded from the MIP packages — install from GitHub only.

Some files are third-party ports included for convenience; see file headers for attribution.