chart data draw root page WORKING wip

This commit is contained in:
DeltaLima 2025-04-09 02:52:46 +02:00
parent 4a7e08a58e
commit d3d5809763
3 changed files with 24 additions and 6 deletions

View file

@ -811,7 +811,7 @@ void LFS_Chart_Rotate_Data(const byte chartId) {
/* timestamp of the oldest file allowed. Anything older gets deleted. convert to unsigned long */
unsigned long timestampOldest = strtoul(Char_Timestamp_yyyymmdd(now() - (3 * Timescale(TIMESCALE_MINUTE))), NULL, 0);
unsigned long timestampOldest = strtoul(Char_Timestamp_yyyymmdd(now() - (5 * Timescale(TIMESCALE_MINUTE))), NULL, 0);
char chartDirPath[10];
snprintf(chartDirPath, sizeof(chartDirPath), "%s%d", CHART_BASE_PATH, chartId);

View file

@ -61,6 +61,6 @@ void TimeR_Init() {
timer.setInterval(1000, Timer_Output);
timer.setInterval(1000, Timer_Sensor);
timer.setInterval(100, Timer_Control);
timer.setInterval(30000, Timer_3s);
timer.setInterval(5000, Timer_3s);
}

View file

@ -152,6 +152,9 @@ String Proc_WebPage_root(const String& var) {
} else if(var == "CHART") {
String html;
/* FOR TESTING ONLY - INCLUDE EXTERNAL CSSCHARTS*/
html += F("<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css'><style>#chart0 { width: 100%%; max-width: 300px; margin: 0 auto;}</style>");
html += F("<div id='chart0'><table class='charts-css line'>");
if(config.grow.dashboard.chartConfigured[0] == true) {
char chartDirPath[10];
snprintf(chartDirPath, sizeof(chartDirPath), "%s%d", CHART_BASE_PATH, 0);
@ -159,6 +162,7 @@ String Proc_WebPage_root(const String& var) {
/* https://github.com/cotestatnt/async-esp-fs-webserver/blob/master/src/AsyncFsWebServer.cpp */
File root = LittleFS.open(chartDirPath, "r");
File file = root.openNextFile();
float previousData = 0;
while (file) {
if (!file.isDirectory()) {
//#ifdef DEBUG
@ -171,10 +175,24 @@ String Proc_WebPage_root(const String& var) {
Serial.println(chartFilePath);
/* the actual file we are reading */
File fileRead = LittleFS.open(chartFilePath, "r");
while(fileRead.available()) {
html += fileRead.readStringUntil(';');
html += "-lol-";
html += fileRead.readStringUntil('\n').toFloat();
/* skip timestamp */
fileRead.readStringUntil(';');
//html += "-lol-";
html += F("<tr>");
//html += F("<td>");
//html += fileRead.readStringUntil(';');
html += F("<td style='--start: calc( ");
html += previousData;
html += F(" / 100); --end: calc( ");
/* previous data gets the new data */
previousData = fileRead.readStringUntil('\n').toFloat();
html += previousData;
html += F(" / 100);'>");
//html += fileRead.readStringUntil('\n').toFloat();
html += F("</td></tr>");
}
fileRead.close();
@ -182,7 +200,7 @@ String Proc_WebPage_root(const String& var) {
file = root.openNextFile();
}
}
html += F("</table></div>");
return html;
} else {
return String();