diff --git a/ESP32/vehicle-monitor.cpp b/ESP32/vehicle-monitor.cpp index e80e8f9..ae8fc0a 100644 --- a/ESP32/vehicle-monitor.cpp +++ b/ESP32/vehicle-monitor.cpp @@ -22,8 +22,8 @@ const float wheelDiameterInches = 20; const int numImpulsesPerTurn = 2; const float wheelCircumferenceMeters = wheelDiameterInches * 0.0254f * 3.1415f / (float)numImpulsesPerTurn; -int16_t batteryVoltage = -1; // in mV -int16_t batteryCurrent = -1; // in mV +uint16_t batteryVoltage = 0; // in mV +uint16_t batteryCurrent = 0; // in mV WiFiMulti wifiMulti; wl_status_t wifi_STA_status = WL_NO_SHIELD; @@ -224,8 +224,8 @@ void loop() averageC = max(0.0f, averageC - 2.5f) / 0.0238f; // convert voltage to current, according to the sensor linear relation // TODO: mutex ? - batteryVoltage = (int16_t)(averageV * 1000.0f + 0.5f); - batteryCurrent = (int16_t)(averageC * 1000.0f + 0.5f); + batteryVoltage = (uint16_t)(averageV * 1000.0f + 0.5f); + batteryCurrent = (uint16_t)(averageC * 1000.0f + 0.5f); delay(10); } diff --git a/WebApp/package.json b/WebApp/package.json index 35891ff..2644ec4 100644 --- a/WebApp/package.json +++ b/WebApp/package.json @@ -14,7 +14,9 @@ }, "devDependencies": { "@types/mithril": "^2.0.9", + "css-loader": "^6.7.1", "html-webpack-plugin": "^5.5.0", + "style-loader": "^3.3.1", "ts-loader": "^9.2.8", "typescript": "^4.6.2", "webpack": "^5.70.0", diff --git a/WebApp/src/main-page.css b/WebApp/src/main-page.css new file mode 100644 index 0000000..535d5e5 --- /dev/null +++ b/WebApp/src/main-page.css @@ -0,0 +1,3 @@ +.main-page p { + font-size: 4rem; +} \ No newline at end of file diff --git a/WebApp/src/main-page.tsx b/WebApp/src/main-page.tsx index e0bb99d..d419f07 100644 --- a/WebApp/src/main-page.tsx +++ b/WebApp/src/main-page.tsx @@ -1,6 +1,8 @@ import m from 'mithril'; import { MonitorApi, Status } from './monitor-api'; +require("./main-page.css"); + export default class MainPage { api = new MonitorApi(false); status?: Status; @@ -22,7 +24,7 @@ export default class MainPage { view() { return this.status - ?
+ ?

Tension batterie : {this.status.batteryVoltage.toFixed(3)}V

Courant : {this.status.motorCurrent.toFixed(3)}A

Puissance : {(this.status.batteryVoltage * this.status.motorCurrent).toFixed(1)}W

diff --git a/WebApp/webpack.config.js b/WebApp/webpack.config.js index 996de34..290f280 100644 --- a/WebApp/webpack.config.js +++ b/WebApp/webpack.config.js @@ -10,6 +10,10 @@ module.exports = { use: 'ts-loader', exclude: /node_modules/, }, + { + test: /\.css$/i, + use: ["style-loader", "css-loader"], + }, ], }, resolve: {