2020-04-10 12:30:08 +02:00
|
|
|
#include <EEPROM.h>
|
|
|
|
#include "wled.h"
|
|
|
|
|
2016-12-31 00:38:51 +01:00
|
|
|
/*
|
2020-11-06 22:12:48 +01:00
|
|
|
* DEPRECATED, do not use for new settings
|
|
|
|
* Only used to restore config from pre-0.11 installations using the deEEP() methods
|
|
|
|
*
|
2016-12-31 00:38:51 +01:00
|
|
|
* Methods to handle saving and loading to non-volatile memory
|
2018-02-28 00:27:10 +01:00
|
|
|
* EEPROM Map: https://github.com/Aircoookie/WLED/wiki/EEPROM-Map
|
2016-12-31 00:38:51 +01:00
|
|
|
*/
|
|
|
|
|
2018-02-28 00:27:10 +01:00
|
|
|
//eeprom Version code, enables default settings instead of 0 init on update
|
2020-09-27 11:43:28 +02:00
|
|
|
#define EEPVER 22
|
2020-11-06 22:12:48 +01:00
|
|
|
#define EEPSIZE 2560 //Maximum is 4096
|
2018-02-28 00:27:10 +01:00
|
|
|
//0 -> old version, default
|
|
|
|
//1 -> 0.4p 1711272 and up
|
|
|
|
//2 -> 0.4p 1711302 and up
|
|
|
|
//3 -> 0.4 1712121 and up
|
|
|
|
//4 -> 0.5.0 and up
|
2018-03-15 12:04:14 +01:00
|
|
|
//5 -> 0.5.1 and up
|
|
|
|
//6 -> 0.6.0 and up
|
2018-08-11 22:57:13 +02:00
|
|
|
//7 -> 0.7.1 and up
|
2018-10-04 16:50:12 +02:00
|
|
|
//8 -> 0.8.0-a and up
|
|
|
|
//9 -> 0.8.0
|
2018-12-04 00:58:06 +01:00
|
|
|
//10-> 0.8.2
|
2019-08-17 12:27:06 +02:00
|
|
|
//11-> 0.8.5-dev #mqttauth @TimothyBrown
|
2019-12-04 02:01:47 +01:00
|
|
|
//12-> 0.8.7-dev
|
2019-12-13 01:23:07 +01:00
|
|
|
//13-> 0.9.0-dev
|
|
|
|
//14-> 0.9.0-b1
|
2020-02-08 20:52:45 +01:00
|
|
|
//15-> 0.9.0-b3
|
2020-02-20 17:08:56 +01:00
|
|
|
//16-> 0.9.1
|
2020-02-23 22:24:51 +01:00
|
|
|
//17-> 0.9.1-dmx
|
2020-03-10 18:21:16 +01:00
|
|
|
//18-> 0.9.1-e131
|
2020-04-13 00:42:27 +02:00
|
|
|
//19-> 0.9.1n
|
2020-04-21 22:56:14 +02:00
|
|
|
//20-> 0.9.1p
|
2020-05-18 16:36:31 +02:00
|
|
|
//21-> 0.10.1p
|
2020-09-27 11:43:28 +02:00
|
|
|
//22-> 2009260
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2020-12-10 16:27:23 +01:00
|
|
|
/*
|
|
|
|
* Erase all (pre 0.11) configuration data on factory reset
|
|
|
|
*/
|
|
|
|
void clearEEPROM()
|
|
|
|
{
|
|
|
|
EEPROM.begin(EEPSIZE);
|
|
|
|
for (int i = 0; i < EEPSIZE; i++)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, 0);
|
|
|
|
}
|
|
|
|
EEPROM.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
void readStringFromEEPROM(uint16_t pos, char* str, uint16_t len)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < len; ++i)
|
|
|
|
{
|
|
|
|
str[i] = EEPROM.read(pos + i);
|
|
|
|
if (str[i] == 0) return;
|
|
|
|
}
|
|
|
|
str[len] = 0; //make sure every string is properly terminated. str must be at least len +1 big.
|
|
|
|
}
|
|
|
|
|
2018-08-11 22:57:13 +02:00
|
|
|
/*
|
|
|
|
* Read all configuration from flash
|
|
|
|
*/
|
2020-10-08 00:52:15 +02:00
|
|
|
void loadSettingsFromEEPROM()
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
|
|
|
if (EEPROM.read(233) != 233) //first boot/reset to default
|
|
|
|
{
|
2020-11-06 22:12:48 +01:00
|
|
|
DEBUG_PRINTLN(F("EEPROM settings invalid, using defaults..."));
|
2016-11-19 19:39:17 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM( 0, clientSSID, 32);
|
|
|
|
readStringFromEEPROM( 32, clientPass, 64);
|
|
|
|
readStringFromEEPROM( 96, cmDNS, 32);
|
|
|
|
readStringFromEEPROM(128, apSSID, 32);
|
|
|
|
readStringFromEEPROM(160, apPass, 64);
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-11-21 23:28:20 +01:00
|
|
|
nightlightDelayMinsDefault = EEPROM.read(224);
|
|
|
|
nightlightDelayMins = nightlightDelayMinsDefault;
|
2020-06-22 12:30:31 +02:00
|
|
|
nightlightMode = EEPROM.read(225);
|
2017-05-08 21:46:04 +02:00
|
|
|
notifyDirectDefault = EEPROM.read(226);
|
|
|
|
notifyDirect = notifyDirectDefault;
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
apChannel = EEPROM.read(227);
|
|
|
|
if (apChannel > 13 || apChannel < 1) apChannel = 1;
|
|
|
|
apHide = EEPROM.read(228);
|
|
|
|
if (apHide > 1) apHide = 1;
|
2021-10-31 11:57:41 +01:00
|
|
|
uint16_t length = EEPROM.read(229) + ((EEPROM.read(398) << 8) & 0xFF00); //was ledCount
|
|
|
|
if (length > MAX_LEDS || length == 0) length = 30;
|
|
|
|
uint8_t pins[5] = {2, 255, 255, 255, 255};
|
|
|
|
uint8_t colorOrder = COL_ORDER_GRB;
|
|
|
|
if (lastEEPROMversion > 9) colorOrder = EEPROM.read(383);
|
|
|
|
if (colorOrder > COL_ORDER_GBR) colorOrder = COL_ORDER_GRB;
|
|
|
|
bool skipFirst = EEPROM.read(2204);
|
|
|
|
bool reversed = EEPROM.read(252);
|
|
|
|
BusConfig bc = BusConfig(EEPROM.read(372) ? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, 0, length, colorOrder, reversed, skipFirst);
|
|
|
|
busses.add(bc);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2016-11-20 01:47:15 +01:00
|
|
|
notifyButton = EEPROM.read(230);
|
2018-03-06 23:47:08 +01:00
|
|
|
notifyTwice = EEPROM.read(231);
|
2021-05-20 19:54:07 +02:00
|
|
|
buttonType[0] = EEPROM.read(232) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
staticIP[0] = EEPROM.read(234);
|
|
|
|
staticIP[1] = EEPROM.read(235);
|
|
|
|
staticIP[2] = EEPROM.read(236);
|
|
|
|
staticIP[3] = EEPROM.read(237);
|
|
|
|
staticGateway[0] = EEPROM.read(238);
|
|
|
|
staticGateway[1] = EEPROM.read(239);
|
|
|
|
staticGateway[2] = EEPROM.read(240);
|
|
|
|
staticGateway[3] = EEPROM.read(241);
|
|
|
|
staticSubnet[0] = EEPROM.read(242);
|
|
|
|
staticSubnet[1] = EEPROM.read(243);
|
|
|
|
staticSubnet[2] = EEPROM.read(244);
|
|
|
|
staticSubnet[3] = EEPROM.read(245);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
briS = EEPROM.read(249); bri = briS;
|
2020-10-08 00:52:15 +02:00
|
|
|
if (!EEPROM.read(369))
|
2017-03-07 22:05:18 +01:00
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
bri = 0; briLast = briS;
|
2017-03-07 22:05:18 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
receiveNotificationBrightness = EEPROM.read(250);
|
2016-11-19 19:39:17 +01:00
|
|
|
fadeTransition = EEPROM.read(251);
|
2018-12-04 00:58:06 +01:00
|
|
|
transitionDelayDefault = EEPROM.read(253) + ((EEPROM.read(254) << 8) & 0xFF00);
|
2018-04-11 23:50:35 +02:00
|
|
|
transitionDelay = transitionDelayDefault;
|
2018-02-20 22:29:48 +01:00
|
|
|
briMultiplier = EEPROM.read(255);
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(256, otaPass, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
nightlightTargetBri = EEPROM.read(288);
|
2017-11-20 00:07:37 +01:00
|
|
|
otaLock = EEPROM.read(289);
|
2018-12-04 00:58:06 +01:00
|
|
|
udpPort = EEPROM.read(290) + ((EEPROM.read(291) << 8) & 0xFF00);
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(292, serverDescription, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2016-12-29 00:03:58 +01:00
|
|
|
ntpEnabled = EEPROM.read(327);
|
2018-03-06 23:47:08 +01:00
|
|
|
currentTimezone = EEPROM.read(328);
|
|
|
|
useAMPM = EEPROM.read(329);
|
2019-05-22 00:23:09 +02:00
|
|
|
strip.gammaCorrectBri = EEPROM.read(330);
|
|
|
|
strip.gammaCorrectCol = EEPROM.read(331);
|
2017-02-24 23:21:48 +01:00
|
|
|
overlayDefault = EEPROM.read(332);
|
2018-09-04 15:51:38 +02:00
|
|
|
if (lastEEPROMversion < 8 && overlayDefault > 0) overlayDefault--; //overlay mode 1 (solid) was removed
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2017-02-24 23:21:48 +01:00
|
|
|
alexaEnabled = EEPROM.read(333);
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(334, alexaInvocationName, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-09-15 17:29:01 +02:00
|
|
|
notifyAlexa = EEPROM.read(366);
|
2017-02-24 23:21:48 +01:00
|
|
|
arlsOffset = EEPROM.read(368);
|
2018-03-14 13:16:28 +01:00
|
|
|
if (!EEPROM.read(367)) arlsOffset = -arlsOffset;
|
2017-03-07 22:05:18 +01:00
|
|
|
turnOnAtBoot = EEPROM.read(369);
|
2021-10-31 11:57:41 +01:00
|
|
|
//strip.isRgbw = EEPROM.read(372);
|
2018-09-11 00:20:12 +02:00
|
|
|
//374 - strip.paletteFade
|
2019-11-12 19:33:34 +01:00
|
|
|
|
|
|
|
apBehavior = EEPROM.read(376);
|
|
|
|
|
2017-11-30 23:35:22 +01:00
|
|
|
//377 = lastEEPROMversion
|
2018-01-27 23:28:20 +01:00
|
|
|
if (lastEEPROMversion > 3) {
|
2018-02-20 22:29:48 +01:00
|
|
|
aOtaEnabled = EEPROM.read(390);
|
|
|
|
receiveNotificationColor = EEPROM.read(391);
|
|
|
|
receiveNotificationEffects = EEPROM.read(392);
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
2019-12-04 02:01:47 +01:00
|
|
|
|
2018-02-28 00:27:10 +01:00
|
|
|
if (lastEEPROMversion > 4) {
|
2021-05-20 19:54:07 +02:00
|
|
|
#ifndef WLED_DISABLE_HUESYNC
|
2018-02-28 00:27:10 +01:00
|
|
|
huePollingEnabled = EEPROM.read(2048);
|
|
|
|
//hueUpdatingEnabled = EEPROM.read(2049);
|
|
|
|
for (int i = 2050; i < 2054; ++i)
|
|
|
|
{
|
|
|
|
hueIP[i-2050] = EEPROM.read(i);
|
|
|
|
}
|
2018-07-21 23:21:07 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(2054, hueApiKey, 46);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-12-04 00:58:06 +01:00
|
|
|
huePollIntervalMs = EEPROM.read(2100) + ((EEPROM.read(2101) << 8) & 0xFF00);
|
2018-02-28 00:27:10 +01:00
|
|
|
notifyHue = EEPROM.read(2102);
|
|
|
|
hueApplyOnOff = EEPROM.read(2103);
|
|
|
|
hueApplyBri = EEPROM.read(2104);
|
|
|
|
hueApplyColor = EEPROM.read(2105);
|
|
|
|
huePollLightId = EEPROM.read(2106);
|
2021-05-20 19:54:07 +02:00
|
|
|
#endif
|
2018-03-15 12:04:14 +01:00
|
|
|
}
|
|
|
|
if (lastEEPROMversion > 5) {
|
2018-03-14 00:25:54 +01:00
|
|
|
overlayMin = EEPROM.read(2150);
|
|
|
|
overlayMax = EEPROM.read(2151);
|
|
|
|
analogClock12pixel = EEPROM.read(2152);
|
|
|
|
analogClock5MinuteMarks = EEPROM.read(2153);
|
|
|
|
analogClockSecondsTrail = EEPROM.read(2154);
|
|
|
|
countdownMode = EEPROM.read(2155);
|
|
|
|
countdownYear = EEPROM.read(2156);
|
|
|
|
countdownMonth = EEPROM.read(2157);
|
|
|
|
countdownDay = EEPROM.read(2158);
|
|
|
|
countdownHour = EEPROM.read(2159);
|
|
|
|
countdownMin = EEPROM.read(2160);
|
|
|
|
countdownSec = EEPROM.read(2161);
|
|
|
|
setCountdown();
|
|
|
|
|
2021-05-20 19:54:07 +02:00
|
|
|
#ifndef WLED_DISABLE_CRONIXIE
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(2165, cronixieDisplay, 6);
|
2018-03-14 00:25:54 +01:00
|
|
|
cronixieBacklight = EEPROM.read(2171);
|
2021-05-20 19:54:07 +02:00
|
|
|
#endif
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2020-11-07 23:54:56 +01:00
|
|
|
//macroBoot = EEPROM.read(2175);
|
2018-03-14 00:25:54 +01:00
|
|
|
macroAlexaOn = EEPROM.read(2176);
|
|
|
|
macroAlexaOff = EEPROM.read(2177);
|
2021-05-20 19:54:07 +02:00
|
|
|
macroButton[0] = EEPROM.read(2178);
|
|
|
|
macroLongPress[0] = EEPROM.read(2179);
|
2018-03-14 00:25:54 +01:00
|
|
|
macroCountdown = EEPROM.read(2180);
|
|
|
|
macroNl = EEPROM.read(2181);
|
2021-05-20 19:54:07 +02:00
|
|
|
macroDoublePress[0] = EEPROM.read(2182);
|
|
|
|
if (macroDoublePress[0] > 16) macroDoublePress[0] = 0;
|
2018-02-28 00:27:10 +01:00
|
|
|
}
|
2018-08-11 22:57:13 +02:00
|
|
|
|
|
|
|
if (lastEEPROMversion > 6)
|
|
|
|
{
|
2018-12-04 00:58:06 +01:00
|
|
|
e131Universe = EEPROM.read(2190) + ((EEPROM.read(2191) << 8) & 0xFF00);
|
2018-08-11 22:57:13 +02:00
|
|
|
e131Multicast = EEPROM.read(2192);
|
2018-12-04 00:58:06 +01:00
|
|
|
realtimeTimeoutMs = EEPROM.read(2193) + ((EEPROM.read(2194) << 8) & 0xFF00);
|
2018-08-11 22:57:13 +02:00
|
|
|
arlsForceMaxBri = EEPROM.read(2195);
|
|
|
|
arlsDisableGammaCorrection = EEPROM.read(2196);
|
|
|
|
}
|
2018-09-11 00:20:12 +02:00
|
|
|
|
|
|
|
if (lastEEPROMversion > 7)
|
|
|
|
{
|
2018-09-22 22:49:24 +02:00
|
|
|
strip.paletteFade = EEPROM.read(374);
|
2018-09-11 00:20:12 +02:00
|
|
|
strip.paletteBlend = EEPROM.read(382);
|
2018-09-22 22:49:24 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
{
|
|
|
|
timerHours[i] = EEPROM.read(2260 + i);
|
|
|
|
timerMinutes[i] = EEPROM.read(2270 + i);
|
|
|
|
timerWeekday[i] = EEPROM.read(2280 + i);
|
2020-11-09 20:48:44 +01:00
|
|
|
timerMacro[i] = EEPROM.read(2290 + i);
|
|
|
|
if (timerMacro[i] > 0) timerMacro[i] += 16; //add 16 to work with macro --> preset mapping
|
2018-09-22 22:49:24 +02:00
|
|
|
if (timerWeekday[i] == 0) timerWeekday[i] = 255;
|
2020-11-07 23:54:56 +01:00
|
|
|
if (timerMacro[i] == 0) timerWeekday[i] = timerWeekday[i] & 0b11111110;
|
2018-09-22 22:49:24 +02:00
|
|
|
}
|
2018-09-11 00:20:12 +02:00
|
|
|
}
|
2018-10-04 16:50:12 +02:00
|
|
|
|
|
|
|
if (lastEEPROMversion > 8)
|
|
|
|
{
|
2019-08-17 12:27:06 +02:00
|
|
|
readStringFromEEPROM(2300, mqttServer, 32);
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(2333, mqttDeviceTopic, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
readStringFromEEPROM(2366, mqttGroupTopic, 32);
|
2018-10-04 16:50:12 +02:00
|
|
|
}
|
2018-12-04 00:58:06 +01:00
|
|
|
|
|
|
|
if (lastEEPROMversion > 9)
|
|
|
|
{
|
2021-05-20 19:54:07 +02:00
|
|
|
//strip.setColorOrder(EEPROM.read(383));
|
2018-12-06 00:27:36 +01:00
|
|
|
irEnabled = EEPROM.read(385);
|
2018-12-04 00:58:06 +01:00
|
|
|
strip.ablMilliampsMax = EEPROM.read(387) + ((EEPROM.read(388) << 8) & 0xFF00);
|
2019-02-11 23:49:04 +01:00
|
|
|
} else if (lastEEPROMversion > 1) //ABL is off by default when updating from version older than 0.8.2
|
2018-12-04 00:58:06 +01:00
|
|
|
{
|
2018-12-06 00:27:36 +01:00
|
|
|
strip.ablMilliampsMax = 65000;
|
|
|
|
} else {
|
2018-12-04 00:58:06 +01:00
|
|
|
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
|
|
|
}
|
2019-08-17 12:27:06 +02:00
|
|
|
|
|
|
|
if (lastEEPROMversion > 10)
|
|
|
|
{
|
2019-08-18 03:34:47 +02:00
|
|
|
readStringFromEEPROM(2399, mqttUser, 40);
|
|
|
|
readStringFromEEPROM(2440, mqttPass, 40);
|
|
|
|
readStringFromEEPROM(2481, mqttClientID, 40);
|
2019-08-18 18:14:17 +02:00
|
|
|
mqttPort = EEPROM.read(2522) + ((EEPROM.read(2523) << 8) & 0xFF00);
|
2019-08-17 12:27:06 +02:00
|
|
|
}
|
|
|
|
|
2019-11-12 19:33:34 +01:00
|
|
|
if (lastEEPROMversion > 11)
|
|
|
|
{
|
|
|
|
strip.milliampsPerLed = EEPROM.read(375);
|
|
|
|
} else if (strip.ablMilliampsMax == 65000) //65000 indicates disabled ABL in <0.8.7
|
|
|
|
{
|
|
|
|
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
|
|
|
strip.milliampsPerLed = 0; //disable ABL
|
|
|
|
}
|
2019-12-04 02:01:47 +01:00
|
|
|
if (lastEEPROMversion > 12)
|
|
|
|
{
|
|
|
|
readStringFromEEPROM(990, ntpServerName, 32);
|
|
|
|
}
|
2019-12-13 01:23:07 +01:00
|
|
|
if (lastEEPROMversion > 13)
|
|
|
|
{
|
|
|
|
mqttEnabled = EEPROM.read(2299);
|
|
|
|
syncToggleReceive = EEPROM.read(397);
|
|
|
|
} else {
|
|
|
|
mqttEnabled = true;
|
|
|
|
syncToggleReceive = false;
|
|
|
|
}
|
2019-11-12 19:33:34 +01:00
|
|
|
|
2020-02-08 20:52:45 +01:00
|
|
|
if (lastEEPROMversion > 14)
|
|
|
|
{
|
|
|
|
DMXAddress = EEPROM.read(2197) + ((EEPROM.read(2198) << 8) & 0xFF00);
|
|
|
|
DMXMode = EEPROM.read(2199);
|
2020-02-09 19:10:29 +01:00
|
|
|
} else {
|
|
|
|
DMXAddress = 1;
|
|
|
|
DMXMode = DMX_MODE_MULTIPLE_RGB;
|
2020-02-08 20:52:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:08:56 +01:00
|
|
|
//if (lastEEPROMversion > 15)
|
|
|
|
//{
|
|
|
|
noWifiSleep = EEPROM.read(370);
|
|
|
|
//}
|
|
|
|
|
2020-03-10 18:21:16 +01:00
|
|
|
if (lastEEPROMversion > 17)
|
|
|
|
{
|
|
|
|
e131SkipOutOfSequence = EEPROM.read(2189);
|
|
|
|
} else {
|
|
|
|
e131SkipOutOfSequence = true;
|
|
|
|
}
|
2020-02-08 20:52:45 +01:00
|
|
|
|
2020-04-13 00:42:27 +02:00
|
|
|
if (lastEEPROMversion > 18)
|
|
|
|
{
|
|
|
|
e131Port = EEPROM.read(2187) + ((EEPROM.read(2188) << 8) & 0xFF00);
|
|
|
|
}
|
|
|
|
|
2020-04-21 22:56:14 +02:00
|
|
|
#ifdef WLED_ENABLE_DMX
|
|
|
|
if (lastEEPROMversion > 19)
|
|
|
|
{
|
|
|
|
e131ProxyUniverse = EEPROM.read(2185) + ((EEPROM.read(2186) << 8) & 0xFF00);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-27 11:43:28 +02:00
|
|
|
if (lastEEPROMversion > 21) {
|
|
|
|
udpPort2 = EEPROM.read(378) + ((EEPROM.read(379) << 8) & 0xFF00);
|
2020-09-27 11:37:16 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 19:55:58 +02:00
|
|
|
receiveDirect = !EEPROM.read(2200);
|
2019-02-19 12:57:50 +01:00
|
|
|
notifyMacro = EEPROM.read(2201);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2021-10-24 21:07:05 +02:00
|
|
|
//strip.rgbwMode = EEPROM.read(2203);
|
2021-05-17 16:23:46 +02:00
|
|
|
//skipFirstLed = EEPROM.read(2204);
|
2018-06-24 01:20:15 +02:00
|
|
|
|
2017-12-12 14:52:28 +01:00
|
|
|
bootPreset = EEPROM.read(389);
|
2018-02-23 01:33:32 +01:00
|
|
|
wifiLock = EEPROM.read(393);
|
2018-12-04 00:58:06 +01:00
|
|
|
utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00);
|
2018-03-06 23:47:08 +01:00
|
|
|
if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative
|
2020-02-24 19:36:25 +01:00
|
|
|
//!EEPROM.read(399); was enableSecTransition
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2018-05-10 19:55:58 +02:00
|
|
|
//favorite setting (preset) memory (25 slots/ each 20byte)
|
2017-11-28 00:21:29 +01:00
|
|
|
//400 - 899 reserved
|
2017-12-28 00:37:13 +01:00
|
|
|
|
|
|
|
//custom macro memory (16 slots/ each 64byte)
|
|
|
|
//1024-2047 reserved
|
2018-02-28 00:27:10 +01:00
|
|
|
|
2021-05-20 19:54:07 +02:00
|
|
|
#ifndef WLED_DISABLE_BLYNK
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(2220, blynkApiKey, 35);
|
2019-12-11 00:59:15 +01:00
|
|
|
if (strlen(blynkApiKey) < 25) blynkApiKey[0] = 0;
|
2021-05-20 19:54:07 +02:00
|
|
|
#endif
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2020-02-24 12:54:23 +01:00
|
|
|
#ifdef WLED_ENABLE_DMX
|
2020-02-23 22:24:51 +01:00
|
|
|
// DMX (2530 - 2549)2535
|
|
|
|
DMXChannels = EEPROM.read(2530);
|
|
|
|
DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00);
|
|
|
|
DMXStart = EEPROM.read(2533) + ((EEPROM.read(2534) << 8) & 0xFF00);
|
|
|
|
|
|
|
|
for (int i=0;i<15;i++) {
|
|
|
|
DMXFixtureMap[i] = EEPROM.read(2535+i);
|
2020-04-10 12:30:08 +02:00
|
|
|
} //last used: 2549
|
2020-11-09 00:50:13 +01:00
|
|
|
DMXStartLED = EEPROM.read(2550);
|
2020-02-24 12:54:23 +01:00
|
|
|
#endif
|
2020-02-23 22:24:51 +01:00
|
|
|
|
2020-06-06 00:57:34 +02:00
|
|
|
//Usermod memory
|
|
|
|
//2551 - 2559 reserved for Usermods, usable by default
|
|
|
|
//2560 - 2943 usable, NOT reserved (need to increase EEPSIZE accordingly, new WLED core features may override this section)
|
|
|
|
//2944 - 3071 reserved for Usermods (need to increase EEPSIZE to 3072 in const.h)
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2017-12-11 23:59:12 +01:00
|
|
|
overlayCurrent = overlayDefault;
|
2018-03-06 23:47:08 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2020-11-06 22:12:48 +01:00
|
|
|
//provided for increased compatibility with usermods written for v0.10
|
|
|
|
void applyMacro(byte index) {
|
|
|
|
applyPreset(index+16);
|
2017-12-28 00:37:13 +01:00
|
|
|
}
|
2020-10-23 17:48:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
// De-EEPROM routine, upgrade from previous versions to v0.11
|
|
|
|
void deEEP() {
|
|
|
|
if (WLED_FS.exists("/presets.json")) return;
|
|
|
|
|
|
|
|
DEBUG_PRINTLN(F("Preset file not found, attempting to load from EEPROM"));
|
|
|
|
DEBUGFS_PRINTLN(F("Allocating saving buffer for dEEP"));
|
2021-11-07 11:58:16 +01:00
|
|
|
#ifdef WLED_USE_DYNAMIC_JSON
|
|
|
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
|
|
|
#else
|
2021-11-12 23:33:10 +01:00
|
|
|
if (!requestJSONBufferLock()) {
|
|
|
|
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-07 11:58:16 +01:00
|
|
|
#endif
|
2021-11-03 14:52:22 +01:00
|
|
|
|
|
|
|
JsonObject sObj = doc.to<JsonObject>();
|
2020-10-23 17:48:01 +02:00
|
|
|
sObj.createNestedObject("0");
|
|
|
|
|
2020-11-05 22:54:13 +01:00
|
|
|
EEPROM.begin(EEPSIZE);
|
2020-10-23 17:48:01 +02:00
|
|
|
if (EEPROM.read(233) == 233) { //valid EEPROM save
|
|
|
|
for (uint16_t index = 1; index <= 16; index++) { //copy presets to presets.json
|
|
|
|
uint16_t i = 380 + index*20;
|
|
|
|
byte ver = EEPROM.read(i);
|
|
|
|
|
|
|
|
if ((index < 16 && ver != 1) || (index == 16 && (ver < 2 || ver > 3))) continue;
|
|
|
|
|
|
|
|
char nbuf[16];
|
|
|
|
sprintf(nbuf, "%d", index);
|
|
|
|
|
|
|
|
JsonObject pObj = sObj.createNestedObject(nbuf);
|
|
|
|
|
2020-11-15 20:58:04 +01:00
|
|
|
sprintf_P(nbuf, (char*)F("Preset %d"), index);
|
2020-10-23 17:48:01 +02:00
|
|
|
pObj["n"] = nbuf;
|
|
|
|
|
|
|
|
pObj["bri"] = EEPROM.read(i+1);
|
|
|
|
|
|
|
|
if (index < 16) {
|
|
|
|
JsonObject segObj = pObj.createNestedObject("seg");
|
|
|
|
|
|
|
|
JsonArray colarr = segObj.createNestedArray("col");
|
|
|
|
|
2021-03-29 02:28:34 +02:00
|
|
|
byte numChannels = (strip.isRgbw)? 4:3;
|
2020-10-23 17:48:01 +02:00
|
|
|
|
|
|
|
for (uint8_t k = 0; k < 3; k++) //k=0 primary (i+2) k=1 secondary (i+6) k=2 tertiary color (i+12)
|
|
|
|
{
|
|
|
|
JsonArray colX = colarr.createNestedArray();
|
|
|
|
uint16_t memloc = i + 6*k;
|
|
|
|
if (k == 0) memloc += 2;
|
|
|
|
|
|
|
|
for (byte j = 0; j < numChannels; j++) colX.add(EEPROM.read(memloc + j));
|
|
|
|
}
|
|
|
|
|
2021-05-20 19:54:07 +02:00
|
|
|
segObj["fx"] = EEPROM.read(i+10);
|
2020-10-23 17:48:01 +02:00
|
|
|
segObj[F("sx")] = EEPROM.read(i+11);
|
|
|
|
segObj[F("ix")] = EEPROM.read(i+16);
|
2021-05-20 19:54:07 +02:00
|
|
|
segObj["pal"] = EEPROM.read(i+17);
|
2020-10-23 17:48:01 +02:00
|
|
|
} else {
|
|
|
|
WS2812FX::Segment* seg = strip.getSegments();
|
|
|
|
memcpy(seg, EEPROM.getDataPtr() +i+2, 240);
|
|
|
|
if (ver == 2) { //versions before 2004230 did not have opacity
|
|
|
|
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
|
|
|
{
|
|
|
|
strip.getSegment(j).opacity = 255;
|
|
|
|
strip.getSegment(j).setOption(SEG_OPTION_ON, 1);
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 22:52:59 +01:00
|
|
|
setValuesFromMainSeg();
|
2020-10-23 17:48:01 +02:00
|
|
|
serializeState(pObj, true, false, true);
|
|
|
|
|
|
|
|
strip.resetSegments();
|
2020-11-15 22:52:59 +01:00
|
|
|
setValuesFromMainSeg();
|
2020-10-23 17:48:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint16_t index = 1; index <= 16; index++) { //copy macros to presets.json
|
|
|
|
char m[65];
|
|
|
|
readStringFromEEPROM(1024+64*(index-1), m, 64);
|
|
|
|
if (m[0]) { //macro exists
|
|
|
|
char nbuf[16];
|
|
|
|
sprintf(nbuf, "%d", index + 16);
|
|
|
|
JsonObject pObj = sObj.createNestedObject(nbuf);
|
2020-11-07 23:54:56 +01:00
|
|
|
sprintf_P(nbuf, "Z Macro %d", index);
|
2020-10-23 17:48:01 +02:00
|
|
|
pObj["n"] = nbuf;
|
|
|
|
pObj["win"] = m;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-05 22:54:13 +01:00
|
|
|
EEPROM.end();
|
2020-10-23 17:48:01 +02:00
|
|
|
|
|
|
|
File f = WLED_FS.open("/presets.json", "w");
|
|
|
|
if (!f) {
|
|
|
|
errorFlag = ERR_FS_GENERAL;
|
|
|
|
return;
|
|
|
|
}
|
2021-11-03 14:52:22 +01:00
|
|
|
serializeJson(doc, f);
|
2020-10-23 17:48:01 +02:00
|
|
|
f.close();
|
2021-11-03 14:52:22 +01:00
|
|
|
|
2021-11-12 23:33:10 +01:00
|
|
|
releaseJSONBufferLock();
|
2021-11-03 14:52:22 +01:00
|
|
|
|
2020-10-23 17:48:01 +02:00
|
|
|
DEBUG_PRINTLN(F("deEEP complete!"));
|
2020-11-05 22:54:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void deEEPSettings() {
|
|
|
|
DEBUG_PRINTLN(F("Restore settings from EEPROM"));
|
|
|
|
EEPROM.begin(EEPSIZE);
|
|
|
|
loadSettingsFromEEPROM();
|
|
|
|
EEPROM.end();
|
|
|
|
|
2021-06-25 01:26:15 +02:00
|
|
|
//call readFromConfig() with an empty object so that usermods can initialize to defaults prior to saving
|
|
|
|
JsonObject empty = JsonObject();
|
|
|
|
usermods.readFromConfig(empty);
|
|
|
|
|
2020-11-05 22:54:13 +01:00
|
|
|
serializeConfig();
|
2020-11-03 00:35:04 +01:00
|
|
|
}
|