aboutsummaryrefslogtreecommitdiff
path: root/hsm-web/Client/src/INA226.vue
blob: bf0141f04a0e7e2ddc7f5809996727d13148ac61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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>