From 4341d368854342965869132ad9b80539c682bc1e Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 4 May 2023 17:09:43 +0200 Subject: [PATCH] move main JSON doc into PSRAM (experimental) this should move the main JSON doc into PSRAM on WROVER boards. * free heap should increase by ~60kb * PSRAM use should go up by the same amount. --- wled00/wled.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wled00/wled.h b/wled00/wled.h index 03492ab9..fc835252 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2305030 +#define VERSION 2305040 // May-the-4th be with you ;-) //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -733,8 +733,19 @@ WLED_GLOBAL int8_t spi_sclk _INIT(-1); WLED_GLOBAL int8_t spi_sclk _INIT(HW_PIN_CLOCKSPI); #endif +#if defined(BOARD_HAS_PSRAM) && (defined(WLED_USE_PSRAM_JSON) || defined(WLED_USE_PSRAM)) +// put the main JSON "doc" into PSRAM +#ifndef WLED_DEFINE_GLOBAL_VARS +extern PSRAMDynamicJsonDocument doc; +#else +PSRAMDynamicJsonDocument doc(JSON_BUFFER_SIZE); // call constructor - fingers crossed that PSRAM is already initialized at this point ... +#endif + +#else // standard: use global (.bss) RAM // global ArduinoJson buffer WLED_GLOBAL StaticJsonDocument doc; +#endif + WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); // enable additional debug output