Q

Dependencies:   mbed

Fork of RD117_MBED by Maxim Integrated

Revision:
3:7c0fb55eb3ff
Parent:
0:346a7fa07998
Child:
4:5273ab1085ab
diff -r 560e76e77544 -r 7c0fb55eb3ff main.cpp
--- a/main.cpp	Thu Apr 21 18:25:34 2016 +0000
+++ b/main.cpp	Thu Apr 21 19:38:17 2016 +0000
@@ -81,9 +81,9 @@
 
 #define MAX_BRIGHTNESS 255
 
-uint32_t un_ir_buffer[500]; //IR LED sensor data
+uint32_t aun_ir_buffer[500]; //IR LED sensor data
 int32_t n_ir_buffer_length;    //data length
-uint32_t un_red_buffer[500];    //Red LED sensor data
+uint32_t aun_red_buffer[500];    //Red LED sensor data
 int32_t n_sp02; //SPO2 value
 int8_t ch_spo2_valid;   //indicator to show if the SP02 calculation is valid
 int32_t n_heart_rate;   //heart rate value
@@ -142,22 +142,22 @@
     {
         while(INT.read()==1);   //wait until the interrupt pin asserts
         
-        maxim_max30102_read_fifo((un_red_buffer+i), (un_ir_buffer+i));  //read from MAX30102 FIFO
+        maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i));  //read from MAX30102 FIFO
             
-        if(un_min>un_red_buffer[i])
-            un_min=un_red_buffer[i];    //update signal min
-        if(un_max<un_red_buffer[i])
-            un_max=un_red_buffer[i];    //update signal max
+        if(un_min>aun_red_buffer[i])
+            un_min=aun_red_buffer[i];    //update signal min
+        if(un_max<aun_red_buffer[i])
+            un_max=aun_red_buffer[i];    //update signal max
         pc.printf("red=");
-        pc.printf("%i", un_red_buffer[i]);
+        pc.printf("%i", aun_red_buffer[i]);
         pc.printf(", ir=");
-        pc.printf("%i\n\r", un_ir_buffer[i]);
+        pc.printf("%i\n\r", aun_ir_buffer[i]);
     }
-    un_prev_data=un_red_buffer[i];
+    un_prev_data=aun_red_buffer[i];
     
     
     //calculate heart rate and SpO2 after first 500 samples (first 5 seconds of samples)
-    maxim_heart_rate_and_oxygen_saturation(un_ir_buffer, n_ir_buffer_length, un_red_buffer ,  &n_sp02, &ch_spo2_valid , &n_heart_rate , &ch_hr_valid); 
+    maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer ,  &n_sp02, &ch_spo2_valid , &n_heart_rate , &ch_hr_valid); 
     
     //Continuously taking samples from MAX30102.  Heart rate and SpO2 are calculated every 1 second
     while(1)
@@ -169,26 +169,26 @@
         //dumping the first 100 sets of samples in the memory and shift the last 400 sets of samples to the top
         for(i=100;i<500;i++)
         {
-            un_red_buffer[i-100]=un_red_buffer[i];
-            un_ir_buffer[i-100]=un_ir_buffer[i];
+            aun_red_buffer[i-100]=aun_red_buffer[i];
+            aun_ir_buffer[i-100]=aun_ir_buffer[i];
             
             //update the signal min and max
-            if(un_min>un_red_buffer[i])
-            un_min=un_red_buffer[i];
-            if(un_max<un_red_buffer[i])
-            un_max=un_red_buffer[i];
+            if(un_min>aun_red_buffer[i])
+            un_min=aun_red_buffer[i];
+            if(un_max<aun_red_buffer[i])
+            un_max=aun_red_buffer[i];
         }
         
         //take 100 sets of samples before calculating the heart rate.
         for(i=400;i<500;i++)
         {
-            un_prev_data=un_red_buffer[i-1];
+            un_prev_data=aun_red_buffer[i-1];
             while(INT.read()==1);
-            maxim_max30102_read_fifo((un_red_buffer+i), (un_ir_buffer+i));
+            maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i));
         
-            if(un_red_buffer[i]>un_prev_data)
+            if(aun_red_buffer[i]>un_prev_data)
             {
-                f_temp=un_red_buffer[i]-un_prev_data;
+                f_temp=aun_red_buffer[i]-un_prev_data;
                 f_temp/=(un_max-un_min);
                 f_temp*=MAX_BRIGHTNESS;
                 n_brightness-=(int)f_temp;
@@ -197,7 +197,7 @@
             }
             else
             {
-                f_temp=un_prev_data-un_red_buffer[i];
+                f_temp=un_prev_data-aun_red_buffer[i];
                 f_temp/=(un_max-un_min);
                 f_temp*=MAX_BRIGHTNESS;
                 n_brightness+=(int)f_temp;
@@ -209,15 +209,15 @@
 #endif
             //send samples and calculation result to terminal program through UART
             pc.printf("red=");
-            pc.printf("%i",un_red_buffer[i]);
+            pc.printf("%i",aun_red_buffer[i]);
             pc.printf(", ir=");
-            pc.printf("%i", un_ir_buffer[i]);
+            pc.printf("%i", aun_ir_buffer[i]);
             pc.printf(", HR=%i, ",n_heart_rate); 
             pc.printf("HRvalid=%i, ",ch_hr_valid);
             pc.printf("SpO2=%i, ",n_sp02);
             pc.printf("SPO2Valid=%i\n\r",ch_spo2_valid);
         }
-        maxim_heart_rate_and_oxygen_saturation(un_ir_buffer, n_ir_buffer_length, un_red_buffer ,  &n_sp02, &ch_spo2_valid , &n_heart_rate , &ch_hr_valid); 
+        maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer ,  &n_sp02, &ch_spo2_valid , &n_heart_rate , &ch_hr_valid); 
 
     }
 }