sforkowany z mirror/meshtastic-firmware
cleanup period stuff for new scheduler
rodzic
d4efb2c44c
commit
a6b98bec1f
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -18,5 +18,5 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
uint32_t doTask();
|
||||
void doTask();
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue