Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
DedeHai committed Apr 30, 2024
2 parents a6bf5b6 + 9f99a18 commit 5472f76
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wled00/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,15 @@ void updateFSInfo() {
// original idea by @akaricchi (https://github.com/Akaricchi)
// returns a pointer to the PSRAM buffer, updates size parameter
static const uint8_t *getPresetCache(size_t &size) {
static unsigned long presetsCachedTime;
static uint8_t *presetsCached;
static size_t presetsCachedSize;
static unsigned long presetsCachedTime = 0;
static uint8_t *presetsCached = nullptr;
static size_t presetsCachedSize = 0;
static byte presetsCachedValidate = 0;

if (presetsModifiedTime != presetsCachedTime) {
//if (presetsModifiedTime != presetsCachedTime) DEBUG_PRINTLN(F("getPresetCache(): presetsModifiedTime changed."));
//if (presetsCachedValidate != cacheInvalidate) DEBUG_PRINTLN(F("getPresetCache(): cacheInvalidate changed."));

if ((presetsModifiedTime != presetsCachedTime) || (presetsCachedValidate != cacheInvalidate)) {
if (presetsCached) {
free(presetsCached);
presetsCached = nullptr;
Expand All @@ -396,6 +400,7 @@ static const uint8_t *getPresetCache(size_t &size) {
File file = WLED_FS.open(FPSTR(getPresetsFileName()), "r");
if (file) {
presetsCachedTime = presetsModifiedTime;
presetsCachedValidate = cacheInvalidate;
presetsCachedSize = 0;
presetsCached = (uint8_t*)ps_malloc(file.size() + 1);
if (presetsCached) {
Expand Down

0 comments on commit 5472f76

Please sign in to comment.