Skip to main content

Tottie wee image rendering library for 64×64 LED matrix displays

Project description

tottie

Tottie /ˈtɒti/ — Scottish word meaning tiny or very small. A tottie wee library for tottie wee displays.

Tottie is a Python library for rendering images onto 64×64 LED matrix displays. It provides the shared rendering primitives used by homeassistant-idotmatrix and homeassistant-trinity.

What's included

  • tottie.moon — Moon phase renderer. Draws the current moon disc with texture, a direction/altitude ring indicator, and a lunar cycle progress bar across the top edge.
  • tottie.overlay — Pixel-font text overlay. Renders track/artist (or any two lines of text) onto an image using a compact 3×5 bitmap font, with automatic text paging for long strings.
  • tottie.image — Image utilities. Square fit (crop-to-fill or letterbox) at any size, and RGB565 conversion for displays that accept raw pixel data over serial/MQTT.

Installation

pip install tottie

Usage

Moon phase

from tottie import render_moon

img = render_moon(lat="51.5", lon="-0.1", elev=10)
img.save("moon.png")

Set mirror_ew=True (the default) when the display is on a north-facing wall, so the moon rises on the correct side.

Now playing overlay

from PIL import Image
from tottie import apply_now_playing_overlay

img = Image.open("album_art.jpg").convert("RGB").resize((64, 64))
apply_now_playing_overlay(img, track="Astronomy", artist="Blue Oyster Cult")
img.save("now_playing.png")

For animated paging (long track/artist names scroll across multiple frames):

from tottie import render_now_playing_frames

frames = render_now_playing_frames(img, track="A Very Long Track Title Indeed", artist="Artist")
# frames is a list of (PIL.Image, duration_ms) pairs

Both functions accept optional dim and position parameters:

  • dim (float, default 0.5) — how much of the original image shows through the text background. 0.0 = solid black, 1.0 = no darkening.
  • position ("top" or "bottom", default "top") — where the text block is placed on the image.
apply_now_playing_overlay(img, track="Astronomy", artist="Blue Oyster Cult", dim=0.7, position="bottom")
render_now_playing_frames(img, track="...", artist="...", dim=0.7, position="bottom")

Image utilities

from PIL import Image
from tottie import crop_and_resize, to_rgb565

img = Image.open("photo.jpg").convert("RGB")
small = crop_and_resize(img, size=64)   # centre-crop square, resize to 64×64
raw = to_rgb565(small)                  # bytes ready to publish over MQTT

crop_and_resize accepts a fit argument:

  • fit="cover" (default) — crop to a square then resize. Pixels outside the crop are discarded. Use anchor="top_left" etc. to bias the crop.
  • fit="contain" — letterbox: scale the whole image to fit, padding the short axis with bg (default black). Preserves the entire source image, good for wide photos like aircraft shots.
letterboxed = crop_and_resize(img, size=64, fit="contain")

Requirements

  • Python 3.11+
  • Pillow
  • ephem (for moon rendering)

Licence

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tottie-0.6.0.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tottie-0.6.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file tottie-0.6.0.tar.gz.

File metadata

  • Download URL: tottie-0.6.0.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tottie-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4931fa75c3bc5aa5d53c53c7ab1416697c66b83af68c3acc6cd9d56f5a7599dd
MD5 33216ae4b2f7b42de961b2f31e317a05
BLAKE2b-256 319894344524dd0eaada625bf32a00835b366a90f365c2f9b65de26f3b877cae

See more details on using hashes here.

Provenance

The following attestation bundles were made for tottie-0.6.0.tar.gz:

Publisher: release.yml on d0ugal/tottie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tottie-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: tottie-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tottie-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ade5e4acbe9c15d269faca0664629d7d67b05aed56a43dc9c45491a91207c01
MD5 36d83b5ddd01305cb7cf00dea9004d0c
BLAKE2b-256 ae5302d63bd2d63ac1e94f142cd7ecacdaafc751576c6065058325d7947f5b47

See more details on using hashes here.

Provenance

The following attestation bundles were made for tottie-0.6.0-py3-none-any.whl:

Publisher: release.yml on d0ugal/tottie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page