TMP1075 two's complement bugfix #681
@ -18,6 +18,13 @@ will consitute of a breaking change warranting a new major release:
|
|||||||
|
|
||||||
# [v4.0.0] to be released
|
# [v4.0.0] to be released
|
||||||
|
|
||||||
|
# [v3.1.1] 2023-06-14
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- TMP1075 bugfix where negative temperatures could not be measured because of a two's-complement
|
||||||
|
conversion bug.
|
||||||
|
|
||||||
# [v3.1.0] 2023-06-14
|
# [v3.1.0] 2023-06-14
|
||||||
|
|
||||||
- `eive-tmtc` version v4.1.0
|
- `eive-tmtc` version v4.1.0
|
||||||
|
@ -86,8 +86,11 @@ ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainin
|
|||||||
ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case TMP1075::GET_TEMP: {
|
case TMP1075::GET_TEMP: {
|
||||||
int16_t tempValueRaw = 0;
|
// Convert 12 bit MSB first raw temperature to 16 bit first.
|
||||||
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
|
int16_t tempValueRaw = static_cast<uint16_t>((packet[0] << 8) | packet[1]) >> 4;
|
||||||
|
// Sign extension to 16 bits: If the sign bit is set, fill up with ones on the left.
|
||||||
|
tempValueRaw = (packet[0] & 0x80) ? (tempValueRaw | 0xF000) : tempValueRaw;
|
||||||
|
// 0.0625 is the sensor sensitivity.
|
||||||
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
|
float tempValue = ((static_cast<float>(tempValueRaw)) * 0.0625);
|
||||||
#if OBSW_DEBUG_TMP1075 == 1
|
#if OBSW_DEBUG_TMP1075 == 1
|
||||||
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
|
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
|
||||||
|
Loading…
Reference in New Issue
Block a user