Refactored variables for better readability

This commit is contained in:
cschwinne 2018-03-14 13:16:28 +01:00
parent 3ef4a2b9d2
commit c93b185f54
18 changed files with 562 additions and 563 deletions

View File

@ -73,7 +73,7 @@ void WS2812FX::stop() {
strip_off();
}
void WS2812FX::setMode(uint8_t m) {
void WS2812FX::setMode(byte m) {
_counter_mode_call = 0;
_counter_mode_step = 0;
_mode_last_call_time = 0;
@ -83,7 +83,7 @@ void WS2812FX::setMode(uint8_t m) {
strip_off_respectLock();
}
void WS2812FX::setSpeed(uint8_t s) {
void WS2812FX::setSpeed(byte s) {
_counter_mode_call = 0;
_counter_mode_step = 0;
_mode_last_call_time = 0;
@ -91,35 +91,35 @@ void WS2812FX::setSpeed(uint8_t s) {
strip_off_respectLock();
}
void WS2812FX::increaseSpeed(uint8_t s) {
void WS2812FX::increaseSpeed(byte s) {
s = constrain(_speed + s, SPEED_MIN, SPEED_MAX);
setSpeed(s);
}
void WS2812FX::decreaseSpeed(uint8_t s) {
void WS2812FX::decreaseSpeed(byte s) {
s = constrain(_speed - s, SPEED_MIN, SPEED_MAX);
setSpeed(s);
}
void WS2812FX::setIntensity(uint8_t in) {
void WS2812FX::setIntensity(byte in) {
_intensity=in;
}
void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b) {
void WS2812FX::setColor(byte r, byte g, byte b) {
setColor(((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
}
void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
void WS2812FX::setColor(byte r, byte g, byte b, byte w) {
setColor(((uint32_t)w << 24)|((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
}
void WS2812FX::setSecondaryColor(uint8_t r, uint8_t g, uint8_t b) {
void WS2812FX::setSecondaryColor(byte r, byte g, byte b) {
setSecondaryColor(((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
}
void WS2812FX::setSecondaryColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
void WS2812FX::setSecondaryColor(byte r, byte g, byte b, byte w) {
setSecondaryColor(((uint32_t)w << 24)|((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
}
@ -136,33 +136,33 @@ void WS2812FX::setSecondaryColor(uint32_t c) {
setBrightness(_brightness);
}
void WS2812FX::increaseBrightness(uint8_t s) {
void WS2812FX::increaseBrightness(byte s) {
s = constrain(_brightness + s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
setBrightness(s);
}
void WS2812FX::decreaseBrightness(uint8_t s) {
void WS2812FX::decreaseBrightness(byte s) {
s = constrain(_brightness - s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
setBrightness(s);
}
boolean WS2812FX::isRunning() {
bool WS2812FX::isRunning() {
return _running;
}
uint8_t WS2812FX::getMode(void) {
byte WS2812FX::getMode(void) {
return _mode_index;
}
uint8_t WS2812FX::getSpeed(void) {
byte WS2812FX::getSpeed(void) {
return _speed;
}
uint8_t WS2812FX::getBrightness(void) {
byte WS2812FX::getBrightness(void) {
return _brightness;
}
uint8_t WS2812FX::getModeCount(void) {
byte WS2812FX::getModeCount(void) {
return MODE_COUNT;
}
@ -198,7 +198,7 @@ void WS2812FX::strip_off_respectLock() {
* The colours are a transition r -> g -> b -> back to r
* Inspired by the Adafruit examples.
*/
uint32_t WS2812FX::color_wheel(uint8_t pos) {
uint32_t WS2812FX::color_wheel(byte pos) {
pos = 255 - pos;
if(pos < 85) {
return ((uint32_t)(255 - pos * 3) << 16) | ((uint32_t)(0) << 8) | (pos * 3);
@ -215,11 +215,11 @@ uint32_t WS2812FX::color_wheel(uint8_t pos) {
/*
* Returns a new, random wheel index with a minimum distance of 42 from pos.
*/
uint8_t WS2812FX::get_random_wheel_index(uint8_t pos) {
uint8_t r = 0;
uint8_t x = 0;
uint8_t y = 0;
uint8_t d = 0;
byte WS2812FX::get_random_wheel_index(byte pos) {
byte r = 0;
byte x = 0;
byte y = 0;
byte d = 0;
while(d < 42) {
r = random(256);
@ -360,13 +360,13 @@ void WS2812FX::mode_multi_dynamic(void) {
void WS2812FX::mode_breath(void) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // step
uint16_t breath_delay_steps[] = { 7, 9, 13, 15, 16, 17, 18, 930, 19, 18, 15, 13, 9, 7, 4, 5, 10 }; // magic numbers for breathing LED
uint8_t breath_brightness_steps[] = { 150, 125, 100, 75, 50, 25, 16, 15, 16, 25, 50, 75, 100, 125, 150, 220, 255 }; // even more magic numbers!
byte breath_brightness_steps[] = { 150, 125, 100, 75, 50, 25, 16, 15, 16, 25, 50, 75, 100, 125, 150, 220, 255 }; // even more magic numbers!
if(_counter_mode_call == 0) {
_mode_color = breath_brightness_steps[0] + 1;
}
uint8_t breath_brightness = _mode_color; // we use _mode_color to store the brightness
byte breath_brightness = _mode_color; // we use _mode_color to store the brightness
if(_counter_mode_step < 8) {
breath_brightness--;
@ -376,7 +376,7 @@ void WS2812FX::mode_breath(void) {
// update index of current delay when target brightness is reached, start over after the last step
if(breath_brightness == breath_brightness_steps[_counter_mode_step]) {
_counter_mode_step = (_counter_mode_step + 1) % (sizeof(breath_brightness_steps)/sizeof(uint8_t));
_counter_mode_step = (_counter_mode_step + 1) % (sizeof(breath_brightness_steps)/sizeof(byte));
}
for(uint16_t i=0; i < _led_count; i++) {
@ -400,10 +400,10 @@ void WS2812FX::mode_fade(void) {
int y = _counter_mode_step - 127;
y = 256 - (abs(y) * 2);
double z = (double)y/256;
uint8_t w = ((_color >> 24) & 0xFF), ws = ((_color_sec >> 24) & 0xFF);
uint8_t r = ((_color >> 16) & 0xFF), rs = ((_color_sec >> 16) & 0xFF);
uint8_t g = ((_color >> 8) & 0xFF), gs = ((_color_sec >> 8) & 0xFF);
uint8_t b = (_color & 0xFF), bs = (_color_sec & 0xFF);
byte w = ((_color >> 24) & 0xFF), ws = ((_color_sec >> 24) & 0xFF);
byte r = ((_color >> 16) & 0xFF), rs = ((_color_sec >> 16) & 0xFF);
byte g = ((_color >> 8) & 0xFF), gs = ((_color_sec >> 8) & 0xFF);
byte b = (_color & 0xFF), bs = (_color_sec & 0xFF);
w = w+((ws - w)*z);
r = r+((rs - r)*z);
g = g+((gs - g)*z);
@ -506,7 +506,7 @@ void WS2812FX::mode_rainbow_cycle(void) {
* Inspired by the Adafruit examples.
*/
void WS2812FX::mode_theater_chase(void) {
uint8_t j = _counter_mode_call % 6;
byte j = _counter_mode_call % 6;
if(j % 2 == 0) {
for(uint16_t i=0; i < _led_count; i=i+3) {
if (!_locked[i+(j/2)])
@ -529,7 +529,7 @@ void WS2812FX::mode_theater_chase(void) {
* Inspired by the Adafruit examples.
*/
void WS2812FX::mode_theater_chase_rainbow(void) {
uint8_t j = _counter_mode_call % 6;
byte j = _counter_mode_call % 6;
if(j % 2 == 0) {
for(uint16_t i=0; i < _led_count; i=i+3) {
if (!_locked[i+(j/2)])
@ -552,10 +552,10 @@ void WS2812FX::mode_theater_chase_rainbow(void) {
* Running lights effect with smooth sine transition.
*/
void WS2812FX::mode_running_lights(void) {
uint8_t w = ((_color >> 24) & 0xFF);
uint8_t r = ((_color >> 16) & 0xFF);
uint8_t g = ((_color >> 8) & 0xFF);
uint8_t b = (_color & 0xFF);
byte w = ((_color >> 24) & 0xFF);
byte r = ((_color >> 16) & 0xFF);
byte g = ((_color >> 8) & 0xFF);
byte b = (_color & 0xFF);
for(uint16_t i=0; i < _led_count; i++) {
int s = (sin(i+_counter_mode_call) * 127) + 128;
@ -900,8 +900,8 @@ void WS2812FX::mode_chase_rainbow(void) {
* _color_sec flashes running on _color.
*/
void WS2812FX::mode_chase_flash(void) {
const static uint8_t flash_count = 4;
uint8_t flash_step = _counter_mode_call % ((flash_count * 2) + 1);
const static byte flash_count = 4;
byte flash_step = _counter_mode_call % ((flash_count * 2) + 1);
for(uint16_t i=0; i < _led_count; i++) {
if (!_locked[i])
@ -933,8 +933,8 @@ void WS2812FX::mode_chase_flash(void) {
* _color_sec flashes running, followed by random color.
*/
void WS2812FX::mode_chase_flash_random(void) {
const static uint8_t flash_count = 4;
uint8_t flash_step = _counter_mode_call % ((flash_count * 2) + 1);
const static byte flash_count = 4;
byte flash_step = _counter_mode_call % ((flash_count * 2) + 1);
for(uint16_t i=0; i < _counter_mode_step; i++) {
if (!_locked[i])
@ -1606,13 +1606,13 @@ void WS2812FX::mode_cc_core()
for (int i = 0; i < _cc_num1; i++)
{
int num = 0;
num = ((k + i + _counter_cc_step) % _cc_i2) +_cc_i1;
num = ((k + i + _counter_ccStep) % _cc_i2) +_cc_i1;
if (_cc_fs) setPixelColor(num, _color);
if (_cc_fe) setPixelColor(_cc_i2 - num, _color);
}
}
show();
_counter_cc_step = (_counter_cc_step + _cc_step) % (_cc_i2 - _cc_i1);
_counter_ccStep = (_counter_ccStep + _ccStep) % (_cc_i2 - _cc_i1);
_mode_delay = 10 + ((250 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX);
}
@ -1831,7 +1831,7 @@ void WS2812FX::setCronixieBacklight(bool b)
_cronixieBacklightEnabled = b;
}
void WS2812FX::setCronixieDigits(uint8_t d[])
void WS2812FX::setCronixieDigits(byte d[])
{
for (int i = 0; i<6; i++)
{
@ -1839,7 +1839,7 @@ void WS2812FX::setCronixieDigits(uint8_t d[])
}
}
double WS2812FX::getPowerEstimate(uint8_t leds, uint32_t c, uint8_t b)
double WS2812FX::getPowerEstimate(byte leds, uint32_t c, byte b)
{
double _mARequired = 100; //ESP power
double _mul = (double)b/255;
@ -1859,7 +1859,7 @@ double WS2812FX::getPowerEstimate(uint8_t leds, uint32_t c, uint8_t b)
//It is NOT guaranteed to stay within the safeAmps margin.
//Stay safe with high amperage and have a reasonable safety margin!
//I am NOT to be held liable for burned down garages!
double WS2812FX::getSafePowerMultiplier(double safeMilliAmps, uint8_t leds, uint32_t c, uint8_t b)
double WS2812FX::getSafePowerMultiplier(double safeMilliAmps, byte leds, uint32_t c, byte b)
{
double _mARequired = getPowerEstimate(leds,c,b);
if (_mARequired > safeMilliAmps)
@ -1869,72 +1869,72 @@ double WS2812FX::getSafePowerMultiplier(double safeMilliAmps, uint8_t leds, uint
return 1.0;
}
void WS2812FX::setCCIndex1(uint8_t i1)
void WS2812FX::setCCIndex1(byte i1)
{
if (i1 < _led_count-1) _cc_i1 = i1;
if (_cc_i2 <= i1) _cc_i2 = i1+1;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCIndex2(uint8_t i2)
void WS2812FX::setCCIndex2(byte i2)
{
if (i2 > _cc_i1) _cc_i2 = i2;
if (_cc_i2 >= _led_count) _cc_i2 = _led_count-1;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCStart(uint8_t is)
void WS2812FX::setCCStart(byte is)
{
_cc_is = (is < _cc_i1 || is > _cc_i2) ? _cc_i1 : is;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCNum1(uint8_t np)
void WS2812FX::setCCNum1(byte np)
{
_cc_num1 = np;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCNum2(uint8_t ns)
void WS2812FX::setCCNum2(byte ns)
{
_cc_num2 = ns;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCStep(uint8_t stp)
void WS2812FX::setCCStep(byte stp)
{
_cc_step = stp;
_counter_cc_step = 0;
_ccStep = stp;
_counter_ccStep = 0;
}
void WS2812FX::setCCFS(bool fs)
{
_cc_fs = fs;
_cc_fe = (fs) ? _cc_fe : true;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCCFE(bool fe)
{
_cc_fe = fe;
_cc_fs = (fe) ? _cc_fs : true;
_counter_cc_step = 0;
_counter_ccStep = 0;
}
void WS2812FX::setCustomChase(uint8_t i1, uint8_t i2, uint8_t is, uint8_t np, uint8_t ns, uint8_t stp, bool fs, bool fe)
void WS2812FX::setCustomChase(byte i1, byte i2, byte is, byte np, byte ns, byte stp, bool fs, bool fe)
{
setCCIndex1(i1);
setCCIndex2(i2);
setCCStart(is);
_cc_num1 = np;
_cc_num2 = ns;
_cc_step = stp;
_ccStep = stp;
setCCFS(fs);
setCCFE(fe);
}
//Added for quick NeoPixelBus compatibility with Adafruit syntax
void WS2812FX::setPixelColorRaw(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
void WS2812FX::setPixelColorRaw(uint16_t i, byte r, byte g, byte b, byte w)
{
#ifdef RGBW
NeoPixelBrightnessBus::SetPixelColor(i, RgbwColor(r,g,b,w));
@ -1943,7 +1943,7 @@ void WS2812FX::setPixelColorRaw(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uin
#endif
}
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
{
if (_reverseMode) i = _led_count - 1 -i;
if (!_cronixieMode)
@ -1955,13 +1955,13 @@ void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_
#endif
} else {
if(i>6)return;
uint8_t o = 10*i;
byte o = 10*i;
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
{
uint8_t rCorr = (int)(((double)((_color_sec>>16) & 0xFF))*_cronixieSecMultiplier);
uint8_t gCorr = (int)(((double)((_color_sec>>8) & 0xFF))*_cronixieSecMultiplier);
uint8_t bCorr = (int)(((double)((_color_sec) & 0xFF))*_cronixieSecMultiplier);
uint8_t wCorr = (int)(((double)((_color_sec>>24) & 0xFF))*_cronixieSecMultiplier);
byte rCorr = (int)(((double)((_color_sec>>16) & 0xFF))*_cronixieSecMultiplier);
byte gCorr = (int)(((double)((_color_sec>>8) & 0xFF))*_cronixieSecMultiplier);
byte bCorr = (int)(((double)((_color_sec) & 0xFF))*_cronixieSecMultiplier);
byte wCorr = (int)(((double)((_color_sec>>24) & 0xFF))*_cronixieSecMultiplier);
for (int j=o; j< o+19; j++)
{
setPixelColorRaw(j,rCorr,gCorr,bCorr,wCorr);
@ -1990,7 +1990,7 @@ void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_
}
}
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b)
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b)
{
setPixelColor(i,r,g,b,0);
}
@ -2005,7 +2005,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
if (_cronixieMode)
{
if(i>6)return 0;
uint8_t o = 10*i;
byte o = 10*i;
switch(_cronixieDigits[i])
{
case 0: i=o+5; break;
@ -2030,7 +2030,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
#endif
}
void WS2812FX::setBrightness(uint8_t b)
void WS2812FX::setBrightness(byte b)
{
_brightness = constrain(b, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
NeoPixelBrightnessBus::SetBrightness(_brightness);
@ -2065,13 +2065,13 @@ void WS2812FX::begin()
//For some reason min and max are not declared here
uint8_t WS2812FX::minval (uint8_t v, uint8_t w)
byte WS2812FX::minval (byte v, byte w)
{
if (w > v) return v;
return w;
}
uint8_t WS2812FX::maxval (uint8_t v, uint8_t w)
byte WS2812FX::maxval (byte v, byte w)
{
if (w > v) return w;
return v;

View File

@ -208,49 +208,49 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
_cc_i2 = n-1;
_cc_num1 = 5;
_cc_num2 = 5;
_cc_step = 1;
_ccStep = 1;
_counter_mode_call = 0;
_counter_mode_step = 0;
_counter_cc_step = 0;
_counter_ccStep = 0;
_fastStandard = false;
_reverseMode = false;
_locked = new boolean[n];
_cronixieDigits = new uint8_t[6];
_locked = new bool[n];
_cronixieDigits = new byte[6];
}
void
show(void),
setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b),
setPixelColor(uint16_t i, byte r, byte g, byte b),
init(void),
service(void),
start(void),
stop(void),
setMode(uint8_t m),
setCustomChase(uint8_t i1, uint8_t i2, uint8_t is, uint8_t np, uint8_t ns, uint8_t stp, bool fs, bool fe),
setCCIndex1(uint8_t i1),
setCCIndex2(uint8_t i2),
setCCStart(uint8_t is),
setCCNum1(uint8_t np),
setCCNum2(uint8_t ns),
setCCStep(uint8_t stp),
setMode(byte m),
setCustomChase(byte i1, byte i2, byte is, byte np, byte ns, byte stp, bool fs, bool fe),
setCCIndex1(byte i1),
setCCIndex2(byte i2),
setCCStart(byte is),
setCCNum1(byte np),
setCCNum2(byte ns),
setCCStep(byte stp),
setCCFS(bool fs),
setCCFE(bool fe),
setSpeed(uint8_t s),
setIntensity(uint8_t in),
increaseSpeed(uint8_t s),
decreaseSpeed(uint8_t s),
setColor(uint8_t r, uint8_t g, uint8_t b),
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
setSpeed(byte s),
setIntensity(byte in),
increaseSpeed(byte s),
decreaseSpeed(byte s),
setColor(byte r, byte g, byte b),
setColor(byte r, byte g, byte b, byte w),
setColor(uint32_t c),
setSecondaryColor(uint8_t r, uint8_t g, uint8_t b),
setSecondaryColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
setSecondaryColor(byte r, byte g, byte b),
setSecondaryColor(byte r, byte g, byte b, byte w),
setSecondaryColor(uint32_t c),
setBrightness(uint8_t b),
increaseBrightness(uint8_t s),
decreaseBrightness(uint8_t s),
setBrightness(byte b),
increaseBrightness(byte s),
decreaseBrightness(byte s),
setReverseMode(bool b),
driverModeCronixie(bool b),
setCronixieDigits(uint8_t* d),
setCronixieDigits(byte* d),
setCronixieBacklight(bool b),
setIndividual(int i),
setIndividual(int i, uint32_t col),
@ -267,12 +267,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
setLedCount(uint16_t i),
setFade(int sp);
boolean
bool
isRunning(void),
isLocked(int i);
uint8_t
get_random_wheel_index(uint8_t),
byte
get_random_wheel_index(byte),
getMode(void),
getSpeed(void),
getIntensity(void),
@ -280,12 +280,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
getModeCount(void);
uint32_t
color_wheel(uint8_t),
color_wheel(byte),
getColor(void);
double
getPowerEstimate(uint8_t leds, uint32_t c, uint8_t b),
getSafePowerMultiplier(double safeMilliAmps, uint8_t leds, uint32_t c, uint8_t b);
getPowerEstimate(byte leds, uint32_t c, byte b),
getSafePowerMultiplier(double safeMilliAmps, byte leds, uint32_t c, byte b);
private:
@ -293,8 +293,8 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
begin(void),
clear(void),
setPixelColor(uint16_t i, uint32_t c),
setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
setPixelColorRaw(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
setPixelColor(uint16_t i, byte r, byte g, byte b, byte w),
setPixelColorRaw(uint16_t i, byte r, byte g, byte b, byte w),
dofade(void),
strip_off(void),
strip_off_respectLock(void),
@ -359,7 +359,7 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
mode_cc_blink(void),
mode_cc_random(void);
boolean
bool
_triggered,
_fastStandard,
_reverseMode,
@ -369,12 +369,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
_cc_fe,
_running;
boolean*
bool*
_locked;
uint8_t
minval(uint8_t v, uint8_t w),
maxval(uint8_t v, uint8_t w),
byte
minval(byte v, byte w),
maxval(byte v, byte w),
_mode_index,
_speed,
_intensity,
@ -383,10 +383,10 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
_cc_is,
_cc_num1,
_cc_num2,
_cc_step,
_ccStep,
_brightness;
uint8_t*
byte*
_cronixieDigits;
uint16_t
@ -398,7 +398,7 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
_color_sec,
_counter_mode_call,
_counter_mode_step,
_counter_cc_step,
_counter_ccStep,
_mode_color,
_mode_color_sec,
_mode_delay;

File diff suppressed because one or more lines are too long

View File

@ -341,7 +341,7 @@ HTTP traffic is not encrypted. An attacker in the same network could intercept f
<button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
<h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.6.0_dev<br>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.6.0<br>
(c) 2016-2018 Christian Schwinne <br>
<i>Licensed under the MIT license</i><br><br>
<i>Uses libraries:</i><br>

View File

@ -3,7 +3,7 @@
*/
/*
* @title WLED project sketch
* @version 0.6.0_dev
* @version 0.6.0
* @author Christian Schwinne
*/
@ -33,12 +33,12 @@
#include "WS2812FX.h"
//version in format yymmddb (b = daily build)
#define VERSION 1803142
const String versionString = "0.6.0_dev";
#define VERSION 1803143
const String versionString = "0.6.0";
//AP and OTA default passwords (change them!)
String appass = "wled1234";
String otapass = "wledota";
String apPass = "wled1234";
String otaPass = "wledota";
//If you have an RGBW strip, also uncomment first line in WS2812FX.h!
bool useRGBW = false;
@ -51,73 +51,72 @@ bool useRGBW = false;
//Hardware-settings (only changeble via code)
#define LEDCOUNT 255 //maximum, exact count set-able via settings
uint8_t buttonPin = 0; //needs pull-up
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
byte buttonPin = 0; //needs pull-up
byte auxPin = 15; //use e.g. for external relay
byte auxDefaultState = 0; //0: input 1: high 2: low
byte auxTriggeredState = 0; //0: input 1: high 2: low
//Default CONFIG
String serverDescription = versionString;
uint8_t currentTheme = 0;
String clientssid = "Your_Network_Here";
String clientpass = "";
String cmdns = "led";
uint8_t ledcount = 10; //lowered to prevent accidental overcurrent
String apssid = ""; //AP off by default (unless setup)
uint8_t apchannel = 1;
uint8_t aphide = 0;
uint8_t apWaitTimeSecs = 32;
boolean recoveryAPDisabled = false;
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
byte currentTheme = 0;
String clientSSID = "Your_Network";
String clientPass = "";
String cmDNS = "led";
byte ledCount = 10; //lowered to prevent accidental overcurrent
String apSSID = ""; //AP off by default (unless setup)
byte apChannel = 1;
byte apHide = 0;
byte apWaitTimeSecs = 32;
bool recoveryAPDisabled = false;
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 = false, useHSBDefault = false;
bool turnOnAtBoot = true;
uint8_t bootPreset = 0;
byte col_s[]{255, 159, 0};
byte col_sec_s[]{0, 0, 0};
byte white_s = 0;
byte white_sec_s = 0;
byte bri_s = 127;
uint8_t nightlightTargetBri = 0, bri_nl_t;
byte bootPreset = 0;
byte colS[]{255, 159, 0};
byte colSecS[]{0, 0, 0};
byte whiteS = 0;
byte whiteSecS = 0;
byte briS = 127;
byte nightlightTargetBri = 0;
bool fadeTransition = true;
bool sweepTransition = false, sweepDirection = true;
uint16_t transitionDelay = 1200;
bool reverseMode = false;
bool otaLock = false, wifiLock = false;
bool aOtaEnabled = true;
bool onlyAP = false;
bool buttonEnabled = true;
bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false, notifyTwice = false;
bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificationColor = true, receiveNotificationEffects = true;
uint8_t briMultiplier = 100;
uint8_t nightlightDelayMins = 60;
byte briMultiplier = 100;
byte nightlightDelayMins = 60;
bool nightlightFade = true;
uint16_t udpPort = 21324;
uint8_t effectDefault = 0;
uint8_t effectSpeedDefault = 75;
uint8_t effectIntensityDefault = 128;
byte effectDefault = 0;
byte effectSpeedDefault = 75;
byte effectIntensityDefault = 128;
//NTP stuff
boolean ntpEnabled = false;
bool ntpEnabled = false;
IPAddress ntpServerIP;
const char* ntpServerName = "0.wled.pool.ntp.org";
//custom chase
uint8_t cc_numPrimary = 2;
uint8_t cc_numSecondary = 4;
uint8_t cc_index1 = 0;
uint8_t cc_index2 = ledcount -1;
bool cc_fromStart = true, cc_fromEnd = false;
uint8_t cc_step = 1;
uint8_t cc_start = 0;
byte ccNumPrimary = 2;
byte ccNumSecondary = 4;
byte ccIndex1 = 0;
byte ccIndex2 = ledCount -1;
bool ccFromStart = true, ccFromEnd = false;
byte ccStep = 1;
byte ccStart = 0;
//alexa
boolean alexaEnabled = true;
bool alexaEnabled = true;
String alexaInvocationName = "Light";
uint8_t macroBoot = 0, macroNl = 0;
uint8_t macroAlexaOn = 0, macroAlexaOff = 0;
uint8_t macroButton = 0, macroCountdown = 0, macroLongPress = 0;
byte macroBoot = 0, macroNl = 0;
byte macroAlexaOn = 0, macroAlexaOff = 0;
byte macroButton = 0, macroCountdown = 0, macroLongPress = 0;
unsigned long countdownTime = 1514764800L;
@ -129,7 +128,7 @@ bool huePollingEnabled = false, hueAttempt = false;
uint16_t huePollIntervalMs = 2500;
uint32_t huePollIntervalMsTemp = 2500;
String hueApiKey = "api";
uint8_t huePollLightId = 1;
byte huePollLightId = 1;
IPAddress hueIP = (0,0,0,0);
bool notifyHue = true;
bool hueApplyOnOff = true, hueApplyBri = true, hueApplyColor = true;
@ -137,70 +136,71 @@ String hueError = "Inactive";
uint16_t hueFailCount = 0;
float hueXLast=0, hueYLast=0;
uint16_t hueHueLast=0, hueCtLast=0;
uint8_t hueSatLast=0, hueBriLast=0;
byte hueSatLast=0, hueBriLast=0;
//Internal vars
byte col[]{0, 0, 0};
byte col_old[]{0, 0, 0};
byte col_t[]{0, 0, 0};
byte col_it[]{0, 0, 0};
byte col_sec[]{0, 0, 0};
byte col_sec_it[]{0, 0, 0};
byte white, white_old, white_t, white_it;
byte white_sec, white_sec_it;
uint8_t lastRandomIndex = 0;
byte colOld[]{0, 0, 0};
byte colT[]{0, 0, 0};
byte colIT[]{0, 0, 0};
byte colSec[]{0, 0, 0};
byte colSecIT[]{0, 0, 0};
byte white, whiteOld, whiteT, whiteIT;
byte whiteSec, whiteSecIT;
byte lastRandomIndex = 0;
unsigned long transitionStartTime;
unsigned long nightlightStartTime;
float tper_last = 0;
float tperLast = 0;
byte bri = 0;
byte bri_old = 0;
byte bri_t = 0;
byte bri_it = 0;
byte bri_last = 127;
boolean transitionActive = false;
boolean buttonPressedBefore = false;
long buttonPressedTime = 0;
long notificationSentTime = 0;
uint8_t notificationSentCallMode = 0;
byte briOld = 0;
byte briT = 0;
byte briIT = 0;
byte briLast = 127;
bool transitionActive = false;
bool buttonPressedBefore = false;
unsigned long buttonPressedTime = 0;
unsigned long notificationSentTime = 0;
byte notificationSentCallMode = 0;
bool notificationTwoRequired = false;
boolean nightlightActive = false;
boolean nightlightActive_old = false;
int nightlightDelayMs;
uint8_t effectCurrent = 0;
uint8_t effectSpeed = 75;
uint8_t effectIntensity = 128;
boolean udpConnected = false;
byte udpIn[1026];
bool nightlightActive = false;
bool nightlightActiveOld = false;
uint32_t nightlightDelayMs;
byte briNlT;
byte effectCurrent = 0;
byte effectSpeed = 75;
byte effectIntensity = 128;
bool onlyAP = false;
bool udpConnected = false;
String cssCol[]={"","","","","",""};
String cssFont="Verdana";
String cssColorString="";
//NTP stuff
boolean ntpConnected = false;
bool ntpConnected = false;
unsigned int ntpLocalPort = 2390;
const int NTP_PACKET_SIZE = 48;
const uint16_t NTP_PACKET_SIZE = 48;
byte ntpPacketBuffer[NTP_PACKET_SIZE];
unsigned long ntpLastSyncTime = 999000000L;
unsigned long ntpPacketSentTime = 999000000L;
uint8_t currentTimezone = 0;
byte currentTimezone = 0;
time_t local;
int utcOffsetSecs = 0;
//overlay stuff
uint8_t overlayDefault = 0;
uint8_t overlayCurrent = 0;
uint8_t overlayMin = 0, overlayMax = ledcount-1;
uint8_t analogClock12pixel = 0;
boolean analogClockSecondsTrail = false;
boolean analogClock5MinuteMarks = false;
uint8_t overlaySpeed = 200;
long overlayRefreshMs = 200;
byte overlayDefault = 0;
byte overlayCurrent = 0;
byte overlayMin = 0, overlayMax = ledCount-1;
byte analogClock12pixel = 0;
bool analogClockSecondsTrail = false;
bool analogClock5MinuteMarks = false;
byte overlaySpeed = 200;
unsigned long overlayRefreshMs = 200;
unsigned long overlayRefreshedTime;
int overlayArr[6];
uint16_t overlayDur[6];
uint16_t overlayPauseDur[6];
int nixieClockI = -1;
boolean nixiePause;
uint8_t countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000
bool nixiePause;
byte countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000
bool countdownOverTriggered = true;
//cronixie
String cronixieDisplay = "HHMMSS";
@ -210,17 +210,16 @@ bool cronixieBacklight = true;
bool countdownMode = false;
bool cronixieInit = false;
int arlsTimeoutMillis = 2500;
boolean arlsTimeout = false;
long arlsTimeoutTime;
boolean arlsSign = true;
uint8_t auxTime = 0;
uint32_t arlsTimeoutMillis = 2500;
bool arlsTimeout = false;
unsigned long arlsTimeoutTime;
byte auxTime = 0;
unsigned long auxStartTime;
boolean auxActive, auxActiveBefore;
boolean showWelcomePage = false;
bool auxActive, auxActiveBefore;
bool showWelcomePage = false;
boolean useGammaCorrectionBri = false;
boolean useGammaCorrectionRGB = true;
bool useGammaCorrectionBri = false;
bool useGammaCorrectionRGB = true;
int arlsOffset = -22; //10: -22 assuming arls52
//alexa udp
@ -267,7 +266,7 @@ int lastWifiState = 3;
long wifiStateChangedTime = 0;
#endif
const uint8_t gamma8[] = {
const byte 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,
@ -291,7 +290,7 @@ void serveMessage(int,String,String,int=255);
void down()
{
bri_t = 0;
briT = 0;
setAllLeds();
DEBUG_PRINTLN("MODULE TERMINATED");
while (1) {delay(1000);}
@ -299,7 +298,7 @@ void down()
void reset()
{
bri_t = 0;
briT = 0;
setAllLeds();
DEBUG_PRINTLN("MODULE RESET");
ESP.restart();
@ -325,7 +324,7 @@ void loop() {
if (dnsActive) dnsServer.processNextRequest();
handleHue();
handleNightlight();
if (bri_t) strip.service(); //do not update strip if off, prevents flicker on ESP32
if (briT) strip.service(); //do not update strip if off, prevents flicker on ESP32
}
//DEBUG

View File

@ -12,7 +12,7 @@
//2 -> 0.4p 1711302 and up
//3 -> 0.4 1712121 and up
//4 -> 0.5.0 and up
//5 -> 0.6.0_dev and up
//5 -> 0.6.0 and up
//todo add settings
void clearEEPROM()
@ -37,50 +37,50 @@ void saveSettingsToEEPROM()
for (int i = 0; i < 32; ++i)
{
EEPROM.write(i, clientssid.charAt(i));
EEPROM.write(i, clientSSID.charAt(i));
}
for (int i = 32; i < 96; ++i)
{
EEPROM.write(i, clientpass.charAt(i-32));
EEPROM.write(i, clientPass.charAt(i-32));
}
for (int i = 96; i < 128; ++i)
{
EEPROM.write(i, cmdns.charAt(i-96));
EEPROM.write(i, cmDNS.charAt(i-96));
}
for (int i = 128; i < 160; ++i)
{
EEPROM.write(i, apssid.charAt(i-128));
EEPROM.write(i, apSSID.charAt(i-128));
}
for (int i = 160; i < 224; ++i)
{
EEPROM.write(i, appass.charAt(i-160));
EEPROM.write(i, apPass.charAt(i-160));
}
EEPROM.write(224, nightlightDelayMins);
EEPROM.write(225, nightlightFade);
EEPROM.write(226, notifyDirectDefault);
EEPROM.write(227, apchannel);
EEPROM.write(228, aphide);
EEPROM.write(229, ledcount);
EEPROM.write(227, apChannel);
EEPROM.write(228, apHide);
EEPROM.write(229, ledCount);
EEPROM.write(230, notifyButton);
EEPROM.write(231, notifyTwice);
EEPROM.write(232, buttonEnabled);
//233 reserved for first boot flag
EEPROM.write(234, staticip[0]);
EEPROM.write(235, staticip[1]);
EEPROM.write(236, staticip[2]);
EEPROM.write(237, staticip[3]);
EEPROM.write(238, staticgateway[0]);
EEPROM.write(239, staticgateway[1]);
EEPROM.write(240, staticgateway[2]);
EEPROM.write(241, staticgateway[3]);
EEPROM.write(242, staticsubnet[0]);
EEPROM.write(243, staticsubnet[1]);
EEPROM.write(244, staticsubnet[2]);
EEPROM.write(245, staticsubnet[3]);
EEPROM.write(246, col_s[0]);
EEPROM.write(247, col_s[1]);
EEPROM.write(248, col_s[2]);
EEPROM.write(249, bri_s);
EEPROM.write(234, staticIP[0]);
EEPROM.write(235, staticIP[1]);
EEPROM.write(236, staticIP[2]);
EEPROM.write(237, staticIP[3]);
EEPROM.write(238, staticGateway[0]);
EEPROM.write(239, staticGateway[1]);
EEPROM.write(240, staticGateway[2]);
EEPROM.write(241, staticGateway[3]);
EEPROM.write(242, staticSubnet[0]);
EEPROM.write(243, staticSubnet[1]);
EEPROM.write(244, staticSubnet[2]);
EEPROM.write(245, staticSubnet[3]);
EEPROM.write(246, colS[0]);
EEPROM.write(247, colS[1]);
EEPROM.write(248, colS[2]);
EEPROM.write(249, briS);
EEPROM.write(250, receiveNotificationBrightness);
EEPROM.write(251, fadeTransition);
EEPROM.write(252, reverseMode);
@ -90,7 +90,7 @@ void saveSettingsToEEPROM()
//255,250,231,230,226 notifier bytes
for (int i = 256; i < 288; ++i)
{
EEPROM.write(i, otapass.charAt(i-256));
EEPROM.write(i, otaPass.charAt(i-256));
}
EEPROM.write(288, nightlightTargetBri);
EEPROM.write(289, otaLock);
@ -115,28 +115,28 @@ void saveSettingsToEEPROM()
EEPROM.write(i, alexaInvocationName.charAt(i-334));
}
EEPROM.write(366, alexaNotify);
EEPROM.write(367, arlsSign);
EEPROM.write(367, (arlsOffset>=0));
EEPROM.write(368, abs(arlsOffset));
EEPROM.write(369, turnOnAtBoot);
EEPROM.write(370, useHSBDefault);
EEPROM.write(371, white_s);
EEPROM.write(371, whiteS);
EEPROM.write(372, useRGBW);
EEPROM.write(373, sweepTransition);
EEPROM.write(374, sweepDirection);
EEPROM.write(375, apWaitTimeSecs);
EEPROM.write(376, recoveryAPDisabled);
EEPROM.write(377, EEPVER); //eeprom was updated to latest
EEPROM.write(378, col_sec_s[0]);
EEPROM.write(379, col_sec_s[1]);
EEPROM.write(380, col_sec_s[2]);
EEPROM.write(381, white_sec_s);
EEPROM.write(382, cc_index1);
EEPROM.write(383, cc_index2);
EEPROM.write(384, cc_numPrimary);
EEPROM.write(385, cc_numSecondary);
EEPROM.write(386, cc_fromStart);
EEPROM.write(387, cc_fromEnd);
EEPROM.write(388, cc_step);
EEPROM.write(378, colSecS[0]);
EEPROM.write(379, colSecS[1]);
EEPROM.write(380, colSecS[2]);
EEPROM.write(381, whiteSecS);
EEPROM.write(382, ccIndex1);
EEPROM.write(383, ccIndex2);
EEPROM.write(384, ccNumPrimary);
EEPROM.write(385, ccNumSecondary);
EEPROM.write(386, ccFromStart);
EEPROM.write(387, ccFromEnd);
EEPROM.write(388, ccStep);
EEPROM.write(389, bootPreset);
EEPROM.write(390, aOtaEnabled);
EEPROM.write(391, receiveNotificationColor);
@ -219,78 +219,78 @@ void loadSettingsFromEEPROM(bool first)
}
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
clientssid = "";
clientSSID = "";
for (int i = 0; i < 32; ++i)
{
if (EEPROM.read(i) == 0) break;
clientssid += char(EEPROM.read(i));
clientSSID += char(EEPROM.read(i));
}
clientpass = "";
clientPass = "";
for (int i = 32; i < 96; ++i)
{
if (EEPROM.read(i) == 0) break;
clientpass += char(EEPROM.read(i));
clientPass += char(EEPROM.read(i));
}
cmdns = "";
cmDNS = "";
for (int i = 96; i < 128; ++i)
{
if (EEPROM.read(i) == 0) break;
cmdns += char(EEPROM.read(i));
cmDNS += char(EEPROM.read(i));
}
apssid = "";
apSSID = "";
for (int i = 128; i < 160; ++i)
{
if (EEPROM.read(i) == 0) break;
apssid += char(EEPROM.read(i));
apSSID += char(EEPROM.read(i));
}
appass = "";
apPass = "";
for (int i = 160; i < 224; ++i)
{
if (EEPROM.read(i) == 0) break;
appass += char(EEPROM.read(i));
apPass += char(EEPROM.read(i));
}
nightlightDelayMins = EEPROM.read(224);
nightlightFade = EEPROM.read(225);
notifyDirectDefault = EEPROM.read(226);
notifyDirect = notifyDirectDefault;
apchannel = EEPROM.read(227);
if (apchannel > 13 || apchannel < 1) apchannel = 1;
aphide = EEPROM.read(228);
if (aphide > 1) aphide = 1;
ledcount = EEPROM.read(229); if (ledcount > LEDCOUNT) ledcount = LEDCOUNT;
apChannel = EEPROM.read(227);
if (apChannel > 13 || apChannel < 1) apChannel = 1;
apHide = EEPROM.read(228);
if (apHide > 1) apHide = 1;
ledCount = EEPROM.read(229); if (ledCount > LEDCOUNT) ledCount = LEDCOUNT;
notifyButton = EEPROM.read(230);
notifyTwice = EEPROM.read(231);
buttonEnabled = EEPROM.read(232);
staticip[0] = EEPROM.read(234);
staticip[1] = EEPROM.read(235);
staticip[2] = EEPROM.read(236);
staticip[3] = EEPROM.read(237);
staticgateway[0] = EEPROM.read(238);
staticgateway[1] = EEPROM.read(239);
staticgateway[2] = EEPROM.read(240);
staticgateway[3] = EEPROM.read(241);
staticsubnet[0] = EEPROM.read(242);
staticsubnet[1] = EEPROM.read(243);
staticsubnet[2] = EEPROM.read(244);
staticsubnet[3] = EEPROM.read(245);
col_s[0] = EEPROM.read(246); col[0] = col_s[0];
col_s[1] = EEPROM.read(247); col[1] = col_s[1];
col_s[2] = EEPROM.read(248); col[2] = col_s[2];
bri_s = EEPROM.read(249); bri = bri_s;
staticIP[0] = EEPROM.read(234);
staticIP[1] = EEPROM.read(235);
staticIP[2] = EEPROM.read(236);
staticIP[3] = EEPROM.read(237);
staticGateway[0] = EEPROM.read(238);
staticGateway[1] = EEPROM.read(239);
staticGateway[2] = EEPROM.read(240);
staticGateway[3] = EEPROM.read(241);
staticSubnet[0] = EEPROM.read(242);
staticSubnet[1] = EEPROM.read(243);
staticSubnet[2] = EEPROM.read(244);
staticSubnet[3] = EEPROM.read(245);
colS[0] = EEPROM.read(246); col[0] = colS[0];
colS[1] = EEPROM.read(247); col[1] = colS[1];
colS[2] = EEPROM.read(248); col[2] = colS[2];
briS = EEPROM.read(249); bri = briS;
if (!EEPROM.read(369) && first)
{
bri = 0; bri_last = bri_s;
bri = 0; briLast = briS;
}
receiveNotificationBrightness = EEPROM.read(250);
fadeTransition = EEPROM.read(251);
reverseMode = EEPROM.read(252);
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
briMultiplier = EEPROM.read(255);
otapass = "";
otaPass = "";
for (int i = 256; i < 288; ++i)
{
if (EEPROM.read(i) == 0) break;
otapass += char(EEPROM.read(i));
otaPass += char(EEPROM.read(i));
}
nightlightTargetBri = EEPROM.read(288);
otaLock = EEPROM.read(289);
@ -317,12 +317,11 @@ void loadSettingsFromEEPROM(bool first)
alexaInvocationName += char(EEPROM.read(i));
}
alexaNotify = EEPROM.read(366);
arlsSign = EEPROM.read(367);
arlsOffset = EEPROM.read(368);
if (!arlsSign) arlsOffset = -arlsOffset;
if (!EEPROM.read(367)) arlsOffset = -arlsOffset;
turnOnAtBoot = EEPROM.read(369);
useHSBDefault = EEPROM.read(370);
white_s = EEPROM.read(371); white = white_s;
whiteS = EEPROM.read(371); white = whiteS;
useRGBW = EEPROM.read(372);
sweepTransition = EEPROM.read(373);
sweepDirection = EEPROM.read(374);
@ -332,18 +331,18 @@ void loadSettingsFromEEPROM(bool first)
}
//377 = lastEEPROMversion
if (lastEEPROMversion > 1) {
col_sec_s[0] = EEPROM.read(378); col_sec[0] = col_sec_s[0];
col_sec_s[1] = EEPROM.read(379); col_sec[1] = col_sec_s[1];
col_sec_s[2] = EEPROM.read(380); col_sec[2] = col_sec_s[2];
white_sec_s = EEPROM.read(381); white_sec = white_sec_s;
cc_index1 = EEPROM.read(382);
cc_index2 = EEPROM.read(383);
cc_numPrimary = EEPROM.read(384);
cc_numSecondary = EEPROM.read(385);
cc_fromStart = EEPROM.read(386);
cc_fromEnd = EEPROM.read(387);
cc_step = EEPROM.read(388);
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
colSecS[0] = EEPROM.read(378); colSec[0] = colSecS[0];
colSecS[1] = EEPROM.read(379); colSec[1] = colSecS[1];
colSecS[2] = EEPROM.read(380); colSec[2] = colSecS[2];
whiteSecS = EEPROM.read(381); whiteSec = whiteSecS;
ccIndex1 = EEPROM.read(382);
ccIndex2 = EEPROM.read(383);
ccNumPrimary = EEPROM.read(384);
ccNumSecondary = EEPROM.read(385);
ccFromStart = EEPROM.read(386);
ccFromEnd = EEPROM.read(387);
ccStep = EEPROM.read(388);
strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
}
if (lastEEPROMversion > 3) {
effectIntensityDefault = EEPROM.read(326); effectIntensity = effectIntensityDefault;
@ -447,7 +446,7 @@ void loadSettingsFromEEPROM(bool first)
//0: preset purpose byte 0:invalid 1:valid preset 1.0
//1:a 2:r 3:g 4:b 5:w 6:er 7:eg 8:eb 9:ew 10:fx 11:sx | custom chase 12:numP 13:numS 14:(0:fs 1:both 2:fe) 15:step 16:ix 17-19:Zeros
void applyPreset(uint8_t index, bool loadBri, bool loadCol, bool loadFX)
void applyPreset(byte index, bool loadBri, bool loadCol, bool loadFX)
{
if (index == 255 || index == 0) loadSettingsFromEEPROM(false);//load boot defaults
if (index > 25 || index < 1) return;
@ -460,29 +459,29 @@ void applyPreset(uint8_t index, bool loadBri, bool loadCol, bool loadFX)
col[1] = EEPROM.read(i+3);
col[2] = EEPROM.read(i+4);
white = EEPROM.read(i+5);
col_sec[0] = EEPROM.read(i+6);
col_sec[1] = EEPROM.read(i+7);
col_sec[2] = EEPROM.read(i+8);
white_sec = EEPROM.read(i+9);
colSec[0] = EEPROM.read(i+6);
colSec[1] = EEPROM.read(i+7);
colSec[2] = EEPROM.read(i+8);
whiteSec = EEPROM.read(i+9);
}
if (loadFX)
{
effectCurrent = EEPROM.read(i+10);
effectSpeed = EEPROM.read(i+11);
effectIntensity = EEPROM.read(i+16);
cc_numPrimary = EEPROM.read(i+12);
cc_numSecondary = EEPROM.read(i+13);
cc_fromEnd = EEPROM.read(i+14);
cc_fromStart = (EEPROM.read(i+14)<2);
cc_step = EEPROM.read(i+15);
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
ccNumPrimary = EEPROM.read(i+12);
ccNumSecondary = EEPROM.read(i+13);
ccFromEnd = EEPROM.read(i+14);
ccFromStart = (EEPROM.read(i+14)<2);
ccStep = EEPROM.read(i+15);
strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
strip.setMode(effectCurrent);
strip.setSpeed(effectSpeed);
strip.setIntensity(effectIntensity);
}
}
void savePreset(uint8_t index)
void savePreset(byte index)
{
if (index > 25) return;
if (index < 1) {saveSettingsToEEPROM();return;}
@ -493,24 +492,24 @@ void savePreset(uint8_t index)
EEPROM.write(i+3, col[1]);
EEPROM.write(i+4, col[2]);
EEPROM.write(i+5, white);
EEPROM.write(i+6, col_sec[0]);
EEPROM.write(i+7, col_sec[1]);
EEPROM.write(i+8, col_sec[2]);
EEPROM.write(i+9, white_sec);
EEPROM.write(i+6, colSec[0]);
EEPROM.write(i+7, colSec[1]);
EEPROM.write(i+8, colSec[2]);
EEPROM.write(i+9, whiteSec);
EEPROM.write(i+10, effectCurrent);
EEPROM.write(i+11, effectSpeed);
EEPROM.write(i+12, cc_numPrimary);
EEPROM.write(i+13, cc_numSecondary);
uint8_t m = 1;
if (!cc_fromStart) m = 2;
if (!cc_fromEnd) m = 0;
EEPROM.write(i+12, ccNumPrimary);
EEPROM.write(i+13, ccNumSecondary);
byte m = 1;
if (!ccFromStart) m = 2;
if (!ccFromEnd) m = 0;
EEPROM.write(i+14, m);
EEPROM.write(i+15, cc_step);
EEPROM.write(i+15, ccStep);
EEPROM.write(i+16, effectIntensity);
EEPROM.commit();
}
String loadMacro(uint8_t index)
String loadMacro(byte index)
{
index-=1;
String m="";
@ -523,7 +522,7 @@ String loadMacro(uint8_t index)
return m;
}
void applyMacro(uint8_t index)
void applyMacro(byte index)
{
index-=1;
if (index > 15) return;
@ -541,7 +540,7 @@ void applyMacro(uint8_t index)
handleSet(mc);
}
void saveMacro(uint8_t index, String mc, bool sing=true) //only commit on single save, not in settings
void saveMacro(byte index, String mc, bool sing=true) //only commit on single save, not in settings
{
index-=1;
if (index > 15) return;

View File

@ -10,7 +10,7 @@ void XML_response()
resp = resp + "<act>";
if (nightlightActive && nightlightFade)
{
resp = resp + bri_t;
resp = resp + briT;
} else
{
resp = resp + bri;
@ -56,7 +56,7 @@ void XML_response()
server.send(200, "text/xml", resp);
}
String getSettings(uint8_t subPage)
String getSettings(byte subPage)
{
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
DEBUG_PRINT("settings resp");
@ -73,36 +73,36 @@ String getSettings(uint8_t subPage)
String si = ".selectedIndex=";
if (subPage == 1) {
resp += ds + "CSSID" + v + "\"" + clientssid + "\";";
resp += ds + "CSSID" + v + "\"" + clientSSID + "\";";
resp += ds + "CPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
for (int i = 0; i < clientPass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "CSIP0" + v + staticip[0] +";";
resp += ds + "CSIP1" + v + staticip[1] +";";
resp += ds + "CSIP2" + v + staticip[2] +";";
resp += ds + "CSIP3" + v + staticip[3] +";";
resp += ds + "CSGW0" + v + staticgateway[0] +";";
resp += ds + "CSGW1" + v + staticgateway[1] +";";
resp += ds + "CSGW2" + v + staticgateway[2] +";";
resp += ds + "CSGW3" + v + staticgateway[3] +";";
resp += ds + "CSSN0" + v + staticsubnet[0] +";";
resp += ds + "CSSN1" + v + staticsubnet[1] +";";
resp += ds + "CSSN2" + v + staticsubnet[2] +";";
resp += ds + "CSSN3" + v + staticsubnet[3] +";";
resp += ds + "CMDNS" + v + "\"" + cmdns + "\";";
resp += ds + "CSIP0" + v + staticIP[0] +";";
resp += ds + "CSIP1" + v + staticIP[1] +";";
resp += ds + "CSIP2" + v + staticIP[2] +";";
resp += ds + "CSIP3" + v + staticIP[3] +";";
resp += ds + "CSGW0" + v + staticGateway[0] +";";
resp += ds + "CSGW1" + v + staticGateway[1] +";";
resp += ds + "CSGW2" + v + staticGateway[2] +";";
resp += ds + "CSGW3" + v + staticGateway[3] +";";
resp += ds + "CSSN0" + v + staticSubnet[0] +";";
resp += ds + "CSSN1" + v + staticSubnet[1] +";";
resp += ds + "CSSN2" + v + staticSubnet[2] +";";
resp += ds + "CSSN3" + v + staticSubnet[3] +";";
resp += ds + "CMDNS" + v + "\"" + cmDNS + "\";";
resp += ds + "APWTM" + v + apWaitTimeSecs +";";
resp += ds + "APSSID" + v + "\"" + apssid + "\";";
resp += ds + "APHSSID" + c + aphide + ";";
resp += ds + "APSSID" + v + "\"" + apSSID + "\";";
resp += ds + "APHSSID" + c + apHide + ";";
resp += ds + "APPASS" + v + "\"";
for (int i = 0; i < appass.length(); i++)
for (int i = 0; i < apPass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "APCHAN" + v + apchannel +";";
resp += ds + "APCHAN" + v + apChannel +";";
resp += dg + "(\"sip\")[0]" + ih + "\"";
if (!WiFi.localIP()[0] == 0)
{
@ -136,20 +136,20 @@ String getSettings(uint8_t subPage)
}
if (subPage == 2) {
resp += ds + "LEDCN" + v + ledcount +";";
resp += ds + "CLDFR" + v + col_s[0] +";";
resp += ds + "CLDFG" + v + col_s[1] +";";
resp += ds + "CLDFB" + v + col_s[2] +";";
resp += ds + "CLDFA" + v + bri_s +";";
resp += ds + "LEDCN" + v + ledCount +";";
resp += ds + "CLDFR" + v + colS[0] +";";
resp += ds + "CLDFG" + v + colS[1] +";";
resp += ds + "CLDFB" + v + colS[2] +";";
resp += ds + "CLDFA" + v + briS +";";
if (useRGBW) {
resp += ds + "CLDFW" + v + white_s +";";
resp += ds + "CLDFW" + v + whiteS +";";
} else {
resp += ds + "CLDFW" + v + "-1;";
}
resp += ds + "CSECR" + v + col_sec_s[0] +";";
resp += ds + "CSECG" + v + col_sec_s[1] +";";
resp += ds + "CSECB" + v + col_sec_s[2] +";";
resp += ds + "CSECW" + v + white_sec_s +";";
resp += ds + "CSECR" + v + colSecS[0] +";";
resp += ds + "CSECG" + v + colSecS[1] +";";
resp += ds + "CSECB" + v + colSecS[2] +";";
resp += ds + "CSECW" + v + whiteSecS +";";
resp += ds + "BOOTN" + c + turnOnAtBoot +";";
resp += ds + "BOOTP" + v + bootPreset +";";
resp += ds + "FXDEF" + v + effectDefault +";";

View File

@ -7,10 +7,10 @@ void _setRandomColor(bool _sec)
lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);
uint32_t _color = strip.color_wheel(lastRandomIndex);
if (_sec){
white_sec = ((_color >> 24) & 0xFF);
col_sec[0] = ((_color >> 16) & 0xFF);
col_sec[1] = ((_color >> 8) & 0xFF);
col_sec[2] = (_color & 0xFF);
whiteSec = ((_color >> 24) & 0xFF);
colSec[0] = ((_color >> 16) & 0xFF);
colSec[1] = ((_color >> 8) & 0xFF);
colSec[2] = (_color & 0xFF);
} else {
white = ((_color >> 24) & 0xFF);
col[0] = ((_color >> 16) & 0xFF);
@ -19,7 +19,7 @@ void _setRandomColor(bool _sec)
}
}
void handleSettingsSet(uint8_t subPage)
void handleSettingsSet(byte subPage)
{
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
if (subPage <1 || subPage >6) return;
@ -27,91 +27,91 @@ void handleSettingsSet(uint8_t subPage)
//WIFI SETTINGS
if (subPage == 1)
{
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
if (server.hasArg("CSSID")) clientSSID = server.arg("CSSID");
if (server.hasArg("CPASS"))
{
if (!server.arg("CPASS").indexOf('*') == 0)
{
DEBUG_PRINTLN("Setting pass");
clientpass = server.arg("CPASS");
clientPass = server.arg("CPASS");
}
}
if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS");
if (server.hasArg("CMDNS")) cmDNS = server.arg("CMDNS");
if (server.hasArg("APWTM"))
{
int i = server.arg("APWTM").toInt();
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
}
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
aphide = server.hasArg("APHSSID");
if (server.hasArg("APSSID")) apSSID = server.arg("APSSID");
apHide = server.hasArg("APHSSID");
if (server.hasArg("APPASS"))
{
if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("APPASS");
if (!server.arg("APPASS").indexOf('*') == 0) apPass = server.arg("APPASS");
}
if (server.hasArg("APCHAN"))
{
int chan = server.arg("APCHAN").toInt();
if (chan > 0 && chan < 14) apchannel = chan;
if (chan > 0 && chan < 14) apChannel = chan;
}
if (server.hasArg("CSIP0"))
{
int i = server.arg("CSIP0").toInt();
if (i >= 0 && i <= 255) staticip[0] = i;
if (i >= 0 && i <= 255) staticIP[0] = i;
}
if (server.hasArg("CSIP1"))
{
int i = server.arg("CSIP1").toInt();
if (i >= 0 && i <= 255) staticip[1] = i;
if (i >= 0 && i <= 255) staticIP[1] = i;
}
if (server.hasArg("CSIP2"))
{
int i = server.arg("CSIP2").toInt();
if (i >= 0 && i <= 255) staticip[2] = i;
if (i >= 0 && i <= 255) staticIP[2] = i;
}
if (server.hasArg("CSIP3"))
{
int i = server.arg("CSIP3").toInt();
if (i >= 0 && i <= 255) staticip[3] = i;
if (i >= 0 && i <= 255) staticIP[3] = i;
}
if (server.hasArg("CSGW0"))
{
int i = server.arg("CSGW0").toInt();
if (i >= 0 && i <= 255) staticgateway[0] = i;
if (i >= 0 && i <= 255) staticGateway[0] = i;
}
if (server.hasArg("CSGW1"))
{
int i = server.arg("CSGW1").toInt();
if (i >= 0 && i <= 255) staticgateway[1] = i;
if (i >= 0 && i <= 255) staticGateway[1] = i;
}
if (server.hasArg("CSGW2"))
{
int i = server.arg("CSGW2").toInt();
if (i >= 0 && i <= 255) staticgateway[2] = i;
if (i >= 0 && i <= 255) staticGateway[2] = i;
}
if (server.hasArg("CSGW3"))
{
int i = server.arg("CSGW3").toInt();
if (i >= 0 && i <= 255) staticgateway[3] = i;
if (i >= 0 && i <= 255) staticGateway[3] = i;
}
if (server.hasArg("CSSN0"))
{
int i = server.arg("CSSN0").toInt();
if (i >= 0 && i <= 255) staticsubnet[0] = i;
if (i >= 0 && i <= 255) staticSubnet[0] = i;
}
if (server.hasArg("CSSN1"))
{
int i = server.arg("CSSN1").toInt();
if (i >= 0 && i <= 255) staticsubnet[1] = i;
if (i >= 0 && i <= 255) staticSubnet[1] = i;
}
if (server.hasArg("CSSN2"))
{
int i = server.arg("CSSN2").toInt();
if (i >= 0 && i <= 255) staticsubnet[2] = i;
if (i >= 0 && i <= 255) staticSubnet[2] = i;
}
if (server.hasArg("CSSN3"))
{
int i = server.arg("CSSN3").toInt();
if (i >= 0 && i <= 255) staticsubnet[3] = i;
if (i >= 0 && i <= 255) staticSubnet[3] = i;
}
}
@ -121,53 +121,53 @@ void handleSettingsSet(uint8_t subPage)
if (server.hasArg("LEDCN"))
{
int i = server.arg("LEDCN").toInt();
if (i >= 0 && i <= LEDCOUNT) ledcount = i;
strip.setLedCount(ledcount);
if (i >= 0 && i <= LEDCOUNT) ledCount = i;
strip.setLedCount(ledCount);
}
if (server.hasArg("CBEOR")) //ignore settings and save current brightness, colors and fx as default
{
col_s[0] = col[0];
col_s[1] = col[1];
col_s[2] = col[2];
if (useRGBW) white_s = white;
bri_s = bri;
colS[0] = col[0];
colS[1] = col[1];
colS[2] = col[2];
if (useRGBW) whiteS = white;
briS = bri;
effectDefault = effectCurrent;
effectSpeedDefault = effectSpeed;
} else {
if (server.hasArg("CLDFR"))
{
int i = server.arg("CLDFR").toInt();
if (i >= 0 && i <= 255) col_s[0] = i;
if (i >= 0 && i <= 255) colS[0] = i;
}
if (server.hasArg("CLDFG"))
{
int i = server.arg("CLDFG").toInt();
if (i >= 0 && i <= 255) col_s[1] = i;
if (i >= 0 && i <= 255) colS[1] = i;
}
if (server.hasArg("CLDFB"))
{
int i = server.arg("CLDFB").toInt();
if (i >= 0 && i <= 255) col_s[2] = i;
if (i >= 0 && i <= 255) colS[2] = i;
}
if (server.hasArg("CSECR"))
{
int i = server.arg("CSECR").toInt();
if (i >= 0 && i <= 255) col_sec_s[0] = i;
if (i >= 0 && i <= 255) colSecS[0] = i;
}
if (server.hasArg("CSECG"))
{
int i = server.arg("CSECG").toInt();
if (i >= 0 && i <= 255) col_sec_s[1] = i;
if (i >= 0 && i <= 255) colSecS[1] = i;
}
if (server.hasArg("CSECB"))
{
int i = server.arg("CSECB").toInt();
if (i >= 0 && i <= 255) col_sec_s[2] = i;
if (i >= 0 && i <= 255) colSecS[2] = i;
}
if (server.hasArg("CSECW"))
{
int i = server.arg("CSECW").toInt();
if (i >= 0 && i <= 255) white_sec_s = i;
if (i >= 0 && i <= 255) whiteSecS = i;
}
if (server.hasArg("CLDFW"))
{
@ -175,16 +175,16 @@ void handleSettingsSet(uint8_t subPage)
if (i >= 0 && i <= 255)
{
useRGBW = true;
white_s = i;
whiteS = i;
} else {
useRGBW = false;
white_s = 0;
whiteS = 0;
}
}
if (server.hasArg("CLDFA"))
{
int i = server.arg("CLDFA").toInt();
if (i >= 0 && i <= 255) bri_s = i;
if (i >= 0 && i <= 255) briS = i;
}
if (server.hasArg("FXDEF"))
{
@ -236,7 +236,6 @@ void handleSettingsSet(uint8_t subPage)
{
int i = server.arg("WOFFS").toInt();
if (i >= -255 && i <= 255) arlsOffset = i;
arlsSign = (i>=0)?true:false;
}
if (server.hasArg("NRBRI"))
{
@ -371,13 +370,13 @@ void handleSettingsSet(uint8_t subPage)
bool pwdCorrect = !otaLock; //always allow access if ota not locked
if (server.hasArg("OPASS"))
{
if (otaLock && otapass.equals(server.arg("OPASS")))
if (otaLock && otaPass.equals(server.arg("OPASS")))
{
pwdCorrect = true;
}
if (!otaLock && server.arg("OPASS").length() > 0)
{
otapass = server.arg("OPASS");
otaPass = server.arg("OPASS");
}
}
@ -393,9 +392,9 @@ void handleSettingsSet(uint8_t subPage)
saveSettingsToEEPROM();
}
boolean handleSet(String req)
bool handleSet(String req)
{
boolean effectUpdated = false;
bool effectUpdated = false;
if (!(req.indexOf("win") >= 0)) {
return false;
}
@ -431,12 +430,12 @@ boolean handleSet(String req)
pos = req.indexOf("HU=");
if (pos > 0) {
uint16_t temphue = req.substring(pos + 3).toInt();
uint8_t tempsat = 255;
byte tempsat = 255;
pos = req.indexOf("SA=");
if (pos > 0) {
tempsat = req.substring(pos + 3).toInt();
}
colorHStoRGB(temphue,tempsat,(req.indexOf("H2")>0)? col_sec:col);
colorHStoRGB(temphue,tempsat,(req.indexOf("H2")>0)? colSec:col);
}
//set red value
@ -463,45 +462,45 @@ boolean handleSet(String req)
//set 2nd red value
pos = req.indexOf("R2=");
if (pos > 0) {
col_sec[0] = req.substring(pos + 3).toInt();
colSec[0] = req.substring(pos + 3).toInt();
}
//set 2nd green value
pos = req.indexOf("G2=");
if (pos > 0) {
col_sec[1] = req.substring(pos + 3).toInt();
colSec[1] = req.substring(pos + 3).toInt();
}
//set 2nd blue value
pos = req.indexOf("B2=");
if (pos > 0) {
col_sec[2] = req.substring(pos + 3).toInt();
colSec[2] = req.substring(pos + 3).toInt();
}
//set 2nd white value
pos = req.indexOf("W2=");
if (pos > 0) {
white_sec = req.substring(pos + 3).toInt();
whiteSec = req.substring(pos + 3).toInt();
}
//set 2nd to white
pos = req.indexOf("SW");
if (pos > 0) {
if(useRGBW) {
white_sec = 255;
col_sec[0] = 0;
col_sec[1] = 0;
col_sec[2] = 0;
whiteSec = 255;
colSec[0] = 0;
colSec[1] = 0;
colSec[2] = 0;
} else {
col_sec[0] = 255;
col_sec[1] = 255;
col_sec[2] = 255;
colSec[0] = 255;
colSec[1] = 255;
colSec[2] = 255;
}
}
//set 2nd to black
pos = req.indexOf("SB");
if (pos > 0) {
white_sec = 0;
col_sec[0] = 0;
col_sec[1] = 0;
col_sec[2] = 0;
whiteSec = 0;
colSec[0] = 0;
colSec[1] = 0;
colSec[2] = 0;
}
//set to random hue SR=0->1st SR=1->2nd
pos = req.indexOf("SR");
@ -511,24 +510,24 @@ boolean handleSet(String req)
//set 2nd to 1st
pos = req.indexOf("SP");
if (pos > 0) {
col_sec[0] = col[0];
col_sec[1] = col[1];
col_sec[2] = col[2];
white_sec = white;
colSec[0] = col[0];
colSec[1] = col[1];
colSec[2] = col[2];
whiteSec = white;
}
//swap 2nd & 1st
pos = req.indexOf("SC");
if (pos > 0) {
uint8_t _temp[4];
byte _temp[4];
for (int i = 0; i<3; i++)
{
_temp[i] = col[i];
col[i] = col_sec[i];
col_sec[i] = _temp[i];
col[i] = colSec[i];
colSec[i] = _temp[i];
}
_temp[3] = white;
white = white_sec;
white_sec = _temp[3];
white = whiteSec;
whiteSec = _temp[3];
}
//set current effect index
@ -654,7 +653,7 @@ boolean handleSet(String req)
if (req.indexOf("NL=0") > 0)
{
nightlightActive = false;
bri = bri_t;
bri = briT;
} else {
nightlightActive = true;
nightlightDelayMins = req.substring(pos + 3).toInt();
@ -665,7 +664,7 @@ boolean handleSet(String req)
pos = req.indexOf("NT=");
if (pos > 0) {
nightlightTargetBri = req.substring(pos + 3).toInt();
nightlightActive_old = false; //re-init
nightlightActiveOld = false; //re-init
}
//toggle nightlight fade
if (req.indexOf("NF=") > 0)
@ -676,7 +675,7 @@ boolean handleSet(String req)
} else {
nightlightFade = true;
}
nightlightActive_old = false; //re-init
nightlightActiveOld = false; //re-init
}
//toggle general purpose output
pos = req.indexOf("AX=");
@ -690,14 +689,14 @@ boolean handleSet(String req)
if (pos > 0) {
switch (req.substring(pos + 3).toInt())
{
case 0: if (bri != 0){bri_last = bri; bri = 0;} break; //off
case 1: bri = bri_last; break; //on
case 0: if (bri != 0){briLast = bri; bri = 0;} break; //off
case 1: bri = briLast; break; //on
default: if (bri == 0) //toggle
{
bri = bri_last;
bri = briLast;
} else
{
bri_last = bri;
briLast = bri;
bri = 0;
}
}
@ -716,15 +715,15 @@ boolean handleSet(String req)
//set custom chase data
bool _cc_updated = false;
pos = req.indexOf("C0="); if (pos > 0) {cc_start = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("C1="); if (pos > 0) {cc_index1 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("C2="); if (pos > 0) {cc_index2 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CP="); if (pos > 0) {cc_numPrimary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CS="); if (pos > 0) {cc_numSecondary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CM="); if (pos > 0) {cc_step = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CF="); if (pos > 0) {cc_fromStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CE="); if (pos > 0) {cc_fromEnd = (req.substring(pos + 3).toInt()); _cc_updated = true;}
if (_cc_updated) strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
pos = req.indexOf("C0="); if (pos > 0) {ccStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("C1="); if (pos > 0) {ccIndex1 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("C2="); if (pos > 0) {ccIndex2 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CP="); if (pos > 0) {ccNumPrimary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CS="); if (pos > 0) {ccNumSecondary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CM="); if (pos > 0) {ccStep = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CF="); if (pos > 0) {ccFromStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
pos = req.indexOf("CE="); if (pos > 0) {ccFromEnd = (req.substring(pos + 3).toInt()); _cc_updated = true;}
if (_cc_updated) strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
//set presets
pos = req.indexOf("PS="); //saves current in preset

View File

@ -25,24 +25,24 @@ void wledInit()
EEPROM.begin(EEPSIZE);
loadSettingsFromEEPROM(true);
DEBUG_PRINT("CC: SSID: ");
DEBUG_PRINT(clientssid);
DEBUG_PRINT(clientSSID);
buildCssColorString();
userBeginPreConnection();
WiFi.disconnect(); //close old connections
if (staticip[0] != 0)
if (staticIP[0] != 0)
{
WiFi.config(staticip, staticgateway, staticsubnet, staticdns);
WiFi.config(staticIP, staticGateway, staticSubnet, staticDNS);
} else
{
WiFi.config(0U, 0U, 0U);
}
if (apssid.length()>0)
if (apSSID.length()>0)
{
DEBUG_PRINT("USING AP");
DEBUG_PRINTLN(apssid.length());
DEBUG_PRINTLN(apSSID.length());
initAP();
} else
{
@ -64,7 +64,7 @@ void wledInit()
}
// Set up mDNS responder:
if (cmdns != NULL && !onlyAP && !MDNS.begin(cmdns.c_str())) {
if (cmDNS != NULL && !onlyAP && !MDNS.begin(cmDNS.c_str())) {
DEBUG_PRINTLN("Error setting up MDNS responder!");
down();
}
@ -78,7 +78,7 @@ void wledInit()
ntpConnected = ntpUdp.begin(ntpLocalPort);
//start captive portal
if (onlyAP || apssid.length() > 0)
if (onlyAP || apSSID.length() > 0)
{
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(53, "*", WiFi.softAPIP());
@ -195,7 +195,7 @@ void wledInit()
});
server.on("/power", HTTP_GET, [](){
String val = (String)(int)strip.getPowerEstimate(ledcount,strip.getColor(),strip.getBrightness());
String val = (String)(int)strip.getPowerEstimate(ledCount,strip.getColor(),strip.getBrightness());
val += "mA currently";
serveMessage(200,val,"This is just an estimate (does not take into account several factors like effects and wire resistance). It is NOT an accurate measurement!",254);
});
@ -305,7 +305,7 @@ void wledInit()
// Initialize NeoPixel Strip
strip.init();
strip.setLedCount(ledcount);
strip.setLedCount(ledCount);
strip.setReverseMode(reverseMode);
strip.setColor(0);
strip.setBrightness(255);
@ -320,17 +320,17 @@ void wledInit()
}
void initAP(){
String save = apssid;
if (apssid.length() <1) apssid = "WLED-AP";
WiFi.softAP(apssid.c_str(), appass.c_str(), apchannel, aphide);
apssid = save;
String save = apSSID;
if (apSSID.length() <1) apSSID = "WLED-AP";
WiFi.softAP(apSSID.c_str(), apPass.c_str(), apChannel, apHide);
apSSID = save;
}
void initCon()
{
int fail_count = 0;
if (clientssid.length() <1 || clientssid.equals("Your_Network_Here")) fail_count = apWaitTimeSecs*2;
WiFi.begin(clientssid.c_str(), clientpass.c_str());
if (clientSSID.length() <1 || clientSSID.equals("Your_Network")) fail_count = apWaitTimeSecs*2;
WiFi.begin(clientSSID.c_str(), clientPass.c_str());
while(WiFi.status() != WL_CONNECTED) {
delay(500);
DEBUG_PRINTLN("C_NC");
@ -443,7 +443,7 @@ void serveMessage(int code, String headl, String subl="", int optionType)
server.sendContent(messageBody);
}
void serveSettings(uint8_t subPage)
void serveSettings(byte subPage)
{
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage
if (!arlsTimeout) //do not serve while receiving realtime

View File

@ -4,7 +4,7 @@
#define WLEDPACKETSIZE 24
void notify(uint8_t callMode, bool followUp=false)
void notify(byte callMode, bool followUp=false)
{
if (!udpConnected) return;
switch (callMode)
@ -29,10 +29,10 @@ void notify(uint8_t callMode, bool followUp=false)
udpOut[9] = effectSpeed;
udpOut[10] = white;
udpOut[11] = 3; //compatibilityVersionByte: 0: old 1: supports white 2: supports secondary color 3: supports FX intensity, 24 byte packet
udpOut[12] = col_sec[0];
udpOut[13] = col_sec[1];
udpOut[14] = col_sec[2];
udpOut[15] = white_sec;
udpOut[12] = colSec[0];
udpOut[13] = colSec[1];
udpOut[14] = colSec[2];
udpOut[15] = whiteSec;
udpOut[16] = effectIntensity;
IPAddress broadcastIp;
@ -53,9 +53,11 @@ void handleNotifications()
}
if(udpConnected && receiveNotifications){
int packetSize = notifierUdp.parsePacket();
uint16_t packetSize = notifierUdp.parsePacket();
if (packetSize > 1026) return;
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) //don't process broadcasts we send ourselves
{
byte udpIn[packetSize];
notifierUdp.read(udpIn, packetSize);
if (udpIn[0] == 0 && !arlsTimeout) //wled notifier, block if realtime packets active
{
@ -70,10 +72,10 @@ void handleNotifications()
white = udpIn[10];
if (udpIn[11] > 1 )
{
col_sec[0] = udpIn[12];
col_sec[1] = udpIn[13];
col_sec[2] = udpIn[14];
white_sec = udpIn[15];
colSec[0] = udpIn[12];
colSec[1] = udpIn[13];
colSec[2] = udpIn[14];
whiteSec = udpIn[15];
}
}
if (udpIn[8] != effectCurrent && receiveNotificationEffects)
@ -105,7 +107,7 @@ void handleNotifications()
arlsTimeout = false;
} else {
if (!arlsTimeout){
strip.setRange(0, ledcount-1, 0);
strip.setRange(0, ledCount-1, 0);
strip.setMode(0);
}
arlsTimeout = true;
@ -113,7 +115,7 @@ void handleNotifications()
}
for (int i = 2; i < packetSize -3; i += 4)
{
if (udpIn[i] + arlsOffset < ledcount && udpIn[i] + arlsOffset >= 0)
if (udpIn[i] + arlsOffset < ledCount && udpIn[i] + arlsOffset >= 0)
if (useGammaCorrectionRGB)
{
strip.setPixelColor(udpIn[i] + arlsOffset, gamma8[udpIn[i+1]], gamma8[udpIn[i+2]], gamma8[udpIn[i+3]]);

View File

@ -3,7 +3,7 @@
*/
void setAllLeds() {
double d = bri_t*briMultiplier;
double d = briT*briMultiplier;
int val = d/100;
if (val > 255) val = 255;
if (useGammaCorrectionBri)
@ -14,26 +14,26 @@ void setAllLeds() {
}
if (useGammaCorrectionRGB)
{
strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]], gamma8[white_t]);
strip.setSecondaryColor(gamma8[col_sec[0]], gamma8[col_sec[1]], gamma8[col_sec[2]], gamma8[white_sec]);
strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[whiteT]);
strip.setSecondaryColor(gamma8[colSec[0]], gamma8[colSec[1]], gamma8[colSec[2]], gamma8[whiteSec]);
} else {
strip.setColor(col_t[0], col_t[1], col_t[2], white_t);
strip.setSecondaryColor(col_sec[0], col_sec[1], col_sec[2], white_sec);
strip.setColor(colT[0], colT[1], colT[2], whiteT);
strip.setSecondaryColor(colSec[0], colSec[1], colSec[2], whiteSec);
}
}
void setLedsStandard()
{
col_old[0] = col[0];
col_old[1] = col[1];
col_old[2] = col[2];
white_old = white;
bri_old = bri;
col_t[0] = col[0];
col_t[1] = col[1];
col_t[2] = col[2];
white_t = white;
bri_t = bri;
colOld[0] = col[0];
colOld[1] = col[1];
colOld[2] = col[2];
whiteOld = white;
briOld = bri;
colT[0] = col[0];
colT[1] = col[1];
colT[2] = col[2];
whiteT = white;
briT = bri;
setAllLeds();
}
@ -41,11 +41,11 @@ bool colorChanged()
{
for (int i = 0; i < 3; i++)
{
if (col[i] != col_it[i]) return true;
if (col_sec[i] != col_sec_it[i]) return true;
if (col[i] != colIT[i]) return true;
if (colSec[i] != colSecIT[i]) return true;
}
if (white != white_it || white_sec != white_sec_it) return true;
if (bri != bri_it) return true;
if (white != whiteIT || whiteSec != whiteSecIT) return true;
if (bri != briIT) return true;
return false;
}
@ -59,31 +59,31 @@ void colorUpdated(int callMode)
}
if (callMode != 5 && nightlightActive && nightlightFade)
{
bri_nl_t = bri;
briNlT = bri;
nightlightDelayMs -= (millis() - nightlightStartTime);
nightlightStartTime = millis();
}
col_it[0] = col[0];
col_it[1] = col[1];
col_it[2] = col[2];
col_sec_it[0] = col_sec[0];
col_sec_it[1] = col_sec[1];
col_sec_it[2] = col_sec[2];
white_it = white;
white_sec_it = white_sec;
bri_it = bri;
if (bri > 0) bri_last = bri;
colIT[0] = col[0];
colIT[1] = col[1];
colIT[2] = col[2];
colSecIT[0] = colSec[0];
colSecIT[1] = colSec[1];
colSecIT[2] = colSec[2];
whiteIT = white;
whiteSecIT = whiteSec;
briIT = bri;
if (bri > 0) briLast = bri;
notify(callMode);
if (fadeTransition || sweepTransition)
{
if (transitionActive)
{
col_old[0] = col_t[0];
col_old[1] = col_t[1];
col_old[2] = col_t[2];
white_old = white_t;
bri_old = bri_t;
tper_last = 0;
colOld[0] = colT[0];
colOld[1] = colT[1];
colOld[2] = colT[2];
whiteOld = whiteT;
briOld = briT;
tperLast = 0;
}
transitionActive = true;
transitionStartTime = millis();
@ -103,34 +103,34 @@ void handleTransitions()
if (tper >= 1.0)
{
transitionActive = false;
tper_last = 0;
tperLast = 0;
if (sweepTransition) strip.unlockAll();
setLedsStandard();
strip.setFastUpdateMode(false);
return;
}
if (tper - tper_last < transitionResolution)
if (tper - tperLast < transitionResolution)
{
return;
}
tper_last = tper;
tperLast = tper;
if (fadeTransition)
{
col_t[0] = col_old[0]+((col[0] - col_old[0])*tper);
col_t[1] = col_old[1]+((col[1] - col_old[1])*tper);
col_t[2] = col_old[2]+((col[2] - col_old[2])*tper);
white_t = white_old +((white - white_old )*tper);
bri_t = bri_old +((bri - bri_old )*tper);
colT[0] = colOld[0]+((col[0] - colOld[0])*tper);
colT[1] = colOld[1]+((col[1] - colOld[1])*tper);
colT[2] = colOld[2]+((col[2] - colOld[2])*tper);
whiteT = whiteOld +((white - whiteOld )*tper);
briT = briOld +((bri - briOld )*tper);
}
if (sweepTransition)
{
strip.lockAll();
if (sweepDirection)
{
strip.unlockRange(0, (int)(tper*(double)ledcount));
strip.unlockRange(0, (int)(tper*(double)ledCount));
} else
{
strip.unlockRange(ledcount - (int)(tper*(double)ledcount), ledcount);
strip.unlockRange(ledCount - (int)(tper*(double)ledCount), ledCount);
}
if (!fadeTransition)
{
@ -145,18 +145,18 @@ void handleNightlight()
{
if (nightlightActive)
{
if (!nightlightActive_old) //init
if (!nightlightActiveOld) //init
{
nightlightStartTime = millis();
notify(4);
nightlightDelayMs = (int)(nightlightDelayMins*60000);
nightlightActive_old = true;
bri_nl_t = bri;
nightlightActiveOld = true;
briNlT = bri;
}
float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
if (nightlightFade)
{
bri = bri_nl_t+((nightlightTargetBri - bri_nl_t)*nper);
bri = briNlT+((nightlightTargetBri - briNlT)*nper);
colorUpdated(5);
}
if (nper >= 1)
@ -167,10 +167,10 @@ void handleNightlight()
bri = nightlightTargetBri;
colorUpdated(5);
}
if (bri == 0) bri_last = bri_nl_t;
if (bri == 0) briLast = briNlT;
}
} else if (nightlightActive_old) //early de-init
} else if (nightlightActiveOld) //early de-init
{
nightlightActive_old = false;
nightlightActiveOld = false;
}
}

View File

@ -27,10 +27,10 @@ void handleButton()
{
if (bri == 0)
{
bri = bri_last;
bri = briLast;
} else
{
bri_last = bri;
briLast = bri;
bri = 0;
}
colorUpdated(2);

View File

@ -89,7 +89,7 @@ void sendNTPPacket()
ntpUdp.endPacket();
}
boolean checkNTPResponse()
bool checkNTPResponse()
{
int cb = ntpUdp.parsePacket();
if (cb) {

View File

@ -16,12 +16,12 @@ void initCronixie()
}
}
void _nixieDisplay(int num[], uint16_t dur[], uint16_t pausedur[], uint8_t cnt)
void _nixieDisplay(int num[], uint16_t dur[], uint16_t pausedur[], byte cnt)
{
strip.setRange(overlayMin, overlayMax, 0);
if (num[nixieClockI] >= 0 && !nixiePause)
{
strip.setIndividual(num[nixieClockI],((uint32_t)white << 24)| ((uint32_t)col_t[0] << 16) | ((uint32_t)col_t[1] << 8) | col_t[2]);
strip.setIndividual(num[nixieClockI],((uint32_t)white << 24)| ((uint32_t)colT[0] << 16) | ((uint32_t)colT[1] << 8) | colT[2]);
strip.unlock(num[nixieClockI]);
}
if (!nixiePause)
@ -138,7 +138,7 @@ void handleOverlays()
void _overlaySolid()
{
strip.unlockAll();
uint32_t cls = (useGammaCorrectionRGB)? gamma8[white_sec*16777216] + gamma8[col_sec[0]]*65536 + gamma8[col_sec[1]]*256 + gamma8[col_sec[2]]:white_sec*16777216 + col_sec[0]*65536 + col_sec[1]*256 + col_sec[2];
uint32_t cls = (useGammaCorrectionRGB)? gamma8[whiteSec*16777216] + gamma8[colSec[0]]*65536 + gamma8[colSec[1]]*256 + gamma8[colSec[2]]:whiteSec*16777216 + colSec[0]*65536 + colSec[1]*256 + colSec[2];
strip.setRange(overlayMin,overlayMax,cls);
overlayRefreshMs = 1902;
}
@ -309,14 +309,14 @@ void _overlayAnalogCountdown()
int overlaySize = overlayMax - overlayMin +1;
double perc = (pval-(double)diff)/pval;
if (perc > 1.0) perc = 1.0;
uint8_t pixelCnt = perc*overlaySize;
byte pixelCnt = perc*overlaySize;
if (analogClock12pixel + pixelCnt > overlayMax)
{
strip.setRange(analogClock12pixel, overlayMax, ((uint32_t)white_sec << 24)| ((uint32_t)col_sec[0] << 16) | ((uint32_t)col_sec[1] << 8) | col_sec[2]);
strip.setRange(overlayMin, overlayMin +pixelCnt -(1+ overlayMax -analogClock12pixel), ((uint32_t)white_sec << 24)| ((uint32_t)col_sec[0] << 16) | ((uint32_t)col_sec[1] << 8) | col_sec[2]);
strip.setRange(analogClock12pixel, overlayMax, ((uint32_t)whiteSec << 24)| ((uint32_t)colSec[0] << 16) | ((uint32_t)colSec[1] << 8) | colSec[2]);
strip.setRange(overlayMin, overlayMin +pixelCnt -(1+ overlayMax -analogClock12pixel), ((uint32_t)whiteSec << 24)| ((uint32_t)colSec[0] << 16) | ((uint32_t)colSec[1] << 8) | colSec[2]);
} else
{
strip.setRange(analogClock12pixel, analogClock12pixel + pixelCnt, ((uint32_t)white_sec << 24)| ((uint32_t)col_sec[0] << 16) | ((uint32_t)col_sec[1] << 8) | col_sec[2]);
strip.setRange(analogClock12pixel, analogClock12pixel + pixelCnt, ((uint32_t)whiteSec << 24)| ((uint32_t)colSec[0] << 16) | ((uint32_t)colSec[1] << 8) | colSec[2]);
}
}
overlayRefreshMs = 998;

View File

@ -80,7 +80,7 @@ void alexaOff()
DEBUG_PRINTLN(body);
}
void alexaDim(uint8_t briL)
void alexaDim(byte briL)
{
String body = "[{\"success\":{\"/lights/1/state/bri\":"+ String(briL) +"}}]";
@ -127,7 +127,7 @@ void respondToSearch() {
UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
#ifdef ARDUINO_ARCH_ESP32
UDP.write((uint8_t*)response.c_str(), response.length());
UDP.write((byte*)response.c_str(), response.length());
#else
UDP.write(response.c_str());
#endif
@ -223,7 +223,7 @@ String briForHue(int realBri)
return String(realBri);
}
boolean handleAlexaApiCall(String req, String body) //basic implementation of Philips hue api functions needed for basic Alexa control
bool handleAlexaApiCall(String req, String body) //basic implementation of Philips hue api functions needed for basic Alexa control
{
DEBUG_PRINTLN("AlexaApiCall");
if (req.indexOf("api") <0) return false;
@ -262,8 +262,8 @@ boolean handleAlexaApiCall(String req, String body) //basic implementation of Ph
return true;
}
boolean connectUDP(){
boolean state = false;
bool connectUDP(){
bool state = false;
DEBUG_PRINTLN("");
DEBUG_PRINTLN("Con UDP");

View File

@ -1,9 +1,9 @@
/*
* Support for the Cronixie clock
*/
uint8_t getSameCodeLength(char code, int index, char const digits[])
byte getSameCodeLength(char code, int index, char const digits[])
{
uint8_t counter = 0;
byte counter = 0;
for (int i = index+1; i < 6; i++)
{
@ -145,12 +145,12 @@ void setCronixie()
void _overlayCronixie()
{
if (countdownMode) checkCountdown();
uint8_t h = hour(local);
uint8_t h0 = h;
uint8_t m = minute(local);
uint8_t s = second(local);
uint8_t d = day(local);
uint8_t mi = month(local);
byte h = hour(local);
byte h0 = h;
byte m = minute(local);
byte s = second(local);
byte d = day(local);
byte mi = month(local);
int y = year(local);
//this has to be changed in time for 22nd century
y -= 2000; if (y<0) y += 30; //makes countdown work

View File

@ -1,7 +1,7 @@
/*
* Color conversion methods
*/
void colorCTtoRGB(uint16_t mired, uint8_t* rgb) //white spectrum to rgb
void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
{
//this is only an approximation using WS2812B with gamma correction enabled
if (mired > 475)
@ -31,11 +31,11 @@ void colorCTtoRGB(uint16_t mired, uint8_t* rgb) //white spectrum to rgb
}
}
void colorHStoRGB(uint16_t hue, uint8_t sat, uint8_t* rgb) //hue, sat to rgb
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
{
float h = ((float)hue)/65535.0;
float s = ((float)sat)/255.0;
uint8_t i = floor(h*6);
byte i = floor(h*6);
float f = h * 6-i;
float p = 255 * (1-s);
float q = 255 * (1-f*s);
@ -50,7 +50,7 @@ void colorHStoRGB(uint16_t hue, uint8_t sat, uint8_t* rgb) //hue, sat to rgb
}
}
void colorXYtoRGB(float x, float y, uint8_t* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
{
float z = 1.0f - x - y;
float X = (1.0f / y) * x;
@ -106,7 +106,7 @@ void colorXYtoRGB(float x, float y, uint8_t* rgb) //coordinates to rgb (https://
rgb[2] = 255.0*b;
}
void colorRGBtoXY(uint8_t* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
{
float X = rgb[0] * 0.664511f + rgb[1] * 0.154324f + rgb[2] * 0.162028f;
float Y = rgb[0] * 0.283881f + rgb[1] * 0.668433f + rgb[2] * 0.047685f;
@ -129,7 +129,7 @@ float maxf (float v, float w)
return v;
}
void colorRGBtoRGBW(uint8_t* rgb, uint8_t* wht) //rgb to rgbw, untested and currently unused
void colorRGBtoRGBW(byte* rgb, byte* wht) //rgb to rgbw, untested and currently unused
{
*wht = (float)minf(rgb[0],minf(rgb[1],rgb[2]))*0.95;
rgb[0]-=wht;

View File

@ -103,7 +103,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
float hueX=0, hueY=0;
uint16_t hueHue=0, hueCt=0;
uint8_t hueBri=0, hueSat=0, hueColormode=0;
byte hueBri=0, hueSat=0, hueColormode=0;
if (getJsonValue(&hueResp,"on").charAt(0) == 't')
{
@ -149,7 +149,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
}
} else //On/Off device
{
hueBri = bri_last;
hueBri = briLast;
}
} else
{
@ -165,7 +165,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
if (hueApplyOnOff)
{
if (hueBri==0) {bri = 0;}
else if (bri==0 && hueBri>0) bri = bri_last;
else if (bri==0 && hueBri>0) bri = briLast;
}
if (hueApplyBri)
{