Merge pull request 'TMP1075 two's complement bugfix' (#681) from tmp-sign-bugfix into main
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
Reviewed-on: #681 Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
This commit is contained in:
commit
05738d1e25
@ -18,6 +18,13 @@ will consitute of a breaking change warranting a new major release:
|
||||
|
||||
# [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
|
||||
|
||||
- `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) {
|
||||
switch (id) {
|
||||
case TMP1075::GET_TEMP: {
|
||||
int16_t tempValueRaw = 0;
|
||||
tempValueRaw = packet[0] << 4 | packet[1] >> 4;
|
||||
// Convert 12 bit MSB first raw temperature to 16 bit first.
|
||||
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);
|
||||
#if OBSW_DEBUG_TMP1075 == 1
|
||||
sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId()
|
||||
|
Loading…
Reference in New Issue
Block a user