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
|
|
|
*/
|
|
|
|
|
2020-02-22 17:20:34 +01:00
|
|
|
#define EEPSIZE 2560 //Maximum is 4096
|
2018-02-28 00:27:10 +01:00
|
|
|
|
|
|
|
//eeprom Version code, enables default settings instead of 0 init on update
|
2020-02-23 22:24:51 +01:00
|
|
|
#define EEPVER 17
|
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
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2019-11-30 11:17:37 +01:00
|
|
|
void commit()
|
|
|
|
{
|
|
|
|
if (!EEPROM.commit()) errorFlag = 2;
|
|
|
|
}
|
|
|
|
|
2018-08-11 22:57:13 +02:00
|
|
|
/*
|
|
|
|
* Erase all configuration data
|
|
|
|
*/
|
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);
|
|
|
|
}
|
2019-11-30 11:17:37 +01:00
|
|
|
commit();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
void writeStringToEEPROM(uint16_t pos, char* str, uint16_t len)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < len; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(pos + i, str[i]);
|
|
|
|
if (str[i] == 0) return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Write configuration to flash
|
|
|
|
*/
|
2016-11-19 19:39:17 +01:00
|
|
|
void saveSettingsToEEPROM()
|
|
|
|
{
|
|
|
|
if (EEPROM.read(233) != 233) //set no first boot flag
|
|
|
|
{
|
|
|
|
clearEEPROM();
|
|
|
|
EEPROM.write(233, 233);
|
|
|
|
}
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM( 0, clientSSID, 32);
|
|
|
|
writeStringToEEPROM( 32, clientPass, 64);
|
|
|
|
writeStringToEEPROM( 96, cmDNS, 32);
|
|
|
|
writeStringToEEPROM(128, apSSID, 32);
|
|
|
|
writeStringToEEPROM(160, apPass, 64);
|
|
|
|
|
2018-11-21 23:28:20 +01:00
|
|
|
EEPROM.write(224, nightlightDelayMinsDefault);
|
2016-11-20 00:07:04 +01:00
|
|
|
EEPROM.write(225, nightlightFade);
|
2017-05-08 21:46:04 +02:00
|
|
|
EEPROM.write(226, notifyDirectDefault);
|
2018-03-14 13:16:28 +01:00
|
|
|
EEPROM.write(227, apChannel);
|
|
|
|
EEPROM.write(228, apHide);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(229, ledCount & 0xFF);
|
2016-11-20 01:47:15 +01:00
|
|
|
EEPROM.write(230, notifyButton);
|
2018-03-06 23:47:08 +01:00
|
|
|
EEPROM.write(231, notifyTwice);
|
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
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-07-21 23:21:07 +02:00
|
|
|
for (int i = 0; i<4; i++) //ip addresses
|
|
|
|
{
|
|
|
|
EEPROM.write(234+i, staticIP[i]);
|
|
|
|
EEPROM.write(238+i, staticGateway[i]);
|
|
|
|
EEPROM.write(242+i, staticSubnet[i]);
|
|
|
|
}
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
EEPROM.write(249, briS);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(250, receiveNotificationBrightness);
|
2016-11-19 19:39:17 +01:00
|
|
|
EEPROM.write(251, fadeTransition);
|
2019-05-22 00:23:09 +02:00
|
|
|
EEPROM.write(252, strip.reverseMode);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(253, transitionDelayDefault & 0xFF);
|
2018-04-11 23:50:35 +02:00
|
|
|
EEPROM.write(254, (transitionDelayDefault >> 8) & 0xFF);
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(255, briMultiplier);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2016-11-20 01:47:15 +01:00
|
|
|
//255,250,231,230,226 notifier bytes
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(256, otaPass, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
EEPROM.write(288, nightlightTargetBri);
|
2017-11-20 00:07:37 +01:00
|
|
|
EEPROM.write(289, otaLock);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(290, udpPort & 0xFF);
|
2016-12-11 20:11:14 +01:00
|
|
|
EEPROM.write(291, (udpPort >> 8) & 0xFF);
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(292, serverDescription, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2016-12-29 00:03:58 +01:00
|
|
|
EEPROM.write(327, ntpEnabled);
|
2018-03-06 23:47:08 +01:00
|
|
|
EEPROM.write(328, currentTimezone);
|
|
|
|
EEPROM.write(329, useAMPM);
|
2019-05-22 00:23:09 +02:00
|
|
|
EEPROM.write(330, strip.gammaCorrectBri);
|
|
|
|
EEPROM.write(331, strip.gammaCorrectCol);
|
2017-02-24 23:21:48 +01:00
|
|
|
EEPROM.write(332, overlayDefault);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2017-02-24 23:21:48 +01:00
|
|
|
EEPROM.write(333, alexaEnabled);
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(334, alexaInvocationName, 32);
|
2018-09-15 17:29:01 +02:00
|
|
|
EEPROM.write(366, notifyAlexa);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
EEPROM.write(367, (arlsOffset>=0));
|
2017-02-24 23:21:48 +01:00
|
|
|
EEPROM.write(368, abs(arlsOffset));
|
2017-03-07 22:05:18 +01:00
|
|
|
EEPROM.write(369, turnOnAtBoot);
|
2019-12-04 02:01:47 +01:00
|
|
|
|
2020-02-20 17:08:56 +01:00
|
|
|
EEPROM.write(370, noWifiSleep);
|
|
|
|
|
2017-10-12 22:20:37 +02:00
|
|
|
EEPROM.write(372, useRGBW);
|
2018-09-08 16:21:44 +02:00
|
|
|
EEPROM.write(374, strip.paletteFade);
|
2019-11-12 19:33:34 +01:00
|
|
|
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
|
2019-10-25 00:14:58 +02:00
|
|
|
EEPROM.write(376, apBehavior);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2017-11-28 00:21:29 +01:00
|
|
|
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-09-11 00:20:12 +02:00
|
|
|
EEPROM.write(382, strip.paletteBlend);
|
2018-11-28 12:24:32 +01:00
|
|
|
EEPROM.write(383, strip.colorOrder);
|
2018-11-21 23:28:20 +01:00
|
|
|
|
|
|
|
EEPROM.write(385, irEnabled);
|
2018-12-04 00:58:06 +01:00
|
|
|
|
|
|
|
EEPROM.write(387, strip.ablMilliampsMax & 0xFF);
|
|
|
|
EEPROM.write(388, (strip.ablMilliampsMax >> 8) & 0xFF);
|
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);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(394, abs(utcOffsetSecs) & 0xFF);
|
2018-03-06 23:47:08 +01:00
|
|
|
EEPROM.write(395, (abs(utcOffsetSecs) >> 8) & 0xFF);
|
|
|
|
EEPROM.write(396, (utcOffsetSecs<0)); //is negative
|
2019-12-13 01:23:07 +01:00
|
|
|
EEPROM.write(397, syncToggleReceive);
|
2018-04-15 15:27:54 +02:00
|
|
|
EEPROM.write(398, (ledCount >> 8) & 0xFF);
|
2020-02-24 19:36:25 +01:00
|
|
|
//EEPROM.write(399, was !enableSecTransition);
|
2018-02-23 01:33:32 +01:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
//favorite setting (preset) memory (25 slots/ each 20byte)
|
2019-12-04 02:01:47 +01:00
|
|
|
//400 - 940 reserved
|
|
|
|
writeStringToEEPROM(990, ntpServerName, 32);
|
2018-10-07 11:56:29 +02:00
|
|
|
|
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]);
|
|
|
|
}
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(2054, hueApiKey, 46);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(2100, huePollIntervalMs & 0xFF);
|
2018-02-28 00:27:10 +01:00
|
|
|
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-03-14 00:25:54 +01:00
|
|
|
|
|
|
|
EEPROM.write(2150, overlayMin);
|
|
|
|
EEPROM.write(2151, overlayMax);
|
|
|
|
EEPROM.write(2152, analogClock12pixel);
|
|
|
|
EEPROM.write(2153, analogClock5MinuteMarks);
|
|
|
|
EEPROM.write(2154, analogClockSecondsTrail);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 00:25:54 +01:00
|
|
|
EEPROM.write(2155, countdownMode);
|
|
|
|
EEPROM.write(2156, countdownYear);
|
|
|
|
EEPROM.write(2157, countdownMonth);
|
|
|
|
EEPROM.write(2158, countdownDay);
|
|
|
|
EEPROM.write(2159, countdownHour);
|
|
|
|
EEPROM.write(2160, countdownMin);
|
|
|
|
EEPROM.write(2161, countdownSec);
|
|
|
|
setCountdown();
|
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(2165, cronixieDisplay, 6);
|
2018-03-14 00:25:54 +01:00
|
|
|
EEPROM.write(2171, cronixieBacklight);
|
|
|
|
setCronixie();
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 00:25:54 +01:00
|
|
|
EEPROM.write(2175, macroBoot);
|
|
|
|
EEPROM.write(2176, macroAlexaOn);
|
|
|
|
EEPROM.write(2177, macroAlexaOff);
|
|
|
|
EEPROM.write(2178, macroButton);
|
|
|
|
EEPROM.write(2179, macroLongPress);
|
|
|
|
EEPROM.write(2180, macroCountdown);
|
|
|
|
EEPROM.write(2181, macroNl);
|
2019-03-13 11:13:03 +01:00
|
|
|
EEPROM.write(2182, macroDoublePress);
|
2018-05-10 19:55:58 +02:00
|
|
|
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(2190, e131Universe & 0xFF);
|
2018-08-11 22:57:13 +02:00
|
|
|
EEPROM.write(2191, (e131Universe >> 8) & 0xFF);
|
|
|
|
EEPROM.write(2192, e131Multicast);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(2193, realtimeTimeoutMs & 0xFF);
|
2018-09-15 17:29:01 +02:00
|
|
|
EEPROM.write(2194, (realtimeTimeoutMs >> 8) & 0xFF);
|
2018-08-11 22:57:13 +02:00
|
|
|
EEPROM.write(2195, arlsForceMaxBri);
|
|
|
|
EEPROM.write(2196, arlsDisableGammaCorrection);
|
2020-02-08 20:52:45 +01:00
|
|
|
EEPROM.write(2197, DMXAddress & 0xFF);
|
|
|
|
EEPROM.write(2198, (DMXAddress >> 8) & 0xFF);
|
|
|
|
EEPROM.write(2199, DMXMode);
|
2018-08-11 22:57:13 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
EEPROM.write(2200, !receiveDirect);
|
2019-02-19 12:57:50 +01:00
|
|
|
EEPROM.write(2201, notifyMacro); //was enableRealtime
|
2020-02-20 00:45:09 +01:00
|
|
|
EEPROM.write(2203, strip.rgbwMode);
|
2018-10-07 11:56:29 +02:00
|
|
|
EEPROM.write(2204, skipFirstLed);
|
2018-06-24 01:20:15 +02:00
|
|
|
|
|
|
|
if (saveCurrPresetCycConf)
|
|
|
|
{
|
2018-10-07 11:56:29 +02:00
|
|
|
EEPROM.write(2205, presetCyclingEnabled);
|
2018-12-04 00:58:06 +01:00
|
|
|
EEPROM.write(2206, presetCycleTime & 0xFF);
|
2018-10-07 11:56:29 +02:00
|
|
|
EEPROM.write(2207, (presetCycleTime >> 8) & 0xFF);
|
|
|
|
EEPROM.write(2208, presetCycleMin);
|
|
|
|
EEPROM.write(2209, presetCycleMax);
|
|
|
|
EEPROM.write(2210, presetApplyBri);
|
2020-02-29 18:42:55 +01:00
|
|
|
// was EEPROM.write(2211, presetApplyCol);
|
|
|
|
// was EEPROM.write(2212, presetApplyFx);
|
2018-06-24 01:20:15 +02:00
|
|
|
saveCurrPresetCycConf = false;
|
|
|
|
}
|
2018-07-16 11:50:09 +02:00
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(2220, blynkApiKey, 35);
|
2018-09-22 22:49:24 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
{
|
|
|
|
EEPROM.write(2260 + i, timerHours[i] );
|
|
|
|
EEPROM.write(2270 + i, timerMinutes[i]);
|
|
|
|
EEPROM.write(2280 + i, timerWeekday[i]);
|
|
|
|
EEPROM.write(2290 + i, timerMacro[i] );
|
|
|
|
}
|
2018-10-04 16:50:12 +02:00
|
|
|
|
2019-12-13 01:23:07 +01:00
|
|
|
EEPROM.write(2299, mqttEnabled);
|
2019-08-17 12:27:06 +02:00
|
|
|
writeStringToEEPROM(2300, mqttServer, 32);
|
2018-10-07 11:56:29 +02:00
|
|
|
writeStringToEEPROM(2333, mqttDeviceTopic, 32);
|
2019-08-17 12:27:06 +02:00
|
|
|
writeStringToEEPROM(2366, mqttGroupTopic, 32);
|
2019-08-18 03:34:47 +02:00
|
|
|
writeStringToEEPROM(2399, mqttUser, 40);
|
|
|
|
writeStringToEEPROM(2440, mqttPass, 40);
|
|
|
|
writeStringToEEPROM(2481, mqttClientID, 40);
|
2019-08-18 18:14:17 +02:00
|
|
|
EEPROM.write(2522, mqttPort & 0xFF);
|
|
|
|
EEPROM.write(2523, (mqttPort >> 8) & 0xFF);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2020-02-23 22:24:51 +01:00
|
|
|
// DMX (2530 - 2549)
|
2020-02-24 12:54:23 +01:00
|
|
|
#ifdef WLED_ENABLE_DMX
|
2020-02-23 22:24:51 +01:00
|
|
|
EEPROM.write(2530, DMXChannels);
|
|
|
|
EEPROM.write(2531, DMXGap & 0xFF);
|
|
|
|
EEPROM.write(2532, (DMXGap >> 8) & 0xFF);
|
|
|
|
EEPROM.write(2533, DMXStart & 0xFF);
|
|
|
|
EEPROM.write(2534, (DMXStart >> 8) & 0xFF);
|
|
|
|
|
2020-02-24 12:54:23 +01:00
|
|
|
for (int i=0; i<15; i++) {
|
2020-02-23 22:24:51 +01:00
|
|
|
EEPROM.write(2535+i, DMXFixtureMap[i]);
|
|
|
|
} // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
|
2020-02-24 12:54:23 +01:00
|
|
|
#endif
|
2020-02-23 22:24:51 +01:00
|
|
|
|
2019-11-30 11:17:37 +01:00
|
|
|
commit();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2018-08-11 22:57:13 +02:00
|
|
|
/*
|
|
|
|
* Read all configuration from flash
|
|
|
|
*/
|
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-11-21 23:28:20 +01:00
|
|
|
DEBUG_PRINT("Settings invalid, restoring defaults...");
|
2016-11-19 19:39:17 +01:00
|
|
|
saveSettingsToEEPROM();
|
2018-11-21 23:28:20 +01:00
|
|
|
DEBUG_PRINTLN("done");
|
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;
|
2016-11-20 01:47:15 +01:00
|
|
|
nightlightFade = 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;
|
2019-10-26 00:00:44 +02:00
|
|
|
ledCount = EEPROM.read(229) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > MAX_LEDS || ledCount == 0) ledCount = 30;
|
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);
|
2016-11-19 19:39:17 +01:00
|
|
|
buttonEnabled = EEPROM.read(232);
|
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;
|
2017-12-11 23:59:12 +01:00
|
|
|
if (!EEPROM.read(369) && first)
|
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);
|
2019-05-22 00:23:09 +02:00
|
|
|
strip.reverseMode = EEPROM.read(252);
|
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);
|
2017-10-12 22:20:37 +02:00
|
|
|
useRGBW = 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) {
|
|
|
|
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);
|
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();
|
|
|
|
|
2018-10-07 11:56:29 +02:00
|
|
|
readStringFromEEPROM(2165, cronixieDisplay, 6);
|
2018-03-14 00:25:54 +01:00
|
|
|
cronixieBacklight = EEPROM.read(2171);
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2018-03-14 00:25:54 +01:00
|
|
|
macroBoot = EEPROM.read(2175);
|
|
|
|
macroAlexaOn = EEPROM.read(2176);
|
|
|
|
macroAlexaOff = EEPROM.read(2177);
|
|
|
|
macroButton = EEPROM.read(2178);
|
|
|
|
macroLongPress = EEPROM.read(2179);
|
|
|
|
macroCountdown = EEPROM.read(2180);
|
|
|
|
macroNl = EEPROM.read(2181);
|
2019-03-13 11:13:03 +01:00
|
|
|
macroDoublePress = EEPROM.read(2182);
|
|
|
|
if (macroDoublePress > 16) macroDoublePress = 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);
|
2018-12-04 00:58:06 +01:00
|
|
|
timerMacro[i] = EEPROM.read(2290 + i);
|
2018-09-22 22:49:24 +02:00
|
|
|
if (timerWeekday[i] == 0) timerWeekday[i] = 255;
|
|
|
|
}
|
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)
|
|
|
|
{
|
2018-12-06 00:27:36 +01:00
|
|
|
strip.colorOrder = EEPROM.read(383);
|
|
|
|
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-02-08 20:52:45 +01: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
|
|
|
|
2020-02-20 00:45:09 +01:00
|
|
|
strip.rgbwMode = EEPROM.read(2203);
|
2018-06-24 01:20:15 +02:00
|
|
|
skipFirstLed = EEPROM.read(2204);
|
|
|
|
|
|
|
|
if (EEPROM.read(2210) || EEPROM.read(2211) || EEPROM.read(2212))
|
|
|
|
{
|
|
|
|
presetCyclingEnabled = EEPROM.read(2205);
|
2018-12-04 00:58:06 +01:00
|
|
|
presetCycleTime = EEPROM.read(2206) + ((EEPROM.read(2207) << 8) & 0xFF00);
|
2018-06-24 01:20:15 +02:00
|
|
|
presetCycleMin = EEPROM.read(2208);
|
|
|
|
presetCycleMax = EEPROM.read(2209);
|
|
|
|
presetApplyBri = EEPROM.read(2210);
|
2020-02-29 18:42:55 +01:00
|
|
|
//was presetApplyCol = EEPROM.read(2211);
|
|
|
|
//was presetApplyFx = EEPROM.read(2212);
|
2018-06-24 01:20:15 +02:00
|
|
|
}
|
2019-08-17 12:27:06 +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
|
|
|
|
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;
|
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);
|
|
|
|
} //last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
|
2020-02-24 12:54:23 +01:00
|
|
|
#endif
|
2020-02-23 22:24:51 +01:00
|
|
|
|
2018-02-28 00:27:10 +01:00
|
|
|
//user MOD memory
|
|
|
|
//2944 - 3071 reserved
|
2019-08-17 12:27:06 +02:00
|
|
|
|
2017-12-11 23:59:12 +01:00
|
|
|
overlayCurrent = overlayDefault;
|
2019-11-30 11:17:37 +01:00
|
|
|
|
|
|
|
savedToPresets();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2017-11-28 00:21:29 +01:00
|
|
|
//PRESET PROTOCOL 20 bytes
|
2019-12-02 12:41:35 +01:00
|
|
|
//0: preset purpose byte 0:invalid 1:valid preset 2:segment preset 2.0
|
2018-09-06 02:05:56 +02: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: fp 18-19:Zeros
|
2019-11-30 11:17:37 +01:00
|
|
|
//determines which presets already contain save data
|
|
|
|
void savedToPresets()
|
|
|
|
{
|
2019-12-02 12:41:35 +01:00
|
|
|
for (byte index = 1; index < 16; index++)
|
2019-11-30 11:17:37 +01:00
|
|
|
{
|
|
|
|
uint16_t i = 380 + index*20;
|
|
|
|
|
|
|
|
if (EEPROM.read(i) == 1) {
|
|
|
|
savedPresets |= 0x01 << (index-1);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
savedPresets &= ~(0x01 << (index-1));
|
|
|
|
}
|
|
|
|
}
|
2019-12-02 12:41:35 +01:00
|
|
|
if (EEPROM.read(700) == 2) {
|
|
|
|
savedPresets |= 0x01 << 15;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
savedPresets &= ~(0x01 << 15);
|
|
|
|
}
|
2019-11-30 11:17:37 +01:00
|
|
|
}
|
2017-11-28 00:21:29 +01:00
|
|
|
|
2020-02-29 18:42:55 +01:00
|
|
|
bool applyPreset(byte index, bool loadBri = true)
|
2017-11-28 00:21:29 +01:00
|
|
|
{
|
2018-11-18 00:31:45 +01:00
|
|
|
if (index == 255 || index == 0)
|
|
|
|
{
|
|
|
|
loadSettingsFromEEPROM(false);//load boot defaults
|
|
|
|
return true;
|
|
|
|
}
|
2019-12-02 12:41:35 +01:00
|
|
|
if (index > 16 || index < 1) return false;
|
2017-12-11 23:59:12 +01:00
|
|
|
uint16_t i = 380 + index*20;
|
2019-12-02 12:41:35 +01:00
|
|
|
if (index < 16) {
|
|
|
|
if (EEPROM.read(i) != 1) return false;
|
2019-12-03 14:15:12 +01:00
|
|
|
strip.applyToAllSelected = true;
|
2019-12-02 12:41:35 +01:00
|
|
|
if (loadBri) bri = EEPROM.read(i+1);
|
2020-02-29 18:42:55 +01:00
|
|
|
|
|
|
|
for (byte j=0; j<4; j++)
|
2019-12-02 12:41:35 +01:00
|
|
|
{
|
2020-02-29 18:42:55 +01:00
|
|
|
col[j] = EEPROM.read(i+j+2);
|
|
|
|
colSec[j] = EEPROM.read(i+j+6);
|
2019-12-02 12:41:35 +01:00
|
|
|
}
|
2020-02-29 18:42:55 +01:00
|
|
|
strip.setColor(2, EEPROM.read(i+12), EEPROM.read(i+13), EEPROM.read(i+14), EEPROM.read(i+15)); //tertiary color
|
|
|
|
|
|
|
|
effectCurrent = EEPROM.read(i+10);
|
|
|
|
effectSpeed = EEPROM.read(i+11);
|
|
|
|
effectIntensity = EEPROM.read(i+16);
|
|
|
|
effectPalette = EEPROM.read(i+17);
|
2019-12-02 12:41:35 +01:00
|
|
|
} else {
|
|
|
|
if (EEPROM.read(i) != 2) return false;
|
2019-12-03 14:15:12 +01:00
|
|
|
strip.applyToAllSelected = false;
|
2019-12-02 12:41:35 +01:00
|
|
|
if (loadBri) bri = EEPROM.read(i+1);
|
|
|
|
WS2812FX::Segment* seg = strip.getSegments();
|
|
|
|
memcpy(seg, EEPROM.getDataPtr() +i+2, 240);
|
2019-12-03 14:15:12 +01:00
|
|
|
setValuesFromMainSeg();
|
2017-11-28 00:21:29 +01:00
|
|
|
}
|
2019-12-01 01:42:52 +01:00
|
|
|
currentPreset = index;
|
|
|
|
isPreset = true;
|
2018-11-18 00:31:45 +01:00
|
|
|
return true;
|
2017-11-28 00:21:29 +01:00
|
|
|
}
|
|
|
|
|
2020-03-03 17:53:47 +01:00
|
|
|
void savePreset(byte index, bool persist = true)
|
2017-11-28 00:21:29 +01:00
|
|
|
{
|
2019-12-02 12:41:35 +01:00
|
|
|
if (index > 16) return;
|
2017-12-11 23:59:12 +01:00
|
|
|
if (index < 1) {saveSettingsToEEPROM();return;}
|
|
|
|
uint16_t i = 380 + index*20;//min400
|
2019-12-02 12:41:35 +01:00
|
|
|
|
|
|
|
if (index < 16) {
|
|
|
|
EEPROM.write(i, 1);
|
|
|
|
EEPROM.write(i+1, bri);
|
|
|
|
for (uint16_t j=0; j<4; j++)
|
|
|
|
{
|
|
|
|
EEPROM.write(i+j+2, col[j]);
|
|
|
|
EEPROM.write(i+j+6, colSec[j]);
|
|
|
|
}
|
|
|
|
EEPROM.write(i+10, effectCurrent);
|
|
|
|
EEPROM.write(i+11, effectSpeed);
|
2019-12-24 00:06:23 +01:00
|
|
|
|
|
|
|
uint32_t colTer = strip.getSegment(strip.getMainSegmentId()).colors[2];
|
|
|
|
EEPROM.write(i+12, (colTer >> 16) & 0xFF);
|
|
|
|
EEPROM.write(i+13, (colTer >> 8) & 0xFF);
|
|
|
|
EEPROM.write(i+14, (colTer >> 0) & 0xFF);
|
|
|
|
EEPROM.write(i+15, (colTer >> 24) & 0xFF);
|
2019-12-02 12:41:35 +01:00
|
|
|
|
|
|
|
EEPROM.write(i+16, effectIntensity);
|
|
|
|
EEPROM.write(i+17, effectPalette);
|
|
|
|
} else { //segment 16 can save segments
|
|
|
|
EEPROM.write(i, 2);
|
|
|
|
EEPROM.write(i+1, bri);
|
|
|
|
WS2812FX::Segment* seg = strip.getSegments();
|
|
|
|
memcpy(EEPROM.getDataPtr() +i+2, seg, 240);
|
2019-02-05 21:53:39 +01:00
|
|
|
}
|
2019-12-02 12:41:35 +01:00
|
|
|
|
2020-03-03 17:53:47 +01:00
|
|
|
if (persist) commit();
|
2019-12-03 14:15:12 +01:00
|
|
|
savedToPresets();
|
2019-12-01 01:42:52 +01:00
|
|
|
currentPreset = index;
|
|
|
|
isPreset = true;
|
2017-11-28 00:21:29 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2019-03-16 02:09:37 +01:00
|
|
|
void loadMacro(byte index, char* m)
|
2017-12-28 00:37:13 +01:00
|
|
|
{
|
2018-03-06 23:47:08 +01:00
|
|
|
index-=1;
|
2019-03-16 02:09:37 +01:00
|
|
|
if (index > 15) return;
|
2019-03-11 19:30:49 +01:00
|
|
|
readStringFromEEPROM(1024+64*index, m, 64);
|
2018-03-06 23:47:08 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
void applyMacro(byte index)
|
2018-03-06 23:47:08 +01:00
|
|
|
{
|
|
|
|
index-=1;
|
|
|
|
if (index > 15) return;
|
|
|
|
String mc="win&";
|
2019-03-16 02:09:37 +01:00
|
|
|
char m[65];
|
|
|
|
loadMacro(index+1, m);
|
|
|
|
mc += m;
|
2017-12-28 00:37:13 +01:00
|
|
|
mc += "&IN"; //internal, no XML response
|
2018-09-15 17:29:01 +02:00
|
|
|
if (!notifyMacro) mc += "&NN";
|
2017-12-28 00:37:13 +01:00
|
|
|
String forbidden = "&M="; //dont apply if called by the macro itself to prevent loop
|
|
|
|
/*
|
2019-08-17 12:27:06 +02:00
|
|
|
* NOTE: loop is still possible if you call a different macro from a macro, which then calls the first macro again.
|
2017-12-28 00:37:13 +01:00
|
|
|
* To prevent that, but also disable calling macros within macros, comment the next line out.
|
|
|
|
*/
|
|
|
|
forbidden = forbidden + index;
|
|
|
|
if (mc.indexOf(forbidden) >= 0) return;
|
2019-02-16 00:21:22 +01:00
|
|
|
handleSet(nullptr, mc);
|
2017-12-28 00:37:13 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 11:52:23 +01:00
|
|
|
|
2020-03-03 17:53:47 +01:00
|
|
|
void saveMacro(byte index, String mc, bool persist = true) //only commit on single save, not in settings
|
2017-12-28 00:37:13 +01:00
|
|
|
{
|
2018-03-06 23:47:08 +01:00
|
|
|
index-=1;
|
2017-12-28 00:37:13 +01:00
|
|
|
if (index > 15) return;
|
|
|
|
int s = 1024+index*64;
|
|
|
|
for (int i = s; i < s+64; i++)
|
|
|
|
{
|
|
|
|
EEPROM.write(i, mc.charAt(i-s));
|
|
|
|
}
|
2020-03-03 17:53:47 +01:00
|
|
|
if (persist) commit();
|
2017-12-28 00:37:13 +01:00
|
|
|
}
|