Merge pull request #22 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-02-09 08:57:15 -05:00 committed by GitHub
commit 680923bdd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 47 deletions

View File

@ -346,7 +346,7 @@ uint16_t WS2812FX::mode_dual_scan(void) {
* Cycles all LEDs at once through a rainbow. * Cycles all LEDs at once through a rainbow.
*/ */
uint16_t WS2812FX::mode_rainbow(void) { uint16_t WS2812FX::mode_rainbow(void) {
uint16_t counter = (now * ((SEGMENT.speed >> 3) +2)) & 0xFFFF; uint16_t counter = (now * ((SEGMENT.speed >> 2) +2)) & 0xFFFF;
counter = counter >> 8; counter = counter >> 8;
if (SEGMENT.intensity < 128){ if (SEGMENT.intensity < 128){
@ -363,7 +363,7 @@ uint16_t WS2812FX::mode_rainbow(void) {
* Cycles a rainbow over the entire string of LEDs. * Cycles a rainbow over the entire string of LEDs.
*/ */
uint16_t WS2812FX::mode_rainbow_cycle(void) { uint16_t WS2812FX::mode_rainbow_cycle(void) {
uint16_t counter = (now * ((SEGMENT.speed >> 3) +2)) & 0xFFFF; uint16_t counter = (now * ((SEGMENT.speed >> 2) +2)) & 0xFFFF;
counter = counter >> 8; counter = counter >> 8;
for(uint16_t i = 0; i < SEGLEN; i++) { for(uint16_t i = 0; i < SEGLEN; i++) {
@ -691,39 +691,57 @@ uint16_t WS2812FX::mode_android(void) {
* color2 and color3 = colors of two adjacent leds * color2 and color3 = colors of two adjacent leds
*/ */
uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool dopalette) { uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool dopalette) {
uint16_t counter = now * (SEGMENT.speed >> 3) + 1; uint16_t counter = now * ((SEGMENT.speed >> 2) + 1);
uint16_t a = counter * SEGLEN >> 16; uint16_t a = counter * SEGLEN >> 16;
SEGENV.step = a; SEGENV.step = a;
if (SEGENV.call == 0) SEGENV.aux1 = a; uint8_t size = 1 + (SEGMENT.intensity * SEGLEN >> 10);
if (SEGENV.call == 0) {SEGENV.aux0 = 0; SEGENV.aux1 = a;}
// Use intensity setting to vary chase up to 1/2 string length // Use intensity setting to vary chase up to 1/2 string length
uint16_t b = (a + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; uint16_t b = (a + size) % SEGLEN;
uint16_t c = (b + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; uint16_t c = (b + size) % SEGLEN;
if (dopalette) color1 = color_from_palette(a, true, PALETTE_SOLID_WRAP, 1); if (dopalette) color1 = color_from_palette(a, true, PALETTE_SOLID_WRAP, 1);
setPixelColor(a, color1); setPixelColor(a, color1);
if (SEGENV.aux0 == 0) { // catch the first pixels after color change from "chase random" (because they have the "old" color)
for (uint16_t i = 0; i < a; i++) {
uint32_t color = getPixelColor(0);
setPixelColor(i, color1);
}
SEGENV.aux0 = 1;
}
setPixelColor(b, color2); setPixelColor(b, color2);
setPixelColor(c, color3); setPixelColor(c, color3);
if (a > SEGENV.aux1) { // when speed is too fast, this catches the gaps if (a != SEGENV.aux1) { // when speed is too fast, this catches the gaps
for (uint16_t i = SEGENV.aux1; i < a ; i++) { if (a > SEGENV.aux1) {
setPixelColor(i, color1); for (uint16_t i = SEGENV.aux1; i <= a; i++) { // sometimes the step-length varies from one to the next call - therefor "<= a" and not "< a"
uint16_t b1 = (i + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; setPixelColor(i, color1);
uint16_t c1 = (b1 + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; uint16_t b1 = (i + size) % SEGLEN;
setPixelColor(b1, color2); uint16_t c1 = (b1 + size) % SEGLEN;
setPixelColor(c1, color3); setPixelColor(b1, color2);
} setPixelColor(c1, color3);
} else if (a < SEGENV.aux1 && a < 10) { // this is for the start of the strip }
for (uint16_t i = 0; i < a ; i++) { } else {
setPixelColor(i, color1); for (uint16_t i = SEGENV.aux1; i <= SEGLEN; i++) { // from last position to the end
uint16_t b1 = (i + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; setPixelColor(i, color1);
uint16_t c1 = (b1 + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN; uint16_t b1 = (i + size) % SEGLEN;
setPixelColor(b1, color2); uint16_t c1 = (b1 + size) % SEGLEN;
setPixelColor(c1, color3); setPixelColor(b1, color2);
setPixelColor(c1, color3);
}
for (uint16_t i = 0; i < a; i++) { // from 0 to the actual position
setPixelColor(i, color1);
uint16_t b1 = (i + size) % SEGLEN;
uint16_t c1 = (b1 + size) % SEGLEN;
setPixelColor(b1, color2);
setPixelColor(c1, color3);
}
SEGENV.step = 0; SEGENV.step = 0;
SEGENV.aux0 = 0;
} }
} }
SEGENV.aux1 = a++; SEGENV.aux1 = ++a;
return FRAMETIME; return FRAMETIME;
} }
@ -741,10 +759,12 @@ uint16_t WS2812FX::mode_chase_color(void) {
* Primary running followed by random color. * Primary running followed by random color.
*/ */
uint16_t WS2812FX::mode_chase_random(void) { uint16_t WS2812FX::mode_chase_random(void) {
if (!SEGENV.allocateData(2)) return mode_static(); //allocation failed
if (SEGENV.call == 0) SEGENV.data[0] = 0;
if (SEGENV.step == 0) { if (SEGENV.step == 0) {
SEGENV.aux0 = get_random_wheel_index(SEGENV.aux0); SEGENV.data[0] = get_random_wheel_index(SEGENV.data[0]);
} }
return chase(color_wheel(SEGENV.aux0), SEGCOLOR(0), SEGCOLOR(0), false); return chase(color_wheel(SEGENV.data[0]), SEGCOLOR(0), SEGCOLOR(0), false);
} }
@ -1207,6 +1227,7 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2)
{ {
uint16_t counter = now * ((SEGMENT.speed >> 2) +1); uint16_t counter = now * ((SEGMENT.speed >> 2) +1);
uint16_t idexR = (counter * SEGLEN) >> 16; uint16_t idexR = (counter * SEGLEN) >> 16;
uint8_t size = 1 + SEGMENT.intensity >> 3;
if (idexR >= SEGLEN) idexR = 0; if (idexR >= SEGLEN) idexR = 0;
uint16_t topindex = SEGLEN >> 1; uint16_t topindex = SEGLEN >> 1;
@ -1214,10 +1235,11 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2)
if (SEGENV.call == 0) SEGENV.aux0 = idexR; if (SEGENV.call == 0) SEGENV.aux0 = idexR;
if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs
if (SEGENV.aux0 == idexR) { for (uint8_t i=0; i <= size; i++) {
setPixelColor(idexR, color1); setPixelColor(idexR+i, color1);
setPixelColor(idexB, color2); setPixelColor(idexB+i, color2);
} else { }
if (SEGENV.aux0 != idexR) {
uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR; uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR;
for (uint8_t i = 0; i <= gap ; i++) { for (uint8_t i = 0; i <= gap ; i++) {
if ((idexR - i) < 0) idexR = SEGLEN-1 + i; if ((idexR - i) < 0) idexR = SEGLEN-1 + i;

View File

@ -105,6 +105,9 @@
<h3>MQTT</h3> <h3>MQTT</h3>
Enable MQTT: <input type="checkbox" name="MQ"><br> Enable MQTT: <input type="checkbox" name="MQ"><br>
Broker: <input name="MS" maxlength="32"><br> Broker: <input name="MS" maxlength="32"><br>
Port: <input name="MQPORT" type="number" min="1" max="65535"><br>
<b>The MQTT credentials are sent over an unsecured connection.<br>
Never use the MQTT password for another service!</b><br>
Username: <input name="MQTTUSER" maxlength="32"><br> Username: <input name="MQTTUSER" maxlength="32"><br>
Password: <input type="password" input name="MQTTPASS" maxlength="32"><br> Password: <input type="password" input name="MQTTPASS" maxlength="32"><br>
Client ID: <input name="MQTTCID" maxlength="32"><br> Client ID: <input name="MQTTCID" maxlength="32"><br>
@ -113,18 +116,15 @@
<a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a> <a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
<h3>Philips Hue</h3> <h3>Philips Hue</h3>
<i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br> <i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br>
Poll Hue light <input name="HL" type="number" min="1" max="99" required> every <input name="HI" type="number" min="100" max="65000" required> ms: <input type="checkbox" name="HP"><br> Poll Hue light <input name="HL" type="number" min="1" max="99"> every <input name="HI" type="number" min="100" max="65000"> ms: <input type="checkbox" name="HP"><br>
Then, receive <input type="checkbox" name="HO"> On/Off, <input type="checkbox" name="HB"> Brightness, and <input type="checkbox" name="HC"> Color<br> Then, receive <input type="checkbox" name="HO"> On/Off, <input type="checkbox" name="HB"> Brightness, and <input type="checkbox" name="HC"> Color<br>
Hue Bridge IP:<br> Hue Bridge IP:<br>
<input name="H0" type="number" min="0" max="255" required> . <input name="H0" type="number" min="0" max="255"> .
<input name="H1" type="number" min="0" max="255" required> . <input name="H1" type="number" min="0" max="255"> .
<input name="H2" type="number" min="0" max="255" required> . <input name="H2" type="number" min="0" max="255"> .
<input name="H3" type="number" min="0" max="255" required><br> <input name="H3" type="number" min="0" max="255"><br>
<b>Press the pushlink button on the bridge, after that save this page!</b><br> <b>Press the pushlink button on the bridge, after that save this page!</b><br>
(when first connecting)<br> (when first connecting)<br>
<!--Update Hue group <input name="HUEGR" type="number" min="0" max="99" required> <br>
Send <input type="checkbox" name="HUEIO"> On/Off, <input type="checkbox" name="HUEBR"> Brightness, and <input type="checkbox" name="HUECL"> Color<br>-->
<!--After device color update, ignore Hue updates for <input name="HUELI" type="number" min="0" max="255" required> minutes<br>-->
Hue status: <span class="hms"> Internal ESP Error! </span><hr> Hue status: <span class="hms"> Internal ESP Error! </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button> <button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form> </form>

View File

@ -20,7 +20,7 @@ const char PAGE_msg[] PROGMEM = R"=====(<!DOCTYPE html>
const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html> const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Update</title><script>function B(){window.history.back()}</script> <html><head><meta content='width=device-width' name='viewport'><title>WLED Update</title><script>function B(){window.history.back()}</script>
<style>.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}</style></head> <style>.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.9.0-b1<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)====="; <body><h2>WLED Software Update</h2>Installed version: 0.9.1<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)=====";
//new user welcome page //new user welcome page

View File

@ -223,7 +223,7 @@ Device Auth token: <input name="BK" maxlength="33"><br>
<h3>MQTT</h3> <h3>MQTT</h3>
Enable MQTT: <input type="checkbox" name="MQ"><br> Enable MQTT: <input type="checkbox" name="MQ"><br>
Broker: <input name="MS" maxlength="32"> Broker: <input name="MS" maxlength="32">
Port: <input name="MQPORT" type="number" min="1" max="65535" required><br> Port: <input name="MQPORT" type="number" min="1" max="65535"><br>
<b>The MQTT credentials are sent over an unsecured connection.<br> <b>The MQTT credentials are sent over an unsecured connection.<br>
Never use the MQTT password for another service!</b><br> Never use the MQTT password for another service!</b><br>
Username: <input name="MQUSER" maxlength="40"><br> Username: <input name="MQUSER" maxlength="40"><br>
@ -370,7 +370,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<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="AO"><br> Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
<h3>About</h3> <h3>About</h3>
<a href="https://github.com/Aircoookie/WLED" target="_blank">WLED</a> version 0.9.0-b2<br><br> <a href="https://github.com/Aircoookie/WLED" target="_blank">WLED</a> version 0.9.1<br><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About" target="_blank">Contributors, dependencies and special thanks</a><br> <a href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About" target="_blank">Contributors, dependencies and special thanks</a><br>
A huge thank you to everyone who helped me create WLED!<br><br> A huge thank you to everyone who helped me create WLED!<br><br>
(c) 2016-2020 Christian Schwinne <br> (c) 2016-2020 Christian Schwinne <br>

View File

@ -3,7 +3,7 @@
*/ */
/* /*
* @title WLED project sketch * @title WLED project sketch
* @version 0.9.0-b2 * @version 0.9.1
* @author Christian Schwinne * @author Christian Schwinne
*/ */
@ -90,9 +90,9 @@
#endif #endif
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 2001281 #define VERSION 2002021
char versionString[] = "0.9.0-b2"; char versionString[] = "0.9.1";
//AP and OTA default passwords (for maximum change them!) //AP and OTA default passwords (for maximum change them!)
@ -115,9 +115,7 @@ char cmDNS[33] = "x"; //mDNS address (placeholder, will
char apSSID[33] = ""; //AP off by default (unless setup) char apSSID[33] = ""; //AP off by default (unless setup)
byte apChannel = 1; //2.4GHz WiFi AP channel (1-13) byte apChannel = 1; //2.4GHz WiFi AP channel (1-13)
byte apHide = 0; //hidden AP SSID byte apHide = 0; //hidden AP SSID
//byte apWaitTimeSecs = 32; //time to wait for connection before opening AP
byte apBehavior = 0; //0: Open AP when no connection after boot 1: Open when no connection 2: Always open 3: Only when button pressed for 6 sec byte apBehavior = 0; //0: Open AP when no connection after boot 1: Open when no connection 2: Always open 3: Only when button pressed for 6 sec
//bool recoveryAPDisabled = false; //never open AP (not recommended)
IPAddress staticIP(0, 0, 0, 0); //static IP of ESP IPAddress staticIP(0, 0, 0, 0); //static IP of ESP
IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP
IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks

View File

@ -152,6 +152,9 @@ void initAP(bool resetAP=false){
void initConnection() void initConnection()
{ {
WiFi.disconnect(); //close old connections WiFi.disconnect(); //close old connections
#ifdef ESP8266
WiFi.setPhyMode(WIFI_PHY_MODE_11N);
#endif
if (staticIP[0] != 0 && staticGateway[0] != 0) if (staticIP[0] != 0 && staticGateway[0] != 0)
{ {

View File

@ -57,7 +57,7 @@ void setAllLeds() {
} }
void setLedsStandard() void setLedsStandard(bool justColors = false)
{ {
for (byte i=0; i<4; i++) for (byte i=0; i<4; i++)
{ {
@ -66,6 +66,7 @@ void setLedsStandard()
colSecOld[i] = colSec[i]; colSecOld[i] = colSec[i];
colSecT[i] = colSec[i]; colSecT[i] = colSec[i];
} }
if (justColors) return;
briOld = bri; briOld = bri;
briT = bri; briT = bri;
setAllLeds(); setAllLeds();
@ -120,7 +121,12 @@ void colorUpdated(int callMode)
colIT[i] = col[i]; colIT[i] = col[i];
colSecIT[i] = colSec[i]; colSecIT[i] = colSec[i];
} }
if (briT == 0 && callMode != 3) resetTimebase(); if (briT == 0)
{
setLedsStandard(true); //do not color transition if starting from off
if (callMode != 3) resetTimebase(); //effect start from beginning
}
briIT = bri; briIT = bri;
if (bri > 0) briLast = bri; if (bri > 0) briLast = bri;