Open GoogleCodeExporter opened 9 years ago
float ds2438::readTempC()
{
//override for now, plsfixkthx
_parasite = 1;
//request temp conversion
_wire->reset();
_wire->select(_deviceAddress);
_wire->write(CONVERTT, _parasite);
delay(20);
//copy data from eeprom to scratchpad & read scratchpad
ScratchPad _scratchPad;
_readMem(_scratchPad);
//return tempC (ignore 3 lsb as they are always 0);
uint8_t x = _scratchPad[TEMP_MSB];
int rawTemp = (x & 0x80)?(-256+x): x; // uint8_t => int
float f = rawTemp + (_scratchPad[TEMP_LSB] >> 3) * 0.03125;
return f;
}
Original comment by rob.till...@gmail.com
on 10 Nov 2010 at 8:16
simpler patch...
float ds2438::readTempC()
{
//override for now, plsfixkthx
_parasite = 1;
//request temp conversion
_wire->reset();
_wire->select(_deviceAddress);
_wire->write(CONVERTT, _parasite);
delay(20);
//copy data from eeprom to scratchpad & read scratchpad
ScratchPad _scratchPad;
_readMem(_scratchPad);
// return tempC (ignore 3 lsb as they are always 0);
// takes care of signbit when shifting
int16_t rawTemperature = (((int16_t) _scratchPad[TEMP_MSB]) << 8) | _scratchPad[TEMP_LSB]) >> 3;
return (float)rawTemp * 0.03125;
}
Original comment by rob.till...@gmail.com
on 10 Nov 2010 at 11:23
Thanks Rob, I don't have a spare 2438 to test with right now but I should have
one next week sometime. I'll test then commit.
Original comment by gfbar...@gmail.com
on 12 Nov 2010 at 3:29
Issue 1 has been merged into this issue.
Original comment by gfbar...@gmail.com
on 12 Nov 2010 at 8:00
"simpler patch" works with this fix:
int16_t rawTemp = ((((int16_t) _scratchPad[TEMP_MSB]) << 8) | _scratchPad[TEMP_LSB]) >> 3;
Original comment by mart.mai...@gmail.com
on 24 Nov 2013 at 10:56
Original issue reported on code.google.com by
rob.till...@gmail.com
on 10 Nov 2010 at 8:11