WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2ff4ee0

Browse files
authored
Merge pull request #5168 from wled/copilot/update-info-endpoint-p-sram
Add psramPresent and psramSize fields to /info endpoint and usage reports
2 parents cc5b504 + 1fee9d4 commit 2ff4ee0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

wled00/data/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,8 @@ function reportUpgradeEvent(info, oldVersion) {
34433443
};
34443444

34453445
// Add optional fields if available
3446-
if (infoData.psram !== undefined) upgradeData.psramSize = Math.round(infoData.psram / (1024 * 1024)); // convert bytes to MB
3446+
if (infoData.psramPresent !== undefined) upgradeData.psramPresent = infoData.psramPresent; // Whether device has PSRAM
3447+
if (infoData.psramSize !== undefined) upgradeData.psramSize = infoData.psramSize; // Total PSRAM size in MB
34473448
// Note: partitionSizes not currently available in /json/info endpoint
34483449

34493450
// Make AJAX call to postUpgradeEvent API

wled00/json.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,16 @@ void serializeInfo(JsonObject root)
839839
#endif
840840

841841
root[F("freeheap")] = getFreeHeapSize();
842-
#if defined(BOARD_HAS_PSRAM)
843-
root[F("psram")] = ESP.getFreePsram();
842+
#ifdef ARDUINO_ARCH_ESP32
843+
// Report PSRAM information
844+
bool hasPsram = psramFound();
845+
root[F("psramPresent")] = hasPsram;
846+
if (hasPsram) {
847+
#if defined(BOARD_HAS_PSRAM)
848+
root[F("psram")] = ESP.getFreePsram(); // Free PSRAM in bytes (backward compatibility)
849+
#endif
850+
root[F("psramSize")] = ESP.getPsramSize() / (1024UL * 1024UL); // Total PSRAM size in MB
851+
}
844852
#endif
845853
root[F("uptime")] = millis()/1000 + rolloverMillis*4294967;
846854

0 commit comments

Comments
 (0)