diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3552020 --- /dev/null +++ b/.clang-format @@ -0,0 +1,35 @@ +# BasedOnStyle: Chromium +--- +Language: Cpp +AlignConsecutiveAssignments: true +AlignConsecutiveBitFields: true +AlignConsecutiveDeclarations: false +AllowShortBlocksOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: Empty +BinPackArguments: true +BinPackParameters: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterFunction: false + BeforeCatch: true + BeforeElse: false +ColumnLimit: 85 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ContinuationIndentWidth: 2 # Same as TabWidth +DerivePointerAlignment: true +IndentAccessModifiers: true +IndentCaseLabels: false +IndentPPDirectives: BeforeHash +IndentWidth: 2 # Same as TabWidth +MaxEmptyLinesToKeep: 2 +PenaltyExcessCharacter: 2 +PointerAlignment: Right +ReferenceAlignment: Left +ReflowComments: IndentOnly +SkipMacroDefinitionBody: true +SortIncludes: Never +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false +SpacesBeforeTrailingComments: 2 +TabWidth: 2 +UseTab: Never diff --git a/examples/GettingStartedProject/GettingStartedProject.ino b/examples/GettingStartedProject/GettingStartedProject.ino index 5929cbb..658b95a 100644 --- a/examples/GettingStartedProject/GettingStartedProject.ino +++ b/examples/GettingStartedProject/GettingStartedProject.ino @@ -21,38 +21,33 @@ // Variables -int PulseSensorPurplePin = 0; // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0 -int LED = LED_BUILTIN; // The on-board Arduion LED +int PulseSensorPurplePin = 0; // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0 +int LED = LED_BUILTIN; // The on-board Arduion LED -int Signal; // holds the incoming raw data. Signal value can range from 0-1024 -int Threshold = 580; // Determine which Signal to "count as a beat", and which to ingore. +int Signal; // holds the incoming raw data. Signal value can range from 0-1024 +int Threshold = 580; // Determine which Signal to "count as a beat", and which to ingore. // The SetUp Function: void setup() { - pinMode(LED,OUTPUT); // pin that will blink to your heartbeat! - Serial.begin(115200); // Set's up Serial Communication at certain speed. - + pinMode(LED, OUTPUT); // pin that will blink to your heartbeat! + Serial.begin(115200); // Set's up Serial Communication at certain speed. } // The Main Loop Function void loop() { Signal = analogRead(PulseSensorPurplePin); // Read the PulseSensor's value. - // Assign this value to the "Signal" variable. - - Serial.println("Signal " + String(Signal)); // Send "reading " followed by the Signal value to Serial Plotter. - - - if(Signal > Threshold){ // If the signal is above "550", then "turn-on" Arduino's on-Board LED. - digitalWrite(LED,HIGH); - } else { - digitalWrite(LED,LOW); // Else, the sigal must be below "550", so "turn-off" this LED. - } - + // Assign this value to the "Signal" variable. -delay(20); + Serial.println("Signal " + String(Signal)); // Send "reading " followed by the Signal value to Serial Plotter. + if (Signal > Threshold) { // If the signal is above "550", then "turn-on" Arduino's on-Board LED. + digitalWrite(LED, HIGH); + } else { + digitalWrite(LED, LOW); // Else, the sigal must be below "550", so "turn-off" this LED. + } + delay(20); } diff --git a/examples/Getting_BPM_to_Monitor/Getting_BPM_to_Monitor.ino b/examples/Getting_BPM_to_Monitor/Getting_BPM_to_Monitor.ino index adb1bda..c0ca5e7 100644 --- a/examples/Getting_BPM_to_Monitor/Getting_BPM_to_Monitor.ino +++ b/examples/Getting_BPM_to_Monitor/Getting_BPM_to_Monitor.ino @@ -9,49 +9,44 @@ 4) Blinks the builtin LED with user's Heartbeat. --------------------------------------------------------------------*/ -#include // Includes the PulseSensorPlayground Library. +#include // Includes the PulseSensorPlayground Library. // Variables -const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0 -const int LED = LED_BUILTIN; // The on-board Arduino LED, close to PIN 13. -int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore. - // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting. - // Otherwise leave the default "550" value. - +const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0 +const int LED = LED_BUILTIN; // The on-board Arduino LED, close to PIN 13. +int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore. + // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting. + // Otherwise leave the default "550" value. + PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor" -void setup() { +void setup() { - Serial.begin(115200); // For Serial Monitor + Serial.begin(115200); // For Serial Monitor - // Configure the PulseSensor object, by assigning our variables to it. - pulseSensor.analogInput(PulseWire); - pulseSensor.blinkOnPulse(LED); //auto-magically blink Arduino's LED with heartbeat. - pulseSensor.setThreshold(Threshold); + // Configure the PulseSensor object, by assigning our variables to it. + pulseSensor.analogInput(PulseWire); + pulseSensor.blinkOnPulse(LED); // auto-magically blink Arduino's LED with heartbeat. + pulseSensor.setThreshold(Threshold); - // Double-check the "pulseSensor" object was created and "began" seeing a signal. - if (pulseSensor.begin()) { - Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset. + // Double-check the "pulseSensor" object was created and "began" seeing a signal. + if (pulseSensor.begin()) { + Serial.println("We created a pulseSensor Object !"); // This prints one time at Arduino power-up, or on Arduino reset. } } - void loop() { - - -if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened". -int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int". - // "myBPM" hold this BPM value now. - Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened". - Serial.print("BPM: "); // Print phrase "BPM: " - Serial.println(myBPM); // Print the value inside of myBPM. -} - delay(20); // considered best practice in a simple sketch. + if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened". + int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int". + // "myBPM" hold this BPM value now. + Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened". + Serial.print("BPM: "); // Print phrase "BPM: " + Serial.println(myBPM); // Print the value inside of myBPM. + } + delay(20); // considered best practice in a simple sketch. } - - diff --git a/examples/PulseSensorLIbrary_V2_System_Test/PulseSensorLIbrary_V2_System_Test.ino b/examples/PulseSensorLIbrary_V2_System_Test/PulseSensorLIbrary_V2_System_Test.ino index 009a597..7f25027 100644 --- a/examples/PulseSensorLIbrary_V2_System_Test/PulseSensorLIbrary_V2_System_Test.ino +++ b/examples/PulseSensorLIbrary_V2_System_Test/PulseSensorLIbrary_V2_System_Test.ino @@ -11,27 +11,21 @@ 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 - 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 - 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. - 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 + This software is not intended for medical use. */ #include @@ -41,8 +35,8 @@ 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 +uint8_t errorCode = 0x00; // maybe used for anything automatic? +int testBPM, testIBI, testAmp, testLastBeatTime; // test variables int beatCounter; int firstBeatTime, lastBeatTime, firstToLastBeatTime; @@ -51,7 +45,7 @@ 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 +const int THRESHOLD = 550; // Adjust this number to avoid noise when idle PulseSensorPlayground pulseSensor; @@ -69,17 +63,18 @@ void setup() { // 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. + 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. + If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino, + which doesn't use interrupts. */ - for(;;) { + for (;;) { // Flash the led to show things didn't work. digitalWrite(PULSE_BLINK, LOW); - delay(50); Serial.println('!'); + delay(50); + Serial.println('!'); digitalWrite(PULSE_BLINK, HIGH); delay(50); } @@ -87,24 +82,23 @@ void setup() { pulseSensor.pause(); delay(100); printInstructions(); - } void loop() { - if(testing){ + if (testing) { runTest(millis()); } - if(normal){ + if (normal) { runNormal(); } checkSerial(); -} // loop +} // loop /* - Receives millis() and runs a test for TEST_DURATION + Receives millis() and runs a test for TEST_DURATION */ -void runTest(unsigned long startTime){ +void runTest(unsigned long startTime) { beatCounter = 0; // reset the beat counter testIBI = 0; testBPM = 0; @@ -112,13 +106,15 @@ void runTest(unsigned long startTime){ 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()){ + 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(); + if (firstBeatTime < 0) { + firstBeatTime = pulseSensor.getLastBeatTime(); + } + testBPM += pulseSensor.getBeatsPerMinute(); testIBI += pulseSensor.getInterBeatIntervalMs(); testAmp += pulseSensor.getPulseAmplitude(); } @@ -135,11 +131,11 @@ void runTest(unsigned long startTime){ printInstructions(); testing = false; } - -void runNormal(){ - if(pulseSensor.UsingHardwareTimer){ - delay(20); + +void runNormal() { + if (pulseSensor.UsingHardwareTimer) { + delay(20); pulseSensor.outputSample(); } else { if (pulseSensor.sawNewSample()) { @@ -152,4 +148,4 @@ void runNormal(){ if (pulseSensor.sawStartOfBeat()) { pulseSensor.outputBeat(); } -} \ No newline at end of file +} diff --git a/examples/PulseSensorLIbrary_V2_System_Test/serialStuff.ino b/examples/PulseSensorLIbrary_V2_System_Test/serialStuff.ino index 1abf714..736b5ec 100644 --- a/examples/PulseSensorLIbrary_V2_System_Test/serialStuff.ino +++ b/examples/PulseSensorLIbrary_V2_System_Test/serialStuff.ino @@ -2,10 +2,10 @@ */ -void checkSerial(){ - if(Serial.available()){ +void checkSerial() { + if (Serial.available()) { char inChar = Serial.read(); - switch(inChar){ + switch (inChar) { case 't': testing = true; break; @@ -19,29 +19,31 @@ void checkSerial(){ printInstructions(); break; default: - Serial.print("i got "); Serial.println(inChar); + Serial.print("I got "); + Serial.println(inChar); } - } // Serial.available -} // checkSerial + } // Serial.available +} // checkSerial -void printResults(){ - float durationOfBeats = float(firstToLastBeatTime/1000.0); - Serial.println("\tTEST COMPLETE"); +void printResults() { + float durationOfBeats = float(firstToLastBeatTime / 1000.0); + Serial.println("\tTEST COMPLETE"); Serial.print("\tAverage BPM: "); Serial.println(testBPM); Serial.print("\tAverage IBI: "); Serial.println(testIBI); Serial.print("\tAverage Pulse Amplitude: "); Serial.println(testAmp); - Serial.print("\tFirst to last heartbeat time: "); Serial.print(durationOfBeats,3); Serial.println(" Seconds"); + Serial.print("\tFirst to last heartbeat time: "); Serial.print(durationOfBeats, 3); Serial.println(" Seconds"); Serial.print("\tPlayground Library is using a "); - if(pulseSensor.UsingHardwareTimer){ + if (pulseSensor.UsingHardwareTimer) { Serial.println("hardware timer"); } else { Serial.println("software timer"); } } -void printInstructions(){ - Serial.print("\nPulseSensor Playground "); Serial.println(PULSESENSOR_PLAYGROUND_VERSION_STRING); +void printInstructions() { + Serial.print("\nPulseSensor Playground "); + Serial.println(PULSESENSOR_PLAYGROUND_VERSION_STRING); Serial.println("Full System Test Instructions:"); Serial.println("\n\t1) Connect PulseSensor wires to the board under test"); Serial.println("\t2) Use a known good signal source to connect PulseSensor to"); @@ -52,11 +54,11 @@ void printInstructions(){ Serial.println("\nSend 'r' to run the pulseSensor with normal output"); Serial.println("Send 'p' to pause normal output, and print this message"); Serial.print("PulseSensor is currently "); - if(pulseSensor.isPaused()){ + if (pulseSensor.isPaused()) { Serial.println("paused"); } else { Serial.println("running!"); } // Serial.println(""); // Serial.println(""); -} \ No newline at end of file +} diff --git a/examples/PulseSensor_ATtiny85_Serial/PulseSensor_ATtiny85_Serial.ino b/examples/PulseSensor_ATtiny85_Serial/PulseSensor_ATtiny85_Serial.ino index b104da4..91d9da2 100644 --- a/examples/PulseSensor_ATtiny85_Serial/PulseSensor_ATtiny85_Serial.ino +++ b/examples/PulseSensor_ATtiny85_Serial/PulseSensor_ATtiny85_Serial.ino @@ -61,17 +61,17 @@ const int OUTPUT_TYPE = PROCESSING_VISUALIZER; Adjust as neccesary. */ const int PULSE_INPUT = A1; -const int PULSE_BLINK = 1; // Pin 13 is the on-board LED +const int PULSE_BLINK = 1; // Pin 13 is the on-board LED const int PULSE_FADE = 0; -const int THRESHOLD = 550; // Adjust this number to avoid noise when idle -const int TX_PIN = 3; // Using software serial +const int THRESHOLD = 550; // Adjust this number to avoid noise when idle +const int TX_PIN = 3; // Using software serial const int RX_PIN = 4; /* All the PulseSensor Playground functions. */ PulseSensorPlayground pulseSensor; -SoftwareSerial pulseUART(TX_PIN,RX_PIN); +SoftwareSerial pulseUART(TX_PIN, RX_PIN); void setup() { /* @@ -105,7 +105,7 @@ void setup() { If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino, which doesn't use interrupts. */ - for(;;) { + for (;;) { // Flash the led to show things didn't work. digitalWrite(PULSE_BLINK, LOW); delay(50); @@ -127,44 +127,44 @@ void loop() { will check to see how much time has passed, then read and process a sample (analog voltage) from the PulseSensor. Call this function often to maintain 500Hz sample rate, - that is every 2 milliseconds. Best not to have any delay() + that is every 2 milliseconds. Best not to have any delay() functions in the loop when using a software timer. Check the compatibility of your hardware at this link and delete the unused code portions in your saved copy, if you like. */ -if(pulseSensor.UsingHardwareTimer){ - /* - Wait a bit. - We don't output every sample, because our baud rate - won't support that much I/O. - */ - delay(20); - // write the latest sample to Serial. - pulseSensor.outputSample(); -} else { -/* - When using a software timer, we have to check to see if it is time - to acquire another sample. A call to sawNewSample will do that. -*/ - if (pulseSensor.sawNewSample()) { + if (pulseSensor.UsingHardwareTimer) { + /* + Wait a bit. + We don't output every sample, because our baud rate + won't support that much I/O. + */ + delay(20); + // write the latest sample to Serial. + pulseSensor.outputSample(); + } else { /* + When using a software timer, we have to check to see if it is time + to acquire another sample. A call to sawNewSample will do that. + */ + if (pulseSensor.sawNewSample()) { + /* Every so often, send the latest Sample. We don't print every sample, because our baud rate won't support that much I/O. - */ - if (--pulseSensor.samplesUntilReport == (byte) 0) { - pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE; - pulseSensor.outputSample(); + */ + if (--pulseSensor.samplesUntilReport == (byte) 0) { + pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE; + pulseSensor.outputSample(); + } } } -} /* - If a beat has happened since we last checked, - write the per-beat information to Serial. - */ - if (pulseSensor.sawStartOfBeat()) { - pulseSensor.outputBeat(); - } + If a beat has happened since we last checked, + write the per-beat information to Serial. + */ + if (pulseSensor.sawStartOfBeat()) { + pulseSensor.outputBeat(); + } } diff --git a/examples/PulseSensor_ATtiny85_noSerial/PulseSensor_ATtiny85_noSerial.ino b/examples/PulseSensor_ATtiny85_noSerial/PulseSensor_ATtiny85_noSerial.ino index f798507..4f25bbc 100644 --- a/examples/PulseSensor_ATtiny85_noSerial/PulseSensor_ATtiny85_noSerial.ino +++ b/examples/PulseSensor_ATtiny85_noSerial/PulseSensor_ATtiny85_noSerial.ino @@ -49,9 +49,9 @@ Adjust as neccesary. */ const int PULSE_INPUT = A1; -const int PULSE_BLINK = 1; // Pin 13 is the on-board LED +const int PULSE_BLINK = 1; // Pin 13 is the on-board LED const int PULSE_FADE = 0; -const int THRESHOLD = 550; // Adjust this number to avoid noise when idle +const int THRESHOLD = 550; // Adjust this number to avoid noise when idle /* All the PulseSensor Playground functions. @@ -76,7 +76,7 @@ void setup() { If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino, which doesn't use interrupts. */ - for(;;) { + for (;;) { // Flash the led to show things didn't work. digitalWrite(PULSE_BLINK, LOW); delay(50); @@ -89,9 +89,9 @@ void setup() { void loop() { /* When we're not outputting serial messages - there's not much to do here. - In case you want to add more behavior to the sketch - you can use sawStartOfBeat() or isInsideBeat() - to have the sketch do stuff when there's a beat. + there's not much to do here. + In case you want to add more behavior to the sketch + you can use sawStartOfBeat() or isInsideBeat() + to have the sketch do stuff when there's a beat. */ } diff --git a/examples/PulseSensor_BPM/PulseSensor_BPM.ino b/examples/PulseSensor_BPM/PulseSensor_BPM.ino index ec136c6..53e35e4 100644 --- a/examples/PulseSensor_BPM/PulseSensor_BPM.ino +++ b/examples/PulseSensor_BPM/PulseSensor_BPM.ino @@ -67,7 +67,7 @@ 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 +const int THRESHOLD = 550; // Adjust this number to avoid noise when idle /* All the PulseSensor Playground functions. @@ -106,10 +106,11 @@ void setup() { If your Sketch hangs here, try PulseSensor_BPM_Alternative.ino, which doesn't use interrupts. */ - for(;;) { + for (;;) { // Flash the led to show things didn't work. digitalWrite(PULSE_BLINK, LOW); - delay(50); Serial.println('!'); + delay(50); + Serial.println('!'); digitalWrite(PULSE_BLINK, HIGH); delay(50); } @@ -117,56 +118,56 @@ void setup() { } void loop() { - /* - See if a sample is ready from the PulseSensor. - - If USE_HARDWARE_TIMER is true, the PulseSensor Playground - will automatically read and process samples from - the PulseSensor. - - If USE_HARDWARE_TIMER is false, the call to sawNewSample() - will check to see how much time has passed, then read - and process a sample (analog voltage) from the PulseSensor. - Call this function often to maintain 500Hz sample rate, - that is every 2 milliseconds. Best not to have any delay() - functions in the loop when using a software timer. - - Check the compatibility of your hardware at this link - - and delete the unused code portions in your saved copy, if you like. - */ -if(pulseSensor.UsingHardwareTimer){ /* - Wait a bit. - We don't output every sample, because our baud rate - won't support that much I/O. - */ - delay(20); - // write the latest sample to Serial. - pulseSensor.outputSample(); -} else { -/* - When using a software timer, we have to check to see if it is time - to acquire another sample. A call to sawNewSample will do that. -*/ - if (pulseSensor.sawNewSample()) { + See if a sample is ready from the PulseSensor. + + If USE_HARDWARE_TIMER is true, the PulseSensor Playground + will automatically read and process samples from + the PulseSensor. + + If USE_HARDWARE_TIMER is false, the call to sawNewSample() + will check to see how much time has passed, then read + and process a sample (analog voltage) from the PulseSensor. + Call this function often to maintain 500Hz sample rate, + that is every 2 milliseconds. Best not to have any delay() + functions in the loop when using a software timer. + + Check the compatibility of your hardware at this link + + and delete the unused code portions in your saved copy, if you like. + */ + if (pulseSensor.UsingHardwareTimer) { + /* + Wait a bit. + We don't output every sample, because our baud rate + won't support that much I/O. + */ + delay(20); + // write the latest sample to Serial. + pulseSensor.outputSample(); + } else { /* + When using a software timer, we have to check to see if it is time + to acquire another sample. A call to sawNewSample will do that. + */ + if (pulseSensor.sawNewSample()) { + /* Every 20 milliseconds, send the latest Sample. We don't print every sample, because our baud rate won't support that much I/O. - */ - if ((pulseSensor.samplesUntilReport--) == 0) { - pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE; - pulseSensor.outputSample(); + */ + if ((pulseSensor.samplesUntilReport--) == 0) { + pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE; + pulseSensor.outputSample(); + } } } -} /* - If a beat has happened since we last checked, - write the per-beat information to Serial, formatted as CSV: - BPM, IBI, PulseSensor Signal - */ - if (pulseSensor.sawStartOfBeat()) { - pulseSensor.outputBeat(); - } + If a beat has happened since we last checked, + write the per-beat information to Serial, formatted as CSV: + BPM, IBI, PulseSensor Signal + */ + if (pulseSensor.sawStartOfBeat()) { + pulseSensor.outputBeat(); + } } diff --git a/examples/PulseSensor_ESP32/PulseSensor_ESP32.ino b/examples/PulseSensor_ESP32/PulseSensor_ESP32.ino index 8bdb0a5..c465c63 100644 --- a/examples/PulseSensor_ESP32/PulseSensor_ESP32.ino +++ b/examples/PulseSensor_ESP32/PulseSensor_ESP32.ino @@ -37,11 +37,11 @@ /* The following libraries are necessary - for the asynchronous web server + for the asynchronous web server */ #include #include -#include // https://github.com/dvarrel/ESPAsyncTCP +#include // https://github.com/dvarrel/ESPAsyncTCP #include // https://github.com/dvarrel/ESPAsyncWebSrv #include @@ -83,26 +83,26 @@ PulseSensorPlayground pulseSensor; Adjust as neccesary. */ const int PULSE_INPUT = A0; -const int PULSE_BLINK = 13; +const int PULSE_BLINK = 13; const int PULSE_FADE = 5; -const int THRESHOLD = 685; +const int THRESHOLD = 685; /* Replace with your network credentials */ -const char* ssid = "SSID"; -const char* password = "PASSWORD"; +const char *ssid = "SSID"; +const char *password = "PASSWORD"; -/* - Create AsyncWebServer object on port 80 - Create an Event Source on /events +/* + Create AsyncWebServer object on port 80 + Create an Event Source on /events */ AsyncWebServer server(80); AsyncEventSource events("/events"); /* - The following code between the two "rawliteral" tags - will be stored as text. It contains the html, - css, and javascript that will be used to build - the asynchronous server. + The following code between the two "rawliteral" tags + will be stored as text. It contains the html, + css, and javascript that will be used to build + the asynchronous server. */ const char index_html[] PROGMEM = R"rawliteral( @@ -112,14 +112,14 @@ const char index_html[] PROGMEM = R"rawliteral(