GY-63_MS5611/libraries/CountDown/CountDown.h

54 lines
1.2 KiB
C
Raw Normal View History

2020-11-27 05:10:47 -05:00
#pragma once
//
// FILE: CountDown.h
// AUTHOR: Rob Tillaart
2021-10-19 15:40:11 -04:00
// VERSION: 0.2.5
// PURPOSE: CountDown library for Arduino
2020-11-27 05:10:47 -05:00
// URL: https://github.com/RobTillaart/CountDown
//
2020-11-27 05:10:47 -05:00
// HISTORY: See CountDown.cpp
//
2021-01-29 06:31:58 -05:00
#include "Arduino.h"
2020-11-27 05:10:47 -05:00
2021-01-29 06:31:58 -05:00
2021-10-19 15:40:11 -04:00
#define COUNTDOWN_LIB_VERSION (F("0.2.5"))
2021-01-29 06:31:58 -05:00
class CountDown
{
public:
2020-11-27 05:10:47 -05:00
enum Resolution { MILLIS, MICROS, SECONDS, MINUTES };
explicit CountDown(const enum Resolution res = MILLIS);
2021-01-29 06:31:58 -05:00
void setResolution(const enum Resolution res = MILLIS);
bool start(uint32_t ticks);
// Implicit set resolution to SECONDS.
bool start(uint8_t days, uint16_t hours, uint32_t minutes, uint32_t seconds);
// Implicit set resolution to MINUTES.
bool start(uint8_t days, uint16_t hours, uint32_t minutes);
void stop();
void cont();
uint32_t remaining();
2021-01-29 06:31:58 -05:00
bool isRunning();
enum Resolution resolution() const { return _res; };
private:
enum State { RUNNING, STOPPED };
2020-11-27 05:10:47 -05:00
uint32_t _ticks;
uint32_t _remaining;
enum State _state;
enum Resolution _res;
2020-11-27 05:10:47 -05:00
uint32_t _starttime;
void calcRemaining();
};
2021-10-19 15:40:11 -04:00
2020-11-27 05:10:47 -05:00
// -- END OF FILE --