Skip to content

Commit

Permalink
Change temp type to int16
Browse files Browse the repository at this point in the history
  • Loading branch information
protocentralashwin committed Nov 5, 2024
1 parent ed57ff8 commit 24d53d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/ble_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void ble_temp_notify(int16_t temp_val)

uint16_t temp_val_uint16 = temp_val;

temp_val_uint16 = temp_val_uint16 / 10;
temp_val_uint16 = temp_val_uint16;

temp_att_ble[0] = temp_val_uint16 & 0xFF;
temp_att_ble[1] = (temp_val_uint16 >> 8) & 0xFF;
Expand Down
2 changes: 1 addition & 1 deletion app/src/display/display_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void hpi_disp_update_temp(int32_t temp)
}

char buf[32];
double temp_d = (double)(temp / 1000.00);
double temp_d = (double)(temp / 100.00);
sprintf(buf, "%.1f", temp_d);
lv_label_set_text(label_temp, buf);
}
Expand Down
8 changes: 5 additions & 3 deletions app/src/hw_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,20 @@ static void usb_init()
printk("\nUSB Init complete\n\n");
}

int32_t hpi_hw_read_temp(void)
int16_t hpi_hw_read_temp(void)
{
int ret = 0;
int32_t temp_val = 0;
int32_t i32_temp_val = 0;
int16_t temp_val = 0;

struct sensor_value temp_sample;
sensor_sample_fetch(max30205_dev);
sensor_channel_get(max30205_dev, SENSOR_CHAN_AMBIENT_TEMP, &temp_sample);
// Convert to degree F
if (temp_sample.val1 > 0)
{
temp_val = (temp_sample.val1 * 9 / 5) + 32000;
i32_temp_val = (temp_sample.val1 * 9 / 5) + 32000;
temp_val = (int16_t) (i32_temp_val / 10);
}

return temp_val;
Expand Down
2 changes: 1 addition & 1 deletion app/src/hw_module.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef hw_module_h
#define hw_module_h

int32_t hpi_hw_read_temp(void);
int16_t hpi_hw_read_temp(void);

void send_usb_cdc(const char *buf, size_t len);

Expand Down

0 comments on commit 24d53d2

Please sign in to comment.