mirror of
https://github.com/supleed2/ELEC50003-P1-CW.git
synced 2024-11-10 01:35:50 +00:00
Add data flow for battery stats when Energy is not integrated
This commit is contained in:
parent
34114e1b55
commit
f0c4567102
|
@ -15,6 +15,7 @@
|
||||||
#include "instruction.h"
|
#include "instruction.h"
|
||||||
#include "colour.h"
|
#include "colour.h"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include "time.h"
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Enable extra debugging info for ESP32
|
#pragma region Enable extra debugging info for ESP32
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
#define TX3pin 4 // Pin 11 on expansion board, UART3
|
#define TX3pin 4 // Pin 11 on expansion board, UART3
|
||||||
#define RX4pin 15 // Pin 12 on expansion board, UART4
|
#define RX4pin 15 // Pin 12 on expansion board, UART4
|
||||||
#define TX4pin 2 // Pin 13 on expansion board, UART4
|
#define TX4pin 2 // Pin 13 on expansion board, UART4
|
||||||
|
#define ntpServer "pool.ntp.org"
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Function Declarations
|
#pragma region Function Declarations
|
||||||
|
@ -74,6 +76,7 @@ int bb_centre_x, bb_centre_y;
|
||||||
float chargeGoal;
|
float chargeGoal;
|
||||||
int waitGoal;
|
int waitGoal;
|
||||||
String colour;
|
String colour;
|
||||||
|
time_t now;
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
@ -124,6 +127,8 @@ void setup()
|
||||||
}
|
}
|
||||||
Serial.println("mDNS set up, access Control Panel at 'rover2.local/'");
|
Serial.println("mDNS set up, access Control Panel at 'rover2.local/'");
|
||||||
|
|
||||||
|
configTime(0, 0, ntpServer);
|
||||||
|
|
||||||
webserver.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
webserver.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||||
{ request->send(SPIFFS, "/index.html", "text/html"); }); // Serve "index.html" at root page
|
{ request->send(SPIFFS, "/index.html", "text/html"); }); // Serve "index.html" at root page
|
||||||
webserver.on("/command.js", HTTP_GET, [](AsyncWebServerRequest *request)
|
webserver.on("/command.js", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||||
|
@ -403,8 +408,9 @@ void sendToCommand()
|
||||||
DynamicJsonDocument tdoc(1024);
|
DynamicJsonDocument tdoc(1024);
|
||||||
tdoc["st"] = Status;
|
tdoc["st"] = Status;
|
||||||
tdoc["bV"] = batteryVoltage;
|
tdoc["bV"] = batteryVoltage;
|
||||||
tdoc["bL"] = batteryLevel;
|
tdoc["bL"] = 100; // tdoc["bL"] = batteryLevel; Hardcoded value as Energy is not present on demo Rover
|
||||||
tdoc["bC"] = batteryCycles;
|
time(&now);
|
||||||
|
tdoc["bC"] = (now - 1623750000)/21600; // tdoc["bC"] = batteryCycles; Estimates cycles in number of 6 hour periods
|
||||||
tdoc["tD"] = odometer;
|
tdoc["tD"] = odometer;
|
||||||
tdoc["cH"] = heading;
|
tdoc["cH"] = heading;
|
||||||
tdoc["pos"][0] = xpos;
|
tdoc["pos"][0] = xpos;
|
||||||
|
@ -436,6 +442,7 @@ void recvFromDrive() // Update telemetry data and state info from Drive packet
|
||||||
odometer = rdoc["mm"];
|
odometer = rdoc["mm"];
|
||||||
xpos = rdoc["pos"][0];
|
xpos = rdoc["pos"][0];
|
||||||
ypos = rdoc["pos"][1];
|
ypos = rdoc["pos"][1];
|
||||||
|
batteryVoltage = rdoc["bV"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue