Skip to content

Commit 0b337d4

Browse files
committed
int |-> float fixed p3t readings
1 parent 6dbd277 commit 0b337d4

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

general/include/p3t1755.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef struct {
6565
ReadPtr read;
6666
} p3t1755_t;
6767

68-
static inline int16_t p3t1755_raw_to_celsius(uint16_t raw);
68+
static inline float p3t1755_raw_to_celsius(uint16_t raw);
6969

7070
void p3t1755_init(p3t1755_t *p3t, WritePtr write, ReadPtr read,
7171
uint16_t dev_addr);

general/src/p3t1755.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ int p3t1755_read_reg(p3t1755_t *p3t, uint16_t reg, uint8_t *data,
2525
return p3t->read(p3t->dev_addr, reg, data, length);
2626
}
2727

28-
inline int16_t p3t1755_raw_to_celsius(uint16_t raw) {
28+
inline float p3t1755_raw_to_celsius(uint16_t raw) {
2929
PRINTLN_INFO("raw temp: %d", raw);
3030
if (raw & 1 << 11) { // Check if sign bit is set |-> t<0
31-
return -(int16_t)(raw * p3t1755_TEMP_RESOLUTION);
31+
return -(raw * p3t1755_TEMP_RESOLUTION);
3232
} else
33-
return (int16_t)(raw * p3t1755_TEMP_RESOLUTION);
33+
return (raw * p3t1755_TEMP_RESOLUTION);
3434
}
3535

3636
int p3t1755_read_temperature(p3t1755_t *p3t, float *temp_c) {

0 commit comments

Comments
 (0)