/Ws2812b-cgi-rust

A tiny CGI application which to bridge JSON update requests to a WS2812B serial driver

Primary LanguageRust

License BSD-2-Clause License MIT AppVeyor CI

ws2812b-cgi

Welcome to ws2812b-cgi 🎉 This application is a tiny (CGI) application which reads a JSON array with update commands from stdin, translates them into WS2812B driver commands, and sends them to the driver's serial port.

Configuration

Due to configuration limits in a CGI environment, the configuration is set during compilation via the following environment variables:

  • WS2812B_CGI_SERIALDEVICE: The path to the serial device (defaults to /dev/ws2812b.serial)
  • WS2812B_CGI_TIMEOUT: The timeout for a CGI process in seconds, used for the internal watchdog (defaults to 10 seconds)

Example

Change the 0th pixel of the 0th strip to white (RGBW 255,255,255,0):

echo '[{ "strip": 0, "pixel": 0, "rgbw": [255,255,255,0] }]' | ws2812b

Docker

The docker image uses /dev/ws2812b.serial as serial device path - you can simply mount your real device onto this path. Please note, that the docker-compose.yml is an example and must be adapted to your specific setup.