summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseniy-Movshev <dodoradio@outlook.com>2023-02-06 22:54:40 +0000
committerArseniy-Movshev <dodoradio@outlook.com>2023-02-07 12:21:59 +0000
commit31a0592f40ccbe0ed31abcd8bf39c2c00dab699a (patch)
tree0cc6648f060bfa5ca3975edb7d7e7addc7700048
parentba534a200056c44fca6ec129867cec27fccc6f7e (diff)
try to fix file overwriting instead of appending
Diffstat (limited to '')
-rw-r--r--sensors.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/sensors.cpp b/sensors.cpp
index df87122..ac286c1 100644
--- a/sensors.cpp
+++ b/sensors.cpp
@@ -81,19 +81,20 @@ void Logger::setupRecordHeartrate() {
}
void Logger::recordHeartrate() {
+ qDebug() << "bpm update received";
int bpm = heartrateSensor->reading()->bpm();
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << " : " << bpm << heartrateSensor->status() << heartrateSensor->isActive();
if ((bpm == 0) || (heartrateSensor->status() < 3)) {
return;
}
QFile file("out.txt");
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qDebug() << "failed to open file";
return;
}
+ file.seek(file.size());
QTextStream out(&file);
- while(!out.atEnd()){}
- out << QDateTime::currentSecsSinceEpoch() << " : " << bpm;
+ out << QDateTime::currentSecsSinceEpoch() << " : " << bpm << "\n";
qDebug() << "wrote to file";
heartrateSensor->stop();
file.close();