From bdaa8f22b85f402b83dacc4b6e7d4ad20dcef64a Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 21 Feb 2017 23:13:05 +0100 Subject: [PATCH] bri percentage int overflow fixed pre alexa integration --- TODO.txt | 3 +++ wled00/wled00.ino | 9 ++++++--- wled00/wled07_notify.ino | 6 +++--- wled00/wled08_led.ino | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 8a33b88a5..5b0da6b8d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,7 @@ captive portal for ap +alexa support +ntp bug +bri bug simple slide transition additional color picker field implement HSB slider option diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 51994b91c..28303aede 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -37,9 +37,10 @@ * @author Christian Schwinne */ //Hardware-settings (only changeble via code) -#define LEDCOUNT 9 +#define LEDCOUNT 11 +#define MAXDIRECT 52 //for direct access like arls, should be >= LEDCOUNT uint8_t buttonPin = 0; //needs pull-up -uint8_t auxPin = 16; //use e.g. for external relay +uint8_t auxPin = 15; //use e.g. for external relay uint8_t auxDefaultState = 0; //0: input 1: high 2: low uint8_t auxTriggeredState = 0; //0: input 1: high 2: low @@ -98,6 +99,8 @@ boolean overlayReverse = true; uint8_t overlaySpeed = 200; boolean useGammaCorrectionBri = true; boolean useGammaCorrectionRGB = true; +int arlsOffset = -21; //10: -22 assuming arls52 +boolean realtimeEnabled = true; double transitionResolution = 0.011; @@ -123,7 +126,7 @@ int nightlightDelayMs; uint8_t effectCurrent = 0; uint8_t effectSpeed = 75; boolean udpConnected = false; -byte udpIn[LEDCOUNT*4+2]; +byte udpIn[MAXDIRECT*4+2]; //NTP stuff boolean ntpConnected = false; unsigned int ntpLocalPort = 2390; diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index 41ddb2eec..f380bc8a1 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -62,7 +62,7 @@ void handleNotifications() bri = udpIn[2]; colorUpdated(3); } - } else if (udpIn[0] == 1) //warls + } else if (udpIn[0] == 1 && realtimeEnabled) //warls { if (packetSize > 1) { if (udpIn[1] == 0) @@ -78,10 +78,10 @@ void handleNotifications() } for (int i = 2; i < packetSize -3; i += 4) { - if (udpIn[i] < LEDCOUNT) + if (udpIn[i] + arlsOffset < LEDCOUNT && udpIn[i] + arlsOffset >= 0) if (useGammaCorrectionRGB) { - strip.setIndividual(udpIn[i], ((uint32_t)gamma8[udpIn[i+1]] << 16) | ((uint32_t)gamma8[udpIn[i+2]] << 8) | gamma8[udpIn[i+3]]); + strip.setIndividual(udpIn[i] + arlsOffset, ((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 702a43bcc..bec79781c 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -5,6 +5,7 @@ void setAllLeds() { double d = bri_t*bri_n; int val = d/100; + if (val > 255) val = 255; if (useGammaCorrectionBri) { strip.setBrightness(gamma8[val]);