Fixed uptime rollover in UI

This commit is contained in:
Gunnar Skjold
2020-03-08 19:47:47 +01:00
parent 9b70802450
commit c07c2e66d6
5 changed files with 25 additions and 4 deletions

View File

@@ -37,6 +37,8 @@ void AmsWebServer::loop() {
void AmsWebServer::setData(AmsData& data) {
millis64(); // Make sure it catch all those rollovers
this->data.apply(data);
if(maxPwr == 0 && data.getListType() > 1 && config->hasConfig() && config->getMainFuse() > 0 && config->getDistributionSystem() > 0) {
@@ -351,11 +353,10 @@ void AmsWebServer::dataJson() {
json["po_pct"] = -1;
}
unsigned long now = millis();
json["id"] = WiFi.macAddress();
json["maxPower"] = maxPwr;
json["meterType"] = config->getMeterType();
json["currentMillis"] = now;
json["uptime_seconds"] = millis64() / 1000;
double vcc = hw.getVcc();
json["vcc"] = serialized(String(vcc, 3));
@@ -383,6 +384,7 @@ void AmsWebServer::dataJson() {
}
json["status"]["esp"] = espStatus;
unsigned long now = millis();
String hanStatus;
if(config->getMeterType() == 0) {
hanStatus = "secondary";

View File

@@ -8,6 +8,7 @@
#include "AmsConfiguration.h"
#include "HwTools.h"
#include "AmsData.h"
#include "Uptime.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
@@ -33,7 +34,7 @@ public:
void setData(AmsData& data);
private:
int maxPwr;
int maxPwr = 0;
HwTools hw;
AmsConfiguration* config;
AmsData data;