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
|
|
|
#define EEPSIZE 3072
|
|
|
|
|
|
|
|
//eeprom Version code, enables default settings instead of 0 init on update
|
|
|
|
#define EEPVER 5
|
|
|
|
//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
|
|
|
|
//5 -> 0.5.1 and up
|
2017-12-28 00:37:13 +01:00
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
void clearEEPROM()
|
|
|
|
{
|
2017-12-28 00:37:13 +01:00
|
|
|
for (int i = 0; i < EEPSIZE; i++)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
|
|
|
EEPROM.write(i, 0);
|
|
|
|
}
|
|
|
|
EEPROM.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveSettingsToEEPROM()
|
|
|
|
{
|
|
|
|
if (EEPROM.read(233) != 233) //set no first boot flag
|
|
|
|
{
|
|
|
|
clearEEPROM();
|
|
|
|
EEPROM.write(233, 233);
|
2018-02-20 22:29:48 +01:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
showWelcomePage = false;
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
for (int i = 0; i < 32; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, clientssid.charAt(i));
|
|
|
|
}
|
|
|
|
for (int i = 32; i < 96; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, clientpass.charAt(i-32));
|
|
|
|
}
|
|
|
|
for (int i = 96; i < 128; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, cmdns.charAt(i-96));
|
|
|
|
}
|
|
|
|
for (int i = 128; i < 160; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, apssid.charAt(i-128));
|
|
|
|
}
|
|
|
|
for (int i = 160; i < 224; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, appass.charAt(i-160));
|
|
|
|
}
|
2016-11-20 00:07:04 +01:00
|
|
|
EEPROM.write(224, nightlightDelayMins);
|
|
|
|
EEPROM.write(225, nightlightFade);
|
2017-05-08 21:46:04 +02:00
|
|
|
EEPROM.write(226, notifyDirectDefault);
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.write(227, apchannel);
|
2016-11-20 01:47:15 +01:00
|
|
|
EEPROM.write(228, aphide);
|
2017-02-24 23:21:48 +01:00
|
|
|
EEPROM.write(229, ledcount);
|
2016-11-20 01:47:15 +01:00
|
|
|
EEPROM.write(230, notifyButton);
|
2017-05-08 21:46:04 +02:00
|
|
|
//231 was notifyNightlight
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.write(232, buttonEnabled);
|
2016-11-20 01:47:15 +01:00
|
|
|
//233 reserved for first boot flag
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.write(234, staticip[0]);
|
|
|
|
EEPROM.write(235, staticip[1]);
|
|
|
|
EEPROM.write(236, staticip[2]);
|
|
|
|
EEPROM.write(237, staticip[3]);
|
|
|
|
EEPROM.write(238, staticgateway[0]);
|
|
|
|
EEPROM.write(239, staticgateway[1]);
|
|
|
|
EEPROM.write(240, staticgateway[2]);
|
|
|
|
EEPROM.write(241, staticgateway[3]);
|
|
|
|
EEPROM.write(242, staticsubnet[0]);
|
|
|
|
EEPROM.write(243, staticsubnet[1]);
|
|
|
|
EEPROM.write(244, staticsubnet[2]);
|
|
|
|
EEPROM.write(245, staticsubnet[3]);
|
2016-12-29 00:03:58 +01:00
|
|
|
EEPROM.write(246, col_s[0]);
|
|
|
|
EEPROM.write(247, col_s[1]);
|
|
|
|
EEPROM.write(248, col_s[2]);
|
|
|
|
EEPROM.write(249, bri_s);
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(250, receiveNotificationBrightness);
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.write(251, fadeTransition);
|
|
|
|
EEPROM.write(253, (transitionDelay >> 0) & 0xFF);
|
|
|
|
EEPROM.write(254, (transitionDelay >> 8) & 0xFF);
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(255, briMultiplier);
|
2016-11-20 01:47:15 +01:00
|
|
|
//255,250,231,230,226 notifier bytes
|
|
|
|
for (int i = 256; i < 288; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, otapass.charAt(i-256));
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(288, nightlightTargetBri);
|
2017-11-20 00:07:37 +01:00
|
|
|
EEPROM.write(289, otaLock);
|
2016-12-11 20:11:14 +01:00
|
|
|
EEPROM.write(290, (udpPort >> 0) & 0xFF);
|
|
|
|
EEPROM.write(291, (udpPort >> 8) & 0xFF);
|
|
|
|
for (int i = 292; i < 324; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, serverDescription.charAt(i-292));
|
|
|
|
}
|
2016-12-29 00:03:58 +01:00
|
|
|
EEPROM.write(324, effectDefault);
|
|
|
|
EEPROM.write(325, effectSpeedDefault);
|
2018-01-27 23:28:20 +01:00
|
|
|
EEPROM.write(326, effectIntensityDefault);
|
2016-12-29 00:03:58 +01:00
|
|
|
EEPROM.write(327, ntpEnabled);
|
|
|
|
//328 reserved for timezone setting
|
|
|
|
//329 reserved for dst setting
|
2017-02-01 19:25:36 +01:00
|
|
|
EEPROM.write(330, useGammaCorrectionBri);
|
|
|
|
EEPROM.write(331, useGammaCorrectionRGB);
|
2017-02-24 23:21:48 +01:00
|
|
|
EEPROM.write(332, overlayDefault);
|
|
|
|
EEPROM.write(333, alexaEnabled);
|
|
|
|
for (int i = 334; i < 366; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, alexaInvocationName.charAt(i-334));
|
|
|
|
}
|
|
|
|
EEPROM.write(366, alexaNotify);
|
|
|
|
EEPROM.write(367, arlsSign);
|
|
|
|
EEPROM.write(368, abs(arlsOffset));
|
2017-03-07 22:05:18 +01:00
|
|
|
EEPROM.write(369, turnOnAtBoot);
|
2017-05-07 23:51:42 +02:00
|
|
|
EEPROM.write(370, useHSBDefault);
|
2017-09-27 21:45:58 +02:00
|
|
|
EEPROM.write(371, white_s);
|
2017-10-12 22:20:37 +02:00
|
|
|
EEPROM.write(372, useRGBW);
|
2017-10-28 22:22:37 +02:00
|
|
|
EEPROM.write(373, sweepTransition);
|
|
|
|
EEPROM.write(374, sweepDirection);
|
2017-11-20 00:07:37 +01:00
|
|
|
EEPROM.write(375, apWaitTimeSecs);
|
|
|
|
EEPROM.write(376, recoveryAPDisabled);
|
2017-11-28 00:21:29 +01:00
|
|
|
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
2017-11-30 23:35:22 +01:00
|
|
|
EEPROM.write(378, col_sec_s[0]);
|
|
|
|
EEPROM.write(379, col_sec_s[1]);
|
|
|
|
EEPROM.write(380, col_sec_s[2]);
|
|
|
|
EEPROM.write(381, white_sec_s);
|
|
|
|
EEPROM.write(382, cc_index1);
|
|
|
|
EEPROM.write(383, cc_index2);
|
|
|
|
EEPROM.write(384, cc_numPrimary);
|
|
|
|
EEPROM.write(385, cc_numSecondary);
|
|
|
|
EEPROM.write(386, cc_fromStart);
|
|
|
|
EEPROM.write(387, cc_fromEnd);
|
|
|
|
EEPROM.write(388, cc_step);
|
2017-12-12 14:52:28 +01:00
|
|
|
EEPROM.write(389, bootPreset);
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(390, aOtaEnabled);
|
|
|
|
EEPROM.write(391, receiveNotificationColor);
|
|
|
|
EEPROM.write(392, receiveNotificationEffects);
|
2018-02-23 01:33:32 +01:00
|
|
|
EEPROM.write(393, wifiLock);
|
|
|
|
|
|
|
|
for (int k=0;k<6;k++){
|
|
|
|
int in = 900+k*8;
|
|
|
|
for (int i=in; i < in+8; ++i)
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-02-23 01:33:32 +01:00
|
|
|
EEPROM.write(i, cssCol[k].charAt(i-in));
|
2018-02-20 22:29:48 +01:00
|
|
|
}}
|
2018-02-23 01:33:32 +01:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(948,currentTheme);
|
2018-02-23 01:33:32 +01:00
|
|
|
for (int i = 950; i < 982; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, cssFont.charAt(i-950));
|
|
|
|
}
|
2018-02-28 00:27:10 +01:00
|
|
|
|
|
|
|
EEPROM.write(2048, huePollingEnabled);
|
|
|
|
//EEPROM.write(2049, hueUpdatingEnabled);
|
|
|
|
for (int i = 2050; i < 2054; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, hueIP[i-2050]);
|
|
|
|
}
|
|
|
|
for (int i = 2054; i < 2100; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, hueApiKey.charAt(i-2054));
|
|
|
|
}
|
|
|
|
EEPROM.write(2100, (huePollIntervalMs >> 0) & 0xFF);
|
|
|
|
EEPROM.write(2101, (huePollIntervalMs >> 8) & 0xFF);
|
|
|
|
EEPROM.write(2102, notifyHue);
|
|
|
|
EEPROM.write(2103, hueApplyOnOff);
|
|
|
|
EEPROM.write(2104, hueApplyBri);
|
|
|
|
EEPROM.write(2105, hueApplyColor);
|
|
|
|
EEPROM.write(2106, huePollLightId);
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.commit();
|
|
|
|
}
|
|
|
|
|
2017-12-11 23:59:12 +01:00
|
|
|
void loadSettingsFromEEPROM(bool first)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
|
|
|
if (EEPROM.read(233) != 233) //first boot/reset to default
|
|
|
|
{
|
2018-02-23 01:33:32 +01:00
|
|
|
showWelcomePage=true;
|
2016-11-19 19:39:17 +01:00
|
|
|
saveSettingsToEEPROM();
|
|
|
|
return;
|
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
clientssid = "";
|
|
|
|
for (int i = 0; i < 32; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
clientssid += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
clientpass = "";
|
|
|
|
for (int i = 32; i < 96; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
clientpass += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
cmdns = "";
|
|
|
|
for (int i = 96; i < 128; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
cmdns += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
apssid = "";
|
|
|
|
for (int i = 128; i < 160; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
apssid += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
appass = "";
|
|
|
|
for (int i = 160; i < 224; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
appass += char(EEPROM.read(i));
|
|
|
|
}
|
2016-11-20 01:47:15 +01:00
|
|
|
nightlightDelayMins = EEPROM.read(224);
|
|
|
|
nightlightFade = EEPROM.read(225);
|
2017-05-08 21:46:04 +02:00
|
|
|
notifyDirectDefault = EEPROM.read(226);
|
|
|
|
notifyDirect = notifyDirectDefault;
|
2016-11-19 19:39:17 +01:00
|
|
|
apchannel = EEPROM.read(227);
|
|
|
|
if (apchannel > 13 || apchannel < 1) apchannel = 1;
|
2016-11-20 01:47:15 +01:00
|
|
|
aphide = EEPROM.read(228);
|
|
|
|
if (aphide > 1) aphide = 1;
|
2018-01-11 00:28:44 +01:00
|
|
|
ledcount = EEPROM.read(229); if (ledcount > LEDCOUNT) ledcount = LEDCOUNT;
|
2016-11-20 01:47:15 +01:00
|
|
|
notifyButton = EEPROM.read(230);
|
2017-05-08 21:46:04 +02:00
|
|
|
//231 was notifyNightlight
|
2016-11-19 19:39:17 +01:00
|
|
|
buttonEnabled = EEPROM.read(232);
|
|
|
|
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);
|
2016-12-29 00:03:58 +01:00
|
|
|
col_s[0] = EEPROM.read(246); col[0] = col_s[0];
|
|
|
|
col_s[1] = EEPROM.read(247); col[1] = col_s[1];
|
|
|
|
col_s[2] = EEPROM.read(248); col[2] = col_s[2];
|
|
|
|
bri_s = EEPROM.read(249); bri = bri_s;
|
2017-12-11 23:59:12 +01:00
|
|
|
if (!EEPROM.read(369) && first)
|
2017-03-07 22:05:18 +01:00
|
|
|
{
|
|
|
|
bri = 0; bri_last = bri_s;
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
receiveNotificationBrightness = EEPROM.read(250);
|
2016-11-19 19:39:17 +01:00
|
|
|
fadeTransition = EEPROM.read(251);
|
|
|
|
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
2018-02-20 22:29:48 +01:00
|
|
|
briMultiplier = EEPROM.read(255);
|
2016-11-27 21:37:00 +01:00
|
|
|
otapass = "";
|
2016-11-20 01:47:15 +01:00
|
|
|
for (int i = 256; i < 288; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
otapass += char(EEPROM.read(i));
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
nightlightTargetBri = EEPROM.read(288);
|
2017-11-20 00:07:37 +01:00
|
|
|
otaLock = EEPROM.read(289);
|
2016-12-11 20:11:14 +01:00
|
|
|
udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00);
|
|
|
|
serverDescription = "";
|
|
|
|
for (int i = 292; i < 324; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
serverDescription += char(EEPROM.read(i));
|
|
|
|
}
|
2016-12-29 00:03:58 +01:00
|
|
|
effectDefault = EEPROM.read(324); effectCurrent = effectDefault;
|
|
|
|
effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault;
|
|
|
|
ntpEnabled = EEPROM.read(327);
|
2017-02-01 19:25:36 +01:00
|
|
|
useGammaCorrectionBri = EEPROM.read(330);
|
|
|
|
useGammaCorrectionRGB = EEPROM.read(331);
|
2017-02-24 23:21:48 +01:00
|
|
|
overlayDefault = EEPROM.read(332);
|
|
|
|
alexaEnabled = EEPROM.read(333);
|
|
|
|
alexaInvocationName = "";
|
|
|
|
for (int i = 334; i < 366; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
alexaInvocationName += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
alexaNotify = EEPROM.read(366);
|
|
|
|
arlsSign = EEPROM.read(367);
|
|
|
|
arlsOffset = EEPROM.read(368);
|
|
|
|
if (!arlsSign) arlsOffset = -arlsOffset;
|
2017-03-07 22:05:18 +01:00
|
|
|
turnOnAtBoot = EEPROM.read(369);
|
2017-05-07 23:51:42 +02:00
|
|
|
useHSBDefault = EEPROM.read(370);
|
2017-11-19 15:31:17 +01:00
|
|
|
white_s = EEPROM.read(371); white = white_s;
|
2017-10-12 22:20:37 +02:00
|
|
|
useRGBW = EEPROM.read(372);
|
2017-10-28 22:22:37 +02:00
|
|
|
sweepTransition = EEPROM.read(373);
|
|
|
|
sweepDirection = EEPROM.read(374);
|
2017-11-28 00:21:29 +01:00
|
|
|
if (lastEEPROMversion > 0) {
|
|
|
|
apWaitTimeSecs = EEPROM.read(375);
|
|
|
|
recoveryAPDisabled = EEPROM.read(376);
|
|
|
|
}
|
2017-11-30 23:35:22 +01:00
|
|
|
//377 = lastEEPROMversion
|
|
|
|
if (lastEEPROMversion > 1) {
|
2018-01-27 23:28:20 +01:00
|
|
|
col_sec_s[0] = EEPROM.read(378); col_sec[0] = col_sec_s[0];
|
|
|
|
col_sec_s[1] = EEPROM.read(379); col_sec[1] = col_sec_s[1];
|
|
|
|
col_sec_s[2] = EEPROM.read(380); col_sec[2] = col_sec_s[2];
|
|
|
|
white_sec_s = EEPROM.read(381); white_sec = white_sec_s;
|
2017-11-30 23:35:22 +01:00
|
|
|
cc_index1 = EEPROM.read(382);
|
|
|
|
cc_index2 = EEPROM.read(383);
|
|
|
|
cc_numPrimary = EEPROM.read(384);
|
|
|
|
cc_numSecondary = EEPROM.read(385);
|
|
|
|
cc_fromStart = EEPROM.read(386);
|
|
|
|
cc_fromEnd = EEPROM.read(387);
|
|
|
|
cc_step = EEPROM.read(388);
|
2017-12-02 23:58:22 +01:00
|
|
|
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
|
2017-11-30 23:35:22 +01:00
|
|
|
}
|
2018-01-27 23:28:20 +01:00
|
|
|
if (lastEEPROMversion > 3) {
|
|
|
|
effectIntensityDefault = EEPROM.read(326); effectIntensity = effectIntensityDefault;
|
2018-02-20 22:29:48 +01:00
|
|
|
aOtaEnabled = EEPROM.read(390);
|
|
|
|
receiveNotificationColor = EEPROM.read(391);
|
|
|
|
receiveNotificationEffects = EEPROM.read(392);
|
2018-02-23 01:33:32 +01:00
|
|
|
cssFont = "";
|
|
|
|
for (int i = 950; i < 982; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
cssFont += char(EEPROM.read(i));
|
|
|
|
}
|
2018-02-23 22:18:31 +01:00
|
|
|
} else //keep receiving notification behavior from pre0.5.0 after update
|
|
|
|
{
|
|
|
|
receiveNotificationColor = receiveNotificationBrightness;
|
|
|
|
receiveNotificationEffects = receiveNotificationBrightness;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
2018-02-28 00:27:10 +01:00
|
|
|
if (lastEEPROMversion > 4) {
|
|
|
|
huePollingEnabled = EEPROM.read(2048);
|
|
|
|
//hueUpdatingEnabled = EEPROM.read(2049);
|
|
|
|
for (int i = 2050; i < 2054; ++i)
|
|
|
|
{
|
|
|
|
hueIP[i-2050] = EEPROM.read(i);
|
|
|
|
}
|
|
|
|
hueApiKey = "";
|
|
|
|
for (int i = 2054; i < 2100; ++i)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
hueApiKey += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
huePollIntervalMs = ((EEPROM.read(2100) << 0) & 0xFF) + ((EEPROM.read(2101) << 8) & 0xFF00);
|
|
|
|
notifyHue = EEPROM.read(2102);
|
|
|
|
hueApplyOnOff = EEPROM.read(2103);
|
|
|
|
hueApplyBri = EEPROM.read(2104);
|
|
|
|
hueApplyColor = EEPROM.read(2105);
|
|
|
|
huePollLightId = EEPROM.read(2106);
|
|
|
|
}
|
2018-02-20 22:29:48 +01: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);
|
2017-11-28 00:21:29 +01:00
|
|
|
|
|
|
|
//favorite setting memory (25 slots/ each 20byte)
|
|
|
|
//400 - 899 reserved
|
2017-12-28 00:37:13 +01:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
currentTheme = EEPROM.read(948);
|
2018-02-23 01:33:32 +01:00
|
|
|
for (int k=0;k<6;k++){
|
|
|
|
int in=900+k*8;
|
|
|
|
for (int i=in; i < in+8; ++i)
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
cssCol[k] += char(EEPROM.read(i));
|
|
|
|
}}
|
|
|
|
|
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
|
|
|
|
|
|
|
//user MOD memory
|
|
|
|
//2944 - 3071 reserved
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2017-05-07 23:51:42 +02:00
|
|
|
useHSB = useHSBDefault;
|
2017-12-11 23:59:12 +01:00
|
|
|
|
|
|
|
strip.setMode(effectCurrent);
|
|
|
|
strip.setSpeed(effectSpeed);
|
2018-01-27 23:28:20 +01:00
|
|
|
strip.setIntensity(effectIntensity);
|
2017-12-11 23:59:12 +01:00
|
|
|
overlayCurrent = overlayDefault;
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
|
|
|
|
//PRESET PROTOCOL 20 bytes
|
2017-12-02 23:58:22 +01:00
|
|
|
//0: preset purpose byte 0:invalid 1:valid preset 1.0
|
2018-01-27 23:28:20 +01:00
|
|
|
//1:a 2:r 3:g 4:b 5:w 6:er 7:eg 8:eb 9:ew 10:fx 11:sx | custom chase 12:numP 13:numS 14:(0:fs 1:both 2:fe) 15:step 16:ix 17-19:Zeros
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2017-12-02 23:58:22 +01:00
|
|
|
void applyPreset(uint8_t index, bool loadBri, bool loadCol, bool loadFX)
|
2017-11-28 00:21:29 +01:00
|
|
|
{
|
2017-12-11 23:59:12 +01:00
|
|
|
if (index == 255 || index == 0) loadSettingsFromEEPROM(false);//load boot defaults
|
|
|
|
if (index > 25 || index < 1) return;
|
|
|
|
uint16_t i = 380 + index*20;
|
2017-12-02 23:58:22 +01:00
|
|
|
if (EEPROM.read(i) == 0) return;
|
|
|
|
if (loadBri) bri = EEPROM.read(i+1);
|
|
|
|
if (loadCol)
|
2017-11-28 00:21:29 +01:00
|
|
|
{
|
2017-11-30 23:35:22 +01:00
|
|
|
col[0] = EEPROM.read(i+2);
|
|
|
|
col[1] = EEPROM.read(i+3);
|
|
|
|
col[2] = EEPROM.read(i+4);
|
|
|
|
white = EEPROM.read(i+5);
|
|
|
|
col_sec[0] = EEPROM.read(i+6);
|
|
|
|
col_sec[1] = EEPROM.read(i+7);
|
|
|
|
col_sec[2] = EEPROM.read(i+8);
|
|
|
|
white_sec = EEPROM.read(i+9);
|
|
|
|
}
|
2017-12-02 23:58:22 +01:00
|
|
|
if (loadFX)
|
2017-11-30 23:35:22 +01:00
|
|
|
{
|
|
|
|
effectCurrent = EEPROM.read(i+10);
|
|
|
|
effectSpeed = EEPROM.read(i+11);
|
2018-01-27 23:28:20 +01:00
|
|
|
effectIntensity = EEPROM.read(i+16);
|
2017-11-30 23:35:22 +01:00
|
|
|
cc_numPrimary = EEPROM.read(i+12);
|
|
|
|
cc_numSecondary = EEPROM.read(i+13);
|
|
|
|
cc_fromEnd = EEPROM.read(i+14);
|
|
|
|
cc_fromStart = (EEPROM.read(i+14)<2);
|
|
|
|
cc_step = EEPROM.read(i+15);
|
|
|
|
strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
|
2017-12-02 23:58:22 +01:00
|
|
|
strip.setMode(effectCurrent);
|
|
|
|
strip.setSpeed(effectSpeed);
|
2018-01-27 23:28:20 +01:00
|
|
|
strip.setIntensity(effectIntensity);
|
2017-11-28 00:21:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-02 23:58:22 +01:00
|
|
|
void savePreset(uint8_t index)
|
2017-11-28 00:21:29 +01:00
|
|
|
{
|
2017-12-11 23:59:12 +01:00
|
|
|
if (index > 25) return;
|
|
|
|
if (index < 1) {saveSettingsToEEPROM();return;}
|
|
|
|
uint16_t i = 380 + index*20;//min400
|
2017-12-02 23:58:22 +01:00
|
|
|
EEPROM.write(i, 1);
|
|
|
|
EEPROM.write(i+1, bri);
|
|
|
|
EEPROM.write(i+2, col[0]);
|
|
|
|
EEPROM.write(i+3, col[1]);
|
|
|
|
EEPROM.write(i+4, col[2]);
|
|
|
|
EEPROM.write(i+5, white);
|
|
|
|
EEPROM.write(i+6, col_sec[0]);
|
|
|
|
EEPROM.write(i+7, col_sec[1]);
|
|
|
|
EEPROM.write(i+8, col_sec[2]);
|
|
|
|
EEPROM.write(i+9, white_sec);
|
|
|
|
EEPROM.write(i+10, effectCurrent);
|
|
|
|
EEPROM.write(i+11, effectSpeed);
|
|
|
|
EEPROM.write(i+12, cc_numPrimary);
|
|
|
|
EEPROM.write(i+13, cc_numSecondary);
|
|
|
|
uint8_t m = 1;
|
|
|
|
if (!cc_fromStart) m = 2;
|
|
|
|
if (!cc_fromEnd) m = 0;
|
|
|
|
EEPROM.write(i+14, m);
|
|
|
|
EEPROM.write(i+15, cc_step);
|
2018-01-27 23:28:20 +01:00
|
|
|
EEPROM.write(i+16, effectIntensity);
|
2017-11-30 23:35:22 +01:00
|
|
|
EEPROM.commit();
|
2017-11-28 00:21:29 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 00:37:13 +01:00
|
|
|
void applyMacro(uint8_t index)
|
|
|
|
{
|
|
|
|
if (index > 15) return;
|
|
|
|
String mc="win&";
|
|
|
|
for (int i = 1024+64*index; i < 1088+64*index; i++)
|
|
|
|
{
|
|
|
|
if (EEPROM.read(i) == 0) break;
|
|
|
|
mc += char(EEPROM.read(i));
|
|
|
|
}
|
|
|
|
mc += "&IN"; //internal, no XML response
|
|
|
|
if (!macroNotify) mc += "&NN";
|
|
|
|
String forbidden = "&M="; //dont apply if called by the macro itself to prevent loop
|
|
|
|
/*
|
|
|
|
* NOTE: loop is still possible if you call a different macro from a macro, which then calls the first macro again.
|
|
|
|
* To prevent that, but also disable calling macros within macros, comment the next line out.
|
|
|
|
*/
|
|
|
|
forbidden = forbidden + index;
|
|
|
|
if (mc.indexOf(forbidden) >= 0) return;
|
|
|
|
handleSet(mc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveMacro(uint8_t index, String mc)
|
|
|
|
{
|
|
|
|
if (index > 15) return;
|
|
|
|
int s = 1024+index*64;
|
|
|
|
for (int i = s; i < s+64; i++)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, mc.charAt(i-s));
|
|
|
|
}
|
|
|
|
EEPROM.commit();
|
|
|
|
}
|
|
|
|
|