@@ -93,9 +93,11 @@ uint8_t SparkFun_Bio_Sensor_Hub::readSensorHubStatus(){
93
93
// This function sets very basic settings to get sensor and biometric data.
94
94
// The biometric data includes data about heartrate, the confidence
95
95
// level, SpO2 levels, and whether the sensor has detected a finger or not.
96
- uint8_t SparkFun_Bio_Sensor_Hub::configBpm (){
96
+ uint8_t SparkFun_Bio_Sensor_Hub::configBpm (uint8_t mode ){
97
97
98
98
uint8_t statusChauf = 0 ;
99
+ if (mode == MODE_ONE || mode == MODE_TWO){}
100
+ else return INCORR_PARAM;
99
101
100
102
statusChauf = setOutputMode (ALGO_DATA); // Just the data
101
103
if ( statusChauf != SUCCESS )
@@ -112,10 +114,12 @@ uint8_t SparkFun_Bio_Sensor_Hub::configBpm(){
112
114
statusChauf = max30101Control (ENABLE);
113
115
if ( statusChauf != SUCCESS )
114
116
return statusChauf;
115
-
116
- statusChauf = maximFastAlgoControl (MODE_ONE );
117
+
118
+ statusChauf = maximFastAlgoControl (mode );
117
119
if ( statusChauf != SUCCESS )
118
120
return statusChauf;
121
+
122
+ _userSelectedMode = mode;
119
123
120
124
delay (1000 );
121
125
return SUCCESS;
@@ -144,37 +148,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensor(){
144
148
statusChauf = maximFastAlgoControl (MODE_ONE); // Enable algorithm
145
149
if ( statusChauf != SUCCESS )
146
150
return statusChauf;
147
-
148
- delay (1000 );
149
- return SUCCESS;
150
-
151
- }
152
151
153
- // This function sets very basic settings to get sensor and biometric data.
154
- // Sensor data includes 24 bit LED values for the two LED channels: Red and IR.
155
- // The biometric data includes data about heartrate, the confidence
156
- // level, SpO2 levels, and whether the sensor has detected a finger or not.
157
- // Of note, the number of samples is set to one.
158
- uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpm (){
159
-
160
- uint8_t statusChauf; // Our status chauffeur
161
-
162
- statusChauf = setOutputMode (SENSOR_AND_ALGORITHM); // Data and sensor data
163
- if ( statusChauf != SUCCESS )
164
- return statusChauf;
165
-
166
- statusChauf = setFifoThreshold (0x01 ); // One sample before interrupt is fired to the MAX32664
167
- if ( statusChauf != SUCCESS )
168
- return statusChauf;
169
-
170
- statusChauf = max30101Control (ENABLE); // Enable Sensor.
171
- if ( statusChauf != SUCCESS )
172
- return statusChauf;
173
-
174
- statusChauf = maximFastAlgoControl (MODE_ONE); // Enable algorithm
175
- if ( statusChauf != SUCCESS )
176
- return statusChauf;
177
-
178
152
delay (1000 );
179
153
return SUCCESS;
180
154
@@ -184,12 +158,12 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpm(){
184
158
// Sensor data includes 24 bit LED values for the two LED channels: Red and IR.
185
159
// The biometric data includes data about heartrate, the confidence
186
160
// level, SpO2 levels, and whether the sensor has detected a finger or not.
187
- // In addition mode two also gives data on the R value of the SPO2
188
- // measurements, and and extended finger status value.
189
161
// Of note, the number of samples is set to one.
190
- uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpmTwo ( ){
162
+ uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpm ( uint8_t mode ){
191
163
192
164
uint8_t statusChauf; // Our status chauffeur
165
+ if (mode == MODE_ONE || mode == MODE_TWO){}
166
+ else return INCORR_PARAM;
193
167
194
168
statusChauf = setOutputMode (SENSOR_AND_ALGORITHM); // Data and sensor data
195
169
if ( statusChauf != SUCCESS )
@@ -203,10 +177,12 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpmTwo(){
203
177
if ( statusChauf != SUCCESS )
204
178
return statusChauf;
205
179
206
- statusChauf = maximFastAlgoControl (MODE_TWO ); // Enable algorithm
180
+ statusChauf = maximFastAlgoControl (mode ); // Enable algorithm
207
181
if ( statusChauf != SUCCESS )
208
182
return statusChauf;
209
183
184
+ _userSelectedMode = mode;
185
+
210
186
delay (1000 );
211
187
return SUCCESS;
212
188
@@ -232,26 +208,64 @@ bioData SparkFun_Bio_Sensor_Hub::readBpm(){
232
208
}
233
209
234
210
numSamplesOutFifo ();
211
+
212
+ if (_userSelectedMode = MODE_ONE) {
213
+
214
+ readFillArray (READ_DATA_OUTPUT, READ_DATA, MAXFAST_ARRAY_SIZE, bpmArr);
215
+
216
+ // Heart Rate formatting
217
+ libBpm.heartRate = (uint16_t (bpmArr[0 ]) << 8 );
218
+ libBpm.heartRate |= (bpmArr[1 ]);
219
+ libBpm.heartRate /= 10 ;
220
+
221
+ // Confidence formatting
222
+ libBpm.confidence = bpmArr[2 ];
223
+
224
+ // Blood oxygen level formatting
225
+ libBpm.oxygen = uint16_t (bpmArr[3 ]) << 8 ;
226
+ libBpm.oxygen |= bpmArr[4 ];
227
+ libBpm.oxygen /= 10 ;
228
+
229
+ // "Machine State" - has a finger been detected?
230
+ libBpm.status = bpmArr[5 ];
231
+
232
+ return libBpm;
233
+ }
234
+
235
+ else if (_userSelectedMode = MODE_TWO) {
235
236
236
- readFillArray (READ_DATA_OUTPUT, READ_DATA, WHRM_ARRAY_SIZE, bpmArr);
237
+ readFillArray (READ_DATA_OUTPUT, READ_DATA,\
238
+ MAXFAST_ARRAY_SIZE + MAXFAST_EXTENDED_DATA, bpmArrTwo);
237
239
238
- // Heart Rate formatting
239
- libBpm.heartRate = (uint16_t (bpmArr [0 ]) << 8 );
240
- libBpm.heartRate |= (bpmArr [1 ]);
241
- libBpm.heartRate /= 10 ;
240
+ // Heart Rate formatting
241
+ libBpm.heartRate = (uint16_t (bpmArrTwo [0 ]) << 8 );
242
+ libBpm.heartRate |= (bpmArrTwo [1 ]);
243
+ libBpm.heartRate /= 10 ;
242
244
243
- // Confidence formatting
244
- libBpm.confidence = bpmArr [2 ];
245
+ // Confidence formatting
246
+ libBpm.confidence = bpmArrTwo [2 ];
245
247
246
- // Blood oxygen level formatting
247
- libBpm.oxygen = uint16_t (bpmArr [3 ]) << 8 ;
248
- libBpm.oxygen |= bpmArr [4 ];
249
- libBpm.oxygen /= 10 ;
248
+ // Blood oxygen level formatting
249
+ libBpm.oxygen = uint16_t (bpmArrTwo [3 ]) << 8 ;
250
+ libBpm.oxygen |= bpmArrTwo [4 ];
251
+ libBpm.oxygen /= 10 ;
250
252
251
- // "Machine State" - has a finger been detected?
252
- libBpm.status = bpmArr [5 ];
253
+ // "Machine State" - has a finger been detected?
254
+ libBpm.status = bpmArrTwo [5 ];
253
255
254
- return libBpm;
256
+ // Sp02 r Value formatting
257
+ libBpm.rValue = uint16_t (bpmArrTwo[6 ]) << 8 ;
258
+ libBpm.rValue |= bpmArrTwo[7 ];
259
+ libBpm.rValue /= 10 ;
260
+
261
+ // Extended Machine State formatting
262
+ libBpm.extStatus = bpmArrTwo[8 ];
263
+
264
+ // There are two additional bytes of data that were requested but that
265
+ // have not been implemented in firmware 10.1 so will not be saved to
266
+ // user's data.
267
+ return libBpm;
268
+ }
255
269
256
270
}
257
271
@@ -286,39 +300,96 @@ bioData SparkFun_Bio_Sensor_Hub::readSensor(){
286
300
bioData SparkFun_Bio_Sensor_Hub::readSensorBpm (){
287
301
288
302
bioData libLedBpm;
289
- readFillArray (READ_DATA_OUTPUT, READ_DATA, WHRM_ARRAY_SIZE + MAX30101_LED_ARRAY, bpmSenArr);
290
303
291
- // Value of LED one....
292
- libLedBpm.irLed = uint32_t (bpmSenArr[0 ]) << 16 ;
293
- libLedBpm.irLed |= uint32_t (bpmSenArr[1 ]) << 8 ;
294
- libLedBpm.irLed |= bpmSenArr[2 ];
304
+ if (_userSelectedMode == MODE_ONE){
305
+
306
+ readFillArray (READ_DATA_OUTPUT, READ_DATA, MAXFAST_ARRAY_SIZE + MAX30101_LED_ARRAY, bpmSenArr);
307
+
308
+ // Value of LED one....
309
+ libLedBpm.irLed = uint32_t (bpmSenArr[0 ]) << 16 ;
310
+ libLedBpm.irLed |= uint32_t (bpmSenArr[1 ]) << 8 ;
311
+ libLedBpm.irLed |= bpmSenArr[2 ];
312
+
313
+ // Value of LED two...
314
+ libLedBpm.redLed = uint32_t (bpmSenArr[3 ]) << 16 ;
315
+ libLedBpm.redLed |= uint32_t (bpmSenArr[4 ]) << 8 ;
316
+ libLedBpm.redLed |= bpmSenArr[5 ];
317
+
318
+ // -- What happened here? -- There are two uint32_t values that are given by
319
+ // the sensor for LEDs that do not exists on the MAX30101. So we have to
320
+ // request those empty values because they occupy the buffer:
321
+ // bpmSenArr[6-11].
322
+
323
+ // Heart rate formatting
324
+ libLedBpm.heartRate = (uint16_t (bpmSenArr[12 ]) << 8 );
325
+ libLedBpm.heartRate |= (bpmSenArr[13 ]);
326
+ libLedBpm.heartRate /= 10 ;
327
+
328
+ // Confidence formatting
329
+ libLedBpm.confidence = bpmSenArr[14 ];
330
+
331
+ // Blood oxygen level formatting
332
+ libLedBpm.oxygen = uint16_t (bpmSenArr[15 ]) << 8 ;
333
+ libLedBpm.oxygen |= bpmSenArr[16 ];
334
+ libLedBpm.oxygen /= 10 ;
335
+
336
+ // "Machine State" - has a finger been detected?
337
+ libLedBpm.status = bpmSenArr[17 ];
338
+ return libLedBpm;
339
+ }
340
+
341
+ else if (_userSelectedMode == MODE_TWO){
342
+
343
+ readFillArray (READ_DATA_OUTPUT, READ_DATA,\
344
+ MAXFAST_ARRAY_SIZE + MAX30101_LED_ARRAY + MAXFAST_EXTENDED_DATA, bpmSenArrTwo);
345
+
346
+ // Value of LED one....
347
+ libLedBpm.irLed = uint32_t (bpmSenArr[0 ]) << 16 ;
348
+ libLedBpm.irLed |= uint32_t (bpmSenArr[1 ]) << 8 ;
349
+ libLedBpm.irLed |= bpmSenArr[2 ];
350
+
351
+ // Value of LED two...
352
+ libLedBpm.redLed = uint32_t (bpmSenArr[3 ]) << 16 ;
353
+ libLedBpm.redLed |= uint32_t (bpmSenArr[4 ]) << 8 ;
354
+ libLedBpm.redLed |= bpmSenArr[5 ];
355
+
356
+ // -- What happened here? -- There are two uint32_t values that are given by
357
+ // the sensor for LEDs that do not exists on the MAX30101. So we have to
358
+ // request those empty values because they occupy the buffer:
359
+ // bpmSenArr[6-11].
360
+
361
+ // Heart rate formatting
362
+ libLedBpm.heartRate = (uint16_t (bpmSenArr[12 ]) << 8 );
363
+ libLedBpm.heartRate |= (bpmSenArr[13 ]);
364
+ libLedBpm.heartRate /= 10 ;
365
+
366
+ // Confidence formatting
367
+ libLedBpm.confidence = bpmSenArr[14 ];
368
+
369
+ // Blood oxygen level formatting
370
+ libLedBpm.oxygen = uint16_t (bpmSenArr[15 ]) << 8 ;
371
+ libLedBpm.oxygen |= bpmSenArr[16 ];
372
+ libLedBpm.oxygen /= 10 ;
373
+
374
+ // "Machine State" - has a finger been detected?
375
+ libLedBpm.status = bpmSenArr[17 ];
376
+
377
+ // Sp02 r Value formatting
378
+ libLedBpm.rValue = uint16_t (bpmArrTwo[18 ]) << 8 ;
379
+ libLedBpm.rValue |= bpmArrTwo[19 ];
380
+ libLedBpm.rValue /= 10 ;
381
+
382
+ // Extended Machine State formatting
383
+ libLedBpm.extStatus = bpmArrTwo[20 ];
384
+
385
+ // There are two additional bytes of data that were requested but that
386
+ // have not been implemented in firmware 10.1 so will not be saved to
387
+ // user's data.
388
+ //
389
+ return libLedBpm;
390
+
391
+ }
295
392
296
- // Value of LED two...
297
- libLedBpm.redLed = uint32_t (bpmSenArr[3 ]) << 16 ;
298
- libLedBpm.redLed |= uint32_t (bpmSenArr[4 ]) << 8 ;
299
- libLedBpm.redLed |= bpmSenArr[5 ];
300
-
301
- // -- What happened here? -- There are two uint32_t values that are given by
302
- // the sensor for LEDs that do not exists on the MAX30101. So we have to
303
- // request those empty values because they occupy the buffer:
304
- // bpmSenArr[6-11].
305
-
306
- // Heart rate formatting
307
- libLedBpm.heartRate = (uint16_t (bpmSenArr[12 ]) << 8 );
308
- libLedBpm.heartRate |= (bpmSenArr[13 ]);
309
- libLedBpm.heartRate /= 10 ;
310
-
311
- // Confidence formatting
312
- libLedBpm.confidence = bpmSenArr[14 ];
313
-
314
- // Blood oxygen level formatting
315
- libLedBpm.oxygen = uint16_t (bpmSenArr[15 ]) << 8 ;
316
- libLedBpm.oxygen |= bpmSenArr[16 ];
317
- libLedBpm.oxygen /= 10 ;
318
-
319
- // "Machine State" - has a finger been detected?
320
- libLedBpm.status = bpmSenArr[17 ];
321
- return libLedBpm;
322
393
323
394
}
324
395
// This function modifies the pulse width of the MAX30101 LEDs. All of the LEDs
0 commit comments