Skip to main content

Handles various message types for the Brilliant Labs Frame

Project description

Frame Message Package

A Python package for handling various types of 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

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

frame_msg-5.0.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

frame_msg-5.0.0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file frame_msg-5.0.0.tar.gz.

File metadata

  • Download URL: frame_msg-5.0.0.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for frame_msg-5.0.0.tar.gz
Algorithm Hash digest
SHA256 2dafdc1ad95619aac033cd1fe3a7a261ac19a2b4b92d53299d2cf190384fbe46
MD5 bf4fe24117115189f9fb80f5f4ef4430
BLAKE2b-256 123b3c20f2bf3cf18532e2cdd6b18454da0ceb06b893ee9d48ed7adabb647d97

See more details on using hashes here.

File details

Details for the file frame_msg-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: frame_msg-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for frame_msg-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12d99c87ff9adff22594262f41e181003332be127f373558827c4500052c331f
MD5 d3175ce9e39a14ac105c4102704d366e
BLAKE2b-256 2617296cf4fb03766abde26b6a965362d62190c00174a2ff4bb7c5b5c8697810

See more details on using hashes here.

Supported by

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