cleanup period stuff for new scheduler

1.2-legacy
geeksville 2020-02-21 10:20:47 -08:00
rodzic d4efb2c44c
commit a6b98bec1f
5 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -70,7 +70,7 @@ uint32_t GPS::getValidTime()
return timeSetFromGPS ? getTime() : 0;
}
uint32_t GPS::doTask()
void GPS::doTask()
{
#ifdef GPS_RX_PIN
// Consume all characters that have arrived
@ -111,7 +111,7 @@ uint32_t GPS::doTask()
}
// Once we have sent a location we only poll the GPS rarely, otherwise check back every 100ms until we have something over the serial
return hasValidLocation ? 30 * 1000 : 100;
setPeriod(hasValidLocation ? 30 * 1000 : 100);
}
String GPS::getTimeStr()

Wyświetl plik

@ -27,7 +27,7 @@ public:
virtual void loop();
virtual uint32_t doTask();
virtual void doTask();
/// If we haven't yet set our RTC this boot, set it from a GPS derived time
void perhapsSetRTC(const struct timeval *tv);

Wyświetl plik

@ -18,5 +18,5 @@ public:
protected:
uint32_t doTask();
void doTask();
};

Wyświetl plik

@ -12,8 +12,12 @@ void PeriodicTask::loop()
if (period && (now - lastMsec) >= period)
{
lastMsec = now;
period = doTask();
doTask();
}
}
uint32_t Periodic::doTask() { return callback(); }
void Periodic::doTask()
{
uint32_t p = callback();
setPeriod(p);
}

Wyświetl plik

@ -25,6 +25,9 @@ public:
/// call this from loop
virtual void loop();
/// Set a new period in msecs (can be called from doTask or elsewhere and the scheduler will cope)
void setPeriod(uint32_t p) { period = p; }
protected:
virtual uint32_t doTask() = 0;
virtual void doTask() = 0;
};