Merge branch 'master' into master-merge

This commit is contained in:
Blaz Kristan 2022-05-29 18:22:33 +02:00
commit e9cd4d95a7
11 changed files with 432 additions and 115 deletions

View File

@ -6,8 +6,30 @@ The mod takes the colors from the first few pixels and sends them to the lights.
## Configuration
First, enter how often the data will be sent to the lights (in ms).
Then enter the IPs for the lights to be controlled, in order. There is currently a limit of 10 devices that can be controled, but that number
- Interval (ms)
- How frequently to update the WiZ lights, in milliseconds.
- Setting too low may causse ESP to become unresponsive.
- Send Delay (ms)
- An optional millisecond delay after updating each WiZ light.
- Can help smooth out effects when using a larger number of WiZ lights
- Use Enhanced White
- Enables using the WiZ lights onboard white LEDs instead of sending maximum RGB values.
- Tunable with warm and cool LEDs as supported by WiZ bulbs
- Note: Only sent when max RGB value is set, need to have automatic brightness limiter disabled
- ToDo: Have better logic for white value mixing to better take advantage of the lights capabilities
- Always Force Update
- Can be enabled to always send update message to light, even when color matches what was previously sent.
- Force update every x minutes
- Configuration option to allow adjusting the default force update timeout of 5 minutes.
- Setting to 0 has the same impact as enabling Always Force Update
-
Then enter the IPs for the lights to be controlled, in order. There is currently a limit of 15 devices that can be controled, but that number
can be easily changed by updating _MAX_WIZ_LIGHTS_.
## Related project
If you use these lights and python, make sure to check out the [pywizlight](https://github.com/sbidy/pywizlight) project. I learned how to
format the messages to control the lights from that project.

View File

@ -4,18 +4,66 @@
#include <WiFiUdp.h>
// Maximum number of lights supported
#define MAX_WIZ_LIGHTS 10
#define MAX_WIZ_LIGHTS 15
// UDP object, to send messages
WiFiUDP UDP;
// Function to send a color to a light
void sendColor(IPAddress ip, uint32_t color) {
class WizLightsUsermod : public Usermod {
private:
unsigned long lastTime = 0;
long updateInterval;
long sendDelay;
long forceUpdateMinutes;
bool forceUpdate;
bool useEnhancedWhite;
long warmWhite;
long coldWhite;
IPAddress lightsIP[MAX_WIZ_LIGHTS]; // Stores Light IP addresses
bool lightsValid[MAX_WIZ_LIGHTS]; // Stores Light IP address validity
uint32_t colorsSent[MAX_WIZ_LIGHTS]; // Stores last color sent for each light
public:
// Send JSON blob to WiZ Light over UDP
// RGB or C/W white
// TODO:
// Better utilize WLED existing white mixing logic
void wizSendColor(IPAddress ip, uint32_t color) {
UDP.beginPacket(ip, 38899);
// If no LED color, turn light off. Note wiz light setting for "Off fade-out" will be applied by the light itself.
if (color == 0) {
UDP.print("{\"method\":\"setPilot\",\"params\":{\"state\":false}}");
// If color is WHITE, try and use the lights WHITE LEDs instead of mixing RGB LEDs
} else if (color == 16777215 && useEnhancedWhite){
// set cold white light only
if (coldWhite > 0 && warmWhite == 0){
UDP.print("{\"method\":\"setPilot\",\"params\":{\"c\":"); UDP.print(coldWhite) ;UDP.print("}}");}
// set warm white light only
if (warmWhite > 0 && coldWhite == 0){
UDP.print("{\"method\":\"setPilot\",\"params\":{\"w\":"); UDP.print(warmWhite) ;UDP.print("}}");}
// set combination of warm and cold white light
if (coldWhite > 0 && warmWhite > 0){
UDP.print("{\"method\":\"setPilot\",\"params\":{\"c\":"); UDP.print(coldWhite) ;UDP.print(",\"w\":"); UDP.print(warmWhite); UDP.print("}}");}
// Send color as RGB
} else {
UDP.print("{\"method\":\"setPilot\",\"params\":{\"state\":true, \"r\":");
UDP.print("{\"method\":\"setPilot\",\"params\":{\"r\":");
UDP.print(R(color));
UDP.print(",\"g\":");
UDP.print(G(color));
@ -23,98 +71,67 @@ void sendColor(IPAddress ip, uint32_t color) {
UDP.print(B(color));
UDP.print("}}");
}
UDP.endPacket();
}
}
// Create label for the usermode page (I cannot make it work with JSON arrays...)
String getJsonLabel(uint8_t i) {
return "ip_light_" + String(i);
}
class WizLightsUsermod : public Usermod {
private:
// Keep track of the last time the lights were updated
unsigned long lastTime = 0;
// Specify how often WLED sends data to the Wiz lights
long updateInterval;
// Save the IP of the lights
IPAddress lightsIP[MAX_WIZ_LIGHTS];
bool lightsValid[MAX_WIZ_LIGHTS];
// Variable that keeps track of RBG values for the lights
uint32_t colorsSent[MAX_WIZ_LIGHTS];
public:
//Functions called by WLED
/*
* loop() is called continuously. Here you can check for events, read sensors, etc.
*/
// TODO: Check millis() rollover
void loop() {
// Calculate how long since the last update
// Make sure we are connected first
if (!WLED_CONNECTED) return;
unsigned long ellapsedTime = millis() - lastTime;
if (ellapsedTime > updateInterval) {
// Keep track of whether we are updating any of the lights
bool update = false;
// Loop through the lights
for (uint8_t i = 0; i < MAX_WIZ_LIGHTS; i++) {
// Check if we have a valid IP
if (!lightsValid[i]) { continue; }
// Get the first colors in the strip
uint32_t new_color = strip.getPixelColor(i);
// Check if the color has changed from the last one sent
// Force an update every 5 minutes, in case the colors don't change
// (the lights could have been reset by turning off and on)
if ((new_color != colorsSent[i]) | (ellapsedTime > 5*60000)) {
// It has changed, send the new color to the light
uint32_t newColor = strip.getPixelColor(i);
if (forceUpdate || (newColor != colorsSent[i]) || (ellapsedTime > forceUpdateMinutes*60000)){
wizSendColor(lightsIP[i], newColor);
colorsSent[i] = newColor;
update = true;
sendColor(lightsIP[i], new_color);
colorsSent[i] = new_color;
delay(sendDelay);
}
}
if (update) lastTime = millis();
}
}
// We sent an update, wait until we do this again
if (update) {
lastTime = millis();
}
}
}
/*
* addToConfig() can be used to add custom persistent settings to the cfg.json file in the "um" (usermod) object.
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
* If you want to force saving the current state, use serializeConfig() in your loop().
*/
void addToConfig(JsonObject& root)
{
JsonObject top = root.createNestedObject("wizLightsUsermod");
top["interval_ms"] = updateInterval;
top["Interval (ms)"] = updateInterval;
top["Send Delay (ms)"] = sendDelay;
top["Use Enhanced White *"] = useEnhancedWhite;
top["* Warm White Value (0-255)"] = warmWhite;
top["* Cold White Value (0-255)"] = coldWhite;
top["Always Force Update"] = forceUpdate;
top["Force Update Every x Minutes"] = forceUpdateMinutes;
for (uint8_t i = 0; i < MAX_WIZ_LIGHTS; i++) {
top[getJsonLabel(i)] = lightsIP[i].toString();
}
}
/*
* readFromConfig() can be used to read back the custom settings you added with addToConfig().
* This is called by WLED when settings are loaded (currently this only happens immediately after boot, or after saving on the Usermod Settings page)
*/
bool readFromConfig(JsonObject& root)
{
// default settings values could be set here (or below using the 3-argument getJsonValue()) instead of in the class definition or constructor
// setting them inside readFromConfig() is slightly more robust, handling the rare but plausible use case of single value being missing after boot (e.g. if the cfg.json was manually edited and a value was removed)
JsonObject top = root["wizLightsUsermod"];
bool configComplete = !top.isNull();
// Read interval to update the lights
configComplete &= getJsonValue(top["interval_ms"], updateInterval, 1000);
configComplete &= getJsonValue(top["Interval (ms)"], updateInterval, 1000); // How frequently to update the wiz lights
configComplete &= getJsonValue(top["Send Delay (ms)"], sendDelay, 0); // Optional delay after sending each UDP message
configComplete &= getJsonValue(top["Use Enhanced White *"], useEnhancedWhite, false); // When color is white use wiz white LEDs instead of mixing RGB
configComplete &= getJsonValue(top["* Warm White Value (0-255)"], warmWhite, 0); // Warm White LED value for Enhanced White
configComplete &= getJsonValue(top["* Cold White Value (0-255)"], coldWhite, 50); // Cold White LED value for Enhanced White
configComplete &= getJsonValue(top["Always Force Update"], forceUpdate, false); // Update wiz light every loop, even if color value has not changed
configComplete &= getJsonValue(top["Force Update Every x Minutes"], forceUpdateMinutes, 5); // Update wiz light if color value has not changed, every x minutes
// Read list of IPs
String tempIp;
@ -123,20 +140,15 @@ class WizLightsUsermod : public Usermod {
lightsValid[i] = lightsIP[i].fromString(tempIp);
// If the IP is not valid, force the value to be empty
if (!lightsValid[i]) {
lightsIP[i].fromString("0.0.0.0");
}
if (!lightsValid[i]){lightsIP[i].fromString("0.0.0.0");}
}
return configComplete;
}
/*
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
* This could be used in the future for the system to determine whether your usermod is installed.
*/
uint16_t getId()
{
return USERMOD_ID_WIZLIGHTS;
}
// Create label for the usermod page (I cannot make it work with JSON arrays...)
String getJsonLabel(uint8_t i) {return "WiZ Light IP #" + String(i+1);}
uint16_t getId(){return USERMOD_ID_WIZLIGHTS;}
};

View File

@ -1,10 +1,13 @@
#include "wled.h"
/*
* Support for DMX via MAX485.
* Change the output pin in src/dependencies/ESPDMX.cpp if needed.
* Library from:
* Support for DMX Output via MAX485.
* Change the output pin in src/dependencies/ESPDMX.cpp, if needed (ESP8266)
* Change the output pin in src/dependencies/SparkFunDMX.cpp, if needed (ESP32)
* ESP8266 Library from:
* https://github.com/Rickgg/ESP-Dmx
* ESP32 Library from:
* https://github.com/sparkfun/SparkFunDMX
*/
#ifdef WLED_ENABLE_DMX
@ -14,10 +17,16 @@ void handleDMX()
// don't act, when in DMX Proxy mode
if (e131ProxyUniverse != 0) return;
// TODO: calculate brightness manually if no shutter channel is set
uint8_t brightness = strip.getBrightness();
bool calc_brightness = true;
// check if no shutter channel is set
for (byte i = 0; i < DMXChannels; i++)
{
if (DMXFixtureMap[i] == 5) calc_brightness = false;
}
uint16_t len = strip.getLengthTotal();
for (int i = DMXStartLED; i < len; i++) { // uses the amount of LEDs as fixture count
@ -35,16 +44,16 @@ void handleDMX()
dmx.write(DMXAddr, 0);
break;
case 1: // Red
dmx.write(DMXAddr, r);
dmx.write(DMXAddr, calc_brightness ? (r * brightness) / 255 : r);
break;
case 2: // Green
dmx.write(DMXAddr, g);
dmx.write(DMXAddr, calc_brightness ? (g * brightness) / 255 : g);
break;
case 3: // Blue
dmx.write(DMXAddr, b);
dmx.write(DMXAddr, calc_brightness ? (b * brightness) / 255 : b);
break;
case 4: // White
dmx.write(DMXAddr, w);
dmx.write(DMXAddr, calc_brightness ? (w * brightness) / 255 : w);
break;
case 5: // Shutter channel. Controls the brightness.
dmx.write(DMXAddr, brightness);
@ -60,7 +69,11 @@ void handleDMX()
}
void initDMX() {
#ifdef ESP8266
dmx.init(512); // initialize with bus length
#else
dmx.initWrite(512); // initialize with bus length
#endif
}
#else

View File

@ -80,7 +80,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
if (stop > start && of > len -1) of = len -1;
strip.setSegment(id, start, stop, grp, spc, of);
byte segbri = 0;
byte segbri = seg.opacity;
if (getVal(elem["bri"], &segbri)) {
if (segbri > 0) seg.setOpacity(segbri, id);
seg.setOption(SEG_OPTION_ON, segbri, id);

View File

@ -11,6 +11,8 @@
// - - - - -
/* ----- LIBRARIES ----- */
#ifdef ESP8266
#include <Arduino.h>
#include "ESPDMX.h"
@ -29,12 +31,12 @@ bool dmxStarted = false;
int sendPin = 2; //dafault on ESP8266
//DMX value array and size. Entry 0 will hold startbyte
uint8_t dmxData[dmxMaxChannel] = {};
int chanSize;
uint8_t dmxDataStore[dmxMaxChannel] = {};
int channelSize;
void DMXESPSerial::init() {
chanSize = defaultMax;
channelSize = defaultMax;
Serial1.begin(DMXSPEED);
pinMode(sendPin, OUTPUT);
@ -48,7 +50,7 @@ void DMXESPSerial::init(int chanQuant) {
chanQuant = defaultMax;
}
chanSize = chanQuant;
channelSize = chanQuant;
Serial1.begin(DMXSPEED);
pinMode(sendPin, OUTPUT);
@ -61,7 +63,7 @@ uint8_t DMXESPSerial::read(int Channel) {
if (Channel < 1) Channel = 1;
if (Channel > dmxMaxChannel) Channel = dmxMaxChannel;
return(dmxData[Channel]);
return(dmxDataStore[Channel]);
}
// Function to send DMX data
@ -69,15 +71,15 @@ void DMXESPSerial::write(int Channel, uint8_t value) {
if (dmxStarted == false) init();
if (Channel < 1) Channel = 1;
if (Channel > chanSize) Channel = chanSize;
if (Channel > channelSize) Channel = channelSize;
if (value < 0) value = 0;
if (value > 255) value = 255;
dmxData[Channel] = value;
dmxDataStore[Channel] = value;
}
void DMXESPSerial::end() {
chanSize = 0;
channelSize = 0;
Serial1.end();
dmxStarted = false;
}
@ -96,10 +98,12 @@ void DMXESPSerial::update() {
//send data
Serial1.begin(DMXSPEED, DMXFORMAT);
digitalWrite(sendPin, LOW);
Serial1.write(dmxData, chanSize);
Serial1.write(dmxDataStore, channelSize);
Serial1.flush();
delay(1);
Serial1.end();
}
// Function to update the DMX bus
#endif

View File

@ -0,0 +1,55 @@
SparkFun License Information
============================
SparkFun uses two different licenses for our files — one for hardware and one for code.
Hardware
---------
**SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**
Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode).
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
Code
--------
**SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).**
The MIT License (MIT)
Copyright (c) 2016 SparkFun Electronics
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,160 @@
/******************************************************************************
SparkFunDMX.h
Arduino Library for the SparkFun ESP32 LED to DMX Shield
Andy England @ SparkFun Electronics
7/22/2019
Development environment specifics:
Arduino IDE 1.6.4
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
Please review the LICENSE.md file included with this example. If you have any questions
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/
/* ----- LIBRARIES ----- */
#ifdef ESP32
#include <Arduino.h>
#include "SparkFunDMX.h"
#include <HardwareSerial.h>
#define dmxMaxChannel 512
#define defaultMax 32
#define DMXSPEED 250000
#define DMXFORMAT SERIAL_8N2
#define BREAKSPEED 83333
#define BREAKFORMAT SERIAL_8N1
int enablePin = -1; // disable the enable pin because it is not needed
int rxPin = -1; // disable the receiving pin because it is not needed
int txPin = 2; // transmit DMX data over this pin (default is pin 2)
//DMX value array and size. Entry 0 will hold startbyte
uint8_t dmxData[dmxMaxChannel] = {};
int chanSize;
int currentChannel = 0;
HardwareSerial DMXSerial(2);
/* Interrupt Timer for DMX Receive */
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
volatile int _interruptCounter;
volatile bool _startCodeDetected = false;
/* Start Code is detected by 21 low interrupts */
void IRAM_ATTR onTimer() {
if (digitalRead(rxPin) == 1)
{
_interruptCounter = 0; //If the RX Pin is high, we are not in an interrupt
}
else
{
_interruptCounter++;
}
if (_interruptCounter > 9)
{
portENTER_CRITICAL_ISR(&timerMux);
_startCodeDetected = true;
DMXSerial.begin(DMXSPEED, DMXFORMAT, rxPin, txPin);
portEXIT_CRITICAL_ISR(&timerMux);
_interruptCounter = 0;
}
}
void SparkFunDMX::initRead(int chanQuant) {
timer = timerBegin(0, 1, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 320, true);
timerAlarmEnable(timer);
_READWRITE = _READ;
if (chanQuant > dmxMaxChannel || chanQuant <= 0)
{
chanQuant = defaultMax;
}
chanSize = chanQuant;
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
pinMode(rxPin, INPUT);
}
// Set up the DMX-Protocol
void SparkFunDMX::initWrite (int chanQuant) {
_READWRITE = _WRITE;
if (chanQuant > dmxMaxChannel || chanQuant <= 0) {
chanQuant = defaultMax;
}
chanSize = chanQuant + 1; //Add 1 for start code
DMXSerial.begin(DMXSPEED, DMXFORMAT, rxPin, txPin);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH);
}
// Function to read DMX data
uint8_t SparkFunDMX::read(int Channel) {
if (Channel > chanSize) Channel = chanSize;
return(dmxData[Channel - 1]); //subtract one to account for start byte
}
// Function to send DMX data
void SparkFunDMX::write(int Channel, uint8_t value) {
if (Channel < 0) Channel = 0;
if (Channel > chanSize) chanSize = Channel;
dmxData[0] = 0;
dmxData[Channel] = value; //add one to account for start byte
}
void SparkFunDMX::update() {
if (_READWRITE == _WRITE)
{
//Send DMX break
digitalWrite(txPin, HIGH);
DMXSerial.begin(BREAKSPEED, BREAKFORMAT, rxPin, txPin);//Begin the Serial port
DMXSerial.write(0);
DMXSerial.flush();
delay(1);
DMXSerial.end();
//Send DMX data
DMXSerial.begin(DMXSPEED, DMXFORMAT, rxPin, txPin);//Begin the Serial port
DMXSerial.write(dmxData, chanSize);
DMXSerial.flush();
DMXSerial.end();//clear our DMX array, end the Hardware Serial port
}
else if (_READWRITE == _READ)//In a perfect world, this function ends serial communication upon packet completion and attaches RX to a CHANGE interrupt so the start code can be read again
{
if (_startCodeDetected == true)
{
while (DMXSerial.available())
{
dmxData[currentChannel++] = DMXSerial.read();
}
if (currentChannel > chanSize) //Set the channel counter back to 0 if we reach the known end size of our packet
{
portENTER_CRITICAL(&timerMux);
_startCodeDetected = false;
DMXSerial.flush();
DMXSerial.end();
portEXIT_CRITICAL(&timerMux);
currentChannel = 0;
}
}
}
}
// Function to update the DMX bus
#endif

View File

@ -0,0 +1,38 @@
/******************************************************************************
SparkFunDMX.h
Arduino Library for the SparkFun ESP32 LED to DMX Shield
Andy England @ SparkFun Electronics
7/22/2019
Development environment specifics:
Arduino IDE 1.6.4
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
Please review the LICENSE.md file included with this example. If you have any questions
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/
#include <inttypes.h>
#ifndef SparkFunDMX_h
#define SparkFunDMX_h
// ---- Methods ----
class SparkFunDMX {
public:
void initRead(int maxChan);
void initWrite(int maxChan);
uint8_t read(int Channel);
void write(int channel, uint8_t value);
void update();
private:
uint8_t _startCodeValue = 0xFF;
bool _READ = true;
bool _WRITE = false;
bool _READWRITE;
};
#endif

View File

@ -327,7 +327,9 @@ void WLED::setup()
sprintf(mqttClientID + 5, "%*s", 6, escapedMac.c_str() + 6);
}
#ifdef WLED_ENABLE_ADALIGHT
if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
#endif
strip.service();
@ -347,7 +349,10 @@ void WLED::setup()
initDMX();
#endif
#ifdef WLED_ENABLE_ADALIGHT
if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
#endif
// HTTP server page init
initServer();

View File

@ -111,7 +111,11 @@
#endif
#ifdef WLED_ENABLE_DMX
#ifdef ESP8266
#include "src/dependencies/dmx/ESPDMX.h"
#else //ESP32
#include "src/dependencies/dmx/SparkFunDMX.h"
#endif
#endif
#include "src/dependencies/e131/ESPAsyncE131.h"
@ -352,7 +356,11 @@ WLED_GLOBAL bool arlsDisableGammaCorrection _INIT(true); // activate if
WLED_GLOBAL bool arlsForceMaxBri _INIT(false); // enable to force max brightness if source has very dark colors that would be black
#ifdef WLED_ENABLE_DMX
WLED_GLOBAL DMXESPSerial dmx;
#ifdef ESP8266
WLED_GLOBAL DMXESPSerial dmx;
#else //ESP32
WLED_GLOBAL SparkFunDMX dmx;
#endif
WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled)
#endif
WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes)

View File

@ -86,8 +86,8 @@ void handleSerial()
Serial.write(0xC9); Serial.write(0xDA);
uint16_t used = strip.getLengthTotal();
uint16_t len = used*3;
Serial.write((len << 8) & 0xFF);
Serial.write( len & 0xFF);
Serial.write(highByte(len));
Serial.write(lowByte(len));
for (uint16_t i=0; i < used; i++) {
uint32_t c = strip.getPixelColor(i);
Serial.write(qadd8(W(c), R(c))); //R, add white channel to RGB channels as a simple RGBW -> RGB map