bri percentage int overflow fixed

pre alexa integration
This commit is contained in:
cschwinne 2017-02-21 23:13:05 +01:00
parent 31a6ddd0b3
commit bdaa8f22b8
4 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,7 @@
captive portal for ap captive portal for ap
alexa support
ntp bug
bri bug
simple slide transition simple slide transition
additional color picker field additional color picker field
implement HSB slider option implement HSB slider option

View File

@ -37,9 +37,10 @@
* @author Christian Schwinne * @author Christian Schwinne
*/ */
//Hardware-settings (only changeble via code) //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 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 auxDefaultState = 0; //0: input 1: high 2: low
uint8_t auxTriggeredState = 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; uint8_t overlaySpeed = 200;
boolean useGammaCorrectionBri = true; boolean useGammaCorrectionBri = true;
boolean useGammaCorrectionRGB = true; boolean useGammaCorrectionRGB = true;
int arlsOffset = -21; //10: -22 assuming arls52
boolean realtimeEnabled = true;
double transitionResolution = 0.011; double transitionResolution = 0.011;
@ -123,7 +126,7 @@ int nightlightDelayMs;
uint8_t effectCurrent = 0; uint8_t effectCurrent = 0;
uint8_t effectSpeed = 75; uint8_t effectSpeed = 75;
boolean udpConnected = false; boolean udpConnected = false;
byte udpIn[LEDCOUNT*4+2]; byte udpIn[MAXDIRECT*4+2];
//NTP stuff //NTP stuff
boolean ntpConnected = false; boolean ntpConnected = false;
unsigned int ntpLocalPort = 2390; unsigned int ntpLocalPort = 2390;

View File

@ -62,7 +62,7 @@ void handleNotifications()
bri = udpIn[2]; bri = udpIn[2];
colorUpdated(3); colorUpdated(3);
} }
} else if (udpIn[0] == 1) //warls } else if (udpIn[0] == 1 && realtimeEnabled) //warls
{ {
if (packetSize > 1) { if (packetSize > 1) {
if (udpIn[1] == 0) if (udpIn[1] == 0)
@ -78,10 +78,10 @@ void handleNotifications()
} }
for (int i = 2; i < packetSize -3; i += 4) for (int i = 2; i < packetSize -3; i += 4)
{ {
if (udpIn[i] < LEDCOUNT) if (udpIn[i] + arlsOffset < LEDCOUNT && udpIn[i] + arlsOffset >= 0)
if (useGammaCorrectionRGB) 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 { } else {
strip.setIndividual(udpIn[i], ((uint32_t)udpIn[i+1] << 16) | ((uint32_t)udpIn[i+2] << 8) | udpIn[i+3]); strip.setIndividual(udpIn[i], ((uint32_t)udpIn[i+1] << 16) | ((uint32_t)udpIn[i+2] << 8) | udpIn[i+3]);
} }

View File

@ -5,6 +5,7 @@
void setAllLeds() { void setAllLeds() {
double d = bri_t*bri_n; double d = bri_t*bri_n;
int val = d/100; int val = d/100;
if (val > 255) val = 255;
if (useGammaCorrectionBri) if (useGammaCorrectionBri)
{ {
strip.setBrightness(gamma8[val]); strip.setBrightness(gamma8[val]);