Skip to content

Commit 58fe146

Browse files
authored
the experiment evolves
trying to find all the conditions when _doc[]_ should _not_ be touched ...
1 parent cde3298 commit 58fe146

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

wled00/wled.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,18 @@ void WLED::loop()
383383
#endif
384384
#endif
385385

386-
#if 0
387-
// MM experiment - JSON garbagecollect once per minute. Warning: may crash at random
386+
#if 0 && defined(ALL_JSON_TO_PSRAM) && defined(WLED_USE_PSRAM_JSON)
387+
// WLEDMM experiment - JSON garbagecollect once per minute. Warning: may crash at random
388388
static unsigned long last_gc_time = 0;
389-
if ((millis() - last_gc_time) > 60000) { // once in 60 seconds
390-
if (!suspendStripService && !doInitBusses && !loadLedmap && !presetsActionPending()) { // make sure no strip or segments are being updated atm
391-
if ((jsonBufferLock == 0) && (fileDoc == nullptr)) { // make sure JSON buffer is availeable
389+
// try once in 60 seconds
390+
if ((millis() - last_gc_time) > 60000) {
391+
// look for a perfect moment -> make sure no strip or segments or presets activity, no configs being updated, no realtime external control
392+
if (!suspendStripService && !doInitBusses && !doReboot && !doCloseFile && !realtimeMode && !loadLedmap && !presetsActionPending()) {
393+
// make sure JSON buffer is not in use
394+
if ( (doSerializeConfig == false) && (jsonBufferLock == 0) && (fileDoc == nullptr)) {
392395
USER_PRINTLN(F("JSON gabage collection (regular)."));
393396
doc.garbageCollect(); // WLEDMM experimental - trigger garbage collection on JSON doc memory pool.
397+
// this will make any pending reference to JSON objects _invalid_
394398
last_gc_time = millis();
395399
} } }
396400
#endif
@@ -1334,7 +1338,15 @@ void WLED::handleStatusLED()
13341338
if (ledStatusType) {
13351339
if (millis() - ledStatusLastMillis >= (1000/ledStatusType)) {
13361340
ledStatusLastMillis = millis();
1337-
ledStatusState = !ledStatusState;
1341+
#if 0
1342+
// WLEDMM un-comment this to stop the blinking
1343+
if ((ledStatusType != 2) && (ledStatusType != 4))
1344+
ledStatusState = !ledStatusState;
1345+
else
1346+
ledStatusState = HIGH;
1347+
#else
1348+
ledStatusState = !ledStatusState;
1349+
#endif
13381350
#if STATUSLED>=0
13391351
digitalWrite(STATUSLED, ledStatusState);
13401352
#else

0 commit comments

Comments
 (0)