Comments (6)
Oh..! I forgot to check one thing..lol..
I'm editing pulsesensorground.cpp like
/*
A central Playground object to manage a set of PulseSensors.
See https://www.pulsesensor.com to get started.
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.
*/
#include <PulseSensorPlayground.h>
// Define the "this" pointer for the ISR
PulseSensorPlayground *PulseSensorPlayground::OurThis;
PulseSensorPlayground::PulseSensorPlayground(int numberOfSensors) {
// Save a static pointer to our playground so the ISR can read it.
OurThis = this;
// Dynamically create the array to minimize ram usage.
SensorCount = (byte) numberOfSensors;
Sensors = new PulseSensor[SensorCount];
#if PULSE_SENSOR_TIMING_ANALYSIS
// We want sample timing analysis, so we construct it.
pTiming = new PulseSensorTimingStatistics(MICROS_PER_READ, 500 * 30L);
#endif // PULSE_SENSOR_TIMING_ANALYSIS
}
boolean PulseSensorPlayground::PulseSensorPlayground::begin() {
for (int i = 0; i < SensorCount; ++i) {
Sensors[i].initializeLEDs();
}
// Note the time, for non-interrupt sampling and for timing statistics.
NextSampleMicros = micros() + MICROS_PER_READ;
SawNewSample = false;
#if PULSE_SENSOR_MEMORY_USAGE
// Report the RAM usage and hang.
printMemoryUsage();
for (;;);
#endif // PULSE_SENSOR_MEMORY_USAGE
// Lastly, set up and turn on the interrupts.
if (UsingInterrupts) {
if (!PulseSensorPlaygroundSetupInterrupt()) {
// The user requested interrupts, but they aren't supported. Say so.
return false;
}
}
return true;
}
void PulseSensorPlayground::analogInput(int inputPin, int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return; // out of range.
}
Sensors[sensorIndex].analogInput(inputPin);
}
void PulseSensorPlayground::blinkOnPulse(int blinkPin, int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return; // out of range.
}
Sensors[sensorIndex].blinkOnPulse(blinkPin);
}
void PulseSensorPlayground::fadeOnPulse(int fadePin, int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return; // out of range.
}
Sensors[sensorIndex].fadeOnPulse(fadePin);
}
boolean PulseSensorPlayground::sawNewSample() {
/*
If using interrupts, this function reads and clears the
'saw a sample' flag that is set by the ISR.
When not using interrupts, this function sees whether it's time
to sample and, if so, reads the sample and processes it.
*/
if (UsingInterrupts) {
// Disable interrupts to avoid a race with the ISR.
DISABLE_PULSE_SENSOR_INTERRUPTS;
boolean sawOne = SawNewSample;
SawNewSample = false;
ENABLE_PULSE_SENSOR_INTERRUPTS;
return sawOne;
}
// Not using interrupts
unsigned long nowMicros = micros();
if ((long) (NextSampleMicros - nowMicros) > 0L) {
return false; // not time yet.
}
NextSampleMicros = nowMicros + MICROS_PER_READ;
#if PULSE_SENSOR_TIMING_ANALYSIS
if (pTiming->recordSampleTime() <= 0) {
pTiming->outputStatistics(SerialOutput.getSerial());
for (;;); // Hang because we've disturbed the timing.
}
#endif // PULSE_SENSOR_TIMING_ANALYSIS
// Act as if the ISR was called.
onSampleTime();
SawNewSample = false;
return true;
}
void PulseSensorPlayground::onSampleTime() {
// Typically called from the ISR.
/*
Read the voltage from each PulseSensor.
We do this separately from processing the voltages
to minimize jitter in acquiring the signal.
*/
for (int i = 0; i < SensorCount; ++i) {
Sensors[i].readNextSample();
}
// Process those voltages.
for (int i = 0; i < SensorCount; ++i) {
Sensors[i].processLatestSample();
Sensors[i].updateLEDs();
}
// Set the flag that says we've read a sample since the Sketch checked.
SawNewSample = true;
}
int PulseSensorPlayground::getLatestSample(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return -1; // out of range.
}
return Sensors[sensorIndex].getLatestSample();
}
int PulseSensorPlayground::getBeatsPerMinute(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return -1; // out of range.
}
return Sensors[sensorIndex].getBeatsPerMinute();
}
int PulseSensorPlayground::getInterBeatIntervalMs(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return -1; // out of range.
}
return Sensors[sensorIndex].getInterBeatIntervalMs();
}
boolean PulseSensorPlayground::sawStartOfBeat(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return false; // out of range.
}
return Sensors[sensorIndex].sawStartOfBeat();
}
boolean PulseSensorPlayground::isInsideBeat(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return false; // out of range.
}
return Sensors[sensorIndex].isInsideBeat();
}
void PulseSensorPlayground::setSerial(Stream &output) {
SerialOutput.setSerial(output);
}
void PulseSensorPlayground::setOutputType(byte outputType) {
SerialOutput.setOutputType(outputType);
}
void PulseSensorPlayground::setThreshold(int threshold, int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return; // out of range.
}
Sensors[sensorIndex].setThreshold(threshold);
}
void PulseSensorPlayground::outputSample() {
SerialOutput.outputSample(Sensors, SensorCount);
}
void PulseSensorPlayground::outputBeat(int sensorIndex) {
SerialOutput.outputBeat(Sensors);
}
void PulseSensorPlayground::outputToSerial(char s, int d) {
SerialOutput.outputToSerial(s,d);
}
int PulseSensorPlayground::getPulseAmplitude(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return -1; // out of range.
}
return Sensors[sensorIndex].getPulseAmplitude();
}
unsigned long PulseSensorPlayground::getLastBeatTime(int sensorIndex) {
if (sensorIndex != constrain(sensorIndex, 0, SensorCount)) {
return -1; // out of range.
}
return Sensors[sensorIndex].getLastBeatTime();
}
#if PULSE_SENSOR_MEMORY_USAGE
void PulseSensorPlayground::printMemoryUsage() {
char stack = 1;
extern char *__data_start;
extern char *__data_end;
extern char *__bss_start;
extern char *__bss_end;
extern char *__heap_start;
extern char *__heap_end;
int data_size = (int)&__data_end - (int)&__data_start;
int bss_size = (int)&__bss_end - (int)&__data_end;
int heap_end = (int)&stack - (int)&__malloc_margin;
int heap_size = heap_end - (int)&__bss_end;
int stack_size = RAMEND - (int)&stack + 1;
int available = (RAMEND - (int)&__data_start + 1);
available -= data_size + bss_size + heap_size + stack_size;
Stream *pOut = SerialOutput.getSerial();
if (pOut) {
pOut->print(F("data "));
pOut->println(data_size);
pOut->print(F("bss "));
pOut->println(bss_size);
pOut->print(F("heap "));
pOut->println(heap_size);
pOut->print(F("stack "));
pOut->println(stack_size);
pOut->print(F("total "));
pOut->println(data_size + bss_size + heap_size + stack_size);
}
}
#endif // PULSE_SENSOR_MEMORY_USAGE
and I will check it..!! sorry..!!
from pulsesensorplayground.
after I did edit like ↑, there were error like
arduino:1.8.8 Hourly Build 2018/11/27 05:33 (Windows 10), board:"Arduino/Genuino MKR1000"
C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src\PulseSensorPlayground.cpp: In member function 'void PulseSensorPlayground::outputBeat(int)':
C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src\PulseSensorPlayground.cpp:204:34: error: no matching function for call to 'PulseSensorSerialOutput::outputBeat(PulseSensor*&)'
SerialOutput.outputBeat(Sensors);
^
C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src\PulseSensorPlayground.cpp:204:34: note: candidate is:
In file included from C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src/PulseSensorPlayground.h:122:0,
from C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src\PulseSensorPlayground.cpp:16:
C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src/utility/PulseSensorSerialOutput.h:72:10: note: void PulseSensorSerialOutput::outputBeat(PulseSensor*, int, int)
void outputBeat(PulseSensor sensors[], int numberOfSensors, int sensorIndex);
^
C:\Users\jisoo\Documents\Arduino\libraries\PulseSensorPlayground-master\src/utility/PulseSensorSerialOutput.h:72:10: note: candidate expects 3 arguments, 1 provided
exit status 1
board Arduino/Genuino MKR1000 compile error
how can I modify code to do exactly?
from pulsesensorplayground.
@biojisoo
Woah, you really went down into a rabbit hole there! No need to edit the library files. While it's great that you can, it's much easier to get what you want in the sketch. Since all you want to do is print the BPM, use the function call getBeatsPerMinute()
which will return the latest BPM as an int variable. Starting with the example sketch, just edit that so that you create a variable to receive the BPM, and then print that. You can also use a call to sawStartOfBeat()
which will return true if there is a beat so that you always get the latest and greatest BPM.
You can find that function and other super cool functions in the PulseSensor Toolbox
from pulsesensorplayground.
Thank you ! I will try it! After it, I will post it on here!
from pulsesensorplayground.
biojisoo, did you ever get this to work? I am currently trying to get the BPM value to store as a variable with the MKR1000 with their BPM_Alternative script. If so could you post script for this? or even let me know what had to be altered in the example script file? Much appreciated, thanks. This is for a university project that i am trying to make
from pulsesensorplayground.
from pulsesensorplayground.
Related Issues (20)
- Generating RMSSD and SDNN from IBI, BPM data HOT 2
- Adafruit Feather nRF52832 Compatibility? HOT 4
- Do we need to set THRESHOLD twice when we use 2 pulsesensors at once? HOT 2
- USE_ARDUINO_INTERRUPTS problem with NodeMCU 0.9 HOT 3
- GETTING STARTED WORKING BUT NOT GETTING BPM TO MONITOR HOT 5
- Quick question, my smart meter has a pulse HOT 1
- Getting_BPM_to_monitor sketch displaying random values at 11250 baud HOT 8
- Node MCU V1 - Plotter is working but no BPM in Monitor HOT 3
- I'm getting high BPM HOT 1
- Code error for sp32 pulse sensor data to thinspeak HOT 19
- Compatibility issue Nano BLE ABX00034 HOT 6
- PulseSensr_BPM_Alternative Compilation Errors HOT 7
- turning off/on the bright light when needed HOT 2
- Can't compile even when including "USE_ARDUINO_INTERRUPTS true" HOT 14
- GETTING STARTED WORKING BUT NOT GETTING BPM TO MONITOR , ALTERNATIVE HOT 1
- No BPM readings HOT 3
- Problem about sensor when connecting with Arduino NANO 33 loT HOT 3
- Pulse sensor BPM_to_Monitor script does not work on Arduino Nano Every HOT 5
- example for esp8266 HOT 3
- sampleTimer.stop() and sampleTimer.start issues HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pulsesensorplayground.