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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file busylib-0.0.1a0.tar.gz.
File metadata
- Download URL: busylib-0.0.1a0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
827fbb6cf66f693d0f0cc52254f0da87605df1870e5572809b8085c6912dcb7d
|
|
| MD5 |
0fba72cb7377c155f71ea693ec41fdf6
|
|
| BLAKE2b-256 |
c6d7be4d743eb1f42086dbdebb2b042bac99688d8343890f28656063eb86d2b4
|
File details
Details for the file busylib-0.0.1a0-py3-none-any.whl.
File metadata
- Download URL: busylib-0.0.1a0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bc8fcb5b7e3503e343d95ac9350d2f73e1b96a89ba98628eacbc9fe38ef085f
|
|
| MD5 |
c2bb80a39d3fa28a7f48b7a8a98181d7
|
|
| BLAKE2b-256 |
251b2ef000b18da2eec704f4a69c36446f71f6e2410fa3c4eeed5220775ad09e
|