![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ECE 4180 Final Project
Dependencies: mbed PulseSensor mbed-rtos LSM9DS1_Library_cal
Diff: main.cpp
- Revision:
- 9:dcbd546412ea
- Parent:
- 8:2d43385e7784
- Child:
- 10:63d223104806
--- a/main.cpp Thu Dec 02 00:58:37 2021 +0000 +++ b/main.cpp Thu Dec 02 18:46:01 2021 +0000 @@ -8,15 +8,15 @@ // a declination to get a more accurate heading. Calculate // your's here: // http://www.ngdc.noaa.gov/geomag-web/#declination -#define DECLINATION -4.94 // Declination (degrees) in Atlanta,GA. +#define DECLINATION -4.94 // Declination (degrees) in Atlanta, GA. LSM9DS1 IMU(p28, p27, 0xD6, 0x3C); Timer timer; /* -temp -pulse -ppm -step +Skin temp +Heart beat +Human resistance +Step count */ // IMU @@ -24,21 +24,19 @@ axis_info_t acc_sample; peak_value_t acc_peak; slid_reg_t acc_slid; -//uint8_t step_cnt = 1; // skin temp AnalogIn skinTemp(p19); -uint8_t temp_skin = 48; +uint8_t temp_skin = 25; -//Pulse -char pulse_symbol; -char pulse_data; +//Heart beat +uint8_t bpm; -//H_R +//Human resistance AnalogIn gsr(p17); AnalogIn sig(p18); -uint8_t hr = 1; +uint8_t Human_Resistance = 128; float gsrValue = 0; float phasic = 0; float baseline = 0; @@ -62,15 +60,11 @@ }; char imu_data[24]; - - - -void sendDataToProcessing(char symbol, int data) +void sendDataToProcessing(int data) { - pc.printf("%c%d\r\n", symbol, data); - pulse_symbol = symbol; - pulse_data = data; + pc.printf("%d\r\n", data); + bpm = data; } @@ -113,13 +107,8 @@ peak_value_init(&acc_peak); struct acce ac2; - //pc.printf("enter loop!!\n"); - while (1) - { - //pc.printf("00\n"); - //timer.reset(); - //timer.start(); + while (1) { uint16_t i = 0; float temp = 0; @@ -201,10 +190,6 @@ } } - - - - // calculate baseline to compare against void Get_Baseline(void) @@ -226,7 +211,7 @@ { float delta; float Serial_Port_Reading; - int Human_Resistance; + int hr; Get_Baseline(); while(1) { @@ -237,18 +222,15 @@ gsrValue = gsr; delta = baseline - gsrValue; } - Human_Resistance = 254* (phasic); + hr = 254* (phasic); //pc.printf("HR!!: %f\n", phasic); //Human_Resistance = ((1024+2*Serial_Port_Reading)*10000)/(512-Serial_Port_Reading); - //printf("%f\n\r", delta); // print for phasic - //printf("%d\n\r", Human_Resistance); // print for gsrValue - hr = Human_Resistance; + Human_Resistance = hr; Thread::wait(100); } } - int main() { @@ -263,33 +245,24 @@ pc.printf("IMU end\n"); PulseSensor sensor(p15, sendDataToProcessing); - //sensor.start(); + sensor.start(); Thread t1(step_counter); Thread t2(skin_temp); Thread t3(hum_R); - char aaa = 1; - char bbb = 2; - char ccc = 11; - char ddd = 4; + bpm = 60; pc.printf("Main Loop\n"); while(1) { - dev.putc(0xff); - //pc.putc(temp_skin); dev.putc(temp_skin); - dev.putc(ccc); - //dev.putc(pulse_symbol); - - dev.putc(hr); + dev.putc(sensor.get_bpm()); + dev.putc(Human_Resistance); dev.putc(get_step()); dev.putc(0xff); - //pc.putc('b'); - //pc.printf("step_cnt: %d\n",get_step()); Thread::wait(200); }