We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 310df7a commit e29e583Copy full SHA for e29e583
src/machine/machine_rp2_adc.go
@@ -100,7 +100,8 @@ func ReadTemperature() (millicelsius int32) {
100
rp.ADC.CS.SetBits(rp.ADC_CS_TS_EN)
101
102
// T = 27 - (ADC_voltage - 0.706)/0.001721
103
- return (27000<<16 - (int32(thermChan.getVoltage())-706<<16)*581) >> 16
+ // 1/0.001721 ≈ 581
104
+ return int32(((int64(27000) << 16) - ((int64(thermChan.getVoltage()) - (int64(706) << 16)) * 581)) >> 16)
105
}
106
107
// waitForReady spins waiting for the ADC peripheral to become ready.
0 commit comments