Added EEPROM support for 25 favorite presets, each 20 bytes
Added EEPROM version byte so routine can load defaults instead of EEPROM 0 value after software update
This commit is contained in:
parent
16d13abafc
commit
5e3a75a6c0
@ -20,7 +20,8 @@
|
|||||||
#include "CallbackFunction.h"
|
#include "CallbackFunction.h"
|
||||||
|
|
||||||
//version in format yymmddb (b = daily build)
|
//version in format yymmddb (b = daily build)
|
||||||
#define VERSION 1711201
|
#define VERSION 1711271
|
||||||
|
|
||||||
|
|
||||||
//If you have an RGBW strip, uncomment first line in WS2812FX.h!
|
//If you have an RGBW strip, uncomment first line in WS2812FX.h!
|
||||||
|
|
||||||
@ -47,6 +48,11 @@
|
|||||||
#define DEBUG_PRINTF(x)
|
#define DEBUG_PRINTF(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//eeprom Version code, enables default settings instead of 0 init on update
|
||||||
|
#define EEPVER 1
|
||||||
|
//0 -> old version, default
|
||||||
|
//1 -> 0.4p 1711271 and up
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @title WLED project sketch
|
* @title WLED project sketch
|
||||||
* @version 0.4p
|
* @version 0.4p
|
||||||
|
@ -18,6 +18,7 @@ void saveSettingsToEEPROM()
|
|||||||
clearEEPROM();
|
clearEEPROM();
|
||||||
EEPROM.write(233, 233);
|
EEPROM.write(233, 233);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
EEPROM.write(i, clientssid.charAt(i));
|
EEPROM.write(i, clientssid.charAt(i));
|
||||||
@ -107,6 +108,7 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(374, sweepDirection);
|
EEPROM.write(374, sweepDirection);
|
||||||
EEPROM.write(375, apWaitTimeSecs);
|
EEPROM.write(375, apWaitTimeSecs);
|
||||||
EEPROM.write(376, recoveryAPDisabled);
|
EEPROM.write(376, recoveryAPDisabled);
|
||||||
|
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +119,8 @@ void loadSettingsFromEEPROM()
|
|||||||
saveSettingsToEEPROM();
|
saveSettingsToEEPROM();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
||||||
|
|
||||||
clientssid = "";
|
clientssid = "";
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
@ -222,7 +226,37 @@ void loadSettingsFromEEPROM()
|
|||||||
useRGBW = EEPROM.read(372);
|
useRGBW = EEPROM.read(372);
|
||||||
sweepTransition = EEPROM.read(373);
|
sweepTransition = EEPROM.read(373);
|
||||||
sweepDirection = EEPROM.read(374);
|
sweepDirection = EEPROM.read(374);
|
||||||
apWaitTimeSecs = EEPROM.read(375);
|
if (lastEEPROMversion > 0) {
|
||||||
recoveryAPDisabled = EEPROM.read(376);
|
apWaitTimeSecs = EEPROM.read(375);
|
||||||
|
recoveryAPDisabled = EEPROM.read(376);
|
||||||
|
}
|
||||||
|
|
||||||
|
//favorite setting memory (25 slots/ each 20byte)
|
||||||
|
//400 - 899 reserved
|
||||||
|
|
||||||
useHSB = useHSBDefault;
|
useHSB = useHSBDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PRESET PROTOCOL 20 bytes
|
||||||
|
//0: multipurpose byte, bit 0: brightness is valid, 1: col valid, 2: ecol valid, 5: cc valid, 6: ccFromStart, 7: ccFromEnd
|
||||||
|
//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:pStart 15-20:undefinded
|
||||||
|
|
||||||
|
void loadPreset(uint8_t index, uint8_t data[])
|
||||||
|
{
|
||||||
|
if (index > 24) return;
|
||||||
|
uint8_t temp[20];
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
data[i] = EEPROM.read(400 + index*20 + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void savePreset(uint8_t index, uint8_t data[])
|
||||||
|
{
|
||||||
|
if (index > 24) return;
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
EEPROM.write(400 + index*20 + i, data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user