Skip to content

joaquinariasgomez/GoLEDStrip

Repository files navigation

Servidor Raspberry + Tira de Leds WS281X

Servidor escrito en Golang que permite una comunicación con la tira de Leds WS281X, vía API, de forma que puedas controlar la tira de LEDs con una serie de peticiones http desde cualquier cliente.

Prerrequisitos

Compilar la librería rpi_ws281x directamente en la Raspberry Pi, de acuerdo a la documentación, para luego copiar los ficheros *.a a /usr/local/lib y los ficheros *.h a /usr/local/include.

Documentación de peticiones

Encender las luces

POST /action (Restaura la configuración de la tira de leds y enciende las luces con la animación por defecto)
Body
type command
"startup" {"instruction":"any","args":[]}
Responses
http code content-type response
201 application/json {"type":"startup","command":{"instruction":"any", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Apagar las luces

POST /action (Apaga las luces y las deja en modo ahorro de energía)
Body
type command
"shutdown" {"instruction":"any","args":[]}
Responses
http code content-type response
201 application/json {"type":"shutdown","command":{"instruction":"any", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Subir brillo

POST /action (Sube el brillo de la tira de LEDs un 25%)
Body
type command
"set-brightness" {"instruction":"increase","args":[]}
Responses
http code content-type response
201 application/json {"type":"set-brightness","command":{"instruction":"increase", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Subir brillo cierta cantidad

POST /action (Sube el brillo de la tira de LEDs una cantidad especificada)
Body
type command
"set-brightness" {"instruction":"increase","args":["10"]}
Responses
http code content-type response
201 application/json {"type":"set-brightness","command":{"instruction":"increase", "args":["10"]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Bajar brillo

POST /action (Baja el brillo de la tira de LEDs un 25%)
Body
type command
"set-brightness" {"instruction":"decrease","args":[]}
Responses
http code content-type response
201 application/json {"type":"set-brightness","command":{"instruction":"decrease", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Bajar brillo cierta cantidad

POST /action (Baja el brillo de la tira de LEDs una cantidad especificada)
Body
type command
"set-brightness" {"instruction":"decrease","args":["10"]}
Responses
http code content-type response
201 application/json {"type":"set-brightness","command":{"instruction":"decrease", "args":["10"]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Modo oficina

POST /action (Pone las luces en modo oficina)
Body
type command
"change-mode" {"instruction":"office-lights","args":[]}
Responses
http code content-type response
201 application/json {"type":"change-mode","command":{"instruction":"office-lights", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Modo Arcoiris Bolas

POST /action (Pone las luces en modo arcoiris bolas)
Body
type command
"change-mode" {"instruction":"rainbow balls","args":[]}
Responses
http code content-type response
201 application/json {"type":"change-mode","command":{"instruction":"rainbow balls", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Modo Arcoiris Continuo

POST /action (Pone las luces en modo arcoiris continuo)
Body
type command
"change-mode" {"instruction":"rainbow continuous","args":[]}
Responses
http code content-type response
201 application/json {"type":"change-mode","command":{"instruction":"rainbow continuous", "args":[]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

Modo Color Estático

POST /action (Pone las luces en modo color estático)
Body
type command
"change-mode" {"instruction":"static-color","args":["0xc1e1c1"]}
Responses
http code content-type response
201 application/json {"type":"change-mode","command":{"instruction":"static-color", "args":["0xc1e1c1"]}}
400 application/json Error message
Example cURL
 curl -X POST -H "Content-Type: application/json" --data @post.json http://localhost:8888/action

About

Go Server to control LED strip over a Raspberry Pi 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published