Skip to content

Simple RESTful HTTP API to control WS2801 LED stripes

Notifications You must be signed in to change notification settings

j4velin/led_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LEDserver

A simple RESTful HTTP API to control WS2801 LED stripes. Additional "effects" can be added by placing an effect_<name>.py file in the same folder (see effect_snake.py for an example)

Install

  • sudo raspi-config -> Interface options -> SPI -> Enable
  • sudo apt-get install python-pip -y
  • sudo pip install adafruit-ws2801
  • sudo pip install flask
  • python led_server.py &

Usage

  • GET on http://<ip>:5000/leds shows the state (e.g. color) of all LEDs
  • GET on http://<ip>:5000/leds/<id> shows the state (e.g. color) of a specific LED
  • POST on .../leds lets you change the color of all LEDs:
    • MimeType: application/json
    • Example body (sets LED#1 to red, LED#2 to green):
      [
         [ 255, 0, 0 ],
         [ 0, 255, 0 ]
      ]
  • POST on .../leds/<id> lets you change the color of a specific LED:
    • MimeType: application/json
    • Example body (sets the LED to blue):
      [ 0, 0, 255 ]
  • POST on .../effect/<name> triggers the effect effect_<name>.py:
    • MimeType: application/json
    • body depends on the effect, example for the snake effect (POST on .../effect/snake):
      {
           "color": [255, 0, 0],
           "delay": 0.1,
           "length": 5
      }

About

Simple RESTful HTTP API to control WS2801 LED stripes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages