Skip to content

Commit d25835c

Browse files
committed
experimental: trying to get the main JSON doc into PSRAM
Its not enough to declare "doc" as DynamicJsonPSRAMDocument - PSRAM is not yet initialized when "doc" is created. So we need a trick to get the main doc into PSRAM later, during WLED::setup(). Code is very experimental, may or may not work, and need more testing -> disabled with "#if 0"
1 parent c688909 commit d25835c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

wled00/wled.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), Pin
606606
if(dmxEnablePin > 0) pinManager.allocatePin(dmxEnablePin, true, PinOwner::DMX);
607607
#endif
608608

609+
#if 0 && defined(WLED_USE_PSRAM_JSON)
610+
doc.garbageCollect(); // WLEDMM experimental - this seems to move the complete doc[] into PSRAM
611+
#endif
612+
609613
// WLEDMM experimental: support for single neoPixel on Adafruit boards
610614
#if 0
611615
//#ifdef PIN_NEOPIXEL

wled00/wled.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ struct PSRAM_Allocator {
191191
}
192192
};
193193
using PSRAMDynamicJsonDocument = BasicJsonDocument<PSRAM_Allocator>;
194+
//#define DynamicJsonDocument PSRAMDynamicJsonDocument // WLEDMM experiment
194195
#else
195196
#define PSRAMDynamicJsonDocument DynamicJsonDocument
196197
#endif
@@ -784,7 +785,17 @@ WLED_GLOBAL int8_t spi_sclk _INIT(HW_PIN_CLOCKSPI);
784785
#endif
785786

786787
// global ArduinoJson buffer
788+
#if 0 && defined(WLED_USE_PSRAM_JSON)
789+
// WLEDMM experimental : always use dynamic JSON
790+
#warning experimental - trying to always use dynamic JSON
791+
#ifndef WLED_DEFINE_GLOBAL_VARS
792+
WLED_GLOBAL PSRAMDynamicJsonDocument doc;
793+
#else
794+
WLED_GLOBAL PSRAMDynamicJsonDocument doc(JSON_BUFFER_SIZE);
795+
#endif
796+
#else
787797
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;
798+
#endif // WLEDMM end
788799
WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
789800

790801
// enable additional debug output

0 commit comments

Comments
 (0)