Small adjustments to new DMX options

pull/665/head
cschwinne 2020-02-09 19:10:29 +01:00
rodzic d9a8dac266
commit e8481818c8
8 zmienionych plików z 49 dodań i 37 usunięć

Wyświetl plik

@ -205,14 +205,14 @@ Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>E1.31 (sACN)</i><br> <i>E1.31 (sACN)</i><br>
Use E1.31 multicast: <input type="checkbox" name="EM"><br> Use E1.31 multicast: <input type="checkbox" name="EM"><br>
E1.31 start universe: <input name="EU" type="number" min="1" max="63999" required><br> E1.31 start universe: <input name="EU" type="number" min="1" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br><br> <i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br>
DMX start address: <input name="DA" type="number" min="1" max="510" value="1" required><br> DMX start address: <input name="DA" type="number" min="1" max="510" value="1" required><br>
DMX mode: <input name="DM" type="radio" value="0"> disabled<br> DMX mode: <input name="DM" type="radio" value="0"> disabled<br>
<input name="DM" type="radio" value="1"> Single RGB (3 Channels for all LEDs: Red Green Blue)<br> <input name="DM" type="radio" value="1"> Single RGB (3 Channels for all LEDs: Red Green Blue)<br>
<input name="DM" type="radio" value="2"> Single DRGB (4 Channels for all LEDs: Dimmer Red Green Blue)<br> <input name="DM" type="radio" value="2"> Single DRGB (4 Channels for all LEDs: Dimmer Red Green Blue)<br>
<input name="DM" type="radio" value="3"> Effect (11 Channels parametrizing Effects: Dimmer Effect Speed Intensity Palette PriRed PriGreen PriBlue SecRed SecGreen SecBlue)<br> <input name="DM" type="radio" value="3"> Effect (11 Channels for properties: Dimmer FX Speed Intensity Palette PriR PriG PriB SecR SecG SecB)<br>
<input name="DM" type="radio" value="4"> Multiple RGB (3 Channels for each LED: Red Green Blue)<br> <input name="DM" type="radio" value="4"> Multiple RGB (3 Channels for each LED: Red Green Blue)<br>
<input name="DM" type="radio" value="5"> Multiple DRGB (1+3 Channels for each LED: Dimmer Red1 Green1 Blue1 Red2 Green2 Blue2...)<br> <input name="DM" type="radio" value="5"> Multiple DRGB (1+3 Channels for each LED: Dimmer R1 G1 B1 R2 G2 B2...)<br><br>
Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br> Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br>
Force max brightness: <input type="checkbox" name="FB"><br> Force max brightness: <input type="checkbox" name="FB"><br>
Disable realtime gamma correction: <input type="checkbox" name="RG"><br> Disable realtime gamma correction: <input type="checkbox" name="RG"><br>

Wyświetl plik

@ -191,8 +191,6 @@ uint16_t DMXAddress; //DMX start address of fixture, a.
uint8_t DMXOldDimmer = 0; //only update brightness on change uint8_t DMXOldDimmer = 0; //only update brightness on change
uint8_t e131LastSequenceNumber = 0; //to detect packet loss uint8_t e131LastSequenceNumber = 0; //to detect packet loss
bool e131Multicast = false; //multicast or unicast bool e131Multicast = false; //multicast or unicast
IPAddress e131ClientIP; //E1.31 client IP
String e131ClientUA; //E1.31 client User Agent
bool mqttEnabled = false; bool mqttEnabled = false;
char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac) char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac)
@ -366,10 +364,17 @@ bool presetApplyBri = false, presetApplyCol = true, presetApplyFx = true;
bool saveCurrPresetCycConf = false; bool saveCurrPresetCycConf = false;
//realtime //realtime
bool realtimeActive = false; #define REALTIME_MODE_INACTIVE 0
#define REALTIME_MODE_GENERIC 1
#define REALTIME_MODE_UDP 2
#define REALTIME_MODE_HYPERION 3
#define REALTIME_MODE_E131 4
#define REALTIME_MODE_ADALIGHT 5
byte realtimeMode = 0;
IPAddress realtimeIP = (0,0,0,0); IPAddress realtimeIP = (0,0,0,0);
unsigned long realtimeTimeout = 0; unsigned long realtimeTimeout = 0;
//mqtt //mqtt
long lastMqttReconnectAttempt = 0; long lastMqttReconnectAttempt = 0;
long lastInterfaceUpdate = 0; long lastInterfaceUpdate = 0;
@ -431,6 +436,7 @@ AsyncMqttClient* mqtt = NULL;
void colorFromUint32(uint32_t,bool=false); void colorFromUint32(uint32_t,bool=false);
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte); void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
void handleE131Packet(e131_packet_t*, IPAddress); void handleE131Packet(e131_packet_t*, IPAddress);
void arlsLock(uint32_t,byte);
void handleOverlayDraw(); void handleOverlayDraw();
#define E131_MAX_UNIVERSE_COUNT 9 #define E131_MAX_UNIVERSE_COUNT 9
@ -531,7 +537,7 @@ void loop() {
yield(); yield();
if (doReboot) reset(); if (doReboot) reset();
if (!realtimeActive) //block stuff if WARLS/Adalight is enabled if (!realtimeMode) //block stuff if WARLS/Adalight is enabled
{ {
if (apActive) dnsServer.processNextRequest(); if (apActive) dnsServer.processNextRequest();
#ifndef WLED_DISABLE_OTA #ifndef WLED_DISABLE_OTA

Wyświetl plik

@ -479,6 +479,9 @@ void loadSettingsFromEEPROM(bool first)
{ {
DMXAddress = EEPROM.read(2197) + ((EEPROM.read(2198) << 8) & 0xFF00); DMXAddress = EEPROM.read(2197) + ((EEPROM.read(2198) << 8) & 0xFF00);
DMXMode = EEPROM.read(2199); DMXMode = EEPROM.read(2199);
} else {
DMXAddress = 1;
DMXMode = DMX_MODE_MULTIPLE_RGB;
} }

Wyświetl plik

@ -58,27 +58,25 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
oappend("</ps><cy>"); oappend("</ps><cy>");
oappendi(presetCyclingEnabled); oappendi(presetCyclingEnabled);
oappend("</cy><ds>"); oappend("</cy><ds>");
if (realtimeActive) if (realtimeMode)
{ {
String mesg = "Live "; String mesg = "Live ";
if (realtimeIP[0] == 0) if (realtimeMode == REALTIME_MODE_E131)
{ {
mesg += "E1.31 mode "; mesg += "E1.31 mode ";
mesg += DMXMode; mesg += DMXMode;
mesg += " at fixture DMX Address "; mesg += " at DMX Address ";
mesg += DMXAddress; mesg += DMXAddress;
mesg += " from '"; mesg += " from ";
mesg += e131ClientUA; mesg += realtimeIP[0];
mesg += "' (";
mesg += e131ClientIP[0];
for (int i = 1; i < 4; i++) for (int i = 1; i < 4; i++)
{ {
mesg += "."; mesg += ".";
mesg += e131ClientIP[i]; mesg += realtimeIP[i];
} }
mesg += ") seq="; mesg += " seq=";
mesg += e131LastSequenceNumber; mesg += e131LastSequenceNumber;
} else { } else if (realtimeMode == REALTIME_MODE_UDP || realtimeMode == REALTIME_MODE_HYPERION) {
mesg += "UDP from "; mesg += "UDP from ";
mesg += realtimeIP[0]; mesg += realtimeIP[0];
for (int i = 1; i < 4; i++) for (int i = 1; i < 4; i++)
@ -86,6 +84,10 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
mesg += "."; mesg += ".";
mesg += realtimeIP[i]; mesg += realtimeIP[i];
} }
} else if (realtimeMode == REALTIME_MODE_ADALIGHT) {
mesg += "USB Adalight";
} else { //generic
mesg += "data";
} }
oappend((char*)mesg.c_str()); oappend((char*)mesg.c_str());
} else { } else {

Wyświetl plik

@ -67,8 +67,8 @@ void handleSerial()
setRealtimePixel(pixel++, red, green, blue, 0); setRealtimePixel(pixel++, red, green, blue, 0);
if (--count > 0) state = AdaState::Data_Red; if (--count > 0) state = AdaState::Data_Red;
else { else {
if (!realtimeActive && bri == 0) strip.setBrightness(briLast); if (!realtimeMode && bri == 0) strip.setBrightness(briLast);
arlsLock(realtimeTimeoutMs); arlsLock(realtimeTimeoutMs, REALTIME_MODE_ADALIGHT);
strip.show(); strip.show();
state = AdaState::Header_A; state = AdaState::Header_A;

Wyświetl plik

@ -72,14 +72,14 @@ void notify(byte callMode, bool followUp=false)
} }
void arlsLock(uint32_t timeoutMs) void arlsLock(uint32_t timeoutMs, byte md = REALTIME_MODE_GENERIC)
{ {
if (!realtimeActive){ if (!realtimeMode){
for (uint16_t i = 0; i < ledCount; i++) for (uint16_t i = 0; i < ledCount; i++)
{ {
strip.setPixelColor(i,0,0,0,0); strip.setPixelColor(i,0,0,0,0);
} }
realtimeActive = true; realtimeMode = md;
} }
realtimeTimeout = millis() + timeoutMs; realtimeTimeout = millis() + timeoutMs;
if (timeoutMs == 255001 || timeoutMs == 65000) realtimeTimeout = UINT32_MAX; if (timeoutMs == 255001 || timeoutMs == 65000) realtimeTimeout = UINT32_MAX;
@ -103,8 +103,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
e131LastSequenceNumber = p->sequence_number; e131LastSequenceNumber = p->sequence_number;
// update status info // update status info
e131ClientIP = clientIP; realtimeIP = clientIP;
e131ClientUA = String((char *)p->source_name);
uint16_t uni = htons(p->universe); uint16_t uni = htons(p->universe);
uint8_t previousUniverses = uni - e131Universe; uint8_t previousUniverses = uni - e131Universe;
@ -141,7 +140,6 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
if (DMXOldDimmer != p->property_values[DMXAddress+0]) { if (DMXOldDimmer != p->property_values[DMXAddress+0]) {
DMXOldDimmer = p->property_values[DMXAddress+0]; DMXOldDimmer = p->property_values[DMXAddress+0];
bri = p->property_values[DMXAddress+0]; bri = p->property_values[DMXAddress+0];
strip.setBrightness(bri);
} }
if (p->property_values[DMXAddress+1] < MODE_COUNT) if (p->property_values[DMXAddress+1] < MODE_COUNT)
effectCurrent = p->property_values[DMXAddress+ 1]; effectCurrent = p->property_values[DMXAddress+ 1];
@ -154,8 +152,13 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
colSec[0] = p->property_values[DMXAddress+ 8]; colSec[0] = p->property_values[DMXAddress+ 8];
colSec[1] = p->property_values[DMXAddress+ 9]; colSec[1] = p->property_values[DMXAddress+ 9];
colSec[2] = p->property_values[DMXAddress+10]; colSec[2] = p->property_values[DMXAddress+10];
fadeTransition = false; // act fast if (dmxChannels-DMXAddress+1 > 11)
colorUpdated(5); // don't send UDP {
col[3] = p->property_values[DMXAddress+11]; //white
colSec[3] = p->property_values[DMXAddress+12];
}
transitionDelayTemp = 0; // act fast
colorUpdated(3); // don't send UDP
return; // don't activate realtime live mode return; // don't activate realtime live mode
break; break;
@ -212,7 +215,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
break; break;
} }
arlsLock(realtimeTimeoutMs); arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131);
e131NewData = true; e131NewData = true;
} }
@ -231,12 +234,10 @@ void handleNotifications()
} }
//unlock strip when realtime UDP times out //unlock strip when realtime UDP times out
if (realtimeActive && millis() > realtimeTimeout) if (realtimeMode && millis() > realtimeTimeout)
{ {
strip.setBrightness(bri); strip.setBrightness(bri);
realtimeActive = false; realtimeMode = REALTIME_MODE_INACTIVE;
//strip.setMode(effectCurrent);
realtimeIP[0] = 0;
} }
//receive UDP notifications //receive UDP notifications
@ -253,7 +254,7 @@ void handleNotifications()
DEBUG_PRINTLN(rgbUdp.remoteIP()); DEBUG_PRINTLN(rgbUdp.remoteIP());
uint8_t lbuf[packetSize]; uint8_t lbuf[packetSize];
rgbUdp.read(lbuf, packetSize); rgbUdp.read(lbuf, packetSize);
arlsLock(realtimeTimeoutMs); arlsLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
uint16_t id = 0; uint16_t id = 0;
for (uint16_t i = 0; i < packetSize -2; i += 3) for (uint16_t i = 0; i < packetSize -2; i += 3)
{ {
@ -273,7 +274,7 @@ void handleNotifications()
notifierUdp.read(udpIn, packetSize); notifierUdp.read(udpIn, packetSize);
//wled notifier, block if realtime packets active //wled notifier, block if realtime packets active
if (udpIn[0] == 0 && !realtimeActive && receiveNotifications) if (udpIn[0] == 0 && !realtimeMode && receiveNotifications)
{ {
//ignore notification if received within a second after sending a notification ourselves //ignore notification if received within a second after sending a notification ourselves
if (millis() - notificationSentTime < 1000) return; if (millis() - notificationSentTime < 1000) return;
@ -340,7 +341,7 @@ void handleNotifications()
realtimeTimeout = 0; realtimeTimeout = 0;
return; return;
} else { } else {
arlsLock(udpIn[1]*1000 +1); arlsLock(udpIn[1]*1000 +1, REALTIME_MODE_UDP);
} }
if (udpIn[0] == 1) //warls if (udpIn[0] == 1) //warls
{ {

Wyświetl plik

@ -33,7 +33,7 @@ void toggleOnOff()
void setAllLeds() { void setAllLeds() {
if (!realtimeActive || !arlsForceMaxBri) if (!realtimeMode || !arlsForceMaxBri)
{ {
double d = briT*briMultiplier; double d = briT*briMultiplier;
int val = d/100; int val = d/100;

Wyświetl plik

@ -255,7 +255,7 @@ void serializeInfo(JsonObject root)
root["name"] = serverDescription; root["name"] = serverDescription;
root["udpport"] = udpPort; root["udpport"] = udpPort;
root["live"] = realtimeActive; root["live"] = (bool)realtimeMode;
root["fxcount"] = strip.getModeCount(); root["fxcount"] = strip.getModeCount();
root["palcount"] = strip.getPaletteCount(); root["palcount"] = strip.getPaletteCount();