Merge pull request #52 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-03-03 17:47:19 -05:00 committed by GitHub
commit fd1e536cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 108 additions and 44 deletions

View File

@ -16,15 +16,16 @@ extra_configs =
# ------------------------------------------------------------------------------
# Travis CI binaries
default_envs = d1_mini, esp01, esp01_1m, esp32dev
default_envs = d1_mini, esp01, esp01_1m_ota, esp32dev
# Release binaries follow
; default_envs = nodemcuv2, esp01, esp01_1m, esp32dev, custom_WS2801, custom_APA102, custom_LEDPIN_16, custom_LEDPIN_4
; default_envs = nodemcuv2, esp01, esp01_1m_ota, esp01_1m_full, 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 = esp01_1m_ota
; default_envs = esp01_1m_full
; default_envs = esp07
; default_envs = d1_mini
; default_envs = heltec_wifi_kit_8
@ -102,6 +103,14 @@ debug_flags = -D DEBUG=1 -D WLED_DEBUG -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT
# ------------------------------------------------------------------------------
build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=1024 -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
-DSECURE_CLIENT=SECURE_CLIENT_BEARSSL -DBEARSSL_SSL_BASIC
#build_flags for the IRremoteESP8266 library (enabled decoders have to appear here)
-D _IR_ENABLE_DEFAULT_=false
-D DECODE_HASH=true
-D DECODE_NEC=true
-D DECODE_SONY=true
-D DECODE_SAMSUNG=true
-D DECODE_LG=true
build_flags_esp8266 = ${common.build_flags} -DESP8266
build_flags_esp32 = ${common.build_flags} -DARDUINO_ARCH_ESP32
@ -134,7 +143,7 @@ lib_extra_dirs =
lib_compat_mode = strict
lib_deps =
FastLED@3.3.2
NeoPixelBus@2.5.6
NeoPixelBus@2.5.7
ESPAsyncTCP@1.2.0
ESPAsyncUDP@697c75a025
AsyncTCP@1.0.3
@ -163,13 +172,19 @@ board = esp01
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_512k}
build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_OTA -D WLED_DISABLE_ALEXA -D WLED_DISABLE_BLYNK
-D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_HUESYNC -D WLED_DISABLE_INFRARED
-D WLED_DISABLE_HUESYNC -D WLED_DISABLE_INFRARED
[env:esp01_1m]
[env:esp01_1m_ota]
board = esp01_1m
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_1m0m}
build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_INFRARED
build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_ALEXA -D WLED_DISABLE_BLYNK -D WLED_DISABLE_HUESYNC -D WLED_DISABLE_INFRARED
[env:esp01_1m_full]
board = esp01_1m
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_1m0m}
build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_OTA
[env:esp07]
board = esp07

View File

@ -864,6 +864,8 @@ void WS2812FX::setRgbwPwm(void) {
#else
bus->SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, color.W * b / 255);
#endif
_analogLastColor = color;
_analogLastBri = b;
}
#else
void WS2812FX::setRgbwPwm() {}

View File

@ -119,7 +119,7 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2002291
#define VERSION 2003031
char versionString[] = "0.9.1";
@ -541,8 +541,6 @@ bool oappendi(int i)
//boot starts here
void setup() {
wledInit();
}

View File

@ -621,7 +621,7 @@ bool applyPreset(byte index, bool loadBri = true)
return true;
}
void savePreset(byte index)
void savePreset(byte index, bool persist = true)
{
if (index > 16) return;
if (index < 1) {saveSettingsToEEPROM();return;}
@ -653,7 +653,7 @@ void savePreset(byte index)
memcpy(EEPROM.getDataPtr() +i+2, seg, 240);
}
commit();
if (persist) commit();
savedToPresets();
currentPreset = index;
isPreset = true;
@ -689,7 +689,7 @@ void applyMacro(byte index)
}
void saveMacro(byte index, String mc, bool sing=true) //only commit on single save, not in settings
void saveMacro(byte index, String mc, bool persist = true) //only commit on single save, not in settings
{
index-=1;
if (index > 15) return;
@ -698,5 +698,5 @@ void saveMacro(byte index, String mc, bool sing=true) //only commit on single sa
{
EEPROM.write(i, mc.charAt(i-s));
}
if (sing) commit();
if (persist) commit();
}

View File

@ -372,6 +372,13 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
DEBUG_PRINT("API req: ");
DEBUG_PRINTLN(req);
//write presets and macros saved to flash directly?
bool persistSaves = true;
pos = req.indexOf("NP");
if (pos > 0) {
persistSaves = false;
}
//save macro, requires &MS=<slot>(<macro>) format
pos = req.indexOf("&MS=");
if (pos > 0) {
@ -381,7 +388,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
int en = req.indexOf(')');
String mc = req.substring(pos);
if (en > 0) mc = req.substring(pos, en);
saveMacro(i, mc);
saveMacro(i, mc, persistSaves);
}
pos = req.indexOf("IN");
@ -461,7 +468,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
if (pos > 0) presetApplyBri = (req.charAt(pos+3) != '0');
pos = req.indexOf("PS="); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos));
if (pos > 0) savePreset(getNumVal(&req, pos), persistSaves);
//apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) {

View File

@ -72,7 +72,6 @@ bool colorChanged()
{
if (col[i] != colIT[i]) return true;
if (colSec[i] != colSecIT[i]) return true;
//if (col[i] != colNlT[i]) return true; (this effectively made the ESP send out sync packets every time colorUpdated() is called, even if nothing changed)
}
if (bri != briIT) return true;
return false;

View File

@ -156,8 +156,11 @@ bool deserializeState(JsonObject root)
colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
//write presets to flash directly?
bool persistSaves = !(root["np"] | false);
ps = root["psave"] | -1;
if (ps >= 0) savePreset(ps);
if (ps >= 0) savePreset(ps, persistSaves);
return stateResponse;
}

View File

@ -35,14 +35,55 @@ bool decodeIRCustom(uint32_t code)
//relatively change brightness, minumum A=5
void relativeChange(byte* property, int8_t amount, byte lowerBoundary =0)
void relativeChange(byte* property, int8_t amount, byte lowerBoundary = 0, byte higherBoundary = 0xFF)
{
int16_t new_val = (int16_t) *property + amount;
if (new_val > 0xFF) new_val = 0xFF;
if (new_val > higherBoundary) new_val = higherBoundary;
else if (new_val < lowerBoundary) new_val = lowerBoundary;
*property = new_val;
*property = (byte)constrain(new_val,0.1,255.1);
}
void changeEffectSpeed(int8_t amount)
{
if (effectCurrent != 0) {
int16_t new_val = (int16_t) effectSpeed + amount;
effectSpeed = (byte)constrain(new_val,0.1,255.1);
} else { // if Effect == "solid Color", change the hue of the primary color
CRGB fastled_col;
fastled_col.red = col[0];
fastled_col.green = col[1];
fastled_col.blue = col[2];
CHSV prim_hsv = rgb2hsv_approximate(fastled_col);
int16_t new_val = (int16_t) prim_hsv.h + amount;
if (new_val > 255) new_val -= 255; // roll-over if bigger than 255
if (new_val < 0) new_val += 255; // roll-over if smaller than 0
prim_hsv.h = (byte)new_val;
hsv2rgb_rainbow(prim_hsv, fastled_col);
col[0] = fastled_col.red;
col[1] = fastled_col.green;
col[2] = fastled_col.blue;
}
}
void changeEffectIntensity(int8_t amount)
{
if (effectCurrent != 0) {
int16_t new_val = (int16_t) effectIntensity + amount;
effectIntensity = (byte)constrain(new_val,0.1,255.1);
} else { // if Effect == "solid Color", change the saturation of the primary color
CRGB fastled_col;
fastled_col.red = col[0];
fastled_col.green = col[1];
fastled_col.blue = col[2];
CHSV prim_hsv = rgb2hsv_approximate(fastled_col);
int16_t new_val = (int16_t) prim_hsv.s + amount;
prim_hsv.s = (byte)constrain(new_val,0.1,255.1); // constrain to 0-255
hsv2rgb_rainbow(prim_hsv, fastled_col);
col[0] = fastled_col.red;
col[1] = fastled_col.green;
col[2] = fastled_col.blue;
}
}
void decodeIR(uint32_t code)
{
@ -91,6 +132,7 @@ void decodeIR(uint32_t code)
default: return;
}
}
if (nightlightActive && bri == 0) nightlightActive = false;
colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //for notifier, IR is considered a button input
//code <= 0xF70000 also invalid
}
@ -241,10 +283,10 @@ void decodeIR40(uint32_t code)
case IR40_W50 : bri = 127; break;
case IR40_W75 : bri = 191; break;
case IR40_W100 : bri = 255; break;
case IR40_QUICK : relativeChange(&effectSpeed, 10); break;
case IR40_SLOW : relativeChange(&effectSpeed, -10, 5); break;
case IR40_JUMP7 : relativeChange(&effectIntensity, 10); break;
case IR40_AUTO : relativeChange(&effectIntensity, -10, 5); break;
case IR40_QUICK : changeEffectSpeed( 16); break;
case IR40_SLOW : changeEffectSpeed(-16); break;
case IR40_JUMP7 : changeEffectIntensity( 16); break;
case IR40_AUTO : changeEffectIntensity(-16); break;
case IR40_JUMP3 : if (!applyPreset(1)) { effectCurrent = FX_MODE_STATIC; effectPalette = 0; } break;
case IR40_FADE3 : if (!applyPreset(2)) { effectCurrent = FX_MODE_BREATH; effectPalette = 0; } break;
case IR40_FADE7 : if (!applyPreset(3)) { effectCurrent = FX_MODE_FIRE_FLICKER; effectPalette = 0; } break;
@ -292,14 +334,14 @@ void decodeIR44(uint32_t code)
case IR44_COLDWHITE2 : {
if (useRGBW) { colorFromUint32(COLOR2_COLDWHITE2); effectCurrent = 0; }
else colorFromUint24(COLOR_COLDWHITE2); } break;
case IR44_REDPLUS : relativeChange(&effectCurrent, 1); break;
case IR44_REDPLUS : relativeChange(&effectCurrent, 1, 0, MODE_COUNT); break;
case IR44_REDMINUS : relativeChange(&effectCurrent, -1, 0); break;
case IR44_GREENPLUS : relativeChange(&effectPalette, 1); break;
case IR44_GREENPLUS : relativeChange(&effectPalette, 1, 0, strip.getPaletteCount() -1); break;
case IR44_GREENMINUS : relativeChange(&effectPalette, -1, 0); break;
case IR44_BLUEPLUS : relativeChange(&effectIntensity, 10); break;
case IR44_BLUEMINUS : relativeChange(&effectIntensity, -10, 5); break;
case IR44_QUICK : relativeChange(&effectSpeed, 10); break;
case IR44_SLOW : relativeChange(&effectSpeed, -10, 5); break;
case IR44_BLUEPLUS : changeEffectIntensity( 16); break;
case IR44_BLUEMINUS : changeEffectIntensity(-16); break;
case IR44_QUICK : changeEffectSpeed( 16); break;
case IR44_SLOW : changeEffectSpeed(-16); break;
case IR44_DIY1 : if (!applyPreset(1)) { effectCurrent = FX_MODE_STATIC; effectPalette = 0; } break;
case IR44_DIY2 : if (!applyPreset(2)) { effectCurrent = FX_MODE_BREATH; effectPalette = 0; } break;
case IR44_DIY3 : if (!applyPreset(3)) { effectCurrent = FX_MODE_FIRE_FLICKER; effectPalette = 0; } break;
@ -318,7 +360,7 @@ void decodeIR44(uint32_t code)
void decodeIR21(uint32_t code)
{
switch (code) {
switch (code) {
case IR21_BRIGHTER: relativeChange(&bri, 10); break;
case IR21_DARKER: relativeChange(&bri, -10, 5); break;
case IR21_OFF: briLast = bri; bri = 0; break;
@ -341,20 +383,19 @@ void decodeIR21(uint32_t code)
case IR21_FADE: if (!applyPreset(3)) { effectCurrent = FX_MODE_BREATH; effectPalette = 0; } break;
case IR21_SMOOTH: if (!applyPreset(4)) { effectCurrent = FX_MODE_RAINBOW; effectPalette = 0; } break;
default: return;
}
lastValidCode = code;
}
lastValidCode = code;
}
void decodeIR6(uint32_t code)
{
switch (code) {
case IR6_POWER: toggleOnOff(); break;
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
case IR6_VOLUME_UP: /* next effect */ relativeChange(&effectCurrent, 1); break;
case IR6_VOLUME_DOWN:
/* next palette */
relativeChange(&effectPalette, 1);
case IR6_POWER: toggleOnOff(); break;
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
case IR6_VOLUME_UP: relativeChange(&effectCurrent, 1, 0, MODE_COUNT); break; // next effect
case IR6_VOLUME_DOWN: // next palette
relativeChange(&effectPalette, 1, 0, strip.getPaletteCount() -1);
switch(lastIR6ColourIdx) {
case 0: colorFromUint32(COLOR_RED); break;
case 1: colorFromUint32(COLOR_REDDISH); break;
@ -372,8 +413,7 @@ void decodeIR6(uint32_t code)
default: break;
}
lastIR6ColourIdx++;
if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0;
break;
if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0; break;
case IR6_MUTE: effectCurrent = 0; effectPalette = 0; colorFromUint32(COLOR_WHITE); bri=255; break;
}
lastValidCode = code;