2020-02-15 19:15:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
2020-02-21 16:41:36 +00:00
|
|
|
#include "PeriodicTask.h"
|
2020-02-15 19:15:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Periodically invoke a callback.
|
|
|
|
*
|
2020-02-21 16:41:36 +00:00
|
|
|
* This just provides C style callback conventions rather than a virtual function - FIXME, remove?
|
2020-02-15 19:15:43 +00:00
|
|
|
*/
|
2020-02-21 16:41:36 +00:00
|
|
|
class Periodic : public PeriodicTask
|
2020-02-15 19:15:43 +00:00
|
|
|
{
|
|
|
|
uint32_t (*callback)();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
|
|
|
|
Periodic(uint32_t (*_callback)()) : callback(_callback) {}
|
|
|
|
|
2020-02-21 16:41:36 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
uint32_t doTask();
|
2020-02-15 19:15:43 +00:00
|
|
|
};
|