mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 04:43:25 +00:00
mag3110: change method name/signature for obtaining temperature to be uniform with other similar drivers
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
committed by
Ayke van Laethem
parent
35a7590c2d
commit
b7fe897b8c
@@ -16,7 +16,11 @@ func main() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
x, y, z := mag.ReadMagnetic()
|
x, y, z := mag.ReadMagnetic()
|
||||||
println(x, y, z)
|
println("Magnetic readings:", x, y, z)
|
||||||
|
|
||||||
|
c, _ := mag.ReadTemperature()
|
||||||
|
println("Temperature:", float32(c)/1000, "ºC")
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 100)
|
time.Sleep(time.Millisecond * 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -48,9 +48,10 @@ func (d Device) ReadMagnetic() (x int16, y int16, z int16) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadTemperature reads the current die temperature in degrees Celsius.
|
// ReadTemperature reads and returns the current die temperature in
|
||||||
func (d Device) ReadTemperature() (temp int8) {
|
// celsius milli degrees (ºC/1000).
|
||||||
|
func (d Device) ReadTemperature() (int32, error) {
|
||||||
data := make([]byte, 1)
|
data := make([]byte, 1)
|
||||||
d.bus.ReadRegister(uint8(d.Address), DIE_TEMP, data)
|
d.bus.ReadRegister(uint8(d.Address), DIE_TEMP, data)
|
||||||
return int8(data[0])
|
return int32(data[0]) * 1000, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user