GithubHelp home page GithubHelp logo

roaldarbol / belay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brianpugh/belay

0.0 1.0 0.0 788 KB

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

License: Apache License 2.0

Python 99.41% Makefile 0.23% Dockerfile 0.36%

belay's Introduction

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.

belay's People

Contributors

brianpugh avatar dependabot[bot] avatar freemansoft avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.