esprfid / esp-rfid

ESP8266 RFID (RC522, PN532, Wiegand, RDM6300) Access Control system featuring WebSocket, JSON, NTP Client, Javascript, SPIFFS
MIT License
1.35k stars 423 forks source link

Improve rendering of uptime in web UI #607

Closed stupsi099 closed 1 week ago

stupsi099 commented 10 months ago

if you look in status field you can see only a rising number (no date/time) not shure if its a bug or a feature.

grafik

br rupert

matjack1 commented 10 months ago

Hey @stupsi099 the uptime is in seconds now. I agree that it would be nicer if it was parsed and shown in days/hours/seconds.

If anyone wants to try improving that let me know, I can help giving you directions on how to implement this.

pvtex commented 3 months ago

this is no problem just change the file wsRepsonse.esp in the function

void ICACHE_FLASH_ATTR sendStatus(AsyncWebSocketClient *client)

change this line:

root["uptime"] = uptimeSeconds;

tp:

int h = uptimeSeconds / 3600;
int rem = uptimeSeconds % 3600;
int m = rem / 60;
int s = rem % 60;
char uptimebuffer[9];
sprintf(uptimebuffer, "%02d:%02d:%02d", h, m, s);
root["uptime"] = uptimebuffer;
omersiar commented 3 months ago

Rather than making the transformation on limited esp hardware, it would be better to handle it on Client side (browser).

matjack1 commented 1 week ago

True, but I think that's also fine as pvtex did. It's now on dev, closing this!