Browse Source

fix some system information

pull/430/head
DanielR92 2 years ago
parent
commit
8d43db4a21
  1. 25
      src/web/html/api.js
  2. 11
      src/web/html/system.html

25
src/web/html/api.js

@ -32,20 +32,29 @@ function parseESP(obj) {
} }
function parseSysInfo(obj) { function parseSysInfo(obj) {
document.getElementById("sdkversion").innerHTML= "SDKv.: " + obj["sdk_version"]; const data = ["sdk_version", "cpu_freq", "chip_revision", "chip_model", "chip_cores", "esp_type"];
document.getElementById("cpufreq").innerHTML= "CPU MHz: " + obj["cpu_freq"] + "MHz";
document.getElementById("chiprevision").innerHTML= "Rev.: " + obj["chip_revision"];
document.getElementById("chipmodel").innerHTML= "Model: " + obj["chip_model"];
document.getElementById("chipcores").innerHTML= "Core: " + obj["chip_cores"];
document.getElementById("esp_type").innerHTML= "Type: " + obj["esp_type"];
document.getElementById("heap_used").innerHTML= "Used: " + obj["heap_used"]; var ul = document.getElementById("info");
document.getElementById("heap_total").innerHTML= "Total: " + obj["heap_total"];
if(!isNaN(obj["heap_total"])) {
document.getElementById("info").innerHTML = 'Heap:<progress id="heap" max="100" value="0"></progress> <span id="heap_used"></span> bytes (<span id="heap_total"></span> bytes)';
changeProgressbar("heap", obj["heap_used"], obj["heap_total"]);
}
for (const [key, value] of Object.entries(obj)) {
if(!data.includes(key) || (typeof value == 'undefined')) continue;
var li = document.createElement("li");
li.appendChild(document.createTextNode(key + ": " + value));
ul.appendChild(li);
}
} }
function changeProgressbar(id, value, max) { function changeProgressbar(id, value, max) {
document.getElementById(id).value = value; document.getElementById(id).value = value;
document.getElementById(id).max = max; document.getElementById(id).max = max;
document.getElementById("heap_used").textContent = value;
document.getElementById("heap_total").textContent = max;
} }
function setHide(id, hide) { function setHide(id, hide) {

11
src/web/html/system.html

@ -18,15 +18,7 @@
</div> </div>
<div id="wrapper"> <div id="wrapper">
<div id="content"> <div id="content">
<ul> <div id="info"></div>
<li>Heap:<progress id="heap" max="100" value="70"></progress> <span id="heap_used"></span>(<span id="heap_total"></span>)</li>
<li><span id="sdkversion"></span></li>
<li><span id="cpufreq"></span></li>
<li><span id="chiprevision"></span></li>
<li><span id="chipmodel"></span></li>
<li><span id="chipcores"></span></li>
<li><span id="esp_type"></span></li>
</ul>
<div id="system"></div> <div id="system"></div>
</div> </div>
</div> </div>
@ -50,7 +42,6 @@
function parseSys(obj) { function parseSys(obj) {
parseVersion(obj); parseVersion(obj);
parseESP(obj); parseESP(obj);
changeProgressbar("heap", obj["heap_used"], obj["heap_total"]);
} }
function parse(obj) { function parse(obj) {

Loading…
Cancel
Save