firmware/src/Periodic.h

23 lines
486 B
C
Raw Normal View History

#pragma once
#include <Arduino.h>
2020-02-21 16:41:36 +00:00
#include "PeriodicTask.h"
/**
* 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-21 16:41:36 +00:00
class Periodic : public PeriodicTask
{
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();
};