Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RD117_MBED by
Diff: main.cpp
- Revision:
- 9:018902137f7e
- Parent:
- 8:e66033f2fe53
--- a/main.cpp Mon Apr 16 20:01:08 2018 +0000 +++ b/main.cpp Thu Apr 19 16:10:57 2018 +0000 @@ -75,7 +75,7 @@ //#include "algorithm.h" #include "algorithm_by_RF.h" #include "MAX30102.h" -//#include "C12832.h" +#include "C12832.h" #define MAX_BRIGHTNESS 255 @@ -98,7 +98,7 @@ Serial pc(USBTX, USBRX); //initializes the serial port #ifdef TARGET_KL25Z //PwmOut led(PTB18); //initializes the pwm output that connects to the on board LED -DigitalIn INT(PTD1); //pin PTD0 connects to the interrupt output pin of the MAX30102 +DigitalIn INT(PTC9); //pin PTC9 Deniz connects to the interrupt output pin of the MAX30102 #endif #ifdef TARGET_K64F DigitalIn INT(PTD1); //pin PTD1 connects to the interrupt output pin of the MAX30102 @@ -108,28 +108,18 @@ DigitalIn INT(P2_0); //pin P20 connects to the interrupt output pin of the MAX30102 #endif -//C12832 lcd(PTD2,PTD1,PTA20,PTD5, PTD4); +C12832 lcd(PTD2,PTD1,PTD0,PTD5,PTD4); // the setup routine runs once when you press reset: int main() { t.start(); - //lcd.cls(); - // wait(100); - // lcd.printf("Hello world"); - /* - wait(100); + lcd.cls(); + lcd.locate(0,1); + lcd.printf("Press button to start..."); - for (int i = 20; i < 30; i++) - { - for (int j = 20; j <30; j++) - { - lcd.clearpixel(i,j); - } - } - */ uint32_t un_min, un_max, un_prev_data; //variables to calculate the on-board LED brightness that reflects the heartbeats - int i; + int i, nspo2 = 0; int32_t n_brightness; float f_temp, ratio, correl; @@ -152,7 +142,9 @@ uch_dummy=getchar(); maxim_max30102_init(); //initializes the MAX30102 - + lcd.cls(); + lcd.locate(0,1); + lcd.printf("Acquiring data..."); n_brightness=0; un_min=0x3FFFF; @@ -269,7 +261,21 @@ pc.printf("%f ", n_sp02); pc.printf("%i\n\r", ch_spo2_valid); } - rf_heart_rate_and_oxygen_saturation(aun_ir_buffer, BUFFER_SIZE, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid, &ratio, &correl); + rf_heart_rate_and_oxygen_saturation(aun_ir_buffer, BUFFER_SIZE, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid, &ratio, &correl); + if (ch_spo2_valid == 1) + { + lcd.cls(); + lcd.locate(0,1); + nspo2 = (int)(n_sp02); + lcd.printf("SPO2 = %i\n\r", n_sp02); + lcd.printf("Heart Rate = %i", n_heart_rate); + } + else + { + lcd.cls(); + lcd.locate(0,1); + lcd.printf("Recalculating, hold still"); + } } } \ No newline at end of file