Browse Source

Moved RTC time update from GPS to Core workflow rather than position acquisition. Avoid edge cases where the spend time measurement could be wrong because of time update in between the two measure points.

tags/v1.2.0
Bertrand Lemasle 6 years ago
parent
commit
c7063a5698
3 changed files with 16 additions and 6 deletions
  1. +15
    -2
      GpsTracker/Core.cpp
  2. +1
    -0
      GpsTracker/Core.h
  3. +0
    -4
      GpsTracker/Positions.cpp

+ 15
- 2
GpsTracker/Core.cpp View File

@@ -7,14 +7,19 @@
using namespace utils; using namespace utils;


namespace core { namespace core {

uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS; uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS;
uint8_t stoppedInARow = SLEEP_DEFAULT_STOPPED_THRESHOLD - 1; uint8_t stoppedInARow = SLEEP_DEFAULT_STOPPED_THRESHOLD - 1;


void main() { void main() {
bool forceBackup = false; bool forceBackup = false;
positions::prepareBackup();
bool acquired = false;
PositionEntryMetadata metadata; PositionEntryMetadata metadata;
if (positions::acquire(metadata)) {

positions::prepareBackup();
acquired = positions::acquire(metadata);

if (acquired) {
positions::appendLast(metadata); positions::appendLast(metadata);
forceBackup = updateSleepTime(); forceBackup = updateSleepTime();


@@ -22,9 +27,17 @@ namespace core {
} }


positions::doBackup(forceBackup); positions::doBackup(forceBackup);

if (acquired) updateRtcTime();
mainunit::deepSleep(sleepTime); mainunit::deepSleep(sleepTime);
} }


void updateRtcTime() {
tmElements_t time;
gps::getTime(time);
rtc::setTime(time);
}

bool updateSleepTime() { bool updateSleepTime() {
uint8_t velocity = gps::getVelocity(); uint8_t velocity = gps::getVelocity();
uint16_t result = mapSleepTime(velocity); uint16_t result = mapSleepTime(velocity);


+ 1
- 0
GpsTracker/Core.h View File

@@ -14,6 +14,7 @@ namespace core {
extern uint16_t sleepTime; extern uint16_t sleepTime;


void main(); void main();
void updateRtcTime();
bool updateSleepTime(); bool updateSleepTime();
uint16_t mapSleepTime(uint8_t velocity); uint16_t mapSleepTime(uint8_t velocity);
} }

+ 0
- 4
GpsTracker/Positions.cpp View File

@@ -70,10 +70,6 @@ namespace positions {


uint16_t timeToFix = rtc::getTime() - before; uint16_t timeToFix = rtc::getTime() - before;


tmElements_t time;
gps::getTime(time);
rtc::setTime(time);

metadata = { metadata = {
battery.level, battery.level,
battery.voltage, battery.voltage,


Loading…
Cancel
Save