From b2bb34b1e1654f99595c41841c0b1107065a2acf Mon Sep 17 00:00:00 2001 From: MishalJasmine Date: Tue, 5 Nov 2024 18:23:23 +0530 Subject: [PATCH 1/3] added temperature, hr, spo2 and rr to serial packet --- app/src/data_module.c | 24 +++++++++++++++++------- app/src/hw_module.c | 3 +++ app/src/sampling_module.h | 9 ++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/src/data_module.c b/app/src/data_module.c index da4d464..8837d17 100644 --- a/app/src/data_module.c +++ b/app/src/data_module.c @@ -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 @@ -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]; @@ -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); @@ -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; @@ -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) { @@ -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 */ @@ -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) diff --git a/app/src/hw_module.c b/app/src/hw_module.c index 94511f9..4862227 100644 --- a/app/src/hw_module.c +++ b/app/src/hw_module.c @@ -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" @@ -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)); @@ -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); diff --git a/app/src/sampling_module.h b/app/src/sampling_module.h index 6c63dd5..25588f0 100644 --- a/app/src/sampling_module.h +++ b/app/src/sampling_module.h @@ -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; @@ -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; +}; + + From d2ddc54009d29f8742b4f557eea0eadad9409bd8 Mon Sep 17 00:00:00 2001 From: MishalJasmine Date: Tue, 5 Nov 2024 20:21:56 +0530 Subject: [PATCH 2/3] serial streaming of vitals added --- app/src/data_module.c | 51 ++++++++++++++++++--------------------- app/src/hw_module.c | 3 ++- app/src/sampling_module.h | 7 +----- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/app/src/data_module.c b/app/src/data_module.c index 8837d17..862d6d6 100644 --- a/app/src/data_module.c +++ b/app/src/data_module.c @@ -127,12 +127,19 @@ float firCoeffs[NUM_TAPS] = {0.990, 0.990, 0.990, 0.990, 0.990, 0.990, 0.990, 0. arm_fir_instance_f32 sFIR; float firState[NUM_TAPS + BLOCK_SIZE - 1]; +int16_t spo2_serial; +int16_t hr_serial; +int16_t rr_serial; +extern int16_t temp_serial; + 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; + + //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]; @@ -145,32 +152,17 @@ void send_data_ov3_format() hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(resp_serial_streaming[i] >> 8); } - /*for (int i=0;i> 8); } - /*for (int i = 0; i < HPI_OV3_DATA_IR_LEN; i++) - { - 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_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); + hpi_ov3_data[pkt_pos_counter++] = (uint8_t)temp_serial; + hpi_ov3_data[pkt_pos_counter++] = (uint8_t)(temp_serial >> 8); + hpi_ov3_data[pkt_pos_counter++] = spo2_serial; + hpi_ov3_data[pkt_pos_counter++] = hr_serial; + hpi_ov3_data[pkt_pos_counter++] = rr_serial; if (settings_send_usb_enabled) { @@ -451,7 +443,6 @@ 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; @@ -525,8 +516,8 @@ 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; + rr_serial = globalRespirationRate; + // #ifdef CONFIG_BT if (settings_send_ble_enabled) @@ -564,6 +555,7 @@ void data_thread(void) if (settings_send_usb_enabled) { buffer_ppg_data_for_serial(ppg_sensor_sample.ppg_red_samples, PPG_POINTS_PER_SAMPLE); + // buffer_bioz_data_for_serial(ecg_bioz_sensor_sample.bioz_samples, ecg_bioz_sensor_sample.bioz_num_samples); } @@ -607,8 +599,12 @@ void data_thread(void) #endif // #ifdef CONFIG_BT ble_spo2_notify(m_spo2); + if (settings_send_usb_enabled) + { + spo2_serial = m_spo2; + } // #endif - ppg_sensor_sample.spo2 = m_spo2; + } @@ -617,6 +613,7 @@ void data_thread(void) #ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED hpi_scr_home_update_pr(m_hr); #endif + hr_serial = m_hr; } for (int i = FreqS; i < BUFFER_SIZE; i++) diff --git a/app/src/hw_module.c b/app/src/hw_module.c index 4862227..60d38f0 100644 --- a/app/src/hw_module.c +++ b/app/src/hw_module.c @@ -71,6 +71,7 @@ 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; +int16_t temp_serial; #ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED static const struct pwm_dt_spec bl_led_pwm = PWM_DT_SPEC_GET(DT_ALIAS(bl_led_pwm)); @@ -379,7 +380,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; + temp_serial = global_temp_val; #ifdef CONFIG_DISPLAY hpi_disp_update_batt_level(global_batt_level); diff --git a/app/src/sampling_module.h b/app/src/sampling_module.h index 25588f0..0c37576 100644 --- a/app/src/sampling_module.h +++ b/app/src/sampling_module.h @@ -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 rr; + uint16_t rtor; uint16_t hr; uint8_t ecg_lead_off; uint8_t bioz_lead_off; @@ -37,11 +37,6 @@ struct hpi_ppg_sensor_data_t uint8_t spo2; }; -struct hpi_temp_sensor_data_t -{ - int16_t temp; -}; - From 7857b8ab5ab7432daa015b93c841bdd9aad52de0 Mon Sep 17 00:00:00 2001 From: MishalJasmine Date: Wed, 6 Nov 2024 15:16:45 +0530 Subject: [PATCH 3/3] extern variable for temp removed --- app/src/data_module.c | 5 ++++- app/src/hw_module.c | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/data_module.c b/app/src/data_module.c index 862d6d6..0779436 100644 --- a/app/src/data_module.c +++ b/app/src/data_module.c @@ -28,6 +28,7 @@ LOG_MODULE_REGISTER(data_module, CONFIG_SENSOR_LOG_LEVEL); #include "spo2_process.h" #include "resp_process.h" #include "datalog_module.h" +#include "hw_module.h" // ProtoCentral data formats #define CES_CMDIF_PKT_START_1 0x0A @@ -130,7 +131,7 @@ float firState[NUM_TAPS + BLOCK_SIZE - 1]; int16_t spo2_serial; int16_t hr_serial; int16_t rr_serial; -extern int16_t temp_serial; +int16_t temp_serial; void send_data_ov3_format() { @@ -624,6 +625,8 @@ void data_thread(void) } } + temp_serial = hpi_hw_read_temp(); + k_sleep(K_MSEC(1)); } } diff --git a/app/src/hw_module.c b/app/src/hw_module.c index 60d38f0..df2bafd 100644 --- a/app/src/hw_module.c +++ b/app/src/hw_module.c @@ -70,8 +70,6 @@ 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; -int16_t temp_serial; #ifdef CONFIG_HEALTHYPI_DISPLAY_ENABLED static const struct pwm_dt_spec bl_led_pwm = PWM_DT_SPEC_GET(DT_ALIAS(bl_led_pwm)); @@ -380,7 +378,6 @@ void hw_thread(void) global_batt_level = hpi_hw_read_batt(); global_temp_val = hpi_hw_read_temp(); - temp_serial = global_temp_val; #ifdef CONFIG_DISPLAY hpi_disp_update_batt_level(global_batt_level);