Merge pull request #51 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-02-29 13:39:36 -05:00 committed by GitHub
commit f76a440b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 123 additions and 110 deletions

View File

@ -18,18 +18,26 @@
# it (remove "# " before each line) or use own configuration according to the # it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above). # Travis CI documentation (see above).
# #
# * Test the Travis config here:
# < https://config.travis-ci.com/explore >
#
language: python language: python
python: python:
- "2.7" # - "2.7"
sudo: false - "3.5"
os: linux
cache: cache:
bundler: true
ccache: true
directories: directories:
- "~/.platformio" - "~/.platformio"
- "~/.buildcache"
env: env:
- PLATFORMIO_CI_SRC=wled00 - PLATFORMIO_CI_SRC=wled00
install: install:
- pip install -U platformio - pip install -U platformio
- platformio update - platformio update
script: script:
- platformio ci --project-conf=./platformio.ini # - platformio ci --project-conf=./platformio.ini
- platformio run

View File

@ -5,11 +5,24 @@
src_dir = ./wled00 src_dir = ./wled00
data_dir = ./wled00/data data_dir = ./wled00/data
lib_dir = ./wled00/src lib_dir = ./wled00/src
build_cache_dir = ~/.buildcache
extra_configs = extra_configs =
platformio_override.ini platformio_override.ini
; Please uncomment one of the 5 lines below to select your board # ------------------------------------------------------------------------------
default_envs = nodemcuv2 # ENVIRONMENTS
#
# Please uncomment one of the lines below to select your board(s)
# ------------------------------------------------------------------------------
# Travis CI binaries
default_envs = d1_mini, esp01, esp01_1m, esp32dev
# Release binaries follow
; default_envs = nodemcuv2, esp01, esp01_1m, esp32dev, custom_WS2801, custom_APA102, custom_LEDPIN_16, custom_LEDPIN_4
# Single binaries
; default_envs = nodemcuv2
; default_envs = esp01 ; default_envs = esp01
; default_envs = esp01_1m ; default_envs = esp01_1m
; default_envs = esp07 ; default_envs = esp07
@ -21,9 +34,6 @@ default_envs = nodemcuv2
; default_envs = esp8285_4CH_H801 ; default_envs = esp8285_4CH_H801
; default_envs = esp8285_5CH_H801 ; default_envs = esp8285_5CH_H801
# Release binaries follow
; default_envs = nodemcuv2, esp01, esp01_1m, esp32dev, custom_WS2801, custom_APA102, custom_LEDPIN_16, custom_LEDPIN_4
[common] [common]
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# PLATFORM: # PLATFORM:

View File

@ -379,7 +379,7 @@ uint16_t WS2812FX::mode_rainbow_cycle(void) {
/* /*
* theater chase function * theater chase function
*/ */
uint16_t WS2812FX::theater_chase(uint32_t color1, uint32_t color2, bool dopalette) { uint16_t WS2812FX::theater_chase(uint32_t color1, uint32_t color2, bool do_palette) {
byte gap = 2 + ((255 - SEGMENT.intensity) >> 5); byte gap = 2 + ((255 - SEGMENT.intensity) >> 5);
uint32_t cycleTime = 50 + (255 - SEGMENT.speed)*2; uint32_t cycleTime = 50 + (255 - SEGMENT.speed)*2;
uint32_t it = now / cycleTime; uint32_t it = now / cycleTime;
@ -391,7 +391,7 @@ uint16_t WS2812FX::theater_chase(uint32_t color1, uint32_t color2, bool dopalett
for(uint16_t i = 0; i < SEGLEN; i++) { for(uint16_t i = 0; i < SEGLEN; i++) {
if((i % gap) == SEGENV.aux0) { if((i % gap) == SEGENV.aux0) {
if (dopalette) if (do_palette)
{ {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
} else { } else {
@ -690,58 +690,68 @@ uint16_t WS2812FX::mode_android(void) {
* color1 = background color * color1 = background color
* 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 do_palette) {
uint16_t counter = now * ((SEGMENT.speed >> 2) + 1); uint16_t counter = now * ((SEGMENT.speed >> 2) + 1);
uint16_t a = counter * SEGLEN >> 16; uint16_t a = counter * SEGLEN >> 16;
bool chase_random = (SEGMENT.mode == FX_MODE_CHASE_RANDOM);
if (chase_random) {
if (a < SEGENV.step) //we hit the start again, choose new color for Chase random
{
SEGENV.aux1 = SEGENV.aux0; //store previous random color
SEGENV.aux0 = get_random_wheel_index(SEGENV.aux0);
}
color1 = color_wheel(SEGENV.aux0);
}
SEGENV.step = a; SEGENV.step = 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 + size) % SEGLEN; uint8_t size = 1 + (SEGMENT.intensity * SEGLEN >> 10);
uint16_t c = (b + size) % SEGLEN;
if (dopalette) color1 = color_from_palette(a, true, PALETTE_SOLID_WRAP, 1); uint16_t b = a + size; //"trail" of chase, filled with color1
if (b > SEGLEN) b -= SEGLEN;
uint16_t c = b + size;
if (c > SEGLEN) c -= SEGLEN;
setPixelColor(a, color1); //background
if (SEGENV.aux0 == 0) { // catch the first pixels after color change from "chase random" (because they have the "old" color) if (do_palette)
for (uint16_t i = 0; i < a; i++) { {
uint32_t color = getPixelColor(0); for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color1); setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
} }
SEGENV.aux0 = 1; } else fill(color1);
}
setPixelColor(b, color2);
setPixelColor(c, color3);
if (a != SEGENV.aux1) { // when speed is too fast, this catches the gaps //if random, fill old background between a and end
if (a > SEGENV.aux1) { if (chase_random)
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" {
setPixelColor(i, color1); color1 = color_wheel(SEGENV.aux1);
uint16_t b1 = (i + size) % SEGLEN; for (uint16_t i = a; i < SEGLEN; i++)
uint16_t c1 = (b1 + size) % SEGLEN; setPixelColor(i, color1);
setPixelColor(b1, color2); }
setPixelColor(c1, color3);
} //fill between points a and b with color2
} else { if (a < b)
for (uint16_t i = SEGENV.aux1; i <= SEGLEN; i++) { // from last position to the end {
setPixelColor(i, color1); for (uint16_t i = a; i < b; i++)
uint16_t b1 = (i + size) % SEGLEN; setPixelColor(i, color2);
uint16_t c1 = (b1 + size) % SEGLEN; } else {
setPixelColor(b1, color2); for (uint16_t i = a; i < SEGLEN; i++) //fill until end
setPixelColor(c1, color3); setPixelColor(i, color2);
} for (uint16_t i = 0; i < b; i++) //fill from start until b
for (uint16_t i = 0; i < a; i++) { // from 0 to the actual position setPixelColor(i, color2);
setPixelColor(i, color1); }
uint16_t b1 = (i + size) % SEGLEN;
uint16_t c1 = (b1 + size) % SEGLEN; //fill between points b and c with color2
setPixelColor(b1, color2); if (b < c)
setPixelColor(c1, color3); {
} for (uint16_t i = b; i < c; i++)
SEGENV.step = 0; setPixelColor(i, color3);
SEGENV.aux0 = 0; } else {
} for (uint16_t i = b; i < SEGLEN; i++) //fill until end
setPixelColor(i, color3);
for (uint16_t i = 0; i < c; i++) //fill from start until c
setPixelColor(i, color3);
} }
SEGENV.aux1 = ++a;
return FRAMETIME; return FRAMETIME;
} }
@ -751,7 +761,7 @@ uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool
* Bicolor chase, more primary color. * Bicolor chase, more primary color.
*/ */
uint16_t WS2812FX::mode_chase_color(void) { uint16_t WS2812FX::mode_chase_color(void) {
return chase(SEGCOLOR(1), SEGCOLOR(0), SEGCOLOR(0), true); return chase(SEGCOLOR(1), (SEGCOLOR(2)) ? SEGCOLOR(2) : SEGCOLOR(0), SEGCOLOR(0), true);
} }
@ -759,12 +769,19 @@ 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 return chase(SEGCOLOR(1), (SEGCOLOR(2)) ? SEGCOLOR(2) : SEGCOLOR(0), SEGCOLOR(0), false);
if (SEGENV.call == 0) SEGENV.data[0] = 0; }
if (SEGENV.step == 0) {
SEGENV.data[0] = get_random_wheel_index(SEGENV.data[0]);
} /*
return chase(color_wheel(SEGENV.data[0]), SEGCOLOR(0), SEGCOLOR(0), false); * Primary, secondary running on rainbow.
*/
uint16_t WS2812FX::mode_chase_rainbow(void) {
uint8_t color_sep = 256 / SEGLEN;
uint8_t color_index = SEGENV.call & 0xFF;
uint32_t color = color_wheel(((SEGENV.step * color_sep) + color_index) & 0xFF);
return chase(color, SEGCOLOR(0), SEGCOLOR(1), false);
} }
@ -860,18 +877,6 @@ uint16_t WS2812FX::mode_traffic_light(void) {
} }
/*
* Primary, secondary running on rainbow.
*/
uint16_t WS2812FX::mode_chase_rainbow(void) {
uint8_t color_sep = 256 / SEGLEN;
uint8_t color_index = SEGENV.call & 0xFF;
uint32_t color = color_wheel(((SEGENV.step * color_sep) + color_index) & 0xFF);
return chase(color, SEGCOLOR(0), SEGCOLOR(1), 0);
}
/* /*
* Sec flashes running on prim. * Sec flashes running on prim.
*/ */
@ -3161,4 +3166,4 @@ uint16_t WS2812FX::mode_heartbeat(void) {
} }
return FRAMETIME; return FRAMETIME;
} }

View File

@ -119,7 +119,7 @@
#endif #endif
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 2002252 #define VERSION 2002291
char versionString[] = "0.9.1"; char versionString[] = "0.9.1";
@ -390,7 +390,7 @@ bool presetCyclingEnabled = false;
byte presetCycleMin = 1, presetCycleMax = 5; byte presetCycleMin = 1, presetCycleMax = 5;
uint16_t presetCycleTime = 1250; uint16_t presetCycleTime = 1250;
unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin; unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin;
bool presetApplyBri = false, presetApplyCol = true, presetApplyFx = true; bool presetApplyBri = true;
bool saveCurrPresetCycConf = false; bool saveCurrPresetCycConf = false;
//realtime //realtime

View File

@ -232,8 +232,8 @@ void saveSettingsToEEPROM()
EEPROM.write(2208, presetCycleMin); EEPROM.write(2208, presetCycleMin);
EEPROM.write(2209, presetCycleMax); EEPROM.write(2209, presetCycleMax);
EEPROM.write(2210, presetApplyBri); EEPROM.write(2210, presetApplyBri);
EEPROM.write(2211, presetApplyCol); // was EEPROM.write(2211, presetApplyCol);
EEPROM.write(2212, presetApplyFx); // was EEPROM.write(2212, presetApplyFx);
saveCurrPresetCycConf = false; saveCurrPresetCycConf = false;
} }
@ -519,8 +519,8 @@ void loadSettingsFromEEPROM(bool first)
presetCycleMin = EEPROM.read(2208); presetCycleMin = EEPROM.read(2208);
presetCycleMax = EEPROM.read(2209); presetCycleMax = EEPROM.read(2209);
presetApplyBri = EEPROM.read(2210); presetApplyBri = EEPROM.read(2210);
presetApplyCol = EEPROM.read(2211); //was presetApplyCol = EEPROM.read(2211);
presetApplyFx = EEPROM.read(2212); //was presetApplyFx = EEPROM.read(2212);
} }
bootPreset = EEPROM.read(389); bootPreset = EEPROM.read(389);
@ -583,7 +583,7 @@ void savedToPresets()
} }
} }
bool applyPreset(byte index, bool loadBri = true, bool loadCol = true, bool loadFX = true) bool applyPreset(byte index, bool loadBri = true)
{ {
if (index == 255 || index == 0) if (index == 255 || index == 0)
{ {
@ -596,22 +596,18 @@ bool applyPreset(byte index, bool loadBri = true, bool loadCol = true, bool load
if (EEPROM.read(i) != 1) return false; if (EEPROM.read(i) != 1) return false;
strip.applyToAllSelected = true; strip.applyToAllSelected = true;
if (loadBri) bri = EEPROM.read(i+1); if (loadBri) bri = EEPROM.read(i+1);
if (loadCol)
for (byte j=0; j<4; j++)
{ {
for (byte j=0; j<4; j++) col[j] = EEPROM.read(i+j+2);
{ colSec[j] = EEPROM.read(i+j+6);
col[j] = EEPROM.read(i+j+2);
colSec[j] = EEPROM.read(i+j+6);
}
strip.setColor(2, EEPROM.read(i+12), EEPROM.read(i+13), EEPROM.read(i+14), EEPROM.read(i+15)); //tertiary color
}
if (loadFX)
{
effectCurrent = EEPROM.read(i+10);
effectSpeed = EEPROM.read(i+11);
effectIntensity = EEPROM.read(i+16);
effectPalette = EEPROM.read(i+17);
} }
strip.setColor(2, EEPROM.read(i+12), EEPROM.read(i+13), EEPROM.read(i+14), EEPROM.read(i+15)); //tertiary color
effectCurrent = EEPROM.read(i+10);
effectSpeed = EEPROM.read(i+11);
effectIntensity = EEPROM.read(i+16);
effectPalette = EEPROM.read(i+17);
} else { } else {
if (EEPROM.read(i) != 2) return false; if (EEPROM.read(i) != 2) return false;
strip.applyToAllSelected = false; strip.applyToAllSelected = false;

View File

@ -460,18 +460,12 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf("PA="); //apply brightness from preset pos = req.indexOf("PA="); //apply brightness from preset
if (pos > 0) presetApplyBri = (req.charAt(pos+3) != '0'); if (pos > 0) presetApplyBri = (req.charAt(pos+3) != '0');
pos = req.indexOf("PC="); //apply color from preset
if (pos > 0) presetApplyCol = (req.charAt(pos+3) != '0');
pos = req.indexOf("PX="); //apply effects from preset
if (pos > 0) presetApplyFx = (req.charAt(pos+3) != '0');
pos = req.indexOf("PS="); //saves current in preset pos = req.indexOf("PS="); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos)); if (pos > 0) savePreset(getNumVal(&req, pos));
//apply preset //apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) { if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) {
applyPreset(presetCycCurr, presetApplyBri, presetApplyCol, presetApplyFx); applyPreset(presetCycCurr, presetApplyBri);
} }
//set brightness //set brightness
@ -653,7 +647,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf("NB="); pos = req.indexOf("NB=");
if (pos > 0) //sets backlight if (pos > 0) //sets backlight
{ {
presetApplyFx = (req.charAt(pos+3) != '0'); cronixieBacklight = (req.charAt(pos+3) != '0');
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight); if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
overlayRefreshedTime = 0; overlayRefreshedTime = 0;
} }

View File

@ -100,7 +100,7 @@ void beginStrip()
pinMode(BTNPIN, INPUT_PULLUP); pinMode(BTNPIN, INPUT_PULLUP);
#endif #endif
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true); if (bootPreset > 0) applyPreset(bootPreset, turnOnAtBoot);
colorUpdated(NOTIFIER_CALL_MODE_INIT); colorUpdated(NOTIFIER_CALL_MODE_INIT);
//init relay pin //init relay pin

View File

@ -251,7 +251,7 @@ void handleNightlight()
//also handle preset cycle here //also handle preset cycle here
if (presetCyclingEnabled && (millis() - presetCycledTime > presetCycleTime)) if (presetCyclingEnabled && (millis() - presetCycledTime > presetCycleTime))
{ {
applyPreset(presetCycCurr,presetApplyBri,presetApplyCol,presetApplyFx); applyPreset(presetCycCurr,presetApplyBri);
presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin; presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin;
if (presetCycCurr > 25) presetCycCurr = 1; if (presetCycCurr > 25) presetCycCurr = 1;
colorUpdated(NOTIFIER_CALL_MODE_PRESET_CYCLE); colorUpdated(NOTIFIER_CALL_MODE_PRESET_CYCLE);

View File

@ -97,8 +97,8 @@ void setCronixie()
case '-': dP[i] = 11; break; case '-': dP[i] = 11; break;
case 'r': dP[i] = random(1,7); break; //random btw. 1-6 case 'r': dP[i] = random(1,7); break; //random btw. 1-6
case 'R': dP[i] = random(0,10); break; //random btw. 0-9 case 'R': dP[i] = random(0,10); break; //random btw. 0-9
case 't': break; //Test upw. //case 't': break; //Test upw.
case 'T': break; //Test dnw. //case 'T': break; //Test dnw.
case 'b': dP[i] = 14 + getSameCodeLength('b',i,cronixieDisplay); i = i+dP[i]-14; break; case 'b': dP[i] = 14 + getSameCodeLength('b',i,cronixieDisplay); i = i+dP[i]-14; break;
case 'B': dP[i] = 14 + getSameCodeLength('B',i,cronixieDisplay); i = i+dP[i]-14; break; case 'B': dP[i] = 14 + getSameCodeLength('B',i,cronixieDisplay); i = i+dP[i]-14; break;
case 'h': dP[i] = 70 + getSameCodeLength('h',i,cronixieDisplay); i = i+dP[i]-70; break; case 'h': dP[i] = 70 + getSameCodeLength('h',i,cronixieDisplay); i = i+dP[i]-70; break;
@ -113,8 +113,8 @@ void setCronixie()
case 'y': dP[i] = 86 + getSameCodeLength('y',i,cronixieDisplay); i = i+dP[i]-86; break; case 'y': dP[i] = 86 + getSameCodeLength('y',i,cronixieDisplay); i = i+dP[i]-86; break;
case 'I': dP[i] = 39 + getSameCodeLength('I',i,cronixieDisplay); i = i+dP[i]-39; break; //Month. Don't ask me why month and minute both start with M. case 'I': dP[i] = 39 + getSameCodeLength('I',i,cronixieDisplay); i = i+dP[i]-39; break; //Month. Don't ask me why month and minute both start with M.
case 'i': dP[i] = 89 + getSameCodeLength('i',i,cronixieDisplay); i = i+dP[i]-89; break; case 'i': dP[i] = 89 + getSameCodeLength('i',i,cronixieDisplay); i = i+dP[i]-89; break;
case 'W': break; //case 'W': break;
case 'w': break; //case 'w': break;
case 'D': dP[i] = 43 + getSameCodeLength('D',i,cronixieDisplay); i = i+dP[i]-43; break; case 'D': dP[i] = 43 + getSameCodeLength('D',i,cronixieDisplay); i = i+dP[i]-43; break;
case 'd': dP[i] = 93 + getSameCodeLength('d',i,cronixieDisplay); i = i+dP[i]-93; break; case 'd': dP[i] = 93 + getSameCodeLength('d',i,cronixieDisplay); i = i+dP[i]-93; break;
case '0': dP[i] = 0; break; case '0': dP[i] = 0; break;
@ -127,8 +127,8 @@ void setCronixie()
case '7': dP[i] = 7; break; case '7': dP[i] = 7; break;
case '8': dP[i] = 8; break; case '8': dP[i] = 8; break;
case '9': dP[i] = 9; break; case '9': dP[i] = 9; break;
case 'V': break; //user var0 //case 'V': break; //user var0
case 'v': break; //user var1 //case 'v': break; //user var1
} }
} }
DEBUG_PRINT("result "); DEBUG_PRINT("result ");