First commit to development branch

Added AutoRGBW feature
Nightlight turns off if its target brightness is set
This commit is contained in:
cschwinne 2018-05-31 19:26:16 +02:00
parent 89b9fd8a45
commit 5d8d12bc89
12 changed files with 126 additions and 323 deletions

View File

@ -2,7 +2,7 @@
<html>
<head><meta charset="utf-8">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/>
<title>WLED 0.6.5</title>
<title>WLED 0.7.0</title>
<script>
var d=document;
var w=window.getComputedStyle(d.querySelector("html"));

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -93,10 +93,12 @@ Default RGB color:
<input name="CG" type="number" min="0" max="255" required>
<input name="CB" type="number" min="0" max="255" required><br>
Default white value (only RGBW): <input name="CW" type="number" min="0" max="255" required><br>
Auto-calculate white from RGB instead: <input type="checkbox" name="AW"><br>
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br>
Default effect ID: <input name="FX" type="number" min="0" max="57" required><br>
Default effect speed: <input name="SX" type="number" min="0" max="255" required><br>
Default effect intensity: <input name="IX" type="number" min="0" max="255" required><br>
Default secondary RGB(W):<br>
<input name="SR" type="number" min="0" max="255" required>
<input name="SG" type="number" min="0" max="255" required>
<input name="SB" type="number" min="0" max="255" required>
@ -345,7 +347,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
<h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.6.5<br><br>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.7.0<br><br>
<b>Contributors:</b><br>
StormPie <i>(Mobile HTML UI)</i><br><br>
(c) 2016-2018 Christian Schwinne <br>

View File

@ -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;

View File

@ -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);

View File

@ -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] +";";

View File

@ -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) {

View File

@ -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]);

View File

@ -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);
}