diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2026-01-02 11:37:35 +0000 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2026-01-02 11:57:54 +0000 |
| commit | f7f11acafe0a404fa218c13832e32fce574ae0f6 (patch) | |
| tree | f3a531050b4be2d708eb6aac53ce4474f798886b /hsm-web/Client/src | |
| parent | 43af089b3588b6fd29a1b09be9874054e0291c5e (diff) | |
Adds battery monitoring to frontend
Diffstat (limited to 'hsm-web/Client/src')
| -rw-r--r-- | hsm-web/Client/src/App.vue | 11 | ||||
| -rw-r--r-- | hsm-web/Client/src/INA226.vue | 48 | ||||
| -rw-r--r-- | hsm-web/Client/src/config.js | 3 |
3 files changed, 62 insertions, 0 deletions
diff --git a/hsm-web/Client/src/App.vue b/hsm-web/Client/src/App.vue index 202e4d2..84fefcf 100644 --- a/hsm-web/Client/src/App.vue +++ b/hsm-web/Client/src/App.vue @@ -1,3 +1,14 @@ <template> <h1>HsMouse</h1> + <INA226 /> </template> + +<script> +import INA226 from './INA226.vue' + +export default { + components: { + INA226 + } +} +</script> diff --git a/hsm-web/Client/src/INA226.vue b/hsm-web/Client/src/INA226.vue new file mode 100644 index 0000000..bf0141f --- /dev/null +++ b/hsm-web/Client/src/INA226.vue @@ -0,0 +1,48 @@ +<template> + <h3>Battery Status</h3> + <table> + <tbody> + <tr> + <td>{{ ina226Reading.voltage.toFixed(2) }}V</td> + <td>{{ ina226Reading.current.toFixed(2) }}A</td> + <td>{{ ina226Reading.power.toFixed(2) }}W</td> + </tr> + </tbody> + </table> +</template> + +<script> +import axios from 'axios' +import config from './config' + +export default { + data() { + return { + ina226Reading: { + voltage: 0, + current: 0, + power: 0 + } + } + }, + mounted() { + this.getINA226Reading() + }, + methods: { + getINA226Reading() { + axios + .get(`${config.api}/ina226`) + .then(res => { + this.ina226Reading = res.data + setTimeout(this.getINA226Reading, 1000) + }) + } + } +} +</script> + +<style> +table { + width: 100%; +} +</style> diff --git a/hsm-web/Client/src/config.js b/hsm-web/Client/src/config.js new file mode 100644 index 0000000..b8e9a98 --- /dev/null +++ b/hsm-web/Client/src/config.js @@ -0,0 +1,3 @@ +module.exports = { + api: 'http://192.168.8.170:3000' +} |
