mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-06-27 00:31:32 +02:00
27 lines
519 B
C++
27 lines
519 B
C++
#include "AgSchedule.h"
|
|
|
|
AgSchedule::AgSchedule(int period, void (*handler)(void))
|
|
: period(period), handler(handler) {}
|
|
|
|
AgSchedule::~AgSchedule() {}
|
|
|
|
void AgSchedule::run(void) {
|
|
uint32_t ms = (uint32_t)(millis() - count);
|
|
if (ms >= period) {
|
|
handler();
|
|
count = millis();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Set schedule period
|
|
*
|
|
* @param period Period in ms
|
|
*/
|
|
void AgSchedule::setPeriod(int period) { this->period = period; }
|
|
|
|
/**
|
|
* @brief Update period
|
|
*/
|
|
void AgSchedule::update(void) { count = millis(); }
|