aboutsummaryrefslogtreecommitdiff
path: root/hsm-web/Client/src/INA226.vue
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-web/Client/src/INA226.vue')
-rw-r--r--hsm-web/Client/src/INA226.vue53
1 files changed, 53 insertions, 0 deletions
diff --git a/hsm-web/Client/src/INA226.vue b/hsm-web/Client/src/INA226.vue
new file mode 100644
index 0000000..dec961b
--- /dev/null
+++ b/hsm-web/Client/src/INA226.vue
@@ -0,0 +1,53 @@
+<template>
+ <h2>Battery Status</h2>
+ <table id='tina226'>
+ <tbody>
+ <tr>
+ <td>{{ fmt(reading.voltage, 'V') }}</td>
+ <td>{{ fmt(reading.current, 'A') }}</td>
+ <td>{{ fmt(reading.power, 'W') }}</td>
+ </tr>
+ </tbody>
+ </table>
+</template>
+
+<script>
+import axios from 'axios'
+import config from './config'
+
+export default {
+ data() {
+ return {
+ reading: {
+ voltage: 0,
+ current: 0,
+ power: 0
+ }
+ }
+ },
+ mounted() {
+ this.getReading()
+ },
+ methods: {
+ async getReading() {
+ const res = await axios.get(config.api + '/ina226')
+ this.reading = res.data
+
+ setTimeout(this.getReading, 1000)
+ },
+ fmt(val, sfx) {
+ return val.toFixed(2) + sfx
+ }
+ }
+}
+</script>
+
+<style>
+#tina226 td {
+ border: 1.5px solid #2aa198;
+ color: #2aa198;
+ font-family: monospace;
+ font-size: 14px;
+ padding: 5px;
+}
+</style>