33 lines
853 B
C++
33 lines
853 B
C++
#ifndef _INTERVAL_H_
|
|
#define _INTERVAL_H_
|
|
|
|
/* Interval
|
|
* Copyright (C) 2014, 2016, 2018, 2019 Pavel Brychta http://www.xpablo.cz
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify it under the terms of the MIT License
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
|
|
class Interval
|
|
{
|
|
protected:
|
|
uint32_t _timefrom;
|
|
uint32_t _timeout;
|
|
uint8_t _mode; // mode of actual operation (compatibility, oneshot, periodic)
|
|
uint8_t _done;
|
|
public:
|
|
Interval(): _mode(0), _done(0xff) {} // compatibility mode autostart
|
|
Interval(uint32_t tmout): _timeout(tmout), _mode(2), _done(0xff) {} // periodic mode autostart
|
|
bool expired(void);
|
|
void set(uint32_t tmout);
|
|
void setOneshot(uint32_t tmout);
|
|
void setPeriodic(uint32_t tmout);
|
|
void reload(void);
|
|
uint32_t elapsed(void);
|
|
uint32_t remains(void);
|
|
};
|
|
|
|
#endif
|
|
// EOF
|