summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/sensorPlugins/stepCounter.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/daemon/sensorPlugins/stepCounter.cpp b/daemon/sensorPlugins/stepCounter.cpp
index 35618f2..4db6662 100644
--- a/daemon/sensorPlugins/stepCounter.cpp
+++ b/daemon/sensorPlugins/stepCounter.cpp
@@ -51,23 +51,23 @@ StepCounterPlugin::StepCounterPlugin(QObject *parent, int initInterval) :
void StepCounterPlugin::timeUpdate() {
QDateTime currDateTime = QDateTime::currentDateTime();
- if (lastRecordTime.date() < currDateTime.date()) {
- stepsOffset = stepcounterSensor->reading()->steps(); //this 'resets' the reading whenever the screen is first turned on after midnight. this means that, in the morning, the step count will always be zero, but steps taken just before midnight are still counted and not discarded.
- }
uint elapsed = currDateTime.toMSecsSinceEpoch() - 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 StepCounterPlugin::triggerRecording() {
+ if (lastRecordTime.date() < currDateTime.date()) {
+ stepsOffset = stepcounterSensor->reading()->steps(); //this 'resets' the reading whenever the screen is first turned on after midnight. this means that, in the morning, the step count will always be zero, but steps taken just before midnight are still counted and not discarded.
+ }
qDebug() << "stepcounter interval recording";
int steps = stepcounterSensor->reading()->steps();
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << " : " << steps << stepcounterSensor->isActive();
//we probably ought to do some error checking here
fileAddRecord(sensorPathPrefix,QString::number(steps - stepsOffset));
+ lastRecordTime = QDateTime::currentDateTime();
}