hhromic / e131-node

Node.js client/server library for the E1.31 (sACN) protocol
Apache License 2.0
28 stars 12 forks source link

Connecting to a PixLite MKII #5

Closed ccorcos closed 6 years ago

ccorcos commented 6 years ago

Hey there, I'm trying to figure out how I can use this library to control the LEDs on a PixLite MKII.

http://www.advateklights.com/shop/pixlite-pixel-mapping/50-pixlite-16-mkii-control-board.html

It says it supports sACN E1.31 so I figured this would be the perfect library to use. :)

Perhaps I'm misunderstanding the library, but how to I control a specific LED or set of LEDs using this library?

I ran the demo code, but it doesn't seem to be working.

I've set the static IP address and I have the universe and channel number:

image

image

Now I'm running the code... I'm confused about what the packet is and how to fill the buffer in order to trigger certain LEDs. Furthermore, the controller has server LED banks to choose from on the hardware side and I have no idea where that is specified in this library.

const e131 = require("e131")

// Open Advatek Assistant to connect to the controller and set the static IP
const ipAddress = "192.0.1.52"

var client = new e131.Client(ipAddress) // or use a universe
var packet = client.createPacket(24) // we want 8 RGB (x3) slots
var slotsData = packet.getSlotsData()
packet.setSourceName("test E1.31 client")
packet.setUniverse(0x01) // make universe number consistent with the client
// packet.setOption(packet.Options.PREVIEW, true) // don't really change any fixture
packet.setPriority(packet.DEFAULT_PRIORITY) // not strictly needed, done automatically

// slotsData is a Buffer view, you can use it directly
var color = 0
function cycleColor() {
    for (var idx = 0; idx < slotsData.length; idx++) {
        slotsData[idx] = color % 0xff
        color = color + 90
    }
    client.send(packet, function() {
        setTimeout(cycleColor, 125)
    })
}
cycleColor()

Anyways, I would appreciate any help or suggestions you have :)

ccorcos commented 6 years ago

I figured it out. Just a lot of documentation reading. :)

hhromic commented 6 years ago

Sorry for the long delay on replying on this. I'm glad you could sort it out already. Feel free to submit more questions if you need!

ccorcos commented 6 years ago

Hey @hhromic I have a question for you. I'm driving some WS2811 LEDs with this library and it appears to work, but there are some quirks I've yet to figure out.

Basically, if I send just a single packet, nothing happens. If I send packets at a slow rate, some lights appear, but not all of them and its really glitchy. If I send packets at a fast enough rate, everything appears to work, but there's a lot of wasted performance. If I want to drive 20,000 of these LEDs, ideally there wouldn't be any wasted packets.

For reference, here's my code. Its kind of a mess: https://github.com/ccorcos/rainbow/blob/master/server/led.ts#L343-L387

Basically, I just have a bitmap that I write pixels to, and then I read from the bitmap to send packets. That all happens in the renderTestSweep function and I run that as fast as possible. In the updateLoop I update state of the animation at a slower rate. It just seems like a lot of wasted computation here...

function testSweep() {
    let state = 0
    const updateLoop = async () => {
        while (true) {
            state = (state + 1) % pixelsPerOutput
            // await wait()
            await delay(1 / 30 * 1000)
        }
    }
    const renderLoop = async () => {
        while (true) {
            await renderTestSweep(state)
        }
    }
    updateLoop()
    renderLoop()
}