Skip to content

Commit 3deefea

Browse files
committed
Fixed a bug when using software timer
1 parent c2367e8 commit 3deefea

File tree

15 files changed

+57
-187
lines changed

15 files changed

+57
-187
lines changed

examples/.DS_Store

-6 KB
Binary file not shown.

examples/PulseSensor_BPM/PulseSensor_BPM.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
should have been included with this software.
1616
1717
This software is not intended for medical use.
18+
19+
For more information on the PulseSensor methods and functions
20+
go to our Resources page
21+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
1822
*/
1923

2024
/*
@@ -147,19 +151,20 @@ if(pulseSensor.UsingHardwareTimer){
147151
*/
148152
if (pulseSensor.sawNewSample()) {
149153
/*
150-
Every so often, send the latest Sample.
154+
Every 20 milliseconds, send the latest Sample.
151155
We don't print every sample, because our baud rate
152156
won't support that much I/O.
153157
*/
154-
if (--pulseSensor.samplesUntilReport == (byte) 0) {
158+
if ((pulseSensor.samplesUntilReport--) == 0) {
155159
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
156160
pulseSensor.outputSample();
157161
}
158162
}
159163
}
160164
/*
161165
If a beat has happened since we last checked,
162-
write the per-beat information to Serial.
166+
write the per-beat information to Serial, formatted as CSV:
167+
BPM, IBI, PulseSensor Signal
163168
*/
164169
if (pulseSensor.sawStartOfBeat()) {
165170
pulseSensor.outputBeat();

examples/PulseSensor_ESP32/PulseSensor_ESP32.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
should have been included with this software.
2929
3030
This software is not intended for medical use.
31+
32+
For more information on the PulseSensor methods and functions
33+
go to our Resources page
34+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
3135
*/
3236

3337

examples/PulseSensor_Pulse_Transit_Time/PulseSensor_Pulse_Transit_Time.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
should have been included with this software.
2323
2424
This software is not intended for medical use.
25+
26+
For more information on the PulseSensor methods and functions
27+
go to our Resources page
28+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
2529
*/
2630

2731
/*
@@ -182,11 +186,11 @@ if(pulseSensor.UsingHardwareTimer){
182186
*/
183187
if (pulseSensor.sawNewSample()) {
184188
/*
185-
Every so often, send the latest Sample.
189+
Every 20 milliseconds, send the latest Sample.
186190
We don't print every sample, because our baud rate
187191
won't support that much I/O.
188192
*/
189-
if (--pulseSensor.samplesUntilReport == (byte) 0) {
193+
if ((pulseSensor.samplesUntilReport--) == 0) {
190194
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
191195
pulseSensor.outputSample();
192196
}

examples/PulseSensor_Servo_Motor/PulseSensor_Servo_Motor.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
should have been included with this software.
2121
2222
This software is not intended for medical use.
23+
24+
For more information on the PulseSensor methods and functions
25+
go to our Resources page
26+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
2327
*/
2428

2529
/*
@@ -170,7 +174,7 @@ void loop() {
170174
*/
171175
if (pulseSensor.sawNewSample()) {
172176
/*
173-
Every so often, send the latest Sample.
177+
Every 20 milliseconds, send the latest Sample.
174178
We don't print every sample, because our baud rate
175179
won't support that much I/O.
176180
*/

examples/PulseSensor_Speaker/PulseSensor_Speaker.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
should have been included with this software.
2222
2323
This software is not intended for medical use.
24+
25+
For more information on the PulseSensor methods and functions
26+
go to our Resources page
27+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
2428
*/
2529

2630
/*
@@ -164,11 +168,11 @@ void loop() {
164168
*/
165169
if (pulseSensor.sawNewSample()) {
166170
/*
167-
Every so often, send the latest Sample.
171+
Every 20 milliseconds, send the latest Sample.
168172
We don't print every sample, because our baud rate
169173
won't support that much I/O.
170174
*/
171-
if (--pulseSensor.samplesUntilReport == (byte) 0) {
175+
if ((pulseSensor.samplesUntilReport--) == 0) {
172176
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
173177
pulseSensor.outputSample();
174178
}

examples/PulseSensor_UNO_R4_WiFi_LEDmatrix_Heartbeat/PulseSensor_UNO_R4_WiFi_LEDmatrix_Heartbeat.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
should have been included with this software.
1717
1818
This software is not intended for medical use.
19+
20+
For more information on the PulseSensor methods and functions
21+
go to our Resources page
22+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
1923
*/
2024

2125
/*

examples/PulseSensor_UNO_R4_WiFi_LEDmatrix_Plotter/PulseSensor_UNO_R4_WiFi_LEDmatrix_Plotter.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
should have been included with this software.
1818
1919
This software is not intended for medical use.
20+
21+
For more information on the PulseSensor methods and functions
22+
go to our Resources page
23+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
2024
*/
2125

2226
/*

examples/PulseSensor_nRF52_Heartrate_Monitor_Service/PulseSensor_nRF52_Heartrate_Monitor_Service.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
https://www.amazon.com/Heartbeat-Sensor-Projects-PulseSensor-Prototyping/dp/148429324X
1414
There is also a tutorial online here:
1515
https://pulsesensor.com/pages/nrf52-bluetooth-low-energy
16+
17+
For more information on the PulseSensor methods and functions
18+
go to our Resources page
19+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
1620
*/
1721

1822
/*

examples/SoftwareSerialDemo/SoftwareSerialDemo.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
should have been included with this software.
1717
1818
This software is not intended for medical use.
19+
20+
For more information on the PulseSensor methods and functions
21+
go to our Resources page
22+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
1923
*/
2024
/*
2125
Include the PulseSensor Playground library to get all the good stuff!
@@ -151,11 +155,11 @@ void loop() {
151155
*/
152156
if (pulseSensor.sawNewSample()) {
153157
/*
154-
Every so often, send the latest Sample.
158+
Every 20 millisectonds, send the latest Sample.
155159
We don't print every sample, because our baud rate
156160
won't support that much I/O.
157161
*/
158-
if (--pulseSensor.samplesUntilReport == (byte) 0) {
162+
if ((pulseSensor.samplesUntilReport--) == 0) {
159163
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
160164
pulseSensor.outputSample();
161165
}

examples/TwoPulseSensors_On_OneArduino/TwoPulseSensors_On_OneArduino.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
should have been included with this software.
1919
2020
This software is not intended for medical use.
21+
22+
For more information on the PulseSensor methods and functions
23+
go to our Resources page
24+
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
2125
*/
2226

2327
/*
@@ -172,11 +176,11 @@ void loop() {
172176
*/
173177
if (pulseSensor.sawNewSample()) {
174178
/*
175-
Every so often, send the latest Sample.
179+
Every 20 milliseconds, send the latest Sample.
176180
We don't print every sample, because our baud rate
177181
won't support that much I/O.
178182
*/
179-
if (--pulseSensor.samplesUntilReport == (byte) 0) {
183+
if ((pulseSensor.samplesUntilReport--) == 0) {
180184
pulseSensor.samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
181185
pulseSensor.outputSample();
182186
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=PulseSensor Playground
2-
version=2.3.0
2+
version=2.4.0
33
author=Joel Murphy, Yury Gitman, Brad Needham
44
maintainer=Joel Murphy, Yury Gitman
55
sentence=Support at PulseSensor.com

resources/PulseSensor_V2_BPM_Prototype/PulseSensor_V2_BPM_Prototype.ino

Lines changed: 0 additions & 172 deletions
This file was deleted.

src/PulseSensorPlayground.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ bool PulseSensorPlayground::sawNewSample() {
128128
unsigned long nowMicros = micros();
129129
if ((long) (NextSampleMicros - nowMicros) > 0L) {
130130
result = false; // not time yet.
131+
return result;
131132
}
132133
NextSampleMicros = nowMicros + MICROS_PER_READ;
133134

0 commit comments

Comments
 (0)