Handles various message types for the Brilliant Labs Frame
Project description
Frame Message Package
A Python package for handling rich application-level messages for the Brilliant Labs Frame, including sprites, text, audio, IMU data, and photos.
Installation
pip install frame-msg
Usage
import asyncio
from pathlib import Path
from frame_msg import FrameMsg, TxSprite
async def main():
"""
Displays sample images on the Frame display.
The images are indexed (palette) PNG images, in 2, 4, and 16 colors (that is, 1-, 2- and 4-bits-per-pixel).
"""
frame = FrameMsg()
try:
await frame.connect()
# Let the user know we're starting
await frame.print_short_text('Loading...')
# send the std lua files to Frame that handle data accumulation and sprite parsing
await frame.upload_stdlua_libs(lib_names=['data', 'sprite'])
# Send the main lua application from this project to Frame that will run the app
await frame.upload_frame_app(local_filename="lua/sprite_frame_app.lua")
# attach the print response handler so we can see stdout from Frame Lua print() statements
frame.attach_print_response_handler()
# "require" the main frame_app lua file to run it, and block until it has started.
await frame.start_frame_app()
# send the 1-bit image to Frame in chunks
sprite = TxSprite.from_indexed_png_bytes(Path("images/logo_1bit.png").read_bytes())
await frame.send_message(0x20, sprite.pack())
# send a 2-bit image
sprite = TxSprite.from_indexed_png_bytes(Path("images/street_2bit.png").read_bytes())
await frame.send_message(0x20, sprite.pack())
# send a 4-bit image
sprite = TxSprite.from_indexed_png_bytes(Path("images/hotdog_4bit.png").read_bytes())
await frame.send_message(0x20, sprite.pack())
await asyncio.sleep(5.0)
# unhook the print handler
frame.detach_print_response_handler()
# break out of the frame app loop and reboot Frame
await frame.stop_frame_app()
except Exception as e:
print(f"An error occurred: {e}")
finally:
# clean disconnection
await frame.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Acknowledgements
- An early port of TxSprite from Flutter to Python was contributed by David Khachatryan - thanks!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
frame_msg-5.0.2.tar.gz
(23.5 kB
view details)
Built Distribution
frame_msg-5.0.2-py3-none-any.whl
(38.6 kB
view details)
File details
Details for the file frame_msg-5.0.2.tar.gz
.
File metadata
- Download URL: frame_msg-5.0.2.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0edd89b8ffb04fa8e6c432ce67fdf1616096578e4c0a51a90091b1cff105c13 |
|
MD5 | 163a847561f9ae1e42271f617cfc3ee6 |
|
BLAKE2b-256 | 7a80db86d21ac58c77305e239efef7b2b50c40c1665c772d1f37476e0f8b4160 |
File details
Details for the file frame_msg-5.0.2-py3-none-any.whl
.
File metadata
- Download URL: frame_msg-5.0.2-py3-none-any.whl
- Upload date:
- Size: 38.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad64eb87a02797a9be0a98e1472a1cdad7ad8bfa484f67b391303b43147fbcb0 |
|
MD5 | 741d307e8f2aea20dd8560221ce67fdd |
|
BLAKE2b-256 | bc9820373041e60ef47645cd5b99db8290a08239a03a092eee6d59207e1ab668 |