Skip to main content

No project description provided

Project description

https://raw.githubusercontent.com/BrianPugh/belay/main/assets/logo_white_400w.png

Python compat PyPi GHA Status Coverage Documentation Status

Belay is:

  • A python library that enables the rapid development of projects that interact with hardware via a MicroPython or CircuitPython compatible board.

  • A command-line tool for developing standalone MicroPython projects.

  • A Poetry-inspired MicroPython package manager.

Belay supports wired serial connections (USB) and wireless connections via WebREPL over WiFi.

Quick Video of Belay in 22 seconds.

See the documentation for usage and other details.

Who is Belay For?

Belay is for people creating a software project that needs to interact with hardware. Examples include:

  • Control a motor so a webcam is always pointing at a person.

  • Turn on an LED when you receive a notification.

  • Read a potentiometer to control system volume.

The Belay Package Manager is for people that want to use public libraries, and get them on-device in an easy, repeatable, dependable manner.

What Problems Does Belay Solve?

Typically, having a python script interact with hardware involves 3 major challenges:

  1. On-device firmware (usually C or MicroPython) for directly handling hardware interactions. Typically this is developed, compiled, and uploaded as a (nearly) independent project.

  2. A program on your computer that performs the tasks specified and interacts with the device.

  3. Computer-to-device communication protocol. How are commands and results transferred? How does the device execute those commands?

This is lot of work if you just want your computer to do something simple like turn on an LED. Belay simplifies all of this by merging steps 1 and 2 into the same codebase, and manages step 3 for you. Code is automatically synced at the beginning of script execution.

The Belay Package Manager makes it easy to cache, update, and deploy third party libraries with your project.

Installation

Belay requires Python >=3.8 and can be installed via:

pip install belay

The MicroPython-compatible board only needs MicroPython installed; no additional preparation is required. If using CircuitPython, and additional modification needs to be made to boot.py. See documentation for details.

Examples

Turning on an LED with Belay takes only 6 lines of code. Functions decorated with the task decorator are sent to the device and interpreted by the MicroPython interpreter. Calling the decorated function on-host sends a command to the device to execute the actual function.

import belay

device = belay.Device("/dev/ttyUSB0")


@device.task
def set_led(state):
    print(f"Printing from device; turning LED to {state}.")
    Pin(25, Pin.OUT).value(state)


set_led(True)

Outputs from print calls from on-device user-code are forwarded to host stdout.

For more examples, see the examples folder.

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

belay-0.22.5.tar.gz (50.7 kB view details)

Uploaded Source

Built Distribution

belay-0.22.5-py3-none-any.whl (62.4 kB view details)

Uploaded Python 3

File details

Details for the file belay-0.22.5.tar.gz.

File metadata

  • Download URL: belay-0.22.5.tar.gz
  • Upload date:
  • Size: 50.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.8.0-1015-azure

File hashes

Hashes for belay-0.22.5.tar.gz
Algorithm Hash digest
SHA256 4b9e9ecebb32b91f20ea20f15a29480720859d18a70d1935011200a98673a7fd
MD5 33cbeae96aec949e3983fb446dfa34a0
BLAKE2b-256 d357b6a4fb867bbe8c6979f1cc3c8baa863f9002384ff0c7317098c3fa44ab6e

See more details on using hashes here.

File details

Details for the file belay-0.22.5-py3-none-any.whl.

File metadata

  • Download URL: belay-0.22.5-py3-none-any.whl
  • Upload date:
  • Size: 62.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.8.0-1015-azure

File hashes

Hashes for belay-0.22.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a3578f413e698c7ba5b6f3c3a4ee6f1d7c3b8dbb9733ef3c2edc28756268a0c6
MD5 090d3ae3291f8937328cf50af8880882
BLAKE2b-256 5972c88494a7d2ffb50ee4989a9e9ae90409f0d8f37f3d2f5c3923bc6a87636e

See more details on using hashes here.

Supported by

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