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

View File

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

View File

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

View File

@@ -29,7 +29,7 @@ void setupWebServer() {
// ESP Info endpoint // ESP Info endpoint
server.on("/api/espinfo", HTTP_GET, [](AsyncWebServerRequest *request) { 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); AsyncWebServerResponse *response = request->beginResponse(200, "text/html", htmlContent);
request->send(response); request->send(response);
}); });