Coder Social home page Coder Social logo

virtual-led-server's Introduction

Virtual LED Server

⚠️ DEPRECATED ⚠️

This whole tool is now part of https://github.com/BinaryBrain/Rpi-SK6812-ws2812b-RGBW-http-server


This is an express server that exposes an API to drive virtual RGBW LED strips in your browser.

It can be used as a dummy server for Rpi-SK6812-ws2812b-RGBW-http-server.

Software Install

Run the server with:

npm install
npm start

API

HTTP

Do an HTTP POST with this JSON body:

{
    "colors": [
        { "r": 255, "g": 255, "b": 255, "w": 255 },
        { "r": 255, "g": 0, "b": 0, "w": 0 },
        { "r": 0, "g": 255, "b": 0 },
        { "r": 0, "g": 0, "b": 255 },
        { "r": 0, "g": 0, "b": 0, "w": 255 }
    ]
}

Or this JSON body:

{
    "colors": [
        "FF995522",
        "FF9955",
        "FF995500",
    ]
}

Note that the "white" value is optionnal. It will default to 0. With as many element in the array as your LED strip is. Usually 30, 60 or 120 LED/m.

UDP

The UDP server runs on port 13334 by default.

First byte is header: 0x03 for RGB, 0x04 for RGBW. Rest is payload, each byte is a color value.

For instance:

Head R    G    B    R    G    B   
0x03 0xFF 0x99 0x55 0xFF 0x99 0x55
Head R    G    B    W    R    G    B    W   
0x04 0xFF 0x99 0x55 0x22 0xFF 0x99 0x55 0x22

You can also send a JSON on UDP. If the first character is a curly bracket ({) it will behave like the HTTP API.

{"colors": ["FF9955", "FF9955FF"]}

curl Example

curl -X POST \
  http://<raspberry-ip-address>:13334 \
  -H 'Content-Type: application/json' \
  -d '{ "colors": [{"r": 255, "g": 255, "b": 255, "w": 255}]}'

What we send to ws281x lib

Each line is an UInt32.

RGBW

2^ | 3 2 1 0
i+ | - 0 1 2
---+--------
0  | - r g b
1  | - w r g
2  | - b w r
3  | - g b w
4  | - r g b
5  | - w r g
6  | - b w r
7  | - g b w

GRBW

2^ | 3 2 1 0
i+ | - 0 1 2
---+--------
0  | - g r b
1  | - w g r
2  | - b w g
3  | - r b w
4  | - g r b
5  | - w g r
6  | - b w g
7  | - r b w

virtual-led-server's People

Contributors

binarybrain avatar protectator avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

protectator

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.