HRV -> Mood
Dependencies: MAX30101 Hexi_KW40Z Hexi_OLED_SSD1351
Revision 1:eabf219849ab, committed 2019-03-16
- Comitter:
- jeannie9809
- Date:
- Sat Mar 16 02:43:26 2019 +0000
- Parent:
- 0:338c50c9c8cd
- Child:
- 2:3389bdfd9afa
- Commit message:
- hex screen output correct
Changed in this revision
| 8cee5929f4d8/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/8cee5929f4d8/main.cpp Sat Mar 16 02:20:01 2019 +0000
+++ b/8cee5929f4d8/main.cpp Sat Mar 16 02:43:26 2019 +0000
@@ -29,8 +29,7 @@
/*Create a Thread to handle sending BLE Sensor Data */
Thread txThread;
MAX30101 hr(i2c0);
-int realHeartRate;
-float calorie;
+int ppg_single_sample;
int mask_ppg = 0;
uint32_t count = 0;
uint32_t num;
@@ -40,9 +39,9 @@
const int num_samples = 2129;
int index = 0;
int ppg[num_samples];
-int SDNN_n, SDNN, HF_LF_n, HF_LF;
+int SDNN_n, SDNN;
bool first_sample_set = true;
-double arousal, valence;
+double arousal, valence, HF_LF, HF_LF_n;
void StartHaptic(void) {
hapticTimer.start(50);
@@ -192,16 +191,14 @@
num = *(uint32_t *) sample;
if (num < 310000){
- realHeartRate = 0;
+ ppg_single_sample = 0;
printf("keep closer to your hand \r\n");
}
else {
- //realHeartRate = 65;
- realHeartRate = (num - 310000)/100;
- if (realHeartRate >45){
- printf("%d\r\n", realHeartRate);
- }
+ //ppg_single_sample = 65;
+ ppg_single_sample = num;
+ printf("%d\r\n", ppg_single_sample);
}
//printf("%u\r\n", num);
@@ -227,7 +224,7 @@
t.start(callback(&evqueue, &EventQueue::dispatch_forever));
kw40z_device.attach_buttonLeft(&ButtonLeft);
kw40z_device.attach_buttonRight(&ButtonRight);
-
+
pwr1v8 = 1;
pwr3v3b = 1;
pwr15v = 0;
@@ -247,10 +244,10 @@
/* Fills the screen with solid black */
oled.FillScreen(COLOR_BLACK);
- strcpy((char *) text, "Heart Rate:");
+ strcpy((char *) text, "Raw PPG:");
oled.Label((uint8_t *)text,7,0);
- strcpy((char *) text, "Calorie/Hr:");
+ strcpy((char *) text, "SDNN; LF/HF:");
oled.Label((uint8_t *)text,7,40);
//dynamic text setup
textProperties.fontColor = COLOR_WHITE;
@@ -261,13 +258,12 @@
while (true) {
/* Format the time reading */
- sprintf(text,"%d",realHeartRate);
+ sprintf(text,"%d",ppg_single_sample);
/* Display time reading in 35px by 15px textbox at(x=55, y=40) */
oled.TextBox((uint8_t *)text,55,15,35,15); //Increase textbox for more digits
- if (realHeartRate > 45){
- calorie = (-55.1 + (0.6309*realHeartRate)+(0.1988*75)+(0.2017*25))*60/4.184 ;
- sprintf(text,"%0.2f",calorie);
+ if (ppg_single_sample > 45){
+ sprintf(text,"%d; %.2f",SDNN, HF_LF);
/* Display time reading in 35px by 15px textbox at(x=55, y=40) */
oled.TextBox((uint8_t *)text,55,55,35,15); //Increase textbox for more digits