mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:53:23 +00:00
Location service: only request a fix once every 5 minutes
This should prevent the device from draining battery like crazy. This is not the same as the interval at which we record fixes - getting a fix every 5 minutes gives us a better chance to notice when we moved the minimum distance. Also add some more comments to the code that does the actual handling of storing the data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fb06d27593
commit
6124842b0c
1 changed files with 4 additions and 1 deletions
|
@ -17,6 +17,7 @@ GpsLocation::GpsLocation(QObject *parent)
|
|||
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
|
||||
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
||||
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
||||
gpsSource->setUpdateInterval(5 * 60 * 1000); // 5 minutes so the device doesn't drain the battery
|
||||
} else {
|
||||
status("don't have GPS source");
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ void GpsLocation::serviceEnable(bool toggle)
|
|||
}
|
||||
}
|
||||
|
||||
// these two need to become configurable
|
||||
#define MINTIME 600
|
||||
#define MINDIST 200
|
||||
|
||||
|
@ -53,7 +55,8 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
|
|||
lastCoord.setLongitude(geoSettings->value(QString("gpsFix%1_lon").arg(nr)).toInt() / 1000000.0);
|
||||
time_t lastTime = geoSettings->value(QString("gpsFix%1_time").arg(nr)).toULongLong();
|
||||
}
|
||||
// if we have no record stored or if at least 10 minutes have passed or we moved at least 200m
|
||||
// if we have no record stored or if at least the configured minimum
|
||||
// time has passed or we moved at least the configured minimum distance
|
||||
if (!nr || pos.timestamp().toTime_t() > lastTime + MINTIME || lastCoord.distanceTo(pos.coordinate()) > MINDIST) {
|
||||
geoSettings->setValue("count", nr + 1);
|
||||
geoSettings->setValue(QString("gpsFix%1_time").arg(nr), pos.timestamp().toTime_t());
|
||||
|
|
Loading…
Add table
Reference in a new issue