Incomplete commit for Nightlight Fixes

Interim state (Reason: Local Working Copy Data Corruption)
Affected files: (local changes will be re-implemented in next commit)
settings_sync.html (already recovered)
html_settings.h (already recovered)
wled03_set.ino
wled08_led.ino
wled09_button.ino
wled19_ir.ino
pull/81/head
cschwinne 2018-11-21 23:28:20 +01:00
rodzic c0816c80ae
commit 54d7a81f16
7 zmienionych plików z 93 dodań i 65 usunięć

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -224,7 +224,9 @@ const char PAGE_settings_sync1[] PROGMEM = R"=====(
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>Sync setup</h2>
<h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BT">
On/Off button enabled: <input type="checkbox" name="BT"><br>
Infrared receiver enabled: <input type="checkbox" name="IR"><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a>
<h3>WLED Broadcast</h3>
UDP Port: <input name="UP" maxlength="5" size="4"><br>
Receive <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">Effects<br>

Wyświetl plik

@ -21,10 +21,12 @@
//#define WLED_DISABLE_BLYNK
//#define WLED_DISABLE_CRONIXIE
//#define WLED_DISABLE_HUESYNC
//#define WLED_DISABLE_INFRARED
//#define WLED_DISABLE_MOBILE_UI
//to toggle usb serial debug (un)comment following line(s)
//#define WLED_DEBUG
#define WLED_DEBUG
//library inclusions
#include <Arduino.h>
@ -33,15 +35,19 @@
#include <ESPmDNS.h>
#include "src/dependencies/webserver/WebServer.h"
#include <HTTPClient.h>
#include <IRremote.h>
/*#ifndef WLED_DISABLE_INFRARED
#include <IRremote.h>
#endif*/ //there are issues with ESP32 infrared, so it is disabled for now
#else
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
#ifndef WLED_DISABLE_INFRARED
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
#endif
#endif
#include <EEPROM.h>
@ -68,7 +74,7 @@
//version code in format yymmddb (b = daily build)
#define VERSION 1811172
#define VERSION 1811201
char versionString[] = "0.8.2-dev";
@ -148,8 +154,8 @@ bool useHSBDefault = useHSB;
//Sync CONFIG
bool buttonEnabled = true;
bool irEnabled = true; //Infrared receiver
bool buttonEnabled = true;
bool irEnabled = false; //Infrared receiver
uint16_t udpPort = 21324; //WLED notifier default port
uint16_t udpRgbPort = 19446; //Hyperion port
@ -158,7 +164,7 @@ bool receiveNotificationBrightness = true; //apply brightness from incoming n
bool receiveNotificationColor = true; //apply color
bool receiveNotificationEffects = true; //apply effects setup
bool notifyDirect = true; //send notification if change via UI or HTTP API
bool notifyButton = true;
bool notifyButton = true; //send if updated by button or infrared remote
bool notifyAlexa = false; //send notification if updated via Alexa
bool notifyMacro = false; //send notification for macro
bool notifyHue = true; //send notification if Hue light changes
@ -259,6 +265,7 @@ float tperLast = 0; //crossfade transition progress, 0
bool nightlightActive = false;
bool nightlightActiveOld = false;
uint32_t nightlightDelayMs = 10;
uint8_t nightlightDelayMinsDefault = nightlightDelayMins;
unsigned long nightlightStartTime;
byte briNlT = 0; //current nightlight brightness
@ -407,7 +414,7 @@ E131* e131;
WS2812FX strip = WS2812FX();
//debug macros
#ifdef DEBUG
#ifdef WLED_DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINTF(x) Serial.printf (x)
@ -524,7 +531,7 @@ void loop() {
}
//DEBUG serial logging
#ifdef DEBUG
#ifdef WLED_DEBUG
if (millis() - debugTime > 5000)
{
DEBUG_PRINTLN("---MODULE DEBUG INFO---");

Wyświetl plik

@ -66,7 +66,7 @@ void saveSettingsToEEPROM()
writeStringToEEPROM(128, apSSID, 32);
writeStringToEEPROM(160, apPass, 64);
EEPROM.write(224, nightlightDelayMins);
EEPROM.write(224, nightlightDelayMinsDefault);
EEPROM.write(225, nightlightFade);
EEPROM.write(226, notifyDirectDefault);
EEPROM.write(227, apChannel);
@ -138,6 +138,8 @@ void saveSettingsToEEPROM()
EEPROM.write(380, colSecS[2]);
EEPROM.write(381, whiteSecS);
EEPROM.write(382, strip.paletteBlend);
EEPROM.write(385, irEnabled);
EEPROM.write(389, bootPreset);
EEPROM.write(390, aOtaEnabled);
@ -256,7 +258,9 @@ void loadSettingsFromEEPROM(bool first)
{
if (EEPROM.read(233) != 233) //first boot/reset to default
{
DEBUG_PRINT("Settings invalid, restoring defaults...");
saveSettingsToEEPROM();
DEBUG_PRINTLN("done");
return;
}
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
@ -268,7 +272,8 @@ void loadSettingsFromEEPROM(bool first)
readStringFromEEPROM(128, apSSID, 32);
readStringFromEEPROM(160, apPass, 64);
nightlightDelayMins = EEPROM.read(224);
nightlightDelayMinsDefault = EEPROM.read(224);
nightlightDelayMins = nightlightDelayMinsDefault;
nightlightFade = EEPROM.read(225);
notifyDirectDefault = EEPROM.read(226);
notifyDirect = notifyDirectDefault;
@ -343,6 +348,8 @@ void loadSettingsFromEEPROM(bool first)
effectPaletteDefault = EEPROM.read(373); effectPalette = effectPaletteDefault;
//374 - strip.paletteFade
irEnabled = EEPROM.read(385);
if (lastEEPROMversion > 0) {
apWaitTimeSecs = EEPROM.read(375);
recoveryAPDisabled = EEPROM.read(376);
@ -607,14 +614,16 @@ void saveMacro(byte index, String mc, bool sing=true) //only commit on single sa
void commit()
{
#ifdef ARDUINO_ARCH_ESP32
delay(1);
portDISABLE_INTERRUPTS();
#endif
EEPROM.commit();
#ifdef ARDUINO_ARCH_ESP32
portENABLE_INTERRUPTS();
#endif
DEBUG_PRINT("s");
/*#ifdef ARDUINO_ARCH_ESP32
portMUX_TYPE mMux = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mMux);
#endif*/
EEPROM.commit();
/*#ifdef ARDUINO_ARCH_ESP32
portEXIT_CRITICAL(&mMux);
#endif*/
DEBUG_PRINT(".");
}

Wyświetl plik

@ -216,7 +216,7 @@ void getSettingsJS(byte subPage)
sappend('c',"T2",enableSecTransition);
sappend('v',"BF",briMultiplier);
sappend('v',"TB",nightlightTargetBri);
sappend('v',"TL",nightlightDelayMins);
sappend('v',"TL",nightlightDelayMinsDefault);
sappend('c',"TW",nightlightFade);
sappend('i',"PB",strip.paletteBlend);
sappend('c',"RV",reverseMode);
@ -242,6 +242,7 @@ void getSettingsJS(byte subPage)
if (subPage == 4)
{
sappend('c',"BT",buttonEnabled);
sappend('c',"IR",irEnabled);
sappend('v',"UP",udpPort);
sappend('c',"RB",receiveNotificationBrightness);
sappend('c',"RC",receiveNotificationColor);

Wyświetl plik

@ -251,7 +251,7 @@ void getBuildInfo()
#else
oappend("\r\nspiffs: false\r\n");
#endif
#ifdef DEBUG
#ifdef WLED_DEBUG
oappend("debug: true\r\n");
#else
oappend("debug: false\r\n");
@ -260,8 +260,8 @@ void getBuildInfo()
oappendi(BTNPIN);
oappend("\r\nstrip-pin: gpio");
oappendi(LEDPIN);
oappend("\r\nbrand: wled\r\n");
oappend("\r\nbuild-type: src\r\n");
oappend("\r\nbrand: wled");
oappend("\r\nbuild-type: dev\r\n");
}

Wyświetl plik

@ -150,56 +150,65 @@ void handleNotifications()
olen = 0;
notifierUdp.read(obuf, packetSize);
char* udpIn = obuf;
if (udpIn[0] == 0 && !realtimeActive && receiveNotifications) //wled notifier, block if realtime packets active
//wled notifier, block if realtime packets active
if (udpIn[0] == 0 && !realtimeActive && receiveNotifications)
{
//apply colors from notification
if (receiveNotificationColor)
{
col[0] = udpIn[3];
col[1] = udpIn[4];
col[2] = udpIn[5];
}
if (udpIn[11] > 0 && receiveNotificationColor) //check if sending modules white val is inteded
{
white = udpIn[10];
if (udpIn[11] > 1 )
col[0] = udpIn[3];
col[1] = udpIn[4];
col[2] = udpIn[5];
if (udpIn[11] > 0) //check if sending modules white val is inteded
{
colSec[0] = udpIn[12];
colSec[1] = udpIn[13];
colSec[2] = udpIn[14];
whiteSec = udpIn[15];
white = udpIn[10];
if (udpIn[11] > 1)
{
colSec[0] = udpIn[12];
colSec[1] = udpIn[13];
colSec[2] = udpIn[14];
whiteSec = udpIn[15];
}
}
}
if (udpIn[8] != effectCurrent && receiveNotificationEffects)
//apply effects from notification
if (receiveNotificationEffects)
{
effectCurrent = udpIn[8];
strip.setMode(effectCurrent);
}
if (udpIn[9] != effectSpeed && receiveNotificationEffects)
{
effectSpeed = udpIn[9];
strip.setSpeed(effectSpeed);
}
if (udpIn[11] > 2 && udpIn[16] != effectIntensity && receiveNotificationEffects)
{
effectIntensity = udpIn[16];
strip.setIntensity(effectIntensity);
if (udpIn[8] != effectCurrent)
{
effectCurrent = udpIn[8];
strip.setMode(effectCurrent);
}
if (udpIn[9] != effectSpeed)
{
effectSpeed = udpIn[9];
strip.setSpeed(effectSpeed);
}
if (udpIn[11] > 2 && udpIn[16] != effectIntensity)
{
effectIntensity = udpIn[16];
strip.setIntensity(effectIntensity);
}
if (udpIn[11] > 4 && udpIn[19] != effectPalette)
{
effectPalette = udpIn[19];
strip.setPalette(effectPalette);
}
}
if (udpIn[11] > 3)
{
transitionDelayTemp = ((udpIn[17] << 0) & 0xFF) + ((udpIn[18] << 8) & 0xFF00);
}
if (udpIn[11] > 4 && udpIn[19] != effectPalette && receiveNotificationEffects)
{
effectPalette = udpIn[19];
strip.setPalette(effectPalette);
}
nightlightActive = udpIn[6];
if (!nightlightActive)
{
if (receiveNotificationBrightness) bri = udpIn[2];
colorUpdated(3);
}
if (nightlightActive) nightlightDelayMins = udpIn[7];
if (receiveNotificationBrightness) bri = udpIn[2];
colorUpdated(3);
} else if (udpIn[0] > 0 && udpIn[0] < 4 && receiveDirect) //1 warls //2 drgb //3 drgbw
{
realtimeIP = notifierUdp.remoteIP();