initial pixel tape control
This commit is contained in:
parent
102fa53f8b
commit
e11b8fce9d
@ -26,11 +26,13 @@
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include "sacn.h"
|
||||
#include <ArduinoOSC.h>
|
||||
#include "strobe_esp32.h"
|
||||
|
||||
#include "dmx_universe.h"
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
/*
|
||||
This section to be configured by Lighting Control
|
||||
@ -62,6 +64,8 @@ const String released_value = "99.2";
|
||||
// Configure E1.31 sACN
|
||||
// -----------------------------------
|
||||
const e131_listen_t sACN_mode = E131_UNICAST; // (uni|multi)cast
|
||||
const uint16_t pixel_universe = 1;
|
||||
const uint16_t pixel_address = 001;
|
||||
const uint16_t strobe_universe = 1;
|
||||
const uint16_t strobe_address = 501;
|
||||
|
||||
@ -84,6 +88,9 @@ const uint16_t strobe_address = 501;
|
||||
const int button = A0; // A0, use 100nF to ground
|
||||
const int led = LED_BUILTIN; // IO13
|
||||
|
||||
const uint16_t PixelCount = 8; // not less than 4
|
||||
const uint8_t PixelPin = 21; // make sure to set this to the correct pin
|
||||
NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
/*
|
||||
Change nothing else unless you're really sure.
|
||||
@ -97,6 +104,21 @@ ESPAsyncE131 *e131 = new ESPAsyncE131();
|
||||
bool pressed = false; // track button state
|
||||
uint32_t change_time; // time of button press (ms)
|
||||
|
||||
|
||||
|
||||
void recvPixelData(Universe *universe) {
|
||||
for (int i = 0; i < PixelCount; i++) {
|
||||
uint8_t r, g, b, w;
|
||||
r = universe->data()->data[pixel_address + (i * 4) + 0];
|
||||
g = universe->data()->data[pixel_address + (i * 4) + 1];
|
||||
b = universe->data()->data[pixel_address + (i * 4) + 2];
|
||||
w = universe->data()->data[pixel_address + (i * 4) + 3];
|
||||
strip.SetPixelColor(i, RgbwColor(r, g, b, w));
|
||||
}
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Arduino powerup
|
||||
*/
|
||||
@ -123,16 +145,15 @@ void setup() {
|
||||
Serial.println("STA Failed to configure");
|
||||
}
|
||||
|
||||
|
||||
//// start sACN
|
||||
if (!e131->subscribe(strobe_universe, sACN_mode)) {
|
||||
Serial.println("Failed to start E1.31");
|
||||
} else {
|
||||
if (e131->subscribe(strobe_universe, sACN_mode)) {
|
||||
e131->universe(strobe_universe)->onData(std::bind(&Strobe::recvData,
|
||||
strobe, std::placeholders::_1));
|
||||
Serial.println("Listening for sACN");
|
||||
}
|
||||
|
||||
if (e131->subscribe(pixel_universe, sACN_mode)) {
|
||||
e131->universe(pixel_universe)->onData(std::bind(&recvPixelData,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
//// start fixtures hardware:
|
||||
// button
|
||||
@ -140,6 +161,9 @@ void setup() {
|
||||
if (!strobe->begin(led, 0)) {
|
||||
Serial.println("Strobe failed to configure.");
|
||||
}
|
||||
// pixels
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user