Skip to content

Commit

Permalink
Merge pull request #191 from WorldFamousElectronics/Version-2.0-Beta
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
biomurph authored Jan 12, 2024
2 parents 996839a + 6835f94 commit 61632e8
Show file tree
Hide file tree
Showing 38 changed files with 1,651 additions and 2,394 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.cfg
*.json
*.svd
*.zip
*.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2017 World Famous Electroncs LLC, Brooklyn, New York.
Copyright (c) 2015-2024 World Famous Electroncs LLC, Brooklyn, New York.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
159 changes: 0 additions & 159 deletions README-archive-3-2018.md

This file was deleted.

30 changes: 30 additions & 0 deletions Version 2.0 Beta Read Me.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This branch is for development and testing of PulseSensor Playground Library v2.0

High-level goals for v2.0:

- Remove user requirement for defining USE ARDUINO INTERRUPTS

Files effected:

- All example sketches will need to accomodate changes
- Interrupts.h will be superceded
- PulseSensorPlayground.h and PulseSensorPlayground.cpp will need to accomodate changes
- All comments in all files will be reviewed and editied to reflect paradigm shift


Notes 12/6/23
It works!
The file SelectTimer.h contains the most up to date hardware architecture that
has hardware timer interrupt support.

## TO DO:

- Make adjustments to example sketches to accomodate library decisions
- Make a program PulseSensorFullSystem.ino to make hardware testing easy
- Test ATtiny85 using Digispark board






1 change: 0 additions & 1 deletion examples/Getting_BPM_to_Monitor/Getting_BPM_to_Monitor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
4) Blinks the builtin LED with user's Heartbeat.
--------------------------------------------------------------------*/

#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.

// Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
This example will test functionality of PulseSensor user functions.
Program any hardware with this sketch and open a serial port
to view the test instructions, operation and results.
Functionality that is explicity tested by the program:
pause()
resume()
getInterBeatIntervalMs()
getBeatsPerMinute()
getLatestSample()
getPulseAmplitude()
getLastBeatTime()
All other functionality is implicitly tested by successfully running the program.



Check out the PulseSensor Playground Tools for explaination
of all user functions and directives.
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md

Copyright World Famous Electronics LLC - see LICENSE
Contributors:
Joel Murphy, https://pulsesensor.com
Yury Gitman, https://pulsesensor.com
Bradford Needham, @bneedhamia, https://bluepapertech.com

Licensed under the MIT License, a copy of which
should have been included with this software.

This software is not intended for medical use.
*/

/*
Test notes here
*/

#include <PulseSensorPlayground.h>

// Test variables
#define TEST_DURATION 10000 // run time in milliseconds
unsigned long thisTime;
bool testing = false;
bool normal = false;
uint8_t errorCode = 0x00; // maybe used for anything automatic?
int testBPM, testIBI, testAmp, testLastBeatTime; // test variables
int beatCounter;
int firstBeatTime, lastBeatTime, firstToLastBeatTime;

// Standard PulseSensor Stuff
const int OUTPUT_TYPE = SERIAL_PLOTTER;
const int PULSE_INPUT = A0;
const int PULSE_BLINK = LED_BUILTIN;
const int PULSE_FADE = 5;
const int THRESHOLD = 550; // Adjust this number to avoid noise when idle

PulseSensorPlayground pulseSensor;

void setup() {

Serial.begin(115200);
pulseSensor.analogInput(PULSE_INPUT);
pulseSensor.blinkOnPulse(PULSE_BLINK);
pulseSensor.fadeOnPulse(PULSE_FADE);

pulseSensor.setSerial(Serial);
pulseSensor.setOutputType(OUTPUT_TYPE);
pulseSensor.setThreshold(THRESHOLD);

// Now that everything is ready, start reading the PulseSensor signal.
if (!pulseSensor.begin()) {
/*
PulseSensor initialization failed,
likely because our particular Arduino platform interrupts
aren't supported yet.

If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino,
which doesn't use interrupts.
*/
for(;;) {
// Flash the led to show things didn't work.
digitalWrite(PULSE_BLINK, LOW);
delay(50); Serial.println('!');
digitalWrite(PULSE_BLINK, HIGH);
delay(50);
}
}
pulseSensor.pause();
delay(100);
printInstructions();

}

void loop() {
if(testing){
runTest(millis());
}
if(normal){
runNormal();
}
checkSerial();
} // loop


/*
Receives millis() and runs a test for TEST_DURATION
*/
void runTest(unsigned long startTime){
beatCounter = 0; // reset the beat counter
testIBI = 0;
testBPM = 0;
testAmp = 0;
firstBeatTime = -1;
lastBeatTime = -1;
Serial.println("\n\tSTART TEST");
pulseSensor.resume(); // start the sensing!
while((millis() - startTime) < TEST_DURATION){
Serial.println(pulseSensor.getLatestSample()); // print raw data for plotter or monitor review
if(pulseSensor.sawStartOfBeat()){
beatCounter++;
if(firstBeatTime < 0){ firstBeatTime = pulseSensor.getLastBeatTime(); }
testBPM += pulseSensor.getBeatsPerMinute();
testIBI += pulseSensor.getInterBeatIntervalMs();
testAmp += pulseSensor.getPulseAmplitude();
}
delay(20);
}
lastBeatTime = pulseSensor.getLastBeatTime();
pulseSensor.pause();
testBPM /= beatCounter;
testIBI /= beatCounter;
testAmp /= beatCounter;
firstToLastBeatTime = lastBeatTime - firstBeatTime;

printResults();
printInstructions();
testing = false;
}


void runNormal(){
if(pulseSensor.UsingHardwareTimer){
delay(20);
pulseSensor.outputSample();
} else {
if (pulseSensor.sawNewSample()) {
if (--pulseSensor.samplesUntilReport == (byte) 0) {
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
pulseSensor.outputSample();
}
}
}
if (pulseSensor.sawStartOfBeat()) {
pulseSensor.outputBeat();
}
}
Loading

0 comments on commit 61632e8

Please sign in to comment.