Giter Site home page Giter Site logo

rpi-rgb-api's Introduction

RGB API

A simple asynchronous RESTful API used to control a ws2812b LED strip connected to a Raspberry Pi

Written in Python using Sanic async web framework

LEDs are wired in the below configuration

Starting the API

Requires Python >= 3.7

  1. Clone rpi-rgb-api

git clone https://github.com/evansloan/rpi-rgb-api && cd rpi-rgb-api

  1. Install requirements

pip install -r requirements.txt

  1. Run web server

sudo python app.py

Using the API

Now that the server is running, endpoints can be accessed at <RASPBERRY_PI_IP>:8000/

Available endpoints are located in src/routes/api.py

To set the LEDs to a static color:

curl -H "Content-Type: application/json" -d '{"color": [0,255,0]}' http://192.168.10.164:8000/color

Request body params:

color: Array containing RGB values for the desired color

Apply an effect to the LEDs:

Available effects are located in src/effects.py

curl -H "Content-Type: application/json" \
-d '{"effect": "flash", "color": [0,255,0]}, "duration": 10, "speed": 0.3}' \
http://192.168.10.164:8000/effect

Request body params:

effect: The name of the effect

color: Array containing RGB values for the desired color

duration: The duration of the effect in seconds (set to 0 for infinite duration)

speed: The speed of the effect in seconds

rpi-rgb-api's People

Contributors

evansloan avatar

Watchers

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