Skip to content

Commit

Permalink
duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
warrenguy committed Sep 25, 2024
1 parent 9d53b69 commit b871dec
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions ina219/ina219.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ func (d *Device) Trigger() (err error) {
}

// Measurements reads the bus voltage, shunt voltage, current, and power
// from the device. Use this function with triggered modes and after
// calling Trigger. In continuous mode, use the individual functions
// instead to read the latest values.
// from the device.
func (d *Device) Measurements() (
busVoltage int32,
shuntVoltage int16,
Expand All @@ -86,7 +84,7 @@ func (d *Device) Measurements() (
}

// Read the rest of the values, reading Power last, which resets
// the conversion ready bit.
// the conversion ready bit (relevant for triggered modes).
if shuntVoltage, err = d.ShuntVoltage(); err != nil {
return
}
Expand All @@ -105,9 +103,9 @@ func (d *Device) Measurements() (
// BusVoltage reads the "bus" voltage in millivolts.
//
// It returns an error if the value is invalid due to overflow
// or if the conversion is not ready yet. If you're using a
// continuous mode, use Voltage instead. See above notes on
// Trigger.
// or if the conversion is not ready yet. In a continuous mode
// there should always be a measurement available after the
// device is ready. See above notes on Trigger.
func (d *Device) BusVoltage() (voltage int32, err error) {
val, err := d.ReadRegister(RegBusVoltage)
if err != nil {
Expand All @@ -130,17 +128,6 @@ func (d *Device) BusVoltage() (voltage int32, err error) {
return
}

// Voltage reads the "bus" voltage in millivolts.
func (d *Device) Voltage() (voltage int32, err error) {
val, err := d.ReadRegister(RegBusVoltage)
if err != nil {
return
}

voltage = int32(val>>3) * 4
return
}

// ShuntVoltage reads the "shunt" voltage in 100ths of a volt.
func (d *Device) ShuntVoltage() (voltage int16, err error) {
return d.ReadRegister(RegShuntVoltage)
Expand Down

0 comments on commit b871dec

Please sign in to comment.