• Stars
    star
    236
  • Rank 169,559 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Belay is a python library that enables the rapid development of projects that interact with hardware via a micropython-compatible board.

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 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.

More Repositories

1

cyclopts

Intuitive, easy CLIs based on python type hints.
Python
278
star
2

python-template

Python project and library template for clean, reliable, open-source projects.
Python
257
star
3

game-and-watch-patch

CFW for the Nintendo Game and Watch
C
138
star
4

lox

Threading and Multiprocessing made easy.
Python
90
star
5

autoregistry

Automatic registry design-pattern library for mapping names to functionality.
Python
38
star
6

tamp

Tamp is a low-memory, DEFLATE-inspired lossless compression library.
Python
24
star
7

gnwmanager

C
15
star
8

cookiecutter-esp32-webserver

Cookiecutter template to get you quickly started with an ESP32-based webserver project.
C
13
star
9

cookiecutter-esp-idf-component

Cookiecutter template for an ESP-IDF component
C
5
star
10

pugh_torch

Functions, losses, and module blocks to share between experiments.
Python
4
star
11

micropython-libs

Python
4
star
12

install-micropython

Github Action to install micropython.
JavaScript
4
star
13

python-rai-rpc

Rai_node rpc commands wrapped for python
Python
3
star
14

RaiBlocks-Live-TPS

A simple python script that will display the transactions per second (TPS) of the incoming transactions on a rai_node/rai_wallet.
Python
3
star
15

magnetometer

CLI Magnetometer using a CircuitPython board + Belay
Python
3
star
16

micropython-fnv1a32

Micropython native module for the FNV1a hashing algorithm.
Python
3
star
17

raiblocks-docker

Docker for RaiBlocks
Dockerfile
2
star
18

esp-tamp-demo

C
2
star
19

makerdiary-m60-config

Lightweight repo to be directly used on the 8MB partition of the MakerDiary M60 keyboard
Python
2
star
20

micropython-native-module-template

Template for creating Micropython native module libraries with pre-built binaries
Python
2
star
21

dotfiles

Shell
1
star
22

pytorch-lightning-template

Python
1
star
23

monerod-docker

Dockerfile
1
star
24

esp32_unit_tester

ESP32 Unit Test App for ESP-IDF
C
1
star