Skip to main content

Python library for Busy Bar API

Project description

busylib

A simple and intuitive Python client for interacting with the Busy Bar API. This library allows you to programmatically control the device's display, audio, and assets.

Features

  • Easy-to-use API for all major device functions.
  • Upload and manage assets for your applications.
  • Control the display by drawing text and images.
  • Play and stop audio files.
  • Built-in validation for device IP addresses.

Installation

You can install busylib directly from PyPI:

pip install busylib

Usage

First, import and initialize the BusyBar client with the IP address of your device.

from busylib import BusyBar

try:
    # Default IP is 10.0.4.20, but you can specify your own
    bb = BusyBar("192.168.1.100")
except ValueError as e:
    print(f"Error: {e}")

# Now you can use the bb object to interact with your device.

API Examples

Here are some examples of how to use the library to control your Busy Bar device.

Uploading an Asset

You can upload files (like images or sounds) to be used by your application on the device.

# Upload a file from bytes
with open("path/to/your/image.png", "rb") as f:
    file_bytes = f.read()
    bb.upload_asset(
        app_id="my-app",
        file_name="logo.png",
        file=file_bytes
    )

# Or upload directly from a file-like object
with open("path/to/your/sound.mp3", "rb") as f:
    bb.upload_asset(
        app_id="my-app",
        file_name="notification.mp3",
        file=f
    )

Drawing on the Display

Draw text or images on the device's screen. The draw_display method accepts a list of elements to render.

elements = [
    {
        "type": "text",
        "value": "Hello, World!",
        "x": 10,
        "y": 20,
        "color": "#FFFFFF" # Optional
    },
    {
        "type": "image",
        "path": "logo.png", # Must be uploaded first
        "x": 50,
        "y": 40
    }
]

bb.draw_display(app_id="my-app", elements=elements)

Clearing the Display

To clear everything from the screen:

bb.clear_display()

Playing a Sound

Play an audio file that you have already uploaded.

bb.play_sound(app_id="my-app", path="notification.mp3")

Stopping a Sound

To stop any audio that is currently playing:

bb.stop_sound()

Deleting All Assets for an App

This will remove all files associated with a specific app_id.

bb.delete_assets(app_id="my-app")

Development

To set up a development environment, clone the repository and install the package in editable mode with test dependencies:

git clone https://github.com/busy-app/busylib
cd busylib
python3 -m venv .venv
source .venv/bin/activate
make install-dev

To run the tests:

make test

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

busylib-0.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

busylib-0.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file busylib-0.0.2.tar.gz.

File metadata

  • Download URL: busylib-0.0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for busylib-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a760465ff44a5abf7ae29e7e6f6fc22e97f977d99ef86b52124ef5e3477fd53d
MD5 6494ce83437f444f7a913df0432f3fee
BLAKE2b-256 17c474e43c0da5414872873c5566ddcfbe3eb7fe2e250fc70d7e4744ca303459

See more details on using hashes here.

File details

Details for the file busylib-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: busylib-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for busylib-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3830012842e1ed6e459c86af8b21e0bf60c3419d85cf34a6bda20476798e2ee
MD5 09d0288b2b2e22223749b72f85ad60ea
BLAKE2b-256 48f1a7b6da8116b656a9f50378589612692b41d0017870ee6d4f7dd94ceca102

See more details on using hashes here.

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