mirror of https://github.com/kidoman/embd
better negative rounding
This commit is contained in:
parent
c68eca29cc
commit
0c25e20721
|
@ -322,11 +322,7 @@ func convertWordToTempC(temp uint16) float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *MCP9808) setTemp(reg byte, newTemp float64) error {
|
func (d *MCP9808) setTemp(reg byte, newTemp float64) error {
|
||||||
rounder := 2.0
|
return d.Bus.WriteWordToReg(address, reg, uint16(newTemp*16+2)&0x1ffc)
|
||||||
if newTemp < 0 {
|
|
||||||
rounder = 0.0
|
|
||||||
}
|
|
||||||
return d.Bus.WriteWordToReg(address, reg, uint16(newTemp*16+rounder)&0x1ffc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AmbientTemp reads the current sensor value along with the flags denoting what boundaries the
|
// AmbientTemp reads the current sensor value along with the flags denoting what boundaries the
|
||||||
|
|
Loading…
Reference in New Issue