Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wled00/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3443,8 +3443,8 @@ function reportUpgradeEvent(info, oldVersion) {
};

// Add optional fields if available
if (infoData.psramPresent !== undefined) upgradeData.psramPresent = infoData.psramPresent; // Whether device has PSRAM
if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB
if (infoData.psrSz !== undefined) upgradeData.psramSize = infoData.psrSz; // Total PSRAM size in MB; can be 0

// Note: partitionSizes not currently available in /json/info endpoint

// Make AJAX call to postUpgradeEvent API
Expand Down
14 changes: 5 additions & 9 deletions wled00/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,12 @@ void serializeInfo(JsonObject root)
#endif

root[F("freeheap")] = getFreeHeapSize();
#ifdef ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM)
// Report PSRAM information
bool hasPsram = psramFound();
root[F("psramPresent")] = hasPsram;
if (hasPsram) {
#if defined(BOARD_HAS_PSRAM)
root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility)
#endif
root[F("psramSize")] = ESP.getPsramSize() / (1024UL * 1024UL); // Total PSRAM size in MB
}
// Free PSRAM in bytes (backward compatibility)
root[F("psram")] = ESP.getFreePsram();
// Total PSRAM size in MB, round up to correct for allocator overhead
root[F("psrSz")] = (ESP.getPsramSize() + (1024U * 1024U - 1)) / (1024U * 1024U);
#endif
root[F("uptime")] = millis()/1000 + rolloverMillis*4294967;

Expand Down
10 changes: 7 additions & 3 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,13 @@ void WLED::setup()

#if defined(BOARD_HAS_PSRAM)
// if JSON buffer allocation fails requestJsonBufferLock() will always return false preventing crashes
pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE);
DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE));
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024);
if (psramFound() && ESP.getPsramSize()) {
pDoc = new PSRAMDynamicJsonDocument(2 * JSON_BUFFER_SIZE);
DEBUG_PRINTF_P(PSTR("JSON buffer size: %ubytes\n"), (2 * JSON_BUFFER_SIZE));
DEBUG_PRINTF_P(PSTR("PSRAM: %dkB/%dkB\n"), ESP.getFreePsram()/1024, ESP.getPsramSize()/1024);
} else {
pDoc = new DynamicJsonDocument(JSON_BUFFER_SIZE); // Use onboard RAM instead as a fallback
}
#endif

#if defined(ARDUINO_ARCH_ESP32)
Expand Down