Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Aircoookie/WLED
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Feb 9, 2020
2 parents f646e9b + 258def8 commit 867e436
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 36 deletions.
8 changes: 8 additions & 0 deletions wled00/data/settings_sync.htm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ <h3>Realtime</h3>
Multicast mode: <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>
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="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>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br><br>
Timeout: <input name="ET" type="number" min="100" max="65000" required> ms<br>
Force max brightness: <input type="checkbox" name="FB"><br>
Disable realtime gamma correction: <input type="checkbox" name="RG"><br>
Expand Down
9 changes: 8 additions & 1 deletion wled00/html_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +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 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 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>
Expand Down
26 changes: 22 additions & 4 deletions wled00/wled00.ino
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,18 @@ bool receiveDirect = true; //receive UDP realtime
bool arlsDisableGammaCorrection = true; //activate if gamma correction is handled by the source
bool arlsForceMaxBri = false; //enable to force max brightness if source has very dark colors that would be black

uint16_t e131Universe = 1; //settings for E1.31 (sACN) protocol
bool e131Multicast = false;
uint16_t e131Universe = 1; //settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes)
#define DMX_MODE_DISABLED 0 //not used
#define DMX_MODE_SINGLE_RGB 1 //all LEDs same RGB color (3 channels)
#define DMX_MODE_SINGLE_DRGB 2 //all LEDs same RGB color and master dimmer (4 channels)
#define DMX_MODE_EFFECT 3 //trigger standalone effects of WLED (11 channels)
#define DMX_MODE_MULTIPLE_RGB 4 //every LED is addressed with its own RGB (ledCount * 3 channels)
#define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels)
uint8_t DMXMode; //DMX mode (s.a.)
uint16_t DMXAddress; //DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol]
uint8_t DMXOldDimmer = 0; //only update brightness on change
uint8_t e131LastSequenceNumber = 0; //to detect packet loss
bool e131Multicast = false; //multicast or unicast

bool mqttEnabled = false;
char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac)
Expand Down Expand Up @@ -352,10 +362,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;
Expand Down Expand Up @@ -417,6 +434,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
Expand Down Expand Up @@ -517,7 +535,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
Expand Down
16 changes: 15 additions & 1 deletion wled00/wled01_eeprom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define EEPSIZE 2560

//eeprom Version code, enables default settings instead of 0 init on update
#define EEPVER 14
#define EEPVER 15
//0 -> old version, default
//1 -> 0.4p 1711272 and up
//2 -> 0.4p 1711302 and up
Expand All @@ -22,6 +22,7 @@
//12-> 0.8.7-dev
//13-> 0.9.0-dev
//14-> 0.9.0-b1
//15-> 0.9.0-b3

void commit()
{
Expand Down Expand Up @@ -211,6 +212,9 @@ void saveSettingsToEEPROM()
EEPROM.write(2194, (realtimeTimeoutMs >> 8) & 0xFF);
EEPROM.write(2195, arlsForceMaxBri);
EEPROM.write(2196, arlsDisableGammaCorrection);
EEPROM.write(2197, DMXAddress & 0xFF);
EEPROM.write(2198, (DMXAddress >> 8) & 0xFF);
EEPROM.write(2199, DMXMode);

EEPROM.write(2200, !receiveDirect);
EEPROM.write(2201, notifyMacro); //was enableRealtime
Expand Down Expand Up @@ -471,6 +475,16 @@ void loadSettingsFromEEPROM(bool first)
syncToggleReceive = false;
}

if (lastEEPROMversion > 14)
{
DMXAddress = EEPROM.read(2197) + ((EEPROM.read(2198) << 8) & 0xFF00);
DMXMode = EEPROM.read(2199);
} else {
DMXAddress = 1;
DMXMode = DMX_MODE_MULTIPLE_RGB;
}


receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);

Expand Down
26 changes: 22 additions & 4 deletions wled00/wled02_xml.ino
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,36 @@ 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";
} else {
mesg += "E1.31 mode ";
mesg += DMXMode;
mesg += " at DMX Address ";
mesg += DMXAddress;
mesg += " from ";
mesg += realtimeIP[0];
for (int i = 1; i < 4; i++)
{
mesg += ".";
mesg += realtimeIP[i];
}
mesg += " seq=";
mesg += e131LastSequenceNumber;
} else if (realtimeMode == REALTIME_MODE_UDP || realtimeMode == REALTIME_MODE_HYPERION) {
mesg += "UDP from ";
mesg += realtimeIP[0];
for (int i = 1; i < 4; i++)
{
mesg += ".";
mesg += realtimeIP[i];
}
} else if (realtimeMode == REALTIME_MODE_ADALIGHT) {
mesg += "USB Adalight";
} else { //generic
mesg += "data";
}
oappend((char*)mesg.c_str());
} else {
Expand Down Expand Up @@ -263,6 +279,8 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',"RD",receiveDirect);
sappend('c',"EM",e131Multicast);
sappend('v',"EU",e131Universe);
sappend('v',"DA",DMXAddress);
sappend('v',"DM",DMXMode);
sappend('v',"ET",realtimeTimeoutMs);
sappend('c',"FB",arlsForceMaxBri);
sappend('c',"RG",arlsDisableGammaCorrection);
Expand Down
4 changes: 4 additions & 0 deletions wled00/wled03_set.ino
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
e131Multicast = request->hasArg("EM");
t = request->arg("EU").toInt();
if (t > 0 && t <= 63999) e131Universe = t;
t = request->arg("DA").toInt();
if (t > 0 && t <= 510) DMXAddress = t;
t = request->arg("DM").toInt();
if (t >= DMX_MODE_DISABLED && t <= DMX_MODE_MULTIPLE_DRGB) DMXMode = t;
t = request->arg("ET").toInt();
if (t > 99 && t <= 65000) realtimeTimeoutMs = t;
arlsForceMaxBri = request->hasArg("FB");
Expand Down
4 changes: 2 additions & 2 deletions wled00/wled04_file.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 867e436

Please sign in to comment.