Refactored variables for better readability
This commit is contained in:
parent
3ef4a2b9d2
commit
c93b185f54
@ -73,7 +73,7 @@ void WS2812FX::stop() {
|
|||||||
strip_off();
|
strip_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setMode(uint8_t m) {
|
void WS2812FX::setMode(byte m) {
|
||||||
_counter_mode_call = 0;
|
_counter_mode_call = 0;
|
||||||
_counter_mode_step = 0;
|
_counter_mode_step = 0;
|
||||||
_mode_last_call_time = 0;
|
_mode_last_call_time = 0;
|
||||||
@ -83,7 +83,7 @@ void WS2812FX::setMode(uint8_t m) {
|
|||||||
strip_off_respectLock();
|
strip_off_respectLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setSpeed(uint8_t s) {
|
void WS2812FX::setSpeed(byte s) {
|
||||||
_counter_mode_call = 0;
|
_counter_mode_call = 0;
|
||||||
_counter_mode_step = 0;
|
_counter_mode_step = 0;
|
||||||
_mode_last_call_time = 0;
|
_mode_last_call_time = 0;
|
||||||
@ -91,35 +91,35 @@ void WS2812FX::setSpeed(uint8_t s) {
|
|||||||
strip_off_respectLock();
|
strip_off_respectLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::increaseSpeed(uint8_t s) {
|
void WS2812FX::increaseSpeed(byte s) {
|
||||||
s = constrain(_speed + s, SPEED_MIN, SPEED_MAX);
|
s = constrain(_speed + s, SPEED_MIN, SPEED_MAX);
|
||||||
setSpeed(s);
|
setSpeed(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::decreaseSpeed(uint8_t s) {
|
void WS2812FX::decreaseSpeed(byte s) {
|
||||||
s = constrain(_speed - s, SPEED_MIN, SPEED_MAX);
|
s = constrain(_speed - s, SPEED_MIN, SPEED_MAX);
|
||||||
setSpeed(s);
|
setSpeed(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setIntensity(uint8_t in) {
|
void WS2812FX::setIntensity(byte in) {
|
||||||
_intensity=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);
|
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);
|
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);
|
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);
|
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);
|
setBrightness(_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::increaseBrightness(uint8_t s) {
|
void WS2812FX::increaseBrightness(byte s) {
|
||||||
s = constrain(_brightness + s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
s = constrain(_brightness + s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
||||||
setBrightness(s);
|
setBrightness(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::decreaseBrightness(uint8_t s) {
|
void WS2812FX::decreaseBrightness(byte s) {
|
||||||
s = constrain(_brightness - s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
s = constrain(_brightness - s, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
||||||
setBrightness(s);
|
setBrightness(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean WS2812FX::isRunning() {
|
bool WS2812FX::isRunning() {
|
||||||
return _running;
|
return _running;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getMode(void) {
|
byte WS2812FX::getMode(void) {
|
||||||
return _mode_index;
|
return _mode_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getSpeed(void) {
|
byte WS2812FX::getSpeed(void) {
|
||||||
return _speed;
|
return _speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getBrightness(void) {
|
byte WS2812FX::getBrightness(void) {
|
||||||
return _brightness;
|
return _brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getModeCount(void) {
|
byte WS2812FX::getModeCount(void) {
|
||||||
return MODE_COUNT;
|
return MODE_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void WS2812FX::strip_off_respectLock() {
|
|||||||
* The colours are a transition r -> g -> b -> back to r
|
* The colours are a transition r -> g -> b -> back to r
|
||||||
* Inspired by the Adafruit examples.
|
* Inspired by the Adafruit examples.
|
||||||
*/
|
*/
|
||||||
uint32_t WS2812FX::color_wheel(uint8_t pos) {
|
uint32_t WS2812FX::color_wheel(byte pos) {
|
||||||
pos = 255 - pos;
|
pos = 255 - pos;
|
||||||
if(pos < 85) {
|
if(pos < 85) {
|
||||||
return ((uint32_t)(255 - pos * 3) << 16) | ((uint32_t)(0) << 8) | (pos * 3);
|
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.
|
* Returns a new, random wheel index with a minimum distance of 42 from pos.
|
||||||
*/
|
*/
|
||||||
uint8_t WS2812FX::get_random_wheel_index(uint8_t pos) {
|
byte WS2812FX::get_random_wheel_index(byte pos) {
|
||||||
uint8_t r = 0;
|
byte r = 0;
|
||||||
uint8_t x = 0;
|
byte x = 0;
|
||||||
uint8_t y = 0;
|
byte y = 0;
|
||||||
uint8_t d = 0;
|
byte d = 0;
|
||||||
|
|
||||||
while(d < 42) {
|
while(d < 42) {
|
||||||
r = random(256);
|
r = random(256);
|
||||||
@ -360,13 +360,13 @@ void WS2812FX::mode_multi_dynamic(void) {
|
|||||||
void WS2812FX::mode_breath(void) {
|
void WS2812FX::mode_breath(void) {
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // step
|
// 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
|
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) {
|
if(_counter_mode_call == 0) {
|
||||||
_mode_color = breath_brightness_steps[0] + 1;
|
_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) {
|
if(_counter_mode_step < 8) {
|
||||||
breath_brightness--;
|
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
|
// 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]) {
|
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++) {
|
for(uint16_t i=0; i < _led_count; i++) {
|
||||||
@ -400,10 +400,10 @@ void WS2812FX::mode_fade(void) {
|
|||||||
int y = _counter_mode_step - 127;
|
int y = _counter_mode_step - 127;
|
||||||
y = 256 - (abs(y) * 2);
|
y = 256 - (abs(y) * 2);
|
||||||
double z = (double)y/256;
|
double z = (double)y/256;
|
||||||
uint8_t w = ((_color >> 24) & 0xFF), ws = ((_color_sec >> 24) & 0xFF);
|
byte w = ((_color >> 24) & 0xFF), ws = ((_color_sec >> 24) & 0xFF);
|
||||||
uint8_t r = ((_color >> 16) & 0xFF), rs = ((_color_sec >> 16) & 0xFF);
|
byte r = ((_color >> 16) & 0xFF), rs = ((_color_sec >> 16) & 0xFF);
|
||||||
uint8_t g = ((_color >> 8) & 0xFF), gs = ((_color_sec >> 8) & 0xFF);
|
byte g = ((_color >> 8) & 0xFF), gs = ((_color_sec >> 8) & 0xFF);
|
||||||
uint8_t b = (_color & 0xFF), bs = (_color_sec & 0xFF);
|
byte b = (_color & 0xFF), bs = (_color_sec & 0xFF);
|
||||||
w = w+((ws - w)*z);
|
w = w+((ws - w)*z);
|
||||||
r = r+((rs - r)*z);
|
r = r+((rs - r)*z);
|
||||||
g = g+((gs - g)*z);
|
g = g+((gs - g)*z);
|
||||||
@ -506,7 +506,7 @@ void WS2812FX::mode_rainbow_cycle(void) {
|
|||||||
* Inspired by the Adafruit examples.
|
* Inspired by the Adafruit examples.
|
||||||
*/
|
*/
|
||||||
void WS2812FX::mode_theater_chase(void) {
|
void WS2812FX::mode_theater_chase(void) {
|
||||||
uint8_t j = _counter_mode_call % 6;
|
byte j = _counter_mode_call % 6;
|
||||||
if(j % 2 == 0) {
|
if(j % 2 == 0) {
|
||||||
for(uint16_t i=0; i < _led_count; i=i+3) {
|
for(uint16_t i=0; i < _led_count; i=i+3) {
|
||||||
if (!_locked[i+(j/2)])
|
if (!_locked[i+(j/2)])
|
||||||
@ -529,7 +529,7 @@ void WS2812FX::mode_theater_chase(void) {
|
|||||||
* Inspired by the Adafruit examples.
|
* Inspired by the Adafruit examples.
|
||||||
*/
|
*/
|
||||||
void WS2812FX::mode_theater_chase_rainbow(void) {
|
void WS2812FX::mode_theater_chase_rainbow(void) {
|
||||||
uint8_t j = _counter_mode_call % 6;
|
byte j = _counter_mode_call % 6;
|
||||||
if(j % 2 == 0) {
|
if(j % 2 == 0) {
|
||||||
for(uint16_t i=0; i < _led_count; i=i+3) {
|
for(uint16_t i=0; i < _led_count; i=i+3) {
|
||||||
if (!_locked[i+(j/2)])
|
if (!_locked[i+(j/2)])
|
||||||
@ -552,10 +552,10 @@ void WS2812FX::mode_theater_chase_rainbow(void) {
|
|||||||
* Running lights effect with smooth sine transition.
|
* Running lights effect with smooth sine transition.
|
||||||
*/
|
*/
|
||||||
void WS2812FX::mode_running_lights(void) {
|
void WS2812FX::mode_running_lights(void) {
|
||||||
uint8_t w = ((_color >> 24) & 0xFF);
|
byte w = ((_color >> 24) & 0xFF);
|
||||||
uint8_t r = ((_color >> 16) & 0xFF);
|
byte r = ((_color >> 16) & 0xFF);
|
||||||
uint8_t g = ((_color >> 8) & 0xFF);
|
byte g = ((_color >> 8) & 0xFF);
|
||||||
uint8_t b = (_color & 0xFF);
|
byte b = (_color & 0xFF);
|
||||||
|
|
||||||
for(uint16_t i=0; i < _led_count; i++) {
|
for(uint16_t i=0; i < _led_count; i++) {
|
||||||
int s = (sin(i+_counter_mode_call) * 127) + 128;
|
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.
|
* _color_sec flashes running on _color.
|
||||||
*/
|
*/
|
||||||
void WS2812FX::mode_chase_flash(void) {
|
void WS2812FX::mode_chase_flash(void) {
|
||||||
const static uint8_t flash_count = 4;
|
const static byte flash_count = 4;
|
||||||
uint8_t flash_step = _counter_mode_call % ((flash_count * 2) + 1);
|
byte flash_step = _counter_mode_call % ((flash_count * 2) + 1);
|
||||||
|
|
||||||
for(uint16_t i=0; i < _led_count; i++) {
|
for(uint16_t i=0; i < _led_count; i++) {
|
||||||
if (!_locked[i])
|
if (!_locked[i])
|
||||||
@ -933,8 +933,8 @@ void WS2812FX::mode_chase_flash(void) {
|
|||||||
* _color_sec flashes running, followed by random color.
|
* _color_sec flashes running, followed by random color.
|
||||||
*/
|
*/
|
||||||
void WS2812FX::mode_chase_flash_random(void) {
|
void WS2812FX::mode_chase_flash_random(void) {
|
||||||
const static uint8_t flash_count = 4;
|
const static byte flash_count = 4;
|
||||||
uint8_t flash_step = _counter_mode_call % ((flash_count * 2) + 1);
|
byte flash_step = _counter_mode_call % ((flash_count * 2) + 1);
|
||||||
|
|
||||||
for(uint16_t i=0; i < _counter_mode_step; i++) {
|
for(uint16_t i=0; i < _counter_mode_step; i++) {
|
||||||
if (!_locked[i])
|
if (!_locked[i])
|
||||||
@ -1606,13 +1606,13 @@ void WS2812FX::mode_cc_core()
|
|||||||
for (int i = 0; i < _cc_num1; i++)
|
for (int i = 0; i < _cc_num1; i++)
|
||||||
{
|
{
|
||||||
int num = 0;
|
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_fs) setPixelColor(num, _color);
|
||||||
if (_cc_fe) setPixelColor(_cc_i2 - num, _color);
|
if (_cc_fe) setPixelColor(_cc_i2 - num, _color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
show();
|
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);
|
_mode_delay = 10 + ((250 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1831,7 +1831,7 @@ void WS2812FX::setCronixieBacklight(bool b)
|
|||||||
_cronixieBacklightEnabled = b;
|
_cronixieBacklightEnabled = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setCronixieDigits(uint8_t d[])
|
void WS2812FX::setCronixieDigits(byte d[])
|
||||||
{
|
{
|
||||||
for (int i = 0; i<6; i++)
|
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 _mARequired = 100; //ESP power
|
||||||
double _mul = (double)b/255;
|
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.
|
//It is NOT guaranteed to stay within the safeAmps margin.
|
||||||
//Stay safe with high amperage and have a reasonable safety margin!
|
//Stay safe with high amperage and have a reasonable safety margin!
|
||||||
//I am NOT to be held liable for burned down garages!
|
//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);
|
double _mARequired = getPowerEstimate(leds,c,b);
|
||||||
if (_mARequired > safeMilliAmps)
|
if (_mARequired > safeMilliAmps)
|
||||||
@ -1869,72 +1869,72 @@ double WS2812FX::getSafePowerMultiplier(double safeMilliAmps, uint8_t leds, uint
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setCCIndex1(uint8_t i1)
|
void WS2812FX::setCCIndex1(byte i1)
|
||||||
{
|
{
|
||||||
if (i1 < _led_count-1) _cc_i1 = i1;
|
if (i1 < _led_count-1) _cc_i1 = i1;
|
||||||
if (_cc_i2 <= i1) _cc_i2 = i1+1;
|
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 (i2 > _cc_i1) _cc_i2 = i2;
|
||||||
if (_cc_i2 >= _led_count) _cc_i2 = _led_count-1;
|
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;
|
_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;
|
_cc_num1 = np;
|
||||||
_counter_cc_step = 0;
|
_counter_ccStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setCCNum2(uint8_t ns)
|
void WS2812FX::setCCNum2(byte ns)
|
||||||
{
|
{
|
||||||
_cc_num2 = 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;
|
_ccStep = stp;
|
||||||
_counter_cc_step = 0;
|
_counter_ccStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setCCFS(bool fs)
|
void WS2812FX::setCCFS(bool fs)
|
||||||
{
|
{
|
||||||
_cc_fs = fs;
|
_cc_fs = fs;
|
||||||
_cc_fe = (fs) ? _cc_fe : true;
|
_cc_fe = (fs) ? _cc_fe : true;
|
||||||
_counter_cc_step = 0;
|
_counter_ccStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setCCFE(bool fe)
|
void WS2812FX::setCCFE(bool fe)
|
||||||
{
|
{
|
||||||
_cc_fe = fe;
|
_cc_fe = fe;
|
||||||
_cc_fs = (fe) ? _cc_fs : true;
|
_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);
|
setCCIndex1(i1);
|
||||||
setCCIndex2(i2);
|
setCCIndex2(i2);
|
||||||
setCCStart(is);
|
setCCStart(is);
|
||||||
_cc_num1 = np;
|
_cc_num1 = np;
|
||||||
_cc_num2 = ns;
|
_cc_num2 = ns;
|
||||||
_cc_step = stp;
|
_ccStep = stp;
|
||||||
setCCFS(fs);
|
setCCFS(fs);
|
||||||
setCCFE(fe);
|
setCCFE(fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Added for quick NeoPixelBus compatibility with Adafruit syntax
|
//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
|
#ifdef RGBW
|
||||||
NeoPixelBrightnessBus::SetPixelColor(i, RgbwColor(r,g,b,w));
|
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
|
#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 (_reverseMode) i = _led_count - 1 -i;
|
||||||
if (!_cronixieMode)
|
if (!_cronixieMode)
|
||||||
@ -1955,13 +1955,13 @@ void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if(i>6)return;
|
if(i>6)return;
|
||||||
uint8_t o = 10*i;
|
byte o = 10*i;
|
||||||
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
|
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
|
||||||
{
|
{
|
||||||
uint8_t rCorr = (int)(((double)((_color_sec>>16) & 0xFF))*_cronixieSecMultiplier);
|
byte rCorr = (int)(((double)((_color_sec>>16) & 0xFF))*_cronixieSecMultiplier);
|
||||||
uint8_t gCorr = (int)(((double)((_color_sec>>8) & 0xFF))*_cronixieSecMultiplier);
|
byte gCorr = (int)(((double)((_color_sec>>8) & 0xFF))*_cronixieSecMultiplier);
|
||||||
uint8_t bCorr = (int)(((double)((_color_sec) & 0xFF))*_cronixieSecMultiplier);
|
byte bCorr = (int)(((double)((_color_sec) & 0xFF))*_cronixieSecMultiplier);
|
||||||
uint8_t wCorr = (int)(((double)((_color_sec>>24) & 0xFF))*_cronixieSecMultiplier);
|
byte wCorr = (int)(((double)((_color_sec>>24) & 0xFF))*_cronixieSecMultiplier);
|
||||||
for (int j=o; j< o+19; j++)
|
for (int j=o; j< o+19; j++)
|
||||||
{
|
{
|
||||||
setPixelColorRaw(j,rCorr,gCorr,bCorr,wCorr);
|
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);
|
setPixelColor(i,r,g,b,0);
|
||||||
}
|
}
|
||||||
@ -2005,7 +2005,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
|
|||||||
if (_cronixieMode)
|
if (_cronixieMode)
|
||||||
{
|
{
|
||||||
if(i>6)return 0;
|
if(i>6)return 0;
|
||||||
uint8_t o = 10*i;
|
byte o = 10*i;
|
||||||
switch(_cronixieDigits[i])
|
switch(_cronixieDigits[i])
|
||||||
{
|
{
|
||||||
case 0: i=o+5; break;
|
case 0: i=o+5; break;
|
||||||
@ -2030,7 +2030,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setBrightness(uint8_t b)
|
void WS2812FX::setBrightness(byte b)
|
||||||
{
|
{
|
||||||
_brightness = constrain(b, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
_brightness = constrain(b, BRIGHTNESS_MIN, BRIGHTNESS_MAX);
|
||||||
NeoPixelBrightnessBus::SetBrightness(_brightness);
|
NeoPixelBrightnessBus::SetBrightness(_brightness);
|
||||||
@ -2065,13 +2065,13 @@ void WS2812FX::begin()
|
|||||||
|
|
||||||
//For some reason min and max are not declared here
|
//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;
|
if (w > v) return v;
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::maxval (uint8_t v, uint8_t w)
|
byte WS2812FX::maxval (byte v, byte w)
|
||||||
{
|
{
|
||||||
if (w > v) return w;
|
if (w > v) return w;
|
||||||
return v;
|
return v;
|
||||||
|
@ -208,49 +208,49 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
_cc_i2 = n-1;
|
_cc_i2 = n-1;
|
||||||
_cc_num1 = 5;
|
_cc_num1 = 5;
|
||||||
_cc_num2 = 5;
|
_cc_num2 = 5;
|
||||||
_cc_step = 1;
|
_ccStep = 1;
|
||||||
_counter_mode_call = 0;
|
_counter_mode_call = 0;
|
||||||
_counter_mode_step = 0;
|
_counter_mode_step = 0;
|
||||||
_counter_cc_step = 0;
|
_counter_ccStep = 0;
|
||||||
_fastStandard = false;
|
_fastStandard = false;
|
||||||
_reverseMode = false;
|
_reverseMode = false;
|
||||||
_locked = new boolean[n];
|
_locked = new bool[n];
|
||||||
_cronixieDigits = new uint8_t[6];
|
_cronixieDigits = new byte[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show(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),
|
init(void),
|
||||||
service(void),
|
service(void),
|
||||||
start(void),
|
start(void),
|
||||||
stop(void),
|
stop(void),
|
||||||
setMode(uint8_t m),
|
setMode(byte m),
|
||||||
setCustomChase(uint8_t i1, uint8_t i2, uint8_t is, uint8_t np, uint8_t ns, uint8_t stp, bool fs, bool fe),
|
setCustomChase(byte i1, byte i2, byte is, byte np, byte ns, byte stp, bool fs, bool fe),
|
||||||
setCCIndex1(uint8_t i1),
|
setCCIndex1(byte i1),
|
||||||
setCCIndex2(uint8_t i2),
|
setCCIndex2(byte i2),
|
||||||
setCCStart(uint8_t is),
|
setCCStart(byte is),
|
||||||
setCCNum1(uint8_t np),
|
setCCNum1(byte np),
|
||||||
setCCNum2(uint8_t ns),
|
setCCNum2(byte ns),
|
||||||
setCCStep(uint8_t stp),
|
setCCStep(byte stp),
|
||||||
setCCFS(bool fs),
|
setCCFS(bool fs),
|
||||||
setCCFE(bool fe),
|
setCCFE(bool fe),
|
||||||
setSpeed(uint8_t s),
|
setSpeed(byte s),
|
||||||
setIntensity(uint8_t in),
|
setIntensity(byte in),
|
||||||
increaseSpeed(uint8_t s),
|
increaseSpeed(byte s),
|
||||||
decreaseSpeed(uint8_t s),
|
decreaseSpeed(byte s),
|
||||||
setColor(uint8_t r, uint8_t g, uint8_t b),
|
setColor(byte r, byte g, byte b),
|
||||||
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
setColor(byte r, byte g, byte b, byte w),
|
||||||
setColor(uint32_t c),
|
setColor(uint32_t c),
|
||||||
setSecondaryColor(uint8_t r, uint8_t g, uint8_t b),
|
setSecondaryColor(byte r, byte g, byte b),
|
||||||
setSecondaryColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
setSecondaryColor(byte r, byte g, byte b, byte w),
|
||||||
setSecondaryColor(uint32_t c),
|
setSecondaryColor(uint32_t c),
|
||||||
setBrightness(uint8_t b),
|
setBrightness(byte b),
|
||||||
increaseBrightness(uint8_t s),
|
increaseBrightness(byte s),
|
||||||
decreaseBrightness(uint8_t s),
|
decreaseBrightness(byte s),
|
||||||
setReverseMode(bool b),
|
setReverseMode(bool b),
|
||||||
driverModeCronixie(bool b),
|
driverModeCronixie(bool b),
|
||||||
setCronixieDigits(uint8_t* d),
|
setCronixieDigits(byte* d),
|
||||||
setCronixieBacklight(bool b),
|
setCronixieBacklight(bool b),
|
||||||
setIndividual(int i),
|
setIndividual(int i),
|
||||||
setIndividual(int i, uint32_t col),
|
setIndividual(int i, uint32_t col),
|
||||||
@ -267,12 +267,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
setLedCount(uint16_t i),
|
setLedCount(uint16_t i),
|
||||||
setFade(int sp);
|
setFade(int sp);
|
||||||
|
|
||||||
boolean
|
bool
|
||||||
isRunning(void),
|
isRunning(void),
|
||||||
isLocked(int i);
|
isLocked(int i);
|
||||||
|
|
||||||
uint8_t
|
byte
|
||||||
get_random_wheel_index(uint8_t),
|
get_random_wheel_index(byte),
|
||||||
getMode(void),
|
getMode(void),
|
||||||
getSpeed(void),
|
getSpeed(void),
|
||||||
getIntensity(void),
|
getIntensity(void),
|
||||||
@ -280,12 +280,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
getModeCount(void);
|
getModeCount(void);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
color_wheel(uint8_t),
|
color_wheel(byte),
|
||||||
getColor(void);
|
getColor(void);
|
||||||
|
|
||||||
double
|
double
|
||||||
getPowerEstimate(uint8_t leds, uint32_t c, uint8_t b),
|
getPowerEstimate(byte leds, uint32_t c, byte b),
|
||||||
getSafePowerMultiplier(double safeMilliAmps, uint8_t leds, uint32_t c, uint8_t b);
|
getSafePowerMultiplier(double safeMilliAmps, byte leds, uint32_t c, byte b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -293,8 +293,8 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
begin(void),
|
begin(void),
|
||||||
clear(void),
|
clear(void),
|
||||||
setPixelColor(uint16_t i, uint32_t c),
|
setPixelColor(uint16_t i, uint32_t c),
|
||||||
setPixelColor(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, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
setPixelColorRaw(uint16_t i, byte r, byte g, byte b, byte w),
|
||||||
dofade(void),
|
dofade(void),
|
||||||
strip_off(void),
|
strip_off(void),
|
||||||
strip_off_respectLock(void),
|
strip_off_respectLock(void),
|
||||||
@ -359,7 +359,7 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
mode_cc_blink(void),
|
mode_cc_blink(void),
|
||||||
mode_cc_random(void);
|
mode_cc_random(void);
|
||||||
|
|
||||||
boolean
|
bool
|
||||||
_triggered,
|
_triggered,
|
||||||
_fastStandard,
|
_fastStandard,
|
||||||
_reverseMode,
|
_reverseMode,
|
||||||
@ -369,12 +369,12 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
_cc_fe,
|
_cc_fe,
|
||||||
_running;
|
_running;
|
||||||
|
|
||||||
boolean*
|
bool*
|
||||||
_locked;
|
_locked;
|
||||||
|
|
||||||
uint8_t
|
byte
|
||||||
minval(uint8_t v, uint8_t w),
|
minval(byte v, byte w),
|
||||||
maxval(uint8_t v, uint8_t w),
|
maxval(byte v, byte w),
|
||||||
_mode_index,
|
_mode_index,
|
||||||
_speed,
|
_speed,
|
||||||
_intensity,
|
_intensity,
|
||||||
@ -383,10 +383,10 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
_cc_is,
|
_cc_is,
|
||||||
_cc_num1,
|
_cc_num1,
|
||||||
_cc_num2,
|
_cc_num2,
|
||||||
_cc_step,
|
_ccStep,
|
||||||
_brightness;
|
_brightness;
|
||||||
|
|
||||||
uint8_t*
|
byte*
|
||||||
_cronixieDigits;
|
_cronixieDigits;
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
@ -398,7 +398,7 @@ class WS2812FX : public NeoPixelBrightnessBus<PIXELFEATURE, PIXELMETHOD> {
|
|||||||
_color_sec,
|
_color_sec,
|
||||||
_counter_mode_call,
|
_counter_mode_call,
|
||||||
_counter_mode_step,
|
_counter_mode_step,
|
||||||
_counter_cc_step,
|
_counter_ccStep,
|
||||||
_mode_color,
|
_mode_color,
|
||||||
_mode_color_sec,
|
_mode_color_sec,
|
||||||
_mode_delay;
|
_mode_delay;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -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>
|
<button type="button" onclick="U()">Manual OTA Update</button><br>
|
||||||
Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
|
Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
|
||||||
<h3>About</h3>
|
<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>
|
(c) 2016-2018 Christian Schwinne <br>
|
||||||
<i>Licensed under the MIT license</i><br><br>
|
<i>Licensed under the MIT license</i><br><br>
|
||||||
<i>Uses libraries:</i><br>
|
<i>Uses libraries:</i><br>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* @title WLED project sketch
|
* @title WLED project sketch
|
||||||
* @version 0.6.0_dev
|
* @version 0.6.0
|
||||||
* @author Christian Schwinne
|
* @author Christian Schwinne
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -33,12 +33,12 @@
|
|||||||
#include "WS2812FX.h"
|
#include "WS2812FX.h"
|
||||||
|
|
||||||
//version in format yymmddb (b = daily build)
|
//version in format yymmddb (b = daily build)
|
||||||
#define VERSION 1803142
|
#define VERSION 1803143
|
||||||
const String versionString = "0.6.0_dev";
|
const String versionString = "0.6.0";
|
||||||
|
|
||||||
//AP and OTA default passwords (change them!)
|
//AP and OTA default passwords (change them!)
|
||||||
String appass = "wled1234";
|
String apPass = "wled1234";
|
||||||
String otapass = "wledota";
|
String otaPass = "wledota";
|
||||||
|
|
||||||
//If you have an RGBW strip, also uncomment first line in WS2812FX.h!
|
//If you have an RGBW strip, also uncomment first line in WS2812FX.h!
|
||||||
bool useRGBW = false;
|
bool useRGBW = false;
|
||||||
@ -51,73 +51,72 @@ bool useRGBW = false;
|
|||||||
|
|
||||||
//Hardware-settings (only changeble via code)
|
//Hardware-settings (only changeble via code)
|
||||||
#define LEDCOUNT 255 //maximum, exact count set-able via settings
|
#define LEDCOUNT 255 //maximum, exact count set-able via settings
|
||||||
uint8_t buttonPin = 0; //needs pull-up
|
byte buttonPin = 0; //needs pull-up
|
||||||
uint8_t auxPin = 15; //use e.g. for external relay
|
byte auxPin = 15; //use e.g. for external relay
|
||||||
uint8_t auxDefaultState = 0; //0: input 1: high 2: low
|
byte auxDefaultState = 0; //0: input 1: high 2: low
|
||||||
uint8_t auxTriggeredState = 0; //0: input 1: high 2: low
|
byte auxTriggeredState = 0; //0: input 1: high 2: low
|
||||||
|
|
||||||
//Default CONFIG
|
//Default CONFIG
|
||||||
String serverDescription = versionString;
|
String serverDescription = versionString;
|
||||||
uint8_t currentTheme = 0;
|
byte currentTheme = 0;
|
||||||
String clientssid = "Your_Network_Here";
|
String clientSSID = "Your_Network";
|
||||||
String clientpass = "";
|
String clientPass = "";
|
||||||
String cmdns = "led";
|
String cmDNS = "led";
|
||||||
uint8_t ledcount = 10; //lowered to prevent accidental overcurrent
|
byte ledCount = 10; //lowered to prevent accidental overcurrent
|
||||||
String apssid = ""; //AP off by default (unless setup)
|
String apSSID = ""; //AP off by default (unless setup)
|
||||||
uint8_t apchannel = 1;
|
byte apChannel = 1;
|
||||||
uint8_t aphide = 0;
|
byte apHide = 0;
|
||||||
uint8_t apWaitTimeSecs = 32;
|
byte apWaitTimeSecs = 32;
|
||||||
boolean recoveryAPDisabled = false;
|
bool recoveryAPDisabled = false;
|
||||||
IPAddress staticip(0, 0, 0, 0);
|
IPAddress staticIP(0, 0, 0, 0);
|
||||||
IPAddress staticgateway(0, 0, 0, 0);
|
IPAddress staticGateway(0, 0, 0, 0);
|
||||||
IPAddress staticsubnet(255, 255, 255, 0);
|
IPAddress staticSubnet(255, 255, 255, 0);
|
||||||
IPAddress staticdns(8, 8, 8, 8); //only for NTP
|
IPAddress staticDNS(8, 8, 8, 8); //only for NTP
|
||||||
bool useHSB = false, useHSBDefault = false;
|
bool useHSB = false, useHSBDefault = false;
|
||||||
bool turnOnAtBoot = true;
|
bool turnOnAtBoot = true;
|
||||||
uint8_t bootPreset = 0;
|
byte bootPreset = 0;
|
||||||
byte col_s[]{255, 159, 0};
|
byte colS[]{255, 159, 0};
|
||||||
byte col_sec_s[]{0, 0, 0};
|
byte colSecS[]{0, 0, 0};
|
||||||
byte white_s = 0;
|
byte whiteS = 0;
|
||||||
byte white_sec_s = 0;
|
byte whiteSecS = 0;
|
||||||
byte bri_s = 127;
|
byte briS = 127;
|
||||||
uint8_t nightlightTargetBri = 0, bri_nl_t;
|
byte nightlightTargetBri = 0;
|
||||||
bool fadeTransition = true;
|
bool fadeTransition = true;
|
||||||
bool sweepTransition = false, sweepDirection = true;
|
bool sweepTransition = false, sweepDirection = true;
|
||||||
uint16_t transitionDelay = 1200;
|
uint16_t transitionDelay = 1200;
|
||||||
bool reverseMode = false;
|
bool reverseMode = false;
|
||||||
bool otaLock = false, wifiLock = false;
|
bool otaLock = false, wifiLock = false;
|
||||||
bool aOtaEnabled = true;
|
bool aOtaEnabled = true;
|
||||||
bool onlyAP = false;
|
|
||||||
bool buttonEnabled = true;
|
bool buttonEnabled = true;
|
||||||
bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false, notifyTwice = false;
|
bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false, notifyTwice = false;
|
||||||
bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificationColor = true, receiveNotificationEffects = true;
|
bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificationColor = true, receiveNotificationEffects = true;
|
||||||
uint8_t briMultiplier = 100;
|
byte briMultiplier = 100;
|
||||||
uint8_t nightlightDelayMins = 60;
|
byte nightlightDelayMins = 60;
|
||||||
bool nightlightFade = true;
|
bool nightlightFade = true;
|
||||||
uint16_t udpPort = 21324;
|
uint16_t udpPort = 21324;
|
||||||
uint8_t effectDefault = 0;
|
byte effectDefault = 0;
|
||||||
uint8_t effectSpeedDefault = 75;
|
byte effectSpeedDefault = 75;
|
||||||
uint8_t effectIntensityDefault = 128;
|
byte effectIntensityDefault = 128;
|
||||||
//NTP stuff
|
//NTP stuff
|
||||||
boolean ntpEnabled = false;
|
bool ntpEnabled = false;
|
||||||
IPAddress ntpServerIP;
|
IPAddress ntpServerIP;
|
||||||
const char* ntpServerName = "0.wled.pool.ntp.org";
|
const char* ntpServerName = "0.wled.pool.ntp.org";
|
||||||
//custom chase
|
//custom chase
|
||||||
uint8_t cc_numPrimary = 2;
|
byte ccNumPrimary = 2;
|
||||||
uint8_t cc_numSecondary = 4;
|
byte ccNumSecondary = 4;
|
||||||
uint8_t cc_index1 = 0;
|
byte ccIndex1 = 0;
|
||||||
uint8_t cc_index2 = ledcount -1;
|
byte ccIndex2 = ledCount -1;
|
||||||
bool cc_fromStart = true, cc_fromEnd = false;
|
bool ccFromStart = true, ccFromEnd = false;
|
||||||
uint8_t cc_step = 1;
|
byte ccStep = 1;
|
||||||
uint8_t cc_start = 0;
|
byte ccStart = 0;
|
||||||
|
|
||||||
//alexa
|
//alexa
|
||||||
boolean alexaEnabled = true;
|
bool alexaEnabled = true;
|
||||||
String alexaInvocationName = "Light";
|
String alexaInvocationName = "Light";
|
||||||
|
|
||||||
uint8_t macroBoot = 0, macroNl = 0;
|
byte macroBoot = 0, macroNl = 0;
|
||||||
uint8_t macroAlexaOn = 0, macroAlexaOff = 0;
|
byte macroAlexaOn = 0, macroAlexaOff = 0;
|
||||||
uint8_t macroButton = 0, macroCountdown = 0, macroLongPress = 0;
|
byte macroButton = 0, macroCountdown = 0, macroLongPress = 0;
|
||||||
|
|
||||||
unsigned long countdownTime = 1514764800L;
|
unsigned long countdownTime = 1514764800L;
|
||||||
|
|
||||||
@ -129,7 +128,7 @@ bool huePollingEnabled = false, hueAttempt = false;
|
|||||||
uint16_t huePollIntervalMs = 2500;
|
uint16_t huePollIntervalMs = 2500;
|
||||||
uint32_t huePollIntervalMsTemp = 2500;
|
uint32_t huePollIntervalMsTemp = 2500;
|
||||||
String hueApiKey = "api";
|
String hueApiKey = "api";
|
||||||
uint8_t huePollLightId = 1;
|
byte huePollLightId = 1;
|
||||||
IPAddress hueIP = (0,0,0,0);
|
IPAddress hueIP = (0,0,0,0);
|
||||||
bool notifyHue = true;
|
bool notifyHue = true;
|
||||||
bool hueApplyOnOff = true, hueApplyBri = true, hueApplyColor = true;
|
bool hueApplyOnOff = true, hueApplyBri = true, hueApplyColor = true;
|
||||||
@ -137,70 +136,71 @@ String hueError = "Inactive";
|
|||||||
uint16_t hueFailCount = 0;
|
uint16_t hueFailCount = 0;
|
||||||
float hueXLast=0, hueYLast=0;
|
float hueXLast=0, hueYLast=0;
|
||||||
uint16_t hueHueLast=0, hueCtLast=0;
|
uint16_t hueHueLast=0, hueCtLast=0;
|
||||||
uint8_t hueSatLast=0, hueBriLast=0;
|
byte hueSatLast=0, hueBriLast=0;
|
||||||
|
|
||||||
//Internal vars
|
//Internal vars
|
||||||
byte col[]{0, 0, 0};
|
byte col[]{0, 0, 0};
|
||||||
byte col_old[]{0, 0, 0};
|
byte colOld[]{0, 0, 0};
|
||||||
byte col_t[]{0, 0, 0};
|
byte colT[]{0, 0, 0};
|
||||||
byte col_it[]{0, 0, 0};
|
byte colIT[]{0, 0, 0};
|
||||||
byte col_sec[]{0, 0, 0};
|
byte colSec[]{0, 0, 0};
|
||||||
byte col_sec_it[]{0, 0, 0};
|
byte colSecIT[]{0, 0, 0};
|
||||||
byte white, white_old, white_t, white_it;
|
byte white, whiteOld, whiteT, whiteIT;
|
||||||
byte white_sec, white_sec_it;
|
byte whiteSec, whiteSecIT;
|
||||||
uint8_t lastRandomIndex = 0;
|
byte lastRandomIndex = 0;
|
||||||
unsigned long transitionStartTime;
|
unsigned long transitionStartTime;
|
||||||
unsigned long nightlightStartTime;
|
unsigned long nightlightStartTime;
|
||||||
float tper_last = 0;
|
float tperLast = 0;
|
||||||
byte bri = 0;
|
byte bri = 0;
|
||||||
byte bri_old = 0;
|
byte briOld = 0;
|
||||||
byte bri_t = 0;
|
byte briT = 0;
|
||||||
byte bri_it = 0;
|
byte briIT = 0;
|
||||||
byte bri_last = 127;
|
byte briLast = 127;
|
||||||
boolean transitionActive = false;
|
bool transitionActive = false;
|
||||||
boolean buttonPressedBefore = false;
|
bool buttonPressedBefore = false;
|
||||||
long buttonPressedTime = 0;
|
unsigned long buttonPressedTime = 0;
|
||||||
long notificationSentTime = 0;
|
unsigned long notificationSentTime = 0;
|
||||||
uint8_t notificationSentCallMode = 0;
|
byte notificationSentCallMode = 0;
|
||||||
bool notificationTwoRequired = false;
|
bool notificationTwoRequired = false;
|
||||||
boolean nightlightActive = false;
|
bool nightlightActive = false;
|
||||||
boolean nightlightActive_old = false;
|
bool nightlightActiveOld = false;
|
||||||
int nightlightDelayMs;
|
uint32_t nightlightDelayMs;
|
||||||
uint8_t effectCurrent = 0;
|
byte briNlT;
|
||||||
uint8_t effectSpeed = 75;
|
byte effectCurrent = 0;
|
||||||
uint8_t effectIntensity = 128;
|
byte effectSpeed = 75;
|
||||||
boolean udpConnected = false;
|
byte effectIntensity = 128;
|
||||||
byte udpIn[1026];
|
bool onlyAP = false;
|
||||||
|
bool udpConnected = false;
|
||||||
String cssCol[]={"","","","","",""};
|
String cssCol[]={"","","","","",""};
|
||||||
String cssFont="Verdana";
|
String cssFont="Verdana";
|
||||||
String cssColorString="";
|
String cssColorString="";
|
||||||
//NTP stuff
|
//NTP stuff
|
||||||
boolean ntpConnected = false;
|
bool ntpConnected = false;
|
||||||
unsigned int ntpLocalPort = 2390;
|
unsigned int ntpLocalPort = 2390;
|
||||||
const int NTP_PACKET_SIZE = 48;
|
const uint16_t NTP_PACKET_SIZE = 48;
|
||||||
byte ntpPacketBuffer[NTP_PACKET_SIZE];
|
byte ntpPacketBuffer[NTP_PACKET_SIZE];
|
||||||
unsigned long ntpLastSyncTime = 999000000L;
|
unsigned long ntpLastSyncTime = 999000000L;
|
||||||
unsigned long ntpPacketSentTime = 999000000L;
|
unsigned long ntpPacketSentTime = 999000000L;
|
||||||
uint8_t currentTimezone = 0;
|
byte currentTimezone = 0;
|
||||||
time_t local;
|
time_t local;
|
||||||
int utcOffsetSecs = 0;
|
int utcOffsetSecs = 0;
|
||||||
|
|
||||||
//overlay stuff
|
//overlay stuff
|
||||||
uint8_t overlayDefault = 0;
|
byte overlayDefault = 0;
|
||||||
uint8_t overlayCurrent = 0;
|
byte overlayCurrent = 0;
|
||||||
uint8_t overlayMin = 0, overlayMax = ledcount-1;
|
byte overlayMin = 0, overlayMax = ledCount-1;
|
||||||
uint8_t analogClock12pixel = 0;
|
byte analogClock12pixel = 0;
|
||||||
boolean analogClockSecondsTrail = false;
|
bool analogClockSecondsTrail = false;
|
||||||
boolean analogClock5MinuteMarks = false;
|
bool analogClock5MinuteMarks = false;
|
||||||
uint8_t overlaySpeed = 200;
|
byte overlaySpeed = 200;
|
||||||
long overlayRefreshMs = 200;
|
unsigned long overlayRefreshMs = 200;
|
||||||
unsigned long overlayRefreshedTime;
|
unsigned long overlayRefreshedTime;
|
||||||
int overlayArr[6];
|
int overlayArr[6];
|
||||||
uint16_t overlayDur[6];
|
uint16_t overlayDur[6];
|
||||||
uint16_t overlayPauseDur[6];
|
uint16_t overlayPauseDur[6];
|
||||||
int nixieClockI = -1;
|
int nixieClockI = -1;
|
||||||
boolean nixiePause;
|
bool nixiePause;
|
||||||
uint8_t countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000
|
byte countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000
|
||||||
bool countdownOverTriggered = true;
|
bool countdownOverTriggered = true;
|
||||||
//cronixie
|
//cronixie
|
||||||
String cronixieDisplay = "HHMMSS";
|
String cronixieDisplay = "HHMMSS";
|
||||||
@ -210,17 +210,16 @@ bool cronixieBacklight = true;
|
|||||||
bool countdownMode = false;
|
bool countdownMode = false;
|
||||||
bool cronixieInit = false;
|
bool cronixieInit = false;
|
||||||
|
|
||||||
int arlsTimeoutMillis = 2500;
|
uint32_t arlsTimeoutMillis = 2500;
|
||||||
boolean arlsTimeout = false;
|
bool arlsTimeout = false;
|
||||||
long arlsTimeoutTime;
|
unsigned long arlsTimeoutTime;
|
||||||
boolean arlsSign = true;
|
byte auxTime = 0;
|
||||||
uint8_t auxTime = 0;
|
|
||||||
unsigned long auxStartTime;
|
unsigned long auxStartTime;
|
||||||
boolean auxActive, auxActiveBefore;
|
bool auxActive, auxActiveBefore;
|
||||||
boolean showWelcomePage = false;
|
bool showWelcomePage = false;
|
||||||
|
|
||||||
boolean useGammaCorrectionBri = false;
|
bool useGammaCorrectionBri = false;
|
||||||
boolean useGammaCorrectionRGB = true;
|
bool useGammaCorrectionRGB = true;
|
||||||
int arlsOffset = -22; //10: -22 assuming arls52
|
int arlsOffset = -22; //10: -22 assuming arls52
|
||||||
|
|
||||||
//alexa udp
|
//alexa udp
|
||||||
@ -267,7 +266,7 @@ int lastWifiState = 3;
|
|||||||
long wifiStateChangedTime = 0;
|
long wifiStateChangedTime = 0;
|
||||||
#endif
|
#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, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
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,
|
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()
|
void down()
|
||||||
{
|
{
|
||||||
bri_t = 0;
|
briT = 0;
|
||||||
setAllLeds();
|
setAllLeds();
|
||||||
DEBUG_PRINTLN("MODULE TERMINATED");
|
DEBUG_PRINTLN("MODULE TERMINATED");
|
||||||
while (1) {delay(1000);}
|
while (1) {delay(1000);}
|
||||||
@ -299,7 +298,7 @@ void down()
|
|||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
bri_t = 0;
|
briT = 0;
|
||||||
setAllLeds();
|
setAllLeds();
|
||||||
DEBUG_PRINTLN("MODULE RESET");
|
DEBUG_PRINTLN("MODULE RESET");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
@ -325,7 +324,7 @@ void loop() {
|
|||||||
if (dnsActive) dnsServer.processNextRequest();
|
if (dnsActive) dnsServer.processNextRequest();
|
||||||
handleHue();
|
handleHue();
|
||||||
handleNightlight();
|
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
|
//DEBUG
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
//2 -> 0.4p 1711302 and up
|
//2 -> 0.4p 1711302 and up
|
||||||
//3 -> 0.4 1712121 and up
|
//3 -> 0.4 1712121 and up
|
||||||
//4 -> 0.5.0 and up
|
//4 -> 0.5.0 and up
|
||||||
//5 -> 0.6.0_dev and up
|
//5 -> 0.6.0 and up
|
||||||
|
|
||||||
//todo add settings
|
//todo add settings
|
||||||
void clearEEPROM()
|
void clearEEPROM()
|
||||||
@ -37,50 +37,50 @@ void saveSettingsToEEPROM()
|
|||||||
|
|
||||||
for (int i = 0; i < 32; ++i)
|
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)
|
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)
|
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)
|
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)
|
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(224, nightlightDelayMins);
|
||||||
EEPROM.write(225, nightlightFade);
|
EEPROM.write(225, nightlightFade);
|
||||||
EEPROM.write(226, notifyDirectDefault);
|
EEPROM.write(226, notifyDirectDefault);
|
||||||
EEPROM.write(227, apchannel);
|
EEPROM.write(227, apChannel);
|
||||||
EEPROM.write(228, aphide);
|
EEPROM.write(228, apHide);
|
||||||
EEPROM.write(229, ledcount);
|
EEPROM.write(229, ledCount);
|
||||||
EEPROM.write(230, notifyButton);
|
EEPROM.write(230, notifyButton);
|
||||||
EEPROM.write(231, notifyTwice);
|
EEPROM.write(231, notifyTwice);
|
||||||
EEPROM.write(232, buttonEnabled);
|
EEPROM.write(232, buttonEnabled);
|
||||||
//233 reserved for first boot flag
|
//233 reserved for first boot flag
|
||||||
EEPROM.write(234, staticip[0]);
|
EEPROM.write(234, staticIP[0]);
|
||||||
EEPROM.write(235, staticip[1]);
|
EEPROM.write(235, staticIP[1]);
|
||||||
EEPROM.write(236, staticip[2]);
|
EEPROM.write(236, staticIP[2]);
|
||||||
EEPROM.write(237, staticip[3]);
|
EEPROM.write(237, staticIP[3]);
|
||||||
EEPROM.write(238, staticgateway[0]);
|
EEPROM.write(238, staticGateway[0]);
|
||||||
EEPROM.write(239, staticgateway[1]);
|
EEPROM.write(239, staticGateway[1]);
|
||||||
EEPROM.write(240, staticgateway[2]);
|
EEPROM.write(240, staticGateway[2]);
|
||||||
EEPROM.write(241, staticgateway[3]);
|
EEPROM.write(241, staticGateway[3]);
|
||||||
EEPROM.write(242, staticsubnet[0]);
|
EEPROM.write(242, staticSubnet[0]);
|
||||||
EEPROM.write(243, staticsubnet[1]);
|
EEPROM.write(243, staticSubnet[1]);
|
||||||
EEPROM.write(244, staticsubnet[2]);
|
EEPROM.write(244, staticSubnet[2]);
|
||||||
EEPROM.write(245, staticsubnet[3]);
|
EEPROM.write(245, staticSubnet[3]);
|
||||||
EEPROM.write(246, col_s[0]);
|
EEPROM.write(246, colS[0]);
|
||||||
EEPROM.write(247, col_s[1]);
|
EEPROM.write(247, colS[1]);
|
||||||
EEPROM.write(248, col_s[2]);
|
EEPROM.write(248, colS[2]);
|
||||||
EEPROM.write(249, bri_s);
|
EEPROM.write(249, briS);
|
||||||
EEPROM.write(250, receiveNotificationBrightness);
|
EEPROM.write(250, receiveNotificationBrightness);
|
||||||
EEPROM.write(251, fadeTransition);
|
EEPROM.write(251, fadeTransition);
|
||||||
EEPROM.write(252, reverseMode);
|
EEPROM.write(252, reverseMode);
|
||||||
@ -90,7 +90,7 @@ void saveSettingsToEEPROM()
|
|||||||
//255,250,231,230,226 notifier bytes
|
//255,250,231,230,226 notifier bytes
|
||||||
for (int i = 256; i < 288; ++i)
|
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(288, nightlightTargetBri);
|
||||||
EEPROM.write(289, otaLock);
|
EEPROM.write(289, otaLock);
|
||||||
@ -115,28 +115,28 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(i, alexaInvocationName.charAt(i-334));
|
EEPROM.write(i, alexaInvocationName.charAt(i-334));
|
||||||
}
|
}
|
||||||
EEPROM.write(366, alexaNotify);
|
EEPROM.write(366, alexaNotify);
|
||||||
EEPROM.write(367, arlsSign);
|
EEPROM.write(367, (arlsOffset>=0));
|
||||||
EEPROM.write(368, abs(arlsOffset));
|
EEPROM.write(368, abs(arlsOffset));
|
||||||
EEPROM.write(369, turnOnAtBoot);
|
EEPROM.write(369, turnOnAtBoot);
|
||||||
EEPROM.write(370, useHSBDefault);
|
EEPROM.write(370, useHSBDefault);
|
||||||
EEPROM.write(371, white_s);
|
EEPROM.write(371, whiteS);
|
||||||
EEPROM.write(372, useRGBW);
|
EEPROM.write(372, useRGBW);
|
||||||
EEPROM.write(373, sweepTransition);
|
EEPROM.write(373, sweepTransition);
|
||||||
EEPROM.write(374, sweepDirection);
|
EEPROM.write(374, sweepDirection);
|
||||||
EEPROM.write(375, apWaitTimeSecs);
|
EEPROM.write(375, apWaitTimeSecs);
|
||||||
EEPROM.write(376, recoveryAPDisabled);
|
EEPROM.write(376, recoveryAPDisabled);
|
||||||
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
||||||
EEPROM.write(378, col_sec_s[0]);
|
EEPROM.write(378, colSecS[0]);
|
||||||
EEPROM.write(379, col_sec_s[1]);
|
EEPROM.write(379, colSecS[1]);
|
||||||
EEPROM.write(380, col_sec_s[2]);
|
EEPROM.write(380, colSecS[2]);
|
||||||
EEPROM.write(381, white_sec_s);
|
EEPROM.write(381, whiteSecS);
|
||||||
EEPROM.write(382, cc_index1);
|
EEPROM.write(382, ccIndex1);
|
||||||
EEPROM.write(383, cc_index2);
|
EEPROM.write(383, ccIndex2);
|
||||||
EEPROM.write(384, cc_numPrimary);
|
EEPROM.write(384, ccNumPrimary);
|
||||||
EEPROM.write(385, cc_numSecondary);
|
EEPROM.write(385, ccNumSecondary);
|
||||||
EEPROM.write(386, cc_fromStart);
|
EEPROM.write(386, ccFromStart);
|
||||||
EEPROM.write(387, cc_fromEnd);
|
EEPROM.write(387, ccFromEnd);
|
||||||
EEPROM.write(388, cc_step);
|
EEPROM.write(388, ccStep);
|
||||||
EEPROM.write(389, bootPreset);
|
EEPROM.write(389, bootPreset);
|
||||||
EEPROM.write(390, aOtaEnabled);
|
EEPROM.write(390, aOtaEnabled);
|
||||||
EEPROM.write(391, receiveNotificationColor);
|
EEPROM.write(391, receiveNotificationColor);
|
||||||
@ -219,78 +219,78 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
}
|
}
|
||||||
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
||||||
|
|
||||||
clientssid = "";
|
clientSSID = "";
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
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)
|
for (int i = 32; i < 96; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
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)
|
for (int i = 96; i < 128; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
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)
|
for (int i = 128; i < 160; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
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)
|
for (int i = 160; i < 224; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
if (EEPROM.read(i) == 0) break;
|
||||||
appass += char(EEPROM.read(i));
|
apPass += char(EEPROM.read(i));
|
||||||
}
|
}
|
||||||
nightlightDelayMins = EEPROM.read(224);
|
nightlightDelayMins = EEPROM.read(224);
|
||||||
nightlightFade = EEPROM.read(225);
|
nightlightFade = EEPROM.read(225);
|
||||||
notifyDirectDefault = EEPROM.read(226);
|
notifyDirectDefault = EEPROM.read(226);
|
||||||
notifyDirect = notifyDirectDefault;
|
notifyDirect = notifyDirectDefault;
|
||||||
apchannel = EEPROM.read(227);
|
apChannel = EEPROM.read(227);
|
||||||
if (apchannel > 13 || apchannel < 1) apchannel = 1;
|
if (apChannel > 13 || apChannel < 1) apChannel = 1;
|
||||||
aphide = EEPROM.read(228);
|
apHide = EEPROM.read(228);
|
||||||
if (aphide > 1) aphide = 1;
|
if (apHide > 1) apHide = 1;
|
||||||
ledcount = EEPROM.read(229); if (ledcount > LEDCOUNT) ledcount = LEDCOUNT;
|
ledCount = EEPROM.read(229); if (ledCount > LEDCOUNT) ledCount = LEDCOUNT;
|
||||||
notifyButton = EEPROM.read(230);
|
notifyButton = EEPROM.read(230);
|
||||||
notifyTwice = EEPROM.read(231);
|
notifyTwice = EEPROM.read(231);
|
||||||
buttonEnabled = EEPROM.read(232);
|
buttonEnabled = EEPROM.read(232);
|
||||||
staticip[0] = EEPROM.read(234);
|
staticIP[0] = EEPROM.read(234);
|
||||||
staticip[1] = EEPROM.read(235);
|
staticIP[1] = EEPROM.read(235);
|
||||||
staticip[2] = EEPROM.read(236);
|
staticIP[2] = EEPROM.read(236);
|
||||||
staticip[3] = EEPROM.read(237);
|
staticIP[3] = EEPROM.read(237);
|
||||||
staticgateway[0] = EEPROM.read(238);
|
staticGateway[0] = EEPROM.read(238);
|
||||||
staticgateway[1] = EEPROM.read(239);
|
staticGateway[1] = EEPROM.read(239);
|
||||||
staticgateway[2] = EEPROM.read(240);
|
staticGateway[2] = EEPROM.read(240);
|
||||||
staticgateway[3] = EEPROM.read(241);
|
staticGateway[3] = EEPROM.read(241);
|
||||||
staticsubnet[0] = EEPROM.read(242);
|
staticSubnet[0] = EEPROM.read(242);
|
||||||
staticsubnet[1] = EEPROM.read(243);
|
staticSubnet[1] = EEPROM.read(243);
|
||||||
staticsubnet[2] = EEPROM.read(244);
|
staticSubnet[2] = EEPROM.read(244);
|
||||||
staticsubnet[3] = EEPROM.read(245);
|
staticSubnet[3] = EEPROM.read(245);
|
||||||
col_s[0] = EEPROM.read(246); col[0] = col_s[0];
|
colS[0] = EEPROM.read(246); col[0] = colS[0];
|
||||||
col_s[1] = EEPROM.read(247); col[1] = col_s[1];
|
colS[1] = EEPROM.read(247); col[1] = colS[1];
|
||||||
col_s[2] = EEPROM.read(248); col[2] = col_s[2];
|
colS[2] = EEPROM.read(248); col[2] = colS[2];
|
||||||
bri_s = EEPROM.read(249); bri = bri_s;
|
briS = EEPROM.read(249); bri = briS;
|
||||||
if (!EEPROM.read(369) && first)
|
if (!EEPROM.read(369) && first)
|
||||||
{
|
{
|
||||||
bri = 0; bri_last = bri_s;
|
bri = 0; briLast = briS;
|
||||||
}
|
}
|
||||||
receiveNotificationBrightness = EEPROM.read(250);
|
receiveNotificationBrightness = EEPROM.read(250);
|
||||||
fadeTransition = EEPROM.read(251);
|
fadeTransition = EEPROM.read(251);
|
||||||
reverseMode = EEPROM.read(252);
|
reverseMode = EEPROM.read(252);
|
||||||
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
||||||
briMultiplier = EEPROM.read(255);
|
briMultiplier = EEPROM.read(255);
|
||||||
otapass = "";
|
otaPass = "";
|
||||||
for (int i = 256; i < 288; ++i)
|
for (int i = 256; i < 288; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
if (EEPROM.read(i) == 0) break;
|
||||||
otapass += char(EEPROM.read(i));
|
otaPass += char(EEPROM.read(i));
|
||||||
}
|
}
|
||||||
nightlightTargetBri = EEPROM.read(288);
|
nightlightTargetBri = EEPROM.read(288);
|
||||||
otaLock = EEPROM.read(289);
|
otaLock = EEPROM.read(289);
|
||||||
@ -317,12 +317,11 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
alexaInvocationName += char(EEPROM.read(i));
|
alexaInvocationName += char(EEPROM.read(i));
|
||||||
}
|
}
|
||||||
alexaNotify = EEPROM.read(366);
|
alexaNotify = EEPROM.read(366);
|
||||||
arlsSign = EEPROM.read(367);
|
|
||||||
arlsOffset = EEPROM.read(368);
|
arlsOffset = EEPROM.read(368);
|
||||||
if (!arlsSign) arlsOffset = -arlsOffset;
|
if (!EEPROM.read(367)) arlsOffset = -arlsOffset;
|
||||||
turnOnAtBoot = EEPROM.read(369);
|
turnOnAtBoot = EEPROM.read(369);
|
||||||
useHSBDefault = EEPROM.read(370);
|
useHSBDefault = EEPROM.read(370);
|
||||||
white_s = EEPROM.read(371); white = white_s;
|
whiteS = EEPROM.read(371); white = whiteS;
|
||||||
useRGBW = EEPROM.read(372);
|
useRGBW = EEPROM.read(372);
|
||||||
sweepTransition = EEPROM.read(373);
|
sweepTransition = EEPROM.read(373);
|
||||||
sweepDirection = EEPROM.read(374);
|
sweepDirection = EEPROM.read(374);
|
||||||
@ -332,18 +331,18 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
}
|
}
|
||||||
//377 = lastEEPROMversion
|
//377 = lastEEPROMversion
|
||||||
if (lastEEPROMversion > 1) {
|
if (lastEEPROMversion > 1) {
|
||||||
col_sec_s[0] = EEPROM.read(378); col_sec[0] = col_sec_s[0];
|
colSecS[0] = EEPROM.read(378); colSec[0] = colSecS[0];
|
||||||
col_sec_s[1] = EEPROM.read(379); col_sec[1] = col_sec_s[1];
|
colSecS[1] = EEPROM.read(379); colSec[1] = colSecS[1];
|
||||||
col_sec_s[2] = EEPROM.read(380); col_sec[2] = col_sec_s[2];
|
colSecS[2] = EEPROM.read(380); colSec[2] = colSecS[2];
|
||||||
white_sec_s = EEPROM.read(381); white_sec = white_sec_s;
|
whiteSecS = EEPROM.read(381); whiteSec = whiteSecS;
|
||||||
cc_index1 = EEPROM.read(382);
|
ccIndex1 = EEPROM.read(382);
|
||||||
cc_index2 = EEPROM.read(383);
|
ccIndex2 = EEPROM.read(383);
|
||||||
cc_numPrimary = EEPROM.read(384);
|
ccNumPrimary = EEPROM.read(384);
|
||||||
cc_numSecondary = EEPROM.read(385);
|
ccNumSecondary = EEPROM.read(385);
|
||||||
cc_fromStart = EEPROM.read(386);
|
ccFromStart = EEPROM.read(386);
|
||||||
cc_fromEnd = EEPROM.read(387);
|
ccFromEnd = EEPROM.read(387);
|
||||||
cc_step = EEPROM.read(388);
|
ccStep = EEPROM.read(388);
|
||||||
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
|
strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
|
||||||
}
|
}
|
||||||
if (lastEEPROMversion > 3) {
|
if (lastEEPROMversion > 3) {
|
||||||
effectIntensityDefault = EEPROM.read(326); effectIntensity = effectIntensityDefault;
|
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
|
//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
|
//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 == 255 || index == 0) loadSettingsFromEEPROM(false);//load boot defaults
|
||||||
if (index > 25 || index < 1) return;
|
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[1] = EEPROM.read(i+3);
|
||||||
col[2] = EEPROM.read(i+4);
|
col[2] = EEPROM.read(i+4);
|
||||||
white = EEPROM.read(i+5);
|
white = EEPROM.read(i+5);
|
||||||
col_sec[0] = EEPROM.read(i+6);
|
colSec[0] = EEPROM.read(i+6);
|
||||||
col_sec[1] = EEPROM.read(i+7);
|
colSec[1] = EEPROM.read(i+7);
|
||||||
col_sec[2] = EEPROM.read(i+8);
|
colSec[2] = EEPROM.read(i+8);
|
||||||
white_sec = EEPROM.read(i+9);
|
whiteSec = EEPROM.read(i+9);
|
||||||
}
|
}
|
||||||
if (loadFX)
|
if (loadFX)
|
||||||
{
|
{
|
||||||
effectCurrent = EEPROM.read(i+10);
|
effectCurrent = EEPROM.read(i+10);
|
||||||
effectSpeed = EEPROM.read(i+11);
|
effectSpeed = EEPROM.read(i+11);
|
||||||
effectIntensity = EEPROM.read(i+16);
|
effectIntensity = EEPROM.read(i+16);
|
||||||
cc_numPrimary = EEPROM.read(i+12);
|
ccNumPrimary = EEPROM.read(i+12);
|
||||||
cc_numSecondary = EEPROM.read(i+13);
|
ccNumSecondary = EEPROM.read(i+13);
|
||||||
cc_fromEnd = EEPROM.read(i+14);
|
ccFromEnd = EEPROM.read(i+14);
|
||||||
cc_fromStart = (EEPROM.read(i+14)<2);
|
ccFromStart = (EEPROM.read(i+14)<2);
|
||||||
cc_step = EEPROM.read(i+15);
|
ccStep = EEPROM.read(i+15);
|
||||||
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
|
strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
|
||||||
strip.setMode(effectCurrent);
|
strip.setMode(effectCurrent);
|
||||||
strip.setSpeed(effectSpeed);
|
strip.setSpeed(effectSpeed);
|
||||||
strip.setIntensity(effectIntensity);
|
strip.setIntensity(effectIntensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void savePreset(uint8_t index)
|
void savePreset(byte index)
|
||||||
{
|
{
|
||||||
if (index > 25) return;
|
if (index > 25) return;
|
||||||
if (index < 1) {saveSettingsToEEPROM();return;}
|
if (index < 1) {saveSettingsToEEPROM();return;}
|
||||||
@ -493,24 +492,24 @@ void savePreset(uint8_t index)
|
|||||||
EEPROM.write(i+3, col[1]);
|
EEPROM.write(i+3, col[1]);
|
||||||
EEPROM.write(i+4, col[2]);
|
EEPROM.write(i+4, col[2]);
|
||||||
EEPROM.write(i+5, white);
|
EEPROM.write(i+5, white);
|
||||||
EEPROM.write(i+6, col_sec[0]);
|
EEPROM.write(i+6, colSec[0]);
|
||||||
EEPROM.write(i+7, col_sec[1]);
|
EEPROM.write(i+7, colSec[1]);
|
||||||
EEPROM.write(i+8, col_sec[2]);
|
EEPROM.write(i+8, colSec[2]);
|
||||||
EEPROM.write(i+9, white_sec);
|
EEPROM.write(i+9, whiteSec);
|
||||||
EEPROM.write(i+10, effectCurrent);
|
EEPROM.write(i+10, effectCurrent);
|
||||||
EEPROM.write(i+11, effectSpeed);
|
EEPROM.write(i+11, effectSpeed);
|
||||||
EEPROM.write(i+12, cc_numPrimary);
|
EEPROM.write(i+12, ccNumPrimary);
|
||||||
EEPROM.write(i+13, cc_numSecondary);
|
EEPROM.write(i+13, ccNumSecondary);
|
||||||
uint8_t m = 1;
|
byte m = 1;
|
||||||
if (!cc_fromStart) m = 2;
|
if (!ccFromStart) m = 2;
|
||||||
if (!cc_fromEnd) m = 0;
|
if (!ccFromEnd) m = 0;
|
||||||
EEPROM.write(i+14, m);
|
EEPROM.write(i+14, m);
|
||||||
EEPROM.write(i+15, cc_step);
|
EEPROM.write(i+15, ccStep);
|
||||||
EEPROM.write(i+16, effectIntensity);
|
EEPROM.write(i+16, effectIntensity);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
String loadMacro(uint8_t index)
|
String loadMacro(byte index)
|
||||||
{
|
{
|
||||||
index-=1;
|
index-=1;
|
||||||
String m="";
|
String m="";
|
||||||
@ -523,7 +522,7 @@ String loadMacro(uint8_t index)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyMacro(uint8_t index)
|
void applyMacro(byte index)
|
||||||
{
|
{
|
||||||
index-=1;
|
index-=1;
|
||||||
if (index > 15) return;
|
if (index > 15) return;
|
||||||
@ -541,7 +540,7 @@ void applyMacro(uint8_t index)
|
|||||||
handleSet(mc);
|
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;
|
index-=1;
|
||||||
if (index > 15) return;
|
if (index > 15) return;
|
||||||
|
@ -10,7 +10,7 @@ void XML_response()
|
|||||||
resp = resp + "<act>";
|
resp = resp + "<act>";
|
||||||
if (nightlightActive && nightlightFade)
|
if (nightlightActive && nightlightFade)
|
||||||
{
|
{
|
||||||
resp = resp + bri_t;
|
resp = resp + briT;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resp = resp + bri;
|
resp = resp + bri;
|
||||||
@ -56,7 +56,7 @@ void XML_response()
|
|||||||
server.send(200, "text/xml", resp);
|
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
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
||||||
DEBUG_PRINT("settings resp");
|
DEBUG_PRINT("settings resp");
|
||||||
@ -73,36 +73,36 @@ String getSettings(uint8_t subPage)
|
|||||||
String si = ".selectedIndex=";
|
String si = ".selectedIndex=";
|
||||||
|
|
||||||
if (subPage == 1) {
|
if (subPage == 1) {
|
||||||
resp += ds + "CSSID" + v + "\"" + clientssid + "\";";
|
resp += ds + "CSSID" + v + "\"" + clientSSID + "\";";
|
||||||
resp += ds + "CPASS" + v + "\"";
|
resp += ds + "CPASS" + v + "\"";
|
||||||
for (int i = 0; i < clientpass.length(); i++)
|
for (int i = 0; i < clientPass.length(); i++)
|
||||||
{
|
{
|
||||||
resp += "*";
|
resp += "*";
|
||||||
}
|
}
|
||||||
resp += "\";";
|
resp += "\";";
|
||||||
resp += ds + "CSIP0" + v + staticip[0] +";";
|
resp += ds + "CSIP0" + v + staticIP[0] +";";
|
||||||
resp += ds + "CSIP1" + v + staticip[1] +";";
|
resp += ds + "CSIP1" + v + staticIP[1] +";";
|
||||||
resp += ds + "CSIP2" + v + staticip[2] +";";
|
resp += ds + "CSIP2" + v + staticIP[2] +";";
|
||||||
resp += ds + "CSIP3" + v + staticip[3] +";";
|
resp += ds + "CSIP3" + v + staticIP[3] +";";
|
||||||
resp += ds + "CSGW0" + v + staticgateway[0] +";";
|
resp += ds + "CSGW0" + v + staticGateway[0] +";";
|
||||||
resp += ds + "CSGW1" + v + staticgateway[1] +";";
|
resp += ds + "CSGW1" + v + staticGateway[1] +";";
|
||||||
resp += ds + "CSGW2" + v + staticgateway[2] +";";
|
resp += ds + "CSGW2" + v + staticGateway[2] +";";
|
||||||
resp += ds + "CSGW3" + v + staticgateway[3] +";";
|
resp += ds + "CSGW3" + v + staticGateway[3] +";";
|
||||||
resp += ds + "CSSN0" + v + staticsubnet[0] +";";
|
resp += ds + "CSSN0" + v + staticSubnet[0] +";";
|
||||||
resp += ds + "CSSN1" + v + staticsubnet[1] +";";
|
resp += ds + "CSSN1" + v + staticSubnet[1] +";";
|
||||||
resp += ds + "CSSN2" + v + staticsubnet[2] +";";
|
resp += ds + "CSSN2" + v + staticSubnet[2] +";";
|
||||||
resp += ds + "CSSN3" + v + staticsubnet[3] +";";
|
resp += ds + "CSSN3" + v + staticSubnet[3] +";";
|
||||||
resp += ds + "CMDNS" + v + "\"" + cmdns + "\";";
|
resp += ds + "CMDNS" + v + "\"" + cmDNS + "\";";
|
||||||
resp += ds + "APWTM" + v + apWaitTimeSecs +";";
|
resp += ds + "APWTM" + v + apWaitTimeSecs +";";
|
||||||
resp += ds + "APSSID" + v + "\"" + apssid + "\";";
|
resp += ds + "APSSID" + v + "\"" + apSSID + "\";";
|
||||||
resp += ds + "APHSSID" + c + aphide + ";";
|
resp += ds + "APHSSID" + c + apHide + ";";
|
||||||
resp += ds + "APPASS" + v + "\"";
|
resp += ds + "APPASS" + v + "\"";
|
||||||
for (int i = 0; i < appass.length(); i++)
|
for (int i = 0; i < apPass.length(); i++)
|
||||||
{
|
{
|
||||||
resp += "*";
|
resp += "*";
|
||||||
}
|
}
|
||||||
resp += "\";";
|
resp += "\";";
|
||||||
resp += ds + "APCHAN" + v + apchannel +";";
|
resp += ds + "APCHAN" + v + apChannel +";";
|
||||||
resp += dg + "(\"sip\")[0]" + ih + "\"";
|
resp += dg + "(\"sip\")[0]" + ih + "\"";
|
||||||
if (!WiFi.localIP()[0] == 0)
|
if (!WiFi.localIP()[0] == 0)
|
||||||
{
|
{
|
||||||
@ -136,20 +136,20 @@ String getSettings(uint8_t subPage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 2) {
|
if (subPage == 2) {
|
||||||
resp += ds + "LEDCN" + v + ledcount +";";
|
resp += ds + "LEDCN" + v + ledCount +";";
|
||||||
resp += ds + "CLDFR" + v + col_s[0] +";";
|
resp += ds + "CLDFR" + v + colS[0] +";";
|
||||||
resp += ds + "CLDFG" + v + col_s[1] +";";
|
resp += ds + "CLDFG" + v + colS[1] +";";
|
||||||
resp += ds + "CLDFB" + v + col_s[2] +";";
|
resp += ds + "CLDFB" + v + colS[2] +";";
|
||||||
resp += ds + "CLDFA" + v + bri_s +";";
|
resp += ds + "CLDFA" + v + briS +";";
|
||||||
if (useRGBW) {
|
if (useRGBW) {
|
||||||
resp += ds + "CLDFW" + v + white_s +";";
|
resp += ds + "CLDFW" + v + whiteS +";";
|
||||||
} else {
|
} else {
|
||||||
resp += ds + "CLDFW" + v + "-1;";
|
resp += ds + "CLDFW" + v + "-1;";
|
||||||
}
|
}
|
||||||
resp += ds + "CSECR" + v + col_sec_s[0] +";";
|
resp += ds + "CSECR" + v + colSecS[0] +";";
|
||||||
resp += ds + "CSECG" + v + col_sec_s[1] +";";
|
resp += ds + "CSECG" + v + colSecS[1] +";";
|
||||||
resp += ds + "CSECB" + v + col_sec_s[2] +";";
|
resp += ds + "CSECB" + v + colSecS[2] +";";
|
||||||
resp += ds + "CSECW" + v + white_sec_s +";";
|
resp += ds + "CSECW" + v + whiteSecS +";";
|
||||||
resp += ds + "BOOTN" + c + turnOnAtBoot +";";
|
resp += ds + "BOOTN" + c + turnOnAtBoot +";";
|
||||||
resp += ds + "BOOTP" + v + bootPreset +";";
|
resp += ds + "BOOTP" + v + bootPreset +";";
|
||||||
resp += ds + "FXDEF" + v + effectDefault +";";
|
resp += ds + "FXDEF" + v + effectDefault +";";
|
||||||
|
@ -7,10 +7,10 @@ void _setRandomColor(bool _sec)
|
|||||||
lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);
|
lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);
|
||||||
uint32_t _color = strip.color_wheel(lastRandomIndex);
|
uint32_t _color = strip.color_wheel(lastRandomIndex);
|
||||||
if (_sec){
|
if (_sec){
|
||||||
white_sec = ((_color >> 24) & 0xFF);
|
whiteSec = ((_color >> 24) & 0xFF);
|
||||||
col_sec[0] = ((_color >> 16) & 0xFF);
|
colSec[0] = ((_color >> 16) & 0xFF);
|
||||||
col_sec[1] = ((_color >> 8) & 0xFF);
|
colSec[1] = ((_color >> 8) & 0xFF);
|
||||||
col_sec[2] = (_color & 0xFF);
|
colSec[2] = (_color & 0xFF);
|
||||||
} else {
|
} else {
|
||||||
white = ((_color >> 24) & 0xFF);
|
white = ((_color >> 24) & 0xFF);
|
||||||
col[0] = ((_color >> 16) & 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
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
||||||
if (subPage <1 || subPage >6) return;
|
if (subPage <1 || subPage >6) return;
|
||||||
@ -27,91 +27,91 @@ void handleSettingsSet(uint8_t subPage)
|
|||||||
//WIFI SETTINGS
|
//WIFI SETTINGS
|
||||||
if (subPage == 1)
|
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.hasArg("CPASS"))
|
||||||
{
|
{
|
||||||
if (!server.arg("CPASS").indexOf('*') == 0)
|
if (!server.arg("CPASS").indexOf('*') == 0)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTLN("Setting pass");
|
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"))
|
if (server.hasArg("APWTM"))
|
||||||
{
|
{
|
||||||
int i = server.arg("APWTM").toInt();
|
int i = server.arg("APWTM").toInt();
|
||||||
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
|
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
|
||||||
}
|
}
|
||||||
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
|
if (server.hasArg("APSSID")) apSSID = server.arg("APSSID");
|
||||||
aphide = server.hasArg("APHSSID");
|
apHide = server.hasArg("APHSSID");
|
||||||
if (server.hasArg("APPASS"))
|
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"))
|
if (server.hasArg("APCHAN"))
|
||||||
{
|
{
|
||||||
int chan = server.arg("APCHAN").toInt();
|
int chan = server.arg("APCHAN").toInt();
|
||||||
if (chan > 0 && chan < 14) apchannel = chan;
|
if (chan > 0 && chan < 14) apChannel = chan;
|
||||||
}
|
}
|
||||||
if (server.hasArg("CSIP0"))
|
if (server.hasArg("CSIP0"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSIP0").toInt();
|
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"))
|
if (server.hasArg("CSIP1"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSIP1").toInt();
|
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"))
|
if (server.hasArg("CSIP2"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSIP2").toInt();
|
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"))
|
if (server.hasArg("CSIP3"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSIP3").toInt();
|
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"))
|
if (server.hasArg("CSGW0"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSGW0").toInt();
|
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"))
|
if (server.hasArg("CSGW1"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSGW1").toInt();
|
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"))
|
if (server.hasArg("CSGW2"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSGW2").toInt();
|
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"))
|
if (server.hasArg("CSGW3"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSGW3").toInt();
|
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"))
|
if (server.hasArg("CSSN0"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSSN0").toInt();
|
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"))
|
if (server.hasArg("CSSN1"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSSN1").toInt();
|
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"))
|
if (server.hasArg("CSSN2"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSSN2").toInt();
|
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"))
|
if (server.hasArg("CSSN3"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSSN3").toInt();
|
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"))
|
if (server.hasArg("LEDCN"))
|
||||||
{
|
{
|
||||||
int i = server.arg("LEDCN").toInt();
|
int i = server.arg("LEDCN").toInt();
|
||||||
if (i >= 0 && i <= LEDCOUNT) ledcount = i;
|
if (i >= 0 && i <= LEDCOUNT) ledCount = i;
|
||||||
strip.setLedCount(ledcount);
|
strip.setLedCount(ledCount);
|
||||||
}
|
}
|
||||||
if (server.hasArg("CBEOR")) //ignore settings and save current brightness, colors and fx as default
|
if (server.hasArg("CBEOR")) //ignore settings and save current brightness, colors and fx as default
|
||||||
{
|
{
|
||||||
col_s[0] = col[0];
|
colS[0] = col[0];
|
||||||
col_s[1] = col[1];
|
colS[1] = col[1];
|
||||||
col_s[2] = col[2];
|
colS[2] = col[2];
|
||||||
if (useRGBW) white_s = white;
|
if (useRGBW) whiteS = white;
|
||||||
bri_s = bri;
|
briS = bri;
|
||||||
effectDefault = effectCurrent;
|
effectDefault = effectCurrent;
|
||||||
effectSpeedDefault = effectSpeed;
|
effectSpeedDefault = effectSpeed;
|
||||||
} else {
|
} else {
|
||||||
if (server.hasArg("CLDFR"))
|
if (server.hasArg("CLDFR"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CLDFR").toInt();
|
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"))
|
if (server.hasArg("CLDFG"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CLDFG").toInt();
|
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"))
|
if (server.hasArg("CLDFB"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CLDFB").toInt();
|
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"))
|
if (server.hasArg("CSECR"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSECR").toInt();
|
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"))
|
if (server.hasArg("CSECG"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSECG").toInt();
|
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"))
|
if (server.hasArg("CSECB"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSECB").toInt();
|
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"))
|
if (server.hasArg("CSECW"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CSECW").toInt();
|
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"))
|
if (server.hasArg("CLDFW"))
|
||||||
{
|
{
|
||||||
@ -175,16 +175,16 @@ void handleSettingsSet(uint8_t subPage)
|
|||||||
if (i >= 0 && i <= 255)
|
if (i >= 0 && i <= 255)
|
||||||
{
|
{
|
||||||
useRGBW = true;
|
useRGBW = true;
|
||||||
white_s = i;
|
whiteS = i;
|
||||||
} else {
|
} else {
|
||||||
useRGBW = false;
|
useRGBW = false;
|
||||||
white_s = 0;
|
whiteS = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server.hasArg("CLDFA"))
|
if (server.hasArg("CLDFA"))
|
||||||
{
|
{
|
||||||
int i = server.arg("CLDFA").toInt();
|
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"))
|
if (server.hasArg("FXDEF"))
|
||||||
{
|
{
|
||||||
@ -236,7 +236,6 @@ void handleSettingsSet(uint8_t subPage)
|
|||||||
{
|
{
|
||||||
int i = server.arg("WOFFS").toInt();
|
int i = server.arg("WOFFS").toInt();
|
||||||
if (i >= -255 && i <= 255) arlsOffset = i;
|
if (i >= -255 && i <= 255) arlsOffset = i;
|
||||||
arlsSign = (i>=0)?true:false;
|
|
||||||
}
|
}
|
||||||
if (server.hasArg("NRBRI"))
|
if (server.hasArg("NRBRI"))
|
||||||
{
|
{
|
||||||
@ -371,13 +370,13 @@ void handleSettingsSet(uint8_t subPage)
|
|||||||
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
||||||
if (server.hasArg("OPASS"))
|
if (server.hasArg("OPASS"))
|
||||||
{
|
{
|
||||||
if (otaLock && otapass.equals(server.arg("OPASS")))
|
if (otaLock && otaPass.equals(server.arg("OPASS")))
|
||||||
{
|
{
|
||||||
pwdCorrect = true;
|
pwdCorrect = true;
|
||||||
}
|
}
|
||||||
if (!otaLock && server.arg("OPASS").length() > 0)
|
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();
|
saveSettingsToEEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean handleSet(String req)
|
bool handleSet(String req)
|
||||||
{
|
{
|
||||||
boolean effectUpdated = false;
|
bool effectUpdated = false;
|
||||||
if (!(req.indexOf("win") >= 0)) {
|
if (!(req.indexOf("win") >= 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -431,12 +430,12 @@ boolean handleSet(String req)
|
|||||||
pos = req.indexOf("HU=");
|
pos = req.indexOf("HU=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
uint16_t temphue = req.substring(pos + 3).toInt();
|
uint16_t temphue = req.substring(pos + 3).toInt();
|
||||||
uint8_t tempsat = 255;
|
byte tempsat = 255;
|
||||||
pos = req.indexOf("SA=");
|
pos = req.indexOf("SA=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
tempsat = req.substring(pos + 3).toInt();
|
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
|
//set red value
|
||||||
@ -463,45 +462,45 @@ boolean handleSet(String req)
|
|||||||
//set 2nd red value
|
//set 2nd red value
|
||||||
pos = req.indexOf("R2=");
|
pos = req.indexOf("R2=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col_sec[0] = req.substring(pos + 3).toInt();
|
colSec[0] = req.substring(pos + 3).toInt();
|
||||||
}
|
}
|
||||||
//set 2nd green value
|
//set 2nd green value
|
||||||
pos = req.indexOf("G2=");
|
pos = req.indexOf("G2=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col_sec[1] = req.substring(pos + 3).toInt();
|
colSec[1] = req.substring(pos + 3).toInt();
|
||||||
}
|
}
|
||||||
//set 2nd blue value
|
//set 2nd blue value
|
||||||
pos = req.indexOf("B2=");
|
pos = req.indexOf("B2=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col_sec[2] = req.substring(pos + 3).toInt();
|
colSec[2] = req.substring(pos + 3).toInt();
|
||||||
}
|
}
|
||||||
//set 2nd white value
|
//set 2nd white value
|
||||||
pos = req.indexOf("W2=");
|
pos = req.indexOf("W2=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
white_sec = req.substring(pos + 3).toInt();
|
whiteSec = req.substring(pos + 3).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
//set 2nd to white
|
//set 2nd to white
|
||||||
pos = req.indexOf("SW");
|
pos = req.indexOf("SW");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
if(useRGBW) {
|
if(useRGBW) {
|
||||||
white_sec = 255;
|
whiteSec = 255;
|
||||||
col_sec[0] = 0;
|
colSec[0] = 0;
|
||||||
col_sec[1] = 0;
|
colSec[1] = 0;
|
||||||
col_sec[2] = 0;
|
colSec[2] = 0;
|
||||||
} else {
|
} else {
|
||||||
col_sec[0] = 255;
|
colSec[0] = 255;
|
||||||
col_sec[1] = 255;
|
colSec[1] = 255;
|
||||||
col_sec[2] = 255;
|
colSec[2] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//set 2nd to black
|
//set 2nd to black
|
||||||
pos = req.indexOf("SB");
|
pos = req.indexOf("SB");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
white_sec = 0;
|
whiteSec = 0;
|
||||||
col_sec[0] = 0;
|
colSec[0] = 0;
|
||||||
col_sec[1] = 0;
|
colSec[1] = 0;
|
||||||
col_sec[2] = 0;
|
colSec[2] = 0;
|
||||||
}
|
}
|
||||||
//set to random hue SR=0->1st SR=1->2nd
|
//set to random hue SR=0->1st SR=1->2nd
|
||||||
pos = req.indexOf("SR");
|
pos = req.indexOf("SR");
|
||||||
@ -511,24 +510,24 @@ boolean handleSet(String req)
|
|||||||
//set 2nd to 1st
|
//set 2nd to 1st
|
||||||
pos = req.indexOf("SP");
|
pos = req.indexOf("SP");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col_sec[0] = col[0];
|
colSec[0] = col[0];
|
||||||
col_sec[1] = col[1];
|
colSec[1] = col[1];
|
||||||
col_sec[2] = col[2];
|
colSec[2] = col[2];
|
||||||
white_sec = white;
|
whiteSec = white;
|
||||||
}
|
}
|
||||||
//swap 2nd & 1st
|
//swap 2nd & 1st
|
||||||
pos = req.indexOf("SC");
|
pos = req.indexOf("SC");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
uint8_t _temp[4];
|
byte _temp[4];
|
||||||
for (int i = 0; i<3; i++)
|
for (int i = 0; i<3; i++)
|
||||||
{
|
{
|
||||||
_temp[i] = col[i];
|
_temp[i] = col[i];
|
||||||
col[i] = col_sec[i];
|
col[i] = colSec[i];
|
||||||
col_sec[i] = _temp[i];
|
colSec[i] = _temp[i];
|
||||||
}
|
}
|
||||||
_temp[3] = white;
|
_temp[3] = white;
|
||||||
white = white_sec;
|
white = whiteSec;
|
||||||
white_sec = _temp[3];
|
whiteSec = _temp[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
//set current effect index
|
//set current effect index
|
||||||
@ -654,7 +653,7 @@ boolean handleSet(String req)
|
|||||||
if (req.indexOf("NL=0") > 0)
|
if (req.indexOf("NL=0") > 0)
|
||||||
{
|
{
|
||||||
nightlightActive = false;
|
nightlightActive = false;
|
||||||
bri = bri_t;
|
bri = briT;
|
||||||
} else {
|
} else {
|
||||||
nightlightActive = true;
|
nightlightActive = true;
|
||||||
nightlightDelayMins = req.substring(pos + 3).toInt();
|
nightlightDelayMins = req.substring(pos + 3).toInt();
|
||||||
@ -665,7 +664,7 @@ boolean handleSet(String req)
|
|||||||
pos = req.indexOf("NT=");
|
pos = req.indexOf("NT=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
nightlightTargetBri = req.substring(pos + 3).toInt();
|
nightlightTargetBri = req.substring(pos + 3).toInt();
|
||||||
nightlightActive_old = false; //re-init
|
nightlightActiveOld = false; //re-init
|
||||||
}
|
}
|
||||||
//toggle nightlight fade
|
//toggle nightlight fade
|
||||||
if (req.indexOf("NF=") > 0)
|
if (req.indexOf("NF=") > 0)
|
||||||
@ -676,7 +675,7 @@ boolean handleSet(String req)
|
|||||||
} else {
|
} else {
|
||||||
nightlightFade = true;
|
nightlightFade = true;
|
||||||
}
|
}
|
||||||
nightlightActive_old = false; //re-init
|
nightlightActiveOld = false; //re-init
|
||||||
}
|
}
|
||||||
//toggle general purpose output
|
//toggle general purpose output
|
||||||
pos = req.indexOf("AX=");
|
pos = req.indexOf("AX=");
|
||||||
@ -690,14 +689,14 @@ boolean handleSet(String req)
|
|||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
switch (req.substring(pos + 3).toInt())
|
switch (req.substring(pos + 3).toInt())
|
||||||
{
|
{
|
||||||
case 0: if (bri != 0){bri_last = bri; bri = 0;} break; //off
|
case 0: if (bri != 0){briLast = bri; bri = 0;} break; //off
|
||||||
case 1: bri = bri_last; break; //on
|
case 1: bri = briLast; break; //on
|
||||||
default: if (bri == 0) //toggle
|
default: if (bri == 0) //toggle
|
||||||
{
|
{
|
||||||
bri = bri_last;
|
bri = briLast;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bri_last = bri;
|
briLast = bri;
|
||||||
bri = 0;
|
bri = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -716,15 +715,15 @@ boolean handleSet(String req)
|
|||||||
|
|
||||||
//set custom chase data
|
//set custom chase data
|
||||||
bool _cc_updated = false;
|
bool _cc_updated = false;
|
||||||
pos = req.indexOf("C0="); if (pos > 0) {cc_start = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
pos = req.indexOf("C0="); if (pos > 0) {ccStart = (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("C1="); if (pos > 0) {ccIndex1 = (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("C2="); if (pos > 0) {ccIndex2 = (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("CP="); if (pos > 0) {ccNumPrimary = (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("CS="); if (pos > 0) {ccNumSecondary = (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("CM="); if (pos > 0) {ccStep = (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("CF="); if (pos > 0) {ccFromStart = (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;}
|
pos = req.indexOf("CE="); if (pos > 0) {ccFromEnd = (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);
|
if (_cc_updated) strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
|
||||||
|
|
||||||
//set presets
|
//set presets
|
||||||
pos = req.indexOf("PS="); //saves current in preset
|
pos = req.indexOf("PS="); //saves current in preset
|
||||||
|
@ -25,24 +25,24 @@ void wledInit()
|
|||||||
EEPROM.begin(EEPSIZE);
|
EEPROM.begin(EEPSIZE);
|
||||||
loadSettingsFromEEPROM(true);
|
loadSettingsFromEEPROM(true);
|
||||||
DEBUG_PRINT("CC: SSID: ");
|
DEBUG_PRINT("CC: SSID: ");
|
||||||
DEBUG_PRINT(clientssid);
|
DEBUG_PRINT(clientSSID);
|
||||||
buildCssColorString();
|
buildCssColorString();
|
||||||
userBeginPreConnection();
|
userBeginPreConnection();
|
||||||
|
|
||||||
WiFi.disconnect(); //close old connections
|
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
|
} else
|
||||||
{
|
{
|
||||||
WiFi.config(0U, 0U, 0U);
|
WiFi.config(0U, 0U, 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apssid.length()>0)
|
if (apSSID.length()>0)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("USING AP");
|
DEBUG_PRINT("USING AP");
|
||||||
DEBUG_PRINTLN(apssid.length());
|
DEBUG_PRINTLN(apSSID.length());
|
||||||
initAP();
|
initAP();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ void wledInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up mDNS responder:
|
// 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!");
|
DEBUG_PRINTLN("Error setting up MDNS responder!");
|
||||||
down();
|
down();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ void wledInit()
|
|||||||
ntpConnected = ntpUdp.begin(ntpLocalPort);
|
ntpConnected = ntpUdp.begin(ntpLocalPort);
|
||||||
|
|
||||||
//start captive portal
|
//start captive portal
|
||||||
if (onlyAP || apssid.length() > 0)
|
if (onlyAP || apSSID.length() > 0)
|
||||||
{
|
{
|
||||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
dnsServer.start(53, "*", WiFi.softAPIP());
|
dnsServer.start(53, "*", WiFi.softAPIP());
|
||||||
@ -195,7 +195,7 @@ void wledInit()
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/power", HTTP_GET, [](){
|
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";
|
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);
|
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
|
// Initialize NeoPixel Strip
|
||||||
strip.init();
|
strip.init();
|
||||||
strip.setLedCount(ledcount);
|
strip.setLedCount(ledCount);
|
||||||
strip.setReverseMode(reverseMode);
|
strip.setReverseMode(reverseMode);
|
||||||
strip.setColor(0);
|
strip.setColor(0);
|
||||||
strip.setBrightness(255);
|
strip.setBrightness(255);
|
||||||
@ -320,17 +320,17 @@ void wledInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initAP(){
|
void initAP(){
|
||||||
String save = apssid;
|
String save = apSSID;
|
||||||
if (apssid.length() <1) apssid = "WLED-AP";
|
if (apSSID.length() <1) apSSID = "WLED-AP";
|
||||||
WiFi.softAP(apssid.c_str(), appass.c_str(), apchannel, aphide);
|
WiFi.softAP(apSSID.c_str(), apPass.c_str(), apChannel, apHide);
|
||||||
apssid = save;
|
apSSID = save;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCon()
|
void initCon()
|
||||||
{
|
{
|
||||||
int fail_count = 0;
|
int fail_count = 0;
|
||||||
if (clientssid.length() <1 || clientssid.equals("Your_Network_Here")) fail_count = apWaitTimeSecs*2;
|
if (clientSSID.length() <1 || clientSSID.equals("Your_Network")) fail_count = apWaitTimeSecs*2;
|
||||||
WiFi.begin(clientssid.c_str(), clientpass.c_str());
|
WiFi.begin(clientSSID.c_str(), clientPass.c_str());
|
||||||
while(WiFi.status() != WL_CONNECTED) {
|
while(WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
DEBUG_PRINTLN("C_NC");
|
DEBUG_PRINTLN("C_NC");
|
||||||
@ -443,7 +443,7 @@ void serveMessage(int code, String headl, String subl="", int optionType)
|
|||||||
server.sendContent(messageBody);
|
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
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage
|
||||||
if (!arlsTimeout) //do not serve while receiving realtime
|
if (!arlsTimeout) //do not serve while receiving realtime
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define WLEDPACKETSIZE 24
|
#define WLEDPACKETSIZE 24
|
||||||
|
|
||||||
void notify(uint8_t callMode, bool followUp=false)
|
void notify(byte callMode, bool followUp=false)
|
||||||
{
|
{
|
||||||
if (!udpConnected) return;
|
if (!udpConnected) return;
|
||||||
switch (callMode)
|
switch (callMode)
|
||||||
@ -29,10 +29,10 @@ void notify(uint8_t callMode, bool followUp=false)
|
|||||||
udpOut[9] = effectSpeed;
|
udpOut[9] = effectSpeed;
|
||||||
udpOut[10] = white;
|
udpOut[10] = white;
|
||||||
udpOut[11] = 3; //compatibilityVersionByte: 0: old 1: supports white 2: supports secondary color 3: supports FX intensity, 24 byte packet
|
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[12] = colSec[0];
|
||||||
udpOut[13] = col_sec[1];
|
udpOut[13] = colSec[1];
|
||||||
udpOut[14] = col_sec[2];
|
udpOut[14] = colSec[2];
|
||||||
udpOut[15] = white_sec;
|
udpOut[15] = whiteSec;
|
||||||
udpOut[16] = effectIntensity;
|
udpOut[16] = effectIntensity;
|
||||||
|
|
||||||
IPAddress broadcastIp;
|
IPAddress broadcastIp;
|
||||||
@ -53,9 +53,11 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(udpConnected && receiveNotifications){
|
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
|
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) //don't process broadcasts we send ourselves
|
||||||
{
|
{
|
||||||
|
byte udpIn[packetSize];
|
||||||
notifierUdp.read(udpIn, packetSize);
|
notifierUdp.read(udpIn, packetSize);
|
||||||
if (udpIn[0] == 0 && !arlsTimeout) //wled notifier, block if realtime packets active
|
if (udpIn[0] == 0 && !arlsTimeout) //wled notifier, block if realtime packets active
|
||||||
{
|
{
|
||||||
@ -70,10 +72,10 @@ void handleNotifications()
|
|||||||
white = udpIn[10];
|
white = udpIn[10];
|
||||||
if (udpIn[11] > 1 )
|
if (udpIn[11] > 1 )
|
||||||
{
|
{
|
||||||
col_sec[0] = udpIn[12];
|
colSec[0] = udpIn[12];
|
||||||
col_sec[1] = udpIn[13];
|
colSec[1] = udpIn[13];
|
||||||
col_sec[2] = udpIn[14];
|
colSec[2] = udpIn[14];
|
||||||
white_sec = udpIn[15];
|
whiteSec = udpIn[15];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (udpIn[8] != effectCurrent && receiveNotificationEffects)
|
if (udpIn[8] != effectCurrent && receiveNotificationEffects)
|
||||||
@ -105,7 +107,7 @@ void handleNotifications()
|
|||||||
arlsTimeout = false;
|
arlsTimeout = false;
|
||||||
} else {
|
} else {
|
||||||
if (!arlsTimeout){
|
if (!arlsTimeout){
|
||||||
strip.setRange(0, ledcount-1, 0);
|
strip.setRange(0, ledCount-1, 0);
|
||||||
strip.setMode(0);
|
strip.setMode(0);
|
||||||
}
|
}
|
||||||
arlsTimeout = true;
|
arlsTimeout = true;
|
||||||
@ -113,7 +115,7 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
for (int i = 2; i < packetSize -3; i += 4)
|
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)
|
if (useGammaCorrectionRGB)
|
||||||
{
|
{
|
||||||
strip.setPixelColor(udpIn[i] + arlsOffset, gamma8[udpIn[i+1]], gamma8[udpIn[i+2]], gamma8[udpIn[i+3]]);
|
strip.setPixelColor(udpIn[i] + arlsOffset, gamma8[udpIn[i+1]], gamma8[udpIn[i+2]], gamma8[udpIn[i+3]]);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void setAllLeds() {
|
void setAllLeds() {
|
||||||
double d = bri_t*briMultiplier;
|
double d = briT*briMultiplier;
|
||||||
int val = d/100;
|
int val = d/100;
|
||||||
if (val > 255) val = 255;
|
if (val > 255) val = 255;
|
||||||
if (useGammaCorrectionBri)
|
if (useGammaCorrectionBri)
|
||||||
@ -14,26 +14,26 @@ void setAllLeds() {
|
|||||||
}
|
}
|
||||||
if (useGammaCorrectionRGB)
|
if (useGammaCorrectionRGB)
|
||||||
{
|
{
|
||||||
strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]], gamma8[white_t]);
|
strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[whiteT]);
|
||||||
strip.setSecondaryColor(gamma8[col_sec[0]], gamma8[col_sec[1]], gamma8[col_sec[2]], gamma8[white_sec]);
|
strip.setSecondaryColor(gamma8[colSec[0]], gamma8[colSec[1]], gamma8[colSec[2]], gamma8[whiteSec]);
|
||||||
} else {
|
} else {
|
||||||
strip.setColor(col_t[0], col_t[1], col_t[2], white_t);
|
strip.setColor(colT[0], colT[1], colT[2], whiteT);
|
||||||
strip.setSecondaryColor(col_sec[0], col_sec[1], col_sec[2], white_sec);
|
strip.setSecondaryColor(colSec[0], colSec[1], colSec[2], whiteSec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLedsStandard()
|
void setLedsStandard()
|
||||||
{
|
{
|
||||||
col_old[0] = col[0];
|
colOld[0] = col[0];
|
||||||
col_old[1] = col[1];
|
colOld[1] = col[1];
|
||||||
col_old[2] = col[2];
|
colOld[2] = col[2];
|
||||||
white_old = white;
|
whiteOld = white;
|
||||||
bri_old = bri;
|
briOld = bri;
|
||||||
col_t[0] = col[0];
|
colT[0] = col[0];
|
||||||
col_t[1] = col[1];
|
colT[1] = col[1];
|
||||||
col_t[2] = col[2];
|
colT[2] = col[2];
|
||||||
white_t = white;
|
whiteT = white;
|
||||||
bri_t = bri;
|
briT = bri;
|
||||||
setAllLeds();
|
setAllLeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ bool colorChanged()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (col[i] != col_it[i]) return true;
|
if (col[i] != colIT[i]) return true;
|
||||||
if (col_sec[i] != col_sec_it[i]) return true;
|
if (colSec[i] != colSecIT[i]) return true;
|
||||||
}
|
}
|
||||||
if (white != white_it || white_sec != white_sec_it) return true;
|
if (white != whiteIT || whiteSec != whiteSecIT) return true;
|
||||||
if (bri != bri_it) return true;
|
if (bri != briIT) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,31 +59,31 @@ void colorUpdated(int callMode)
|
|||||||
}
|
}
|
||||||
if (callMode != 5 && nightlightActive && nightlightFade)
|
if (callMode != 5 && nightlightActive && nightlightFade)
|
||||||
{
|
{
|
||||||
bri_nl_t = bri;
|
briNlT = bri;
|
||||||
nightlightDelayMs -= (millis() - nightlightStartTime);
|
nightlightDelayMs -= (millis() - nightlightStartTime);
|
||||||
nightlightStartTime = millis();
|
nightlightStartTime = millis();
|
||||||
}
|
}
|
||||||
col_it[0] = col[0];
|
colIT[0] = col[0];
|
||||||
col_it[1] = col[1];
|
colIT[1] = col[1];
|
||||||
col_it[2] = col[2];
|
colIT[2] = col[2];
|
||||||
col_sec_it[0] = col_sec[0];
|
colSecIT[0] = colSec[0];
|
||||||
col_sec_it[1] = col_sec[1];
|
colSecIT[1] = colSec[1];
|
||||||
col_sec_it[2] = col_sec[2];
|
colSecIT[2] = colSec[2];
|
||||||
white_it = white;
|
whiteIT = white;
|
||||||
white_sec_it = white_sec;
|
whiteSecIT = whiteSec;
|
||||||
bri_it = bri;
|
briIT = bri;
|
||||||
if (bri > 0) bri_last = bri;
|
if (bri > 0) briLast = bri;
|
||||||
notify(callMode);
|
notify(callMode);
|
||||||
if (fadeTransition || sweepTransition)
|
if (fadeTransition || sweepTransition)
|
||||||
{
|
{
|
||||||
if (transitionActive)
|
if (transitionActive)
|
||||||
{
|
{
|
||||||
col_old[0] = col_t[0];
|
colOld[0] = colT[0];
|
||||||
col_old[1] = col_t[1];
|
colOld[1] = colT[1];
|
||||||
col_old[2] = col_t[2];
|
colOld[2] = colT[2];
|
||||||
white_old = white_t;
|
whiteOld = whiteT;
|
||||||
bri_old = bri_t;
|
briOld = briT;
|
||||||
tper_last = 0;
|
tperLast = 0;
|
||||||
}
|
}
|
||||||
transitionActive = true;
|
transitionActive = true;
|
||||||
transitionStartTime = millis();
|
transitionStartTime = millis();
|
||||||
@ -103,34 +103,34 @@ void handleTransitions()
|
|||||||
if (tper >= 1.0)
|
if (tper >= 1.0)
|
||||||
{
|
{
|
||||||
transitionActive = false;
|
transitionActive = false;
|
||||||
tper_last = 0;
|
tperLast = 0;
|
||||||
if (sweepTransition) strip.unlockAll();
|
if (sweepTransition) strip.unlockAll();
|
||||||
setLedsStandard();
|
setLedsStandard();
|
||||||
strip.setFastUpdateMode(false);
|
strip.setFastUpdateMode(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tper - tper_last < transitionResolution)
|
if (tper - tperLast < transitionResolution)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tper_last = tper;
|
tperLast = tper;
|
||||||
if (fadeTransition)
|
if (fadeTransition)
|
||||||
{
|
{
|
||||||
col_t[0] = col_old[0]+((col[0] - col_old[0])*tper);
|
colT[0] = colOld[0]+((col[0] - colOld[0])*tper);
|
||||||
col_t[1] = col_old[1]+((col[1] - col_old[1])*tper);
|
colT[1] = colOld[1]+((col[1] - colOld[1])*tper);
|
||||||
col_t[2] = col_old[2]+((col[2] - col_old[2])*tper);
|
colT[2] = colOld[2]+((col[2] - colOld[2])*tper);
|
||||||
white_t = white_old +((white - white_old )*tper);
|
whiteT = whiteOld +((white - whiteOld )*tper);
|
||||||
bri_t = bri_old +((bri - bri_old )*tper);
|
briT = briOld +((bri - briOld )*tper);
|
||||||
}
|
}
|
||||||
if (sweepTransition)
|
if (sweepTransition)
|
||||||
{
|
{
|
||||||
strip.lockAll();
|
strip.lockAll();
|
||||||
if (sweepDirection)
|
if (sweepDirection)
|
||||||
{
|
{
|
||||||
strip.unlockRange(0, (int)(tper*(double)ledcount));
|
strip.unlockRange(0, (int)(tper*(double)ledCount));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
strip.unlockRange(ledcount - (int)(tper*(double)ledcount), ledcount);
|
strip.unlockRange(ledCount - (int)(tper*(double)ledCount), ledCount);
|
||||||
}
|
}
|
||||||
if (!fadeTransition)
|
if (!fadeTransition)
|
||||||
{
|
{
|
||||||
@ -145,18 +145,18 @@ void handleNightlight()
|
|||||||
{
|
{
|
||||||
if (nightlightActive)
|
if (nightlightActive)
|
||||||
{
|
{
|
||||||
if (!nightlightActive_old) //init
|
if (!nightlightActiveOld) //init
|
||||||
{
|
{
|
||||||
nightlightStartTime = millis();
|
nightlightStartTime = millis();
|
||||||
notify(4);
|
notify(4);
|
||||||
nightlightDelayMs = (int)(nightlightDelayMins*60000);
|
nightlightDelayMs = (int)(nightlightDelayMins*60000);
|
||||||
nightlightActive_old = true;
|
nightlightActiveOld = true;
|
||||||
bri_nl_t = bri;
|
briNlT = bri;
|
||||||
}
|
}
|
||||||
float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
|
float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
|
||||||
if (nightlightFade)
|
if (nightlightFade)
|
||||||
{
|
{
|
||||||
bri = bri_nl_t+((nightlightTargetBri - bri_nl_t)*nper);
|
bri = briNlT+((nightlightTargetBri - briNlT)*nper);
|
||||||
colorUpdated(5);
|
colorUpdated(5);
|
||||||
}
|
}
|
||||||
if (nper >= 1)
|
if (nper >= 1)
|
||||||
@ -167,10 +167,10 @@ void handleNightlight()
|
|||||||
bri = nightlightTargetBri;
|
bri = nightlightTargetBri;
|
||||||
colorUpdated(5);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ void handleButton()
|
|||||||
{
|
{
|
||||||
if (bri == 0)
|
if (bri == 0)
|
||||||
{
|
{
|
||||||
bri = bri_last;
|
bri = briLast;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bri_last = bri;
|
briLast = bri;
|
||||||
bri = 0;
|
bri = 0;
|
||||||
}
|
}
|
||||||
colorUpdated(2);
|
colorUpdated(2);
|
||||||
|
@ -89,7 +89,7 @@ void sendNTPPacket()
|
|||||||
ntpUdp.endPacket();
|
ntpUdp.endPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkNTPResponse()
|
bool checkNTPResponse()
|
||||||
{
|
{
|
||||||
int cb = ntpUdp.parsePacket();
|
int cb = ntpUdp.parsePacket();
|
||||||
if (cb) {
|
if (cb) {
|
||||||
|
@ -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);
|
strip.setRange(overlayMin, overlayMax, 0);
|
||||||
if (num[nixieClockI] >= 0 && !nixiePause)
|
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]);
|
strip.unlock(num[nixieClockI]);
|
||||||
}
|
}
|
||||||
if (!nixiePause)
|
if (!nixiePause)
|
||||||
@ -138,7 +138,7 @@ void handleOverlays()
|
|||||||
void _overlaySolid()
|
void _overlaySolid()
|
||||||
{
|
{
|
||||||
strip.unlockAll();
|
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);
|
strip.setRange(overlayMin,overlayMax,cls);
|
||||||
overlayRefreshMs = 1902;
|
overlayRefreshMs = 1902;
|
||||||
}
|
}
|
||||||
@ -309,14 +309,14 @@ void _overlayAnalogCountdown()
|
|||||||
int overlaySize = overlayMax - overlayMin +1;
|
int overlaySize = overlayMax - overlayMin +1;
|
||||||
double perc = (pval-(double)diff)/pval;
|
double perc = (pval-(double)diff)/pval;
|
||||||
if (perc > 1.0) perc = 1.0;
|
if (perc > 1.0) perc = 1.0;
|
||||||
uint8_t pixelCnt = perc*overlaySize;
|
byte pixelCnt = perc*overlaySize;
|
||||||
if (analogClock12pixel + pixelCnt > overlayMax)
|
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(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)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)whiteSec << 24)| ((uint32_t)colSec[0] << 16) | ((uint32_t)colSec[1] << 8) | colSec[2]);
|
||||||
} else
|
} 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;
|
overlayRefreshMs = 998;
|
||||||
|
@ -80,7 +80,7 @@ void alexaOff()
|
|||||||
DEBUG_PRINTLN(body);
|
DEBUG_PRINTLN(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
void alexaDim(uint8_t briL)
|
void alexaDim(byte briL)
|
||||||
{
|
{
|
||||||
String body = "[{\"success\":{\"/lights/1/state/bri\":"+ String(briL) +"}}]";
|
String body = "[{\"success\":{\"/lights/1/state/bri\":"+ String(briL) +"}}]";
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ void respondToSearch() {
|
|||||||
|
|
||||||
UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
|
UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
UDP.write((uint8_t*)response.c_str(), response.length());
|
UDP.write((byte*)response.c_str(), response.length());
|
||||||
#else
|
#else
|
||||||
UDP.write(response.c_str());
|
UDP.write(response.c_str());
|
||||||
#endif
|
#endif
|
||||||
@ -223,7 +223,7 @@ String briForHue(int realBri)
|
|||||||
return String(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");
|
DEBUG_PRINTLN("AlexaApiCall");
|
||||||
if (req.indexOf("api") <0) return false;
|
if (req.indexOf("api") <0) return false;
|
||||||
@ -262,8 +262,8 @@ boolean handleAlexaApiCall(String req, String body) //basic implementation of Ph
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean connectUDP(){
|
bool connectUDP(){
|
||||||
boolean state = false;
|
bool state = false;
|
||||||
|
|
||||||
DEBUG_PRINTLN("");
|
DEBUG_PRINTLN("");
|
||||||
DEBUG_PRINTLN("Con UDP");
|
DEBUG_PRINTLN("Con UDP");
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Support for the Cronixie clock
|
* 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++)
|
for (int i = index+1; i < 6; i++)
|
||||||
{
|
{
|
||||||
@ -145,12 +145,12 @@ void setCronixie()
|
|||||||
void _overlayCronixie()
|
void _overlayCronixie()
|
||||||
{
|
{
|
||||||
if (countdownMode) checkCountdown();
|
if (countdownMode) checkCountdown();
|
||||||
uint8_t h = hour(local);
|
byte h = hour(local);
|
||||||
uint8_t h0 = h;
|
byte h0 = h;
|
||||||
uint8_t m = minute(local);
|
byte m = minute(local);
|
||||||
uint8_t s = second(local);
|
byte s = second(local);
|
||||||
uint8_t d = day(local);
|
byte d = day(local);
|
||||||
uint8_t mi = month(local);
|
byte mi = month(local);
|
||||||
int y = year(local);
|
int y = year(local);
|
||||||
//this has to be changed in time for 22nd century
|
//this has to be changed in time for 22nd century
|
||||||
y -= 2000; if (y<0) y += 30; //makes countdown work
|
y -= 2000; if (y<0) y += 30; //makes countdown work
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Color conversion methods
|
* 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
|
//this is only an approximation using WS2812B with gamma correction enabled
|
||||||
if (mired > 475)
|
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 h = ((float)hue)/65535.0;
|
||||||
float s = ((float)sat)/255.0;
|
float s = ((float)sat)/255.0;
|
||||||
uint8_t i = floor(h*6);
|
byte i = floor(h*6);
|
||||||
float f = h * 6-i;
|
float f = h * 6-i;
|
||||||
float p = 255 * (1-s);
|
float p = 255 * (1-s);
|
||||||
float q = 255 * (1-f*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 z = 1.0f - x - y;
|
||||||
float X = (1.0f / y) * x;
|
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;
|
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 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;
|
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;
|
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;
|
*wht = (float)minf(rgb[0],minf(rgb[1],rgb[2]))*0.95;
|
||||||
rgb[0]-=wht;
|
rgb[0]-=wht;
|
||||||
|
@ -103,7 +103,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
|
|
||||||
float hueX=0, hueY=0;
|
float hueX=0, hueY=0;
|
||||||
uint16_t hueHue=0, hueCt=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')
|
if (getJsonValue(&hueResp,"on").charAt(0) == 't')
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
}
|
}
|
||||||
} else //On/Off device
|
} else //On/Off device
|
||||||
{
|
{
|
||||||
hueBri = bri_last;
|
hueBri = briLast;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -165,7 +165,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
if (hueApplyOnOff)
|
if (hueApplyOnOff)
|
||||||
{
|
{
|
||||||
if (hueBri==0) {bri = 0;}
|
if (hueBri==0) {bri = 0;}
|
||||||
else if (bri==0 && hueBri>0) bri = bri_last;
|
else if (bri==0 && hueBri>0) bri = briLast;
|
||||||
}
|
}
|
||||||
if (hueApplyBri)
|
if (hueApplyBri)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user