From ec42177b24b47ba68b3ae49634c942c76a9f92d4 Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 19 Mar 2023 11:14:04 +0000 Subject: Restructure to split to daemon and qml accessor - add separate subdirs for daemon and qml - add some generic qml boilerplate - add a really lazy 'last value' loader implementation - license the project as gplv3 (add copyright notices and license text) --- sensorPlugins/heartrateSensor.cpp | 53 --------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 sensorPlugins/heartrateSensor.cpp (limited to 'sensorPlugins/heartrateSensor.cpp') diff --git a/sensorPlugins/heartrateSensor.cpp b/sensorPlugins/heartrateSensor.cpp deleted file mode 100644 index 3477e9a..0000000 --- a/sensorPlugins/heartrateSensor.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include - -#include "../logger.h" - -#include "heartrateSensor.h" - -HeartrateSensorPlugin::HeartrateSensorPlugin(QObject *parent, int initInterval) : - QObject(parent){ - interval = initInterval; - - hrmSensor = new QHrmSensor(this); - connect(hrmSensor,SIGNAL(readingChanged()),this,SLOT(finishRecording())); - - qDebug() << "heartrate sensor is enabled. interval is (ms) " << interval; - recordIntervalTimer = new QTimer(this); - connect(recordIntervalTimer,SIGNAL(timeout()),this,SLOT(triggerRecording())); - recordIntervalTimer->setSingleShot(true); - recordIntervalTimer->start(interval); - lastRecordTime = QDateTime::currentDateTime(); -} - -void HeartrateSensorPlugin::timeUpdate() { - uint elapsed = QDateTime::currentMSecsSinceEpoch() - lastRecordTime.toMSecsSinceEpoch(); - qDebug() << "time until next steps recording" << recordIntervalTimer->remainingTime() << " elapsed = " << elapsed << " lastRecordTime " << lastRecordTime.toMSecsSinceEpoch(); - if (elapsed > interval) { //if too much time has passed, reset the timer and record - triggerRecording(); - lastRecordTime = QDateTime::currentDateTime(); - } else { //otherwise, restart the timer and compensate for time spent in suspend - recordIntervalTimer->start(interval - elapsed); - } -} - -void HeartrateSensorPlugin::triggerRecording() { - qDebug() << "heartrate interval recording"; - recordIntervalTimer->start(interval); - hrmSensor->start(); -} - -void HeartrateSensorPlugin::finishRecording() { - qDebug() << "bpm update received"; - int bpm = hrmSensor->reading()->bpm(); - qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << " : " << bpm << hrmSensor->status() << hrmSensor->isActive(); - if ((bpm == 0) || (hrmSensor->status() < 3)) { - qDebug() << "hrm sensor accuracy insufficient. waiting."; - return; - } - fileAddRecord(sensorPathPrefix,QString::number(bpm)); - hrmSensor->stop(); -} -- cgit v1.2.3-54-g00ecf