Utils

August 17, 2026 · View on GitHub

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

Example helpers keypins, wifi, and the optional source-only viper_tools accelerator live here. Product-owned desktop modules such as mip, the micropython shim, and frame_recorder live in pydevices utils/ and are installed by pydevices-desktop. A sibling checkout is on sys.path via path.py during source-tree development.

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
keypins.pyPresent key events as pin-like objects
wifi.pyMicroPython network.WLAN shim used by examples
viper_tools.pyOptional MicroPython Viper accelerators for example utilities
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.