Skip to content

Commit aa970d6

Browse files
committed
Extend JSON API info object
- add "clock" - CPU clock in MHz - add "flash" - flash size in MB Fix for wled#3879
1 parent a106342 commit aa970d6

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

wled00/data/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,6 @@ function parseInfo(i) {
694694
function populateInfo(i)
695695
{
696696
var cn="";
697-
var heap = i.freeheap/1024;
698-
heap = heap.toFixed(1);
699697
var pwr = i.leds.pwr;
700698
var pwru = "Not calculated";
701699
if (pwr > 1000) {pwr /= 1000; pwr = pwr.toFixed((pwr > 10) ? 0 : 1); pwru = pwr + " A";}
@@ -720,11 +718,13 @@ ${inforow("Build",i.vid)}
720718
${inforow("Signal strength",i.wifi.signal +"% ("+ i.wifi.rssi, " dBm)")}
721719
${inforow("Uptime",getRuntimeStr(i.uptime))}
722720
${inforow("Time",i.time)}
723-
${inforow("Free heap",heap," kB")}
721+
${inforow("Free heap",(i.freeheap/1024).toFixed(1)," kB")}
724722
${i.psram?inforow("Free PSRAM",(i.psram/1024).toFixed(1)," kB"):""}
725723
${inforow("Estimated current",pwru)}
726724
${inforow("Average FPS",i.leds.fps)}
727725
${inforow("MAC address",i.mac)}
726+
${inforow("CPU clock",i.clock," MHz")}
727+
${inforow("Flash size",i.flash," MB")}
728728
${inforow("Filesystem",i.fs.u + "/" + i.fs.t + " kB (" +Math.round(i.fs.u*100/i.fs.t) + "%)")}
729729
${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")}
730730
</table>`;

wled00/json.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ void serializeInfo(JsonObject root)
749749
root[F("arch")] = ESP.getChipModel();
750750
#endif
751751
root[F("core")] = ESP.getSdkVersion();
752+
root[F("clock")] = ESP.getCpuFreqMHz();
753+
root[F("flash")] = (ESP.getFlashChipSize()/1024)/1024;
752754
#ifdef WLED_DEBUG
753755
root[F("maxalloc")] = ESP.getMaxAllocHeap();
754756
root[F("resetReason0")] = (int)rtc_get_reset_reason(0);
@@ -758,6 +760,8 @@ void serializeInfo(JsonObject root)
758760
#else
759761
root[F("arch")] = "esp8266";
760762
root[F("core")] = ESP.getCoreVersion();
763+
root[F("clock")] = ESP.getCpuFreqMHz();
764+
root[F("flash")] = (ESP.getFlashChipSize()/1024)/1024;
761765
#ifdef WLED_DEBUG
762766
root[F("maxalloc")] = ESP.getMaxFreeBlockSize();
763767
root[F("resetReason")] = (int)ESP.getResetInfoPtr()->reason;

wled00/wled.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,9 @@ void WLED::setup()
362362
DEBUG_PRINT(F(", speed ")); DEBUG_PRINT(ESP.getFlashChipSpeed()/1000000);DEBUG_PRINTLN(F("MHz."));
363363

364364
#else
365-
DEBUG_PRINT(F("esp8266 "));
365+
DEBUG_PRINT(F("esp8266 @ ")); DEBUG_PRINT(ESP.getCpuFreqMHz()); DEBUG_PRINT(F("MHz.\nCore: "));
366366
DEBUG_PRINTLN(ESP.getCoreVersion());
367+
DEBUG_PRINT(F("FLASH: ")); DEBUG_PRINT((ESP.getFlashChipSize()/1024)/1024); DEBUG_PRINTLN(F(" MB"));
367368
#endif
368369
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
369370

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2403280
11+
#define VERSION 2404050
1212

1313
//uncomment this if you have a "my_config.h" file you'd like to use
1414
//#define WLED_USE_MY_CONFIG

0 commit comments

Comments
 (0)