From d25835ceae2cb10f362763cbe7202a95fbbedfc7 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 16 Dec 2023 22:50:05 +0100 Subject: [PATCH] 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" --- wled00/wled.cpp | 4 ++++ wled00/wled.h | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index c051fa39..9fc7cd88 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -606,6 +606,10 @@ pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), Pin if(dmxEnablePin > 0) pinManager.allocatePin(dmxEnablePin, true, PinOwner::DMX); #endif +#if 0 && defined(WLED_USE_PSRAM_JSON) + doc.garbageCollect(); // WLEDMM experimental - this seems to move the complete doc[] into PSRAM +#endif + // WLEDMM experimental: support for single neoPixel on Adafruit boards #if 0 //#ifdef PIN_NEOPIXEL diff --git a/wled00/wled.h b/wled00/wled.h index 4cb8f7e4..4a3ce5ad 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -191,6 +191,7 @@ struct PSRAM_Allocator { } }; using PSRAMDynamicJsonDocument = BasicJsonDocument; +//#define DynamicJsonDocument PSRAMDynamicJsonDocument // WLEDMM experiment #else #define PSRAMDynamicJsonDocument DynamicJsonDocument #endif @@ -784,7 +785,17 @@ WLED_GLOBAL int8_t spi_sclk _INIT(HW_PIN_CLOCKSPI); #endif // global ArduinoJson buffer +#if 0 && defined(WLED_USE_PSRAM_JSON) +// WLEDMM experimental : always use dynamic JSON + #warning experimental - trying to always use dynamic JSON + #ifndef WLED_DEFINE_GLOBAL_VARS + WLED_GLOBAL PSRAMDynamicJsonDocument doc; + #else + WLED_GLOBAL PSRAMDynamicJsonDocument doc(JSON_BUFFER_SIZE); + #endif +#else WLED_GLOBAL StaticJsonDocument doc; +#endif // WLEDMM end WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); // enable additional debug output