From 05a757ede3390d0c1a93e1bb0864a570e68106df Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 1 Feb 2017 19:25:36 +0100 Subject: [PATCH] Added Gamma correction --- TODO.txt | 10 +++++++++- wled00/data/index.htm | 2 +- wled00/data/settings.htm | 4 ++++ wled00/wled00.ino | 20 ++++++++++++++++++++ wled00/wled01_eeprom.ino | 4 ++++ wled00/wled02_xml.ino | 5 +++++ wled00/wled03_set.ino | 4 +++- wled00/wled07_notify.ino | 7 ++++++- wled00/wled08_led.ino | 14 ++++++++++++-- 9 files changed, 64 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 6771ef9c..c2e46f01 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,7 +9,14 @@ add preferred colors to settings -> quickly t. UI, button select, use iframe for settings, seperate tabs for wifi and application confg use iframe for all adv. features? /dumpeeprom and /pusheeprom (ota lock!) -aux trigger pin +(aux trigger pin) partially impl. +get NTP working +audioWLED + Broadcast + Less traffic (distr. and scroll proc. on module) + Make webserver accessible while receiving + More modes? + randomizer ir, touch, pin input Automations @@ -36,5 +43,6 @@ toggle notifier var. brightness BUGS +NTP crash (1-48h) static ip disables mdns ? authentification for security relevant areas ([/settings, /reset]) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index d272bd3a..2e9d6120 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -31,7 +31,7 @@ } } // send HTTP request - request.open("GET", "ajax_in/" + strA + strR + strG + strB + nocache, true); + request.open("GET", "win/" + strA + strR + strG + strB + nocache, true); request.send(null); strA = ""; strR = ""; diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index 2961b750..22efc6be 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -38,6 +38,8 @@ document.S_form.CLDFA.value = this.responseXML.getElementsByTagName('cldfa')[0].innerHTML; document.S_form.FXDEF.value = this.responseXML.getElementsByTagName('fxdef')[0].innerHTML; document.S_form.SXDEF.value = this.responseXML.getElementsByTagName('sxdef')[0].innerHTML; + document.S_form.GCBRI.checked = (this.responseXML.getElementsByTagName('gcbri')[0].innerHTML)!=0?true:false; + document.S_form.GCRGB.checked = (this.responseXML.getElementsByTagName('gcrgb')[0].innerHTML)!=0?true:false; document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false; document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false; document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML; @@ -122,6 +124,8 @@ Default effect ID:
Default effect speed:
Ignore and use current color, brightness and effects:
+ Use Gamma correction for brightness:
+ Use Gamma correction for color:
Brightness factor: %

Button setup

On/Off button enabled:
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 5263223f..28f20986 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -92,6 +92,8 @@ boolean nixieClockDisplaySeconds = false; boolean nixieClock12HourFormat = false; boolean overlayReverse = true; uint8_t overlaySpeed = 200; +boolean useGammaCorrectionBri = true; +boolean useGammaCorrectionRGB = true; double transitionResolution = 0.011; @@ -155,6 +157,24 @@ int lastWifiState = 3; long wifiStateChangedTime = 0; #endif +const uint8_t gamma8[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, + 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, + 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, + 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, + 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, + 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, + 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, + 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, + 90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114, + 115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142, + 144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175, + 177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213, + 215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 }; + void down() { bri_t = 0; diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 1a5c1417..5cd0500b 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -88,6 +88,8 @@ void saveSettingsToEEPROM() EEPROM.write(327, ntpEnabled); //328 reserved for timezone setting //329 reserved for dst setting + EEPROM.write(330, useGammaCorrectionBri); + EEPROM.write(331, useGammaCorrectionRGB); EEPROM.commit(); } @@ -179,4 +181,6 @@ void loadSettingsFromEEPROM() effectDefault = EEPROM.read(324); effectCurrent = effectDefault; effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault; ntpEnabled = EEPROM.read(327); + useGammaCorrectionBri = EEPROM.read(330); + useGammaCorrectionRGB = EEPROM.read(331); } diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index c7af90c1..d6d977e0 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -115,6 +115,11 @@ void XML_response_settings() resp = resp + ""; resp = resp + effectSpeedDefault; resp = resp + ""; + resp = resp + ""; + resp = resp + bool2int(useGammaCorrectionBri); + resp = resp + ""; + resp = resp + bool2int(useGammaCorrectionRGB); + resp = resp + ""; resp = resp + ""; resp = resp + bool2int(buttonEnabled); resp = resp + ""; diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 7b51d29e..fb9aeab3 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -138,6 +138,8 @@ void handleSettingsSet() if (i >= 0 && i <= 255) effectSpeedDefault = i; } } + useGammaCorrectionBri = server.hasArg("GCBRI"); + useGammaCorrectionRGB = server.hasArg("GCRGB"); buttonEnabled = server.hasArg("BTNON"); fadeTransition = server.hasArg("TFADE"); if (server.hasArg("TDLAY")) @@ -194,7 +196,7 @@ void handleSettingsSet() boolean handleSet(String req) { boolean effectUpdated = false; - if (!(req.indexOf("ajax_in") >= 0)) { + if (!(req.indexOf("win") >= 0)) { if (req.indexOf("get-settings") >= 0) { XML_response_settings(); diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index adf1fcf1..28e3d752 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -75,7 +75,12 @@ void handleNotifications() for (int i = 2; i < packetSize -3; i += 4) { if (udpIn[i] < LEDCOUNT) - strip.setIndividual(udpIn[i], ((uint32_t)udpIn[i+1] << 16) | ((uint32_t)udpIn[i+2] << 8) | udpIn[i+3]); + if (useGammaCorrectionRGB) + { + strip.setIndividual(udpIn[i], ((uint32_t)gamma8[udpIn[i+1]] << 16) | ((uint32_t)gamma8[udpIn[i+2]] << 8) | gamma8[udpIn[i+3]]); + } else { + strip.setIndividual(udpIn[i], ((uint32_t)udpIn[i+1] << 16) | ((uint32_t)udpIn[i+2] << 8) | udpIn[i+3]); + } } } } diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index 54e08126..faabc1ce 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -5,8 +5,18 @@ void setAllLeds() { double d = bri_t*bri_n; int val = d/100; - strip.setBrightness(val); - strip.setColor(col_t[0], col_t[1], col_t[2]); + if (useGammaCorrectionBri) + { + strip.setBrightness(gamma8[val]); + } else { + strip.setBrightness(val); + } + if (useGammaCorrectionBri) + { + strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]]); + } else { + strip.setColor(col_t[0], col_t[1], col_t[2]); + } } void setLedsStandard()