From 5d8d12bc89a1e52ac37d4a9bd3c2ee22e3ebc0e9 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 31 May 2018 19:26:16 +0200 Subject: [PATCH] First commit to development branch Added AutoRGBW feature Nightlight turns off if its target brightness is set --- wled00/data/index.htm | 2 +- wled00/data/index_mobile.htm | 407 +++++++++------------------------- wled00/data/settings_leds.htm | Bin 8234 -> 8394 bytes wled00/data/settings_sec.htm | Bin 7708 -> 7708 bytes wled00/htmls00.h | 2 +- wled00/htmls01.h | 4 +- wled00/wled00.ino | 8 +- wled00/wled01_eeprom.ino | 2 + wled00/wled02_xml.ino | 1 + wled00/wled03_set.ino | 3 + wled00/wled08_led.ino | 5 + wled00/wled14_colors.ino | 15 +- 12 files changed, 126 insertions(+), 323 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 300184bf..f7579be1 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -2,7 +2,7 @@ - WLED 0.6.5 + WLED 0.7.0 diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index aee4a37777ecc9b4b91c447a5eb330c8830a5efd..76fb1f8efb76fc2e768b67cc4976681379a50ab8 100644 GIT binary patch delta 104 zcmZ4GaLRGRJ^@chhEj$ShI|HHhGd3Bh8!SS3M3POVyO%Y4CM?N44F`N8bc9KT`o{G sh{2t~2}ox$`m>*a1&s2BZK0 delta 22 dcmbPZGsk8_kQl2OgC2wF`m>*a1(52B-i4 diff --git a/wled00/htmls00.h b/wled00/htmls00.h index 35ceaa5f..3c1b532c 100644 --- a/wled00/htmls00.h +++ b/wled00/htmls00.h @@ -1058,7 +1058,7 @@ const char PAGE_index0[] PROGMEM = R"=====( -WLED 0.6.5 +WLED 0.7.0 )====="; diff --git a/wled00/htmls01.h b/wled00/htmls01.h index 7bc78e64..d87b8a79 100644 --- a/wled00/htmls01.h +++ b/wled00/htmls01.h @@ -93,10 +93,12 @@ Default RGB color:
Default white value (only RGBW):
+Auto-calculate white from RGB instead:
Default brightness: (0-255)
Default effect ID:
Default effect speed:
Default effect intensity:
+Default secondary RGB(W):
@@ -345,7 +347,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
Enable ArduinoOTA:

About

-WLED version 0.6.5

+WLED version 0.7.0

Contributors:
StormPie (Mobile HTML UI)

(c) 2016-2018 Christian Schwinne
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index c16ff171..261cbdf1 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -3,7 +3,7 @@ */ /* * @title WLED project sketch - * @version 0.6.5 + * @version 0.7.0 * @author Christian Schwinne */ @@ -33,8 +33,8 @@ #include "WS2812FX.h" //version in format yymmddb (b = daily build) -#define VERSION 1805222 -const String versionString = "0.6.5"; +#define VERSION 1805311 +const String versionString = "0.7.0"; //AP and OTA default passwords (change them!) String apPass = "wled1234"; @@ -70,7 +70,7 @@ IPAddress staticIP(0, 0, 0, 0); IPAddress staticGateway(0, 0, 0, 0); IPAddress staticSubnet(255, 255, 255, 0); IPAddress staticDNS(8, 8, 8, 8); //only for NTP -bool useHSB = true, useHSBDefault = true, useRGBW = false; +bool useHSB = true, useHSBDefault = true, useRGBW = false, autoRGBtoRGBW = false; bool turnOnAtBoot = true; bool initLedsLast = false; byte bootPreset = 0; diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index acfa1cfd..6755e29f 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -213,6 +213,7 @@ void saveSettingsToEEPROM() EEPROM.write(2200,!receiveDirect); EEPROM.write(2201,enableRealtimeUI); EEPROM.write(2202,uiConfiguration); + EEPROM.write(2203,autoRGBtoRGBW); EEPROM.commit(); } @@ -424,6 +425,7 @@ void loadSettingsFromEEPROM(bool first) receiveDirect = !EEPROM.read(2200); enableRealtimeUI = EEPROM.read(2201); uiConfiguration = EEPROM.read(2202); + autoRGBtoRGBW = EEPROM.read(2203); bootPreset = EEPROM.read(389); wifiLock = EEPROM.read(393); diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 6258f417..e30f4177 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -142,6 +142,7 @@ String getSettings(byte subPage) resp += ds + "CB" + v + colS[2] +";"; resp += ds + "CA" + v + briS +";"; resp += ds + "EW" + c + useRGBW +";"; + resp += ds + "AW" + c + autoRGBtoRGBW +";"; resp += ds + "CW" + v + whiteS +";"; resp += ds + "SR" + v + colSecS[0] +";"; resp += ds + "SG" + v + colSecS[1] +";"; diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 4f6d3965..7a2ccf09 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -122,6 +122,7 @@ void handleSettingsSet(byte subPage) #endif } useRGBW = server.hasArg("EW"); + autoRGBtoRGBW = server.hasArg("AW"); if (server.hasArg("IS")) //ignore settings and save current brightness, colors and fx as default { colS[0] = col[0]; @@ -707,6 +708,8 @@ bool handleSet(String req) } } } + //deactivate nightlight if target brightness is reached + if (bri == nightlightTargetBri) nightlightActive = false; //set time (unix timestamp) pos = req.indexOf("ST="); if (pos > 0) { diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index 4e97d076..f4e83cc9 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -20,6 +20,11 @@ void setAllLeds() { } whiteSecT = whiteSec; } + if (autoRGBtoRGBW) + { + colorRGBtoRGBW(colT,&whiteT); + colorRGBtoRGBW(colSecT,&whiteSecT); + } if (useGammaCorrectionRGB) { strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[whiteT]); diff --git a/wled00/wled14_colors.ino b/wled00/wled14_colors.ino index 533cccc6..6f882299 100644 --- a/wled00/wled14_colors.ino +++ b/wled00/wled14_colors.ino @@ -115,8 +115,6 @@ void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.develo xy[1] = Y / (X + Y + Z); } -/*//For some reason min and max are not declared here - float minf (float v, float w) { if (w > v) return v; @@ -129,11 +127,12 @@ float maxf (float v, float w) return v; } -void colorRGBtoRGBW(byte* rgb, byte* wht) //rgb to rgbw, untested and currently unused +void colorRGBtoRGBW(byte* rgb, byte* wht) //rgb to rgbw (http://codewelt.com/rgbw) { - *wht = (float)minf(rgb[0],minf(rgb[1],rgb[2]))*0.95; - rgb[0]-=wht; - rgb[1]-=wht; - rgb[2]-=wht; -}*/ + float low = minf(rgb[0],minf(rgb[1],rgb[2])); + float high = maxf(rgb[0],maxf(rgb[1],rgb[2])); + if (high < 0.1f) return; + float sat = 255.0f * ((high - low) / high); + *wht = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3); +}