mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
pulsensor: updated example and fixed variable in new API
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
21eb2de086
commit
33c123420a
@ -28,7 +28,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
int doWork = 0;
|
int doWork = 0;
|
||||||
pulsensor_context sensor_ctx;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sig_handler(int signo)
|
sig_handler(int signo)
|
||||||
@ -49,13 +48,13 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
init_pulsensor (&sensor_ctx, handler);
|
Pulsensor *sensor = new Pulsensor(handler);
|
||||||
|
|
||||||
start_sampler (&sensor_ctx);
|
sensor->start_sampler();
|
||||||
while (!doWork) {
|
while (!doWork) {
|
||||||
usleep (5);
|
usleep (5);
|
||||||
}
|
}
|
||||||
stop_sampler (&sensor_ctx);
|
sensor->stop_sampler();
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ Pulsensor::Pulsensor (Callback *obj_call) : pin_ctx(0)
|
|||||||
bpm = 0;
|
bpm = 0;
|
||||||
qs = FALSE;
|
qs = FALSE;
|
||||||
apmlitude = 100;
|
apmlitude = 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Pulsensor::Pulsensor (callback_handler handler) : pin_ctx(0)
|
Pulsensor::Pulsensor (callback_handler handler) : pin_ctx(0)
|
||||||
@ -79,7 +78,7 @@ void Pulsensor::start_sampler ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Pulsensor::stop_sampler () {
|
void Pulsensor::stop_sampler () {
|
||||||
Pulsensor::ctx_counter--;
|
ctx_counter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Pulsensor::do_sample (void *arg) {
|
void *Pulsensor::do_sample (void *arg) {
|
||||||
@ -88,7 +87,7 @@ void *Pulsensor::do_sample (void *arg) {
|
|||||||
|
|
||||||
Pulsensor *pulsensor = static_cast<Pulsensor *>(arg);
|
Pulsensor *pulsensor = static_cast<Pulsensor *>(arg);
|
||||||
|
|
||||||
while (Pulsensor::ctx_counter) {
|
while (pulsensor->ctx_counter) {
|
||||||
data_from_sensor = pulsensor->pin_ctx.read ();
|
data_from_sensor = pulsensor->pin_ctx.read ();
|
||||||
pulsensor->ret = FALSE;
|
pulsensor->ret = FALSE;
|
||||||
|
|
||||||
|
@ -118,6 +118,6 @@ private:
|
|||||||
#else
|
#else
|
||||||
callback_handler callback; /**< The callback function */
|
callback_handler callback; /**< The callback function */
|
||||||
#endif
|
#endif
|
||||||
static volatile uint16_t ctx_counter;
|
volatile uint16_t ctx_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user