Removed duplicated ram info

modified:   data/www/dashboard.html
	modified:   src/esp_info.cpp
	modified:   src/esp_info.h
	modified:   src/web_server.cpp
This commit is contained in:
2025-04-13 12:00:19 +02:00
parent 872a3d7269
commit 1080d3025c
4 changed files with 14 additions and 22 deletions

View File

@@ -31,21 +31,13 @@
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json(); // Expect JSON response
return response.text(); // Changed from json() to text()
})
.then(data => {
console.log('Data received:', data);
if (!data) throw new Error('Empty response');
let html = '';
Object.entries(data).forEach(([key, value]) => {
html += `
<div class="card">
<h3>${key}</h3>
<p>${value}</p>
</div>`;
});
document.getElementById('dashboard').innerHTML = html;
document.getElementById('dashboard').innerHTML = data;
})
.catch(error => {
console.error('Error:', error);

View File

@@ -116,19 +116,19 @@ String getESPInfoHTML() {
String html = "<div class='esp-info'><h3>ESP32 Information</h3>";
html += getTemperatureInfo();
html += getCPUInfo();
html += getRAMInfo();
html += getPSRAMInfo();
html += getFlashInfo();
html += "</div>";
return html;
}
String getRAMInfoHTML() {
String html = "<div class='ram-info'><h3>RAM Information</h3>";
String getMemoryInfoHTML() {
String html = "<div class='memory-info'><h3>Memory Information</h3>";
html += "<h4>Internal RAM</h4>";
html += "<p>Heap Size: " + formatBytes(ESP.getHeapSize()) + "</p>";
html += "<p>Free Heap: " + formatBytes(ESP.getFreeHeap()) + "</p>";
html += "<p>Min Free Heap: " + formatBytes(ESP.getMinFreeHeap()) + "</p>";
html += "<p>Max Alloc Heap: " + formatBytes(ESP.getMaxAllocHeap()) + "</p>";
html += "<h4>PSRAM</h4>";
html += "<p>PSRAM Size: " + formatBytes(ESP.getPsramSize()) + "</p>";
html += "<p>Free PSRAM: " + formatBytes(ESP.getFreePsram()) + "</p>";
@@ -137,6 +137,7 @@ String getRAMInfoHTML() {
html += "</div>";
return html;
}
void printESPInfo() {
Serial.println("ESP32-S3 info");
Serial.println("Internal RAM");

View File

@@ -10,15 +10,14 @@ void prettyPrintBytes(size_t bytes);
String formatBytes(size_t bytes);
// Individual info getters
String getCPUInfo();
String getTemperatureInfo();
String getRAMInfo();
String getPSRAMInfo();
String getFlashInfo();
String getCPUInfo(); // CPU related info only
String getTemperatureInfo(); // Temperature info
String getMemoryInfo(); // RAM and PSRAM info
String getFlashInfo(); // Flash memory info
// HTML generators
String getESPInfoHTML();
String getRAMInfoHTML();
String getESPInfoHTML(); // Combines CPU, Temperature, and Flash info
String getMemoryInfoHTML(); // Memory specific info (replaces getRAMInfoHTML)
// Debug print
void printESPInfo();

View File

@@ -29,7 +29,7 @@ void setupWebServer() {
// ESP Info endpoint
server.on("/api/espinfo", HTTP_GET, [](AsyncWebServerRequest *request) {
String htmlContent = getESPInfoHTML() + getRAMInfoHTML();
String htmlContent = getESPInfoHTML() + getMemoryInfoHTML(); // Updated function name
AsyncWebServerResponse *response = request->beginResponse(200, "text/html", htmlContent);
request->send(response);
});