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
# Travis CI documentation (see above).
#
# * Test the Travis config here:
# < https://config.travis-ci.com/explore >
#
language: python
python:
- "2.7"
sudo: false
# - "2.7"
- "3.5"
os: linux
cache:
bundler: true
ccache: true
directories:
- "~/.platformio"
- "~/.buildcache"
env:
- PLATFORMIO_CI_SRC=wled00
install:
- pip install -U platformio
- platformio update
script:
- platformio ci --project-conf=./platformio.ini
# - platformio ci --project-conf=./platformio.ini
- platformio run

View File

@ -5,11 +5,24 @@
src_dir = ./wled00
data_dir = ./wled00/data
lib_dir = ./wled00/src
build_cache_dir = ~/.buildcache
extra_configs =
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_1m
; default_envs = esp07
@ -21,9 +34,6 @@ default_envs = nodemcuv2
; default_envs = esp8285_4CH_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]
# ------------------------------------------------------------------------------
# PLATFORM:

View File

@ -379,7 +379,7 @@ uint16_t WS2812FX::mode_rainbow_cycle(void) {
/*
* 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);
uint32_t cycleTime = 50 + (255 - SEGMENT.speed)*2;
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++) {
if((i % gap) == SEGENV.aux0) {
if (dopalette)
if (do_palette)
{
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
} else {
@ -690,58 +690,68 @@ uint16_t WS2812FX::mode_android(void) {
* color1 = background color
* 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 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;
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
uint16_t b = (a + size) % SEGLEN;
uint16_t c = (b + size) % SEGLEN;
uint8_t size = 1 + (SEGMENT.intensity * SEGLEN >> 10);
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);
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);
//background
if (do_palette)
{
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
}
} else fill(color1);
//if random, fill old background between a and end
if (chase_random)
{
color1 = color_wheel(SEGENV.aux1);
for (uint16_t i = a; i < SEGLEN; i++)
setPixelColor(i, color1);
}
SEGENV.aux0 = 1;
}
setPixelColor(b, color2);
setPixelColor(c, color3);
if (a != SEGENV.aux1) { // when speed is too fast, this catches the gaps
if (a > SEGENV.aux1) {
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);
uint16_t b1 = (i + size) % SEGLEN;
uint16_t c1 = (b1 + size) % SEGLEN;
setPixelColor(b1, color2);
setPixelColor(c1, color3);
}
//fill between points a and b with color2
if (a < b)
{
for (uint16_t i = a; i < b; i++)
setPixelColor(i, color2);
} else {
for (uint16_t i = SEGENV.aux1; i <= SEGLEN; i++) { // from last position to the end
setPixelColor(i, color1);
uint16_t b1 = (i + size) % SEGLEN;
uint16_t c1 = (b1 + size) % SEGLEN;
setPixelColor(b1, color2);
setPixelColor(c1, color3);
for (uint16_t i = a; i < SEGLEN; i++) //fill until end
setPixelColor(i, color2);
for (uint16_t i = 0; i < b; i++) //fill from start until b
setPixelColor(i, color2);
}
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);
//fill between points b and c with color2
if (b < c)
{
for (uint16_t i = b; i < c; i++)
setPixelColor(i, color3);
} 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.step = 0;
SEGENV.aux0 = 0;
}
}
SEGENV.aux1 = ++a;
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.
*/
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.
*/
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) {
SEGENV.data[0] = get_random_wheel_index(SEGENV.data[0]);
return chase(SEGCOLOR(1), (SEGCOLOR(2)) ? SEGCOLOR(2) : SEGCOLOR(0), SEGCOLOR(0), false);
}
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.
*/

View File

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

View File

@ -232,8 +232,8 @@ void saveSettingsToEEPROM()
EEPROM.write(2208, presetCycleMin);
EEPROM.write(2209, presetCycleMax);
EEPROM.write(2210, presetApplyBri);
EEPROM.write(2211, presetApplyCol);
EEPROM.write(2212, presetApplyFx);
// was EEPROM.write(2211, presetApplyCol);
// was EEPROM.write(2212, presetApplyFx);
saveCurrPresetCycConf = false;
}
@ -519,8 +519,8 @@ void loadSettingsFromEEPROM(bool first)
presetCycleMin = EEPROM.read(2208);
presetCycleMax = EEPROM.read(2209);
presetApplyBri = EEPROM.read(2210);
presetApplyCol = EEPROM.read(2211);
presetApplyFx = EEPROM.read(2212);
//was presetApplyCol = EEPROM.read(2211);
//was presetApplyFx = EEPROM.read(2212);
}
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)
{
@ -596,22 +596,18 @@ bool applyPreset(byte index, bool loadBri = true, bool loadCol = true, bool load
if (EEPROM.read(i) != 1) return false;
strip.applyToAllSelected = true;
if (loadBri) bri = EEPROM.read(i+1);
if (loadCol)
{
for (byte j=0; j<4; j++)
{
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);
}
} else {
if (EEPROM.read(i) != 2) return 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
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
if (pos > 0) savePreset(getNumVal(&req, pos));
//apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) {
applyPreset(presetCycCurr, presetApplyBri, presetApplyCol, presetApplyFx);
applyPreset(presetCycCurr, presetApplyBri);
}
//set brightness
@ -653,7 +647,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf("NB=");
if (pos > 0) //sets backlight
{
presetApplyFx = (req.charAt(pos+3) != '0');
cronixieBacklight = (req.charAt(pos+3) != '0');
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
overlayRefreshedTime = 0;
}

View File

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

View File

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

View File

@ -97,8 +97,8 @@ void setCronixie()
case '-': dP[i] = 11; break;
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 't': break; //Test upw.
case 'T': break; //Test dnw.
//case 't': break; //Test upw.
//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 '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 '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 '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] = 93 + getSameCodeLength('d',i,cronixieDisplay); i = i+dP[i]-93; break;
case '0': dP[i] = 0; break;
@ -127,8 +127,8 @@ void setCronixie()
case '7': dP[i] = 7; break;
case '8': dP[i] = 8; break;
case '9': dP[i] = 9; break;
case 'V': break; //user var0
case 'v': break; //user var1
//case 'V': break; //user var0
//case 'v': break; //user var1
}
}
DEBUG_PRINT("result ");