Avoid unnecessary pointer indirection

pull/54/head
Eldon Stegall 4 years ago
parent 3c236a7d6e
commit ec1825f3f7

@ -5,7 +5,6 @@
package ina219
import (
"unsafe"
"encoding/binary"
"errors"
"fmt"
@ -111,7 +110,7 @@ func (d *Dev) Sense() (PowerMonitor, error) {
return PowerMonitor{}, errReadShunt
}
// Least significant bit is 10µV.
pm.Shunt = physic.ElectricPotential(*((*int16)(unsafe.Pointer(&shunt)))) * 10 * physic.MicroVolt
pm.Shunt = physic.ElectricPotential(int16(shunt)) * 10 * physic.MicroVolt
bus, err := d.m.ReadUint16(busVoltageRegister)
if err != nil {
@ -129,7 +128,7 @@ func (d *Dev) Sense() (PowerMonitor, error) {
if err != nil {
return PowerMonitor{}, errReadCurrent
}
pm.Current = physic.ElectricCurrent(*((*int16)(unsafe.Pointer(&current)))) * d.currentLSB
pm.Current = physic.ElectricCurrent(int16(current)) * d.currentLSB
power, err := d.m.ReadUint16(powerRegister)
if err != nil {

Loading…
Cancel
Save