Small adjustments to new DMX options

This commit is contained in:
cschwinne 2020-02-09 19:10:29 +01:00
parent d9a8dac266
commit e8481818c8
8 changed files with 49 additions and 37 deletions

View File

@ -205,14 +205,14 @@ Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>E1.31 (sACN)</i><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>
<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 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="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="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>
Force max brightness: <input type="checkbox" name="FB"><br>
Disable realtime gamma correction: <input type="checkbox" name="RG"><br>

View File

@ -191,8 +191,6 @@ uint16_t DMXAddress; //DMX start address of fixture, a.
uint8_t DMXOldDimmer = 0; //only update brightness on change
uint8_t e131LastSequenceNumber = 0; //to detect packet loss
bool e131Multicast = false; //multicast or unicast
IPAddress e131ClientIP; //E1.31 client IP
String e131ClientUA; //E1.31 client User Agent
bool mqttEnabled = false;
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;
//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);
unsigned long realtimeTimeout = 0;
//mqtt
long lastMqttReconnectAttempt = 0;
long lastInterfaceUpdate = 0;
@ -431,6 +436,7 @@ AsyncMqttClient* mqtt = NULL;
void colorFromUint32(uint32_t,bool=false);
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
void handleE131Packet(e131_packet_t*, IPAddress);
void arlsLock(uint32_t,byte);
void handleOverlayDraw();
#define E131_MAX_UNIVERSE_COUNT 9
@ -531,7 +537,7 @@ void loop() {
yield();
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();
#ifndef WLED_DISABLE_OTA

View File

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

View File

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

View File

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

View File

@ -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++)
{
strip.setPixelColor(i,0,0,0,0);
}
realtimeActive = true;
realtimeMode = md;
}
realtimeTimeout = millis() + timeoutMs;
if (timeoutMs == 255001 || timeoutMs == 65000) realtimeTimeout = UINT32_MAX;
@ -103,8 +103,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
e131LastSequenceNumber = p->sequence_number;
// update status info
e131ClientIP = clientIP;
e131ClientUA = String((char *)p->source_name);
realtimeIP = clientIP;
uint16_t uni = htons(p->universe);
uint8_t previousUniverses = uni - e131Universe;
@ -141,7 +140,6 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
if (DMXOldDimmer != p->property_values[DMXAddress+0]) {
DMXOldDimmer = p->property_values[DMXAddress+0];
bri = p->property_values[DMXAddress+0];
strip.setBrightness(bri);
}
if (p->property_values[DMXAddress+1] < MODE_COUNT)
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[1] = p->property_values[DMXAddress+ 9];
colSec[2] = p->property_values[DMXAddress+10];
fadeTransition = false; // act fast
colorUpdated(5); // don't send UDP
if (dmxChannels-DMXAddress+1 > 11)
{
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
break;
@ -212,7 +215,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
break;
}
arlsLock(realtimeTimeoutMs);
arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131);
e131NewData = true;
}
@ -231,12 +234,10 @@ void handleNotifications()
}
//unlock strip when realtime UDP times out
if (realtimeActive && millis() > realtimeTimeout)
if (realtimeMode && millis() > realtimeTimeout)
{
strip.setBrightness(bri);
realtimeActive = false;
//strip.setMode(effectCurrent);
realtimeIP[0] = 0;
realtimeMode = REALTIME_MODE_INACTIVE;
}
//receive UDP notifications
@ -253,7 +254,7 @@ void handleNotifications()
DEBUG_PRINTLN(rgbUdp.remoteIP());
uint8_t lbuf[packetSize];
rgbUdp.read(lbuf, packetSize);
arlsLock(realtimeTimeoutMs);
arlsLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
uint16_t id = 0;
for (uint16_t i = 0; i < packetSize -2; i += 3)
{
@ -273,7 +274,7 @@ void handleNotifications()
notifierUdp.read(udpIn, packetSize);
//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
if (millis() - notificationSentTime < 1000) return;
@ -340,7 +341,7 @@ void handleNotifications()
realtimeTimeout = 0;
return;
} else {
arlsLock(udpIn[1]*1000 +1);
arlsLock(udpIn[1]*1000 +1, REALTIME_MODE_UDP);
}
if (udpIn[0] == 1) //warls
{

View File

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

View File

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