Skip to content

Commit

Permalink
added temperature, hr, spo2 and rr to serial packet
Browse files Browse the repository at this point in the history
  • Loading branch information
MishalJasmine committed Nov 5, 2024
1 parent 92f8185 commit b2bb34b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
24 changes: 17 additions & 7 deletions app/src/data_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ char DataPacket[DATA_LEN];
const uint8_t DataPacketHeader[5] = {CES_CMDIF_PKT_START_1, CES_CMDIF_PKT_START_2, DATA_LEN, 0, CES_CMDIF_TYPE_DATA};
const uint8_t DataPacketFooter[2] = {0, CES_CMDIF_PKT_STOP};

#define HPI_OV3_DATA_LEN 40
#define HPI_OV3_DATA_LEN 45
#define HPI_OV3_DATA_ECG_LEN 8
#define HPI_OV3_DATA_BIOZ_LEN 4
#define HPI_OV3_DATA_RED_LEN 8
Expand Down Expand Up @@ -130,6 +130,9 @@ float firState[NUM_TAPS + BLOCK_SIZE - 1];
void send_data_ov3_format()
{
uint8_t pkt_pos_counter = 0;
struct hpi_ecg_bioz_sensor_data_t ecg_bioz_sensor_sample;
struct hpi_ppg_sensor_data_t ppg_sensor_sample;
struct hpi_temp_sensor_data_t temp_sensor_sample;
for (int i = 0; i < HPI_OV3_DATA_ECG_LEN; i++)
{
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)ecg_serial_streaming[i];
Expand Down Expand Up @@ -159,13 +162,13 @@ void send_data_ov3_format()
{
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)raw_ir[i];
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(raw_ir[i] >> 8);
}
}*/

hpi_ov3_data[pkt_pos_counter++] = (uint8_t)temp;
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(temp >> 8);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(spo2);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(hr);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(rr);*/
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)temp_sensor_sample.temp;
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(temp_sensor_sample.temp >> 8);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(ppg_sensor_sample.spo2);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(ecg_bioz_sensor_sample.hr);
hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(ecg_bioz_sensor_sample.rr);

// LOG_INF("Sending Data %d", pkt_pos_counter);

Expand Down Expand Up @@ -448,6 +451,7 @@ void data_thread(void)
struct hpi_ecg_bioz_sensor_data_t ecg_bioz_sensor_sample;
struct hpi_ppg_sensor_data_t ppg_sensor_sample;


// record_init_session_log();

int m_temp_sample_counter = 0;
Expand Down Expand Up @@ -521,6 +525,9 @@ void data_thread(void)
resp_process_sample(resp_i16_buf, resp_i16_filt_out);
resp_algo_process(resp_i16_filt_out, &globalRespirationRate);

ecg_bioz_sensor_sample.hr = ecg_bioz_sensor_sample.hr;
ecg_bioz_sensor_sample.rr = globalRespirationRate;

// #ifdef CONFIG_BT
if (settings_send_ble_enabled)
{
Expand All @@ -547,6 +554,7 @@ void data_thread(void)
k_msgq_put(&q_plot_ecg_bioz, &ecg_bioz_sensor_sample, K_NO_WAIT);
}
#endif

}

/* Get Sample from PPG sampling queue */
Expand Down Expand Up @@ -600,6 +608,8 @@ void data_thread(void)
// #ifdef CONFIG_BT
ble_spo2_notify(m_spo2);
// #endif
ppg_sensor_sample.spo2 = m_spo2;

}

if (validHeartRate)
Expand Down
3 changes: 3 additions & 0 deletions app/src/hw_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "max30001.h"
#include "hw_module.h"
#include "fs_module.h"
#include "sampling_module.h"

#ifdef CONFIG_DISPLAY
#include "display_module.h"
Expand Down Expand Up @@ -69,6 +70,7 @@ const struct device *const max30001_dev = DEVICE_DT_GET_ANY(maxim_max30001);
const struct device *const afe4400_dev = DEVICE_DT_GET_ANY(ti_afe4400);
const struct device *const max30205_dev = DEVICE_DT_GET_ANY(maxim_max30205);
const struct device *fg_dev;
struct hpi_temp_sensor_data_t temp_sensor_sample;

#ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED
static const struct pwm_dt_spec bl_led_pwm = PWM_DT_SPEC_GET(DT_ALIAS(bl_led_pwm));
Expand Down Expand Up @@ -377,6 +379,7 @@ void hw_thread(void)
global_batt_level = hpi_hw_read_batt();

global_temp_val = hpi_hw_read_temp();
temp_sensor_sample.temp = global_temp_val;

#ifdef CONFIG_DISPLAY
hpi_disp_update_batt_level(global_batt_level);
Expand Down
9 changes: 8 additions & 1 deletion app/src/sampling_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct hpi_ecg_bioz_sensor_data_t
int32_t bioz_samples[BIOZ_POINTS_PER_SAMPLE];
uint8_t ecg_num_samples;
uint8_t bioz_num_samples;
uint16_t rtor;
uint16_t rr;
uint16_t hr;
uint8_t ecg_lead_off;
uint8_t bioz_lead_off;
Expand All @@ -34,8 +34,15 @@ struct hpi_ppg_sensor_data_t
int32_t ppg_ir_samples[PPG_POINTS_PER_SAMPLE];
uint8_t ppg_num_samples;
uint8_t ppg_lead_off;
uint8_t spo2;
};

struct hpi_temp_sensor_data_t
{
int16_t temp;
};





Expand Down

0 comments on commit b2bb34b

Please sign in to comment.