Browse Source

Switch 4th and 5th channel and rename variables

rfm69
Niklas Wagner 6 years ago
parent
commit
81dcb644b6
6 changed files with 2638 additions and 2639 deletions
  1. +2
    -2
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. +23
    -25
      code/espurna/light.ino
  4. +2605
    -2604
      code/espurna/static/index.html.gz.h
  5. +4
    -4
      code/html/custom.js
  6. +4
    -4
      code/html/index.html

+ 2
- 2
code/espurna/config/general.h View File

@ -782,8 +782,8 @@
// Used when LIGHT_USE_WHITE AND LIGHT_USE_COLD_WHITE is 1 - (1000000/Kelvin = MiReds)
// Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
#define LIGHT_MIRED_W1 500 // Warmwhite Strip, Value must be __ABOVE__ W2!! (Default: 2000 Kelvin/500 MiRed)
#define LIGHT_MIRED_W2 153 // Coldwhite Strip, Value must be __BELOW__ W1!! (Default: 6535 Kelvin/153 MiRed)
#define LIGHT_MIRED_W1 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
#define LIGHT_MIRED_W2 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
#ifndef LIGHT_USE_GAMMA
#define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels


BIN
code/espurna/data/index.html.gz View File


+ 23
- 25
code/espurna/light.ino View File

@ -40,7 +40,7 @@ bool _light_use_transitions = false;
unsigned int _light_transition_time = LIGHT_TRANSITION_TIME;
bool _light_has_color = false;
bool _light_use_white = false;
bool _light_use_cold_white = false;
bool _light_use_cct = false;
bool _light_use_gamma = false;
unsigned long _light_steps_left = 1;
unsigned char _light_brightness = LIGHT_MAX_BRIGHTNESS;
@ -114,15 +114,18 @@ void _generateBrightness() {
}
// Split the White Value across 2 White LED Strips.
if (_light_use_cold_white) {
if (_light_use_cct) {
// This change the range from 153-500 to 0-347 so we get a value between 0 and 1 in the end.
double miredFactor = ((double) _light_mireds - (double) LIGHT_MIRED_W2)/((double) LIGHT_MIRED_W1 - (double) LIGHT_MIRED_W2);
double miredFactor = ((double) _light_mireds - (double) LIGHT_MIRED_W1)/((double) LIGHT_MIRED_W2 - (double) LIGHT_MIRED_W1);
// set warm white
_light_channel[3].inputValue = 0;
_light_channel[3].value = round(miredFactor * white);
_light_channel[3].value = round(((double) 1.0 - miredFactor) * white);
// set cold white
_light_channel[4].inputValue = 0;
_light_channel[4].value = round(((double) 1.0 - (double) miredFactor) * white);
_light_channel[4].value = round(miredFactor * white);
} else {
_light_channel[3].inputValue = 0;
_light_channel[3].value = white;
@ -130,8 +133,8 @@ void _generateBrightness() {
// Scale up to equal input values. So [250,150,50] -> [200,100,0,50] -> [250, 125, 0, 63]
unsigned char max_in = getMax(_light_channel[0].inputValue, _light_channel[1].inputValue, _light_channel[2].inputValue);
unsigned char max_out = getMax(_light_channel[0].value, _light_channel[1].value, _light_channel[2].value, _light_channel[3].value, (_light_use_cold_white ? _light_channel[4].value : 0));
unsigned char channelSize = _light_use_cold_white ? 5 : 4;
unsigned char max_out = getMax(_light_channel[0].value, _light_channel[1].value, _light_channel[2].value, _light_channel[3].value, (_light_use_cct ? _light_channel[4].value : 0));
unsigned char channelSize = _light_use_cct ? 5 : 4;
double factor = (max_out > 0) ? (double) (max_in / max_out) : 0;
for (unsigned char i=0; i < channelSize; i++) {
@ -191,16 +194,10 @@ void _fromRGB(const char * rgb) {
}
break;
case 'M': // Mired Value
if (_light_has_color) {
unsigned long mireds = atol(p + 1);
_fromMireds(mireds);
}
_fromMireds(atol(p + 1));
break;
case 'K': // Kelvin Value
if (_light_has_color) {
unsigned long kelvin = atol(p + 1);
_fromKelvin(kelvin);
}
_fromKelvin(atol(p + 1));
break;
default: // assume decimal values separated by commas
char * tok;
@ -293,15 +290,14 @@ void _fromHSV(const char * hsv) {
// https://github.com/stelgenhof/AiLight
void _fromKelvin(unsigned long kelvin, bool setMireds) {
// Check we have RGB channels
if (!_light_has_color) return;
if (setMireds) {
_light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS);
}
if (_light_has_color && _light_use_cold_white) {
// _setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE);
if (_light_use_cct) {
_setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE);
return;
}
@ -328,10 +324,12 @@ void _fromKelvin(unsigned long kelvin) {
// Color temperature is measured in mireds (kelvin = 1e6/mired)
void _fromMireds(unsigned long mireds) {
if (!_light_has_color) return;
_light_mireds = mireds = constrain(mireds, LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS);
if (_light_has_color && _light_use_cold_white) {
// _setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE);
if (_light_use_cct) {
_setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE);
return;
}
@ -789,7 +787,7 @@ void _lightWebSocketOnSend(JsonObject& root) {
root["mqttGroupColor"] = getSetting("mqttGroupColor");
root["useColor"] = _light_has_color;
root["useWhite"] = _light_use_white;
root["useColdWhite"] = _light_use_cold_white;
root["useCCT"] = _light_use_cct;
root["useGamma"] = _light_use_gamma;
root["useTransitions"] = _light_use_transitions;
root["lightTime"] = _light_transition_time;
@ -1007,10 +1005,10 @@ void _lightConfigure() {
setSetting("useWhite", _light_use_white);
}
_light_use_cold_white = getSetting("useColdWhite", LIGHT_USE_COLD_WHITE).toInt() == 1;
if (_light_use_cold_white && ((_light_channel.size() < 5) || !_light_use_white)) {
_light_use_cold_white = false;
setSetting("useColdWhite", _light_use_cold_white);
_light_use_cct = getSetting("useCCT", LIGHT_USE_COLD_WHITE).toInt() == 1;
if (_light_use_cct && ((_light_channel.size() < 5) || !_light_use_white)) {
_light_use_cct = false;
setSetting("useCCT", _light_use_cct);
}
_light_use_gamma = getSetting("useGamma", LIGHT_USE_GAMMA).toInt() == 1;


+ 2605
- 2604
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 4
- 4
code/html/custom.js View File

@ -13,7 +13,7 @@ var numReconnect = 0;
var numReload = 0;
var useWhite = false;
var useColdWhite = false;
var useCCT = false;
var now = 0;
var ago = 0;
@ -839,7 +839,7 @@ function initChannels(num) {
max = num % 3;
if ((max > 0) & useWhite) {
max--;
if (useColdWhite) {
if (useCCT) {
max--;
}
}
@ -1024,8 +1024,8 @@ function processData(data) {
useWhite = value;
}
if ("useColdWhite" === key) {
useColdWhite = value;
if ("useCCT" === key) {
useCCT = value;
}
// ---------------------------------------------------------------------


+ 4
- 4
code/html/index.html View File

@ -408,15 +408,15 @@
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useWhite" action="reload" tabindex="9" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use forth dimmable channel as (warm) white light calculated out of the RGB values.<br />Will only work if the device has at least 4 dimmable channels.<br />Enabling this will render useless the "Channel 4" slider in the status page.<br />Reload the page to update the web interface.</div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use forth dimmable channel as (cold) white light calculated out of the RGB values.<br />Will only work if the device has at least 4 dimmable channels.<br />Enabling this will render useless the "Channel 4" slider in the status page.<br />Reload the page to update the web interface.</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use cold white channel</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useColdWhite" action="reload" tabindex="10" /></div>
<label class="pure-u-1 pure-u-lg-1-4">Use white color temperature</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useCCT" action="reload" tabindex="10" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use fifth dimmable channel as cold white light.<br />Will only work if the device has at least 5 dimmable channels and "white channel" above is also ON.<br />Enabling this will render useless the "Channel 5" slider in the status page.<br />Reload the page to update the web interface.</div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use fifth dimmable channel as warm white light and the forth dimmable channel as cold white.<br />Will only work if the device has at least 5 dimmable channels and "white channel" above is also ON.<br />Enabling this will render useless the "Channel 5" slider in the status page.<br />Reload the page to update the web interface.</div>
</div>
<div class="pure-g">


Loading…
Cancel
Save