iot-firmware/src/espmega_iot_timer.hpp

48 lines
1.3 KiB
C++

#pragma once
#include <ESPMegaPRO.h>
/**
* @brief Class representing a timer for ESPMega board.
*
*/
class ESPMega_Timer {
public:
/**
* @brief Loop function to be called in the main loop.
*
*/
void loop();
/**
* @brief Constructor for ESPMega_Timer class.
*
* @param hour The hour at which the timer should trigger.
* @param minute The minute at which the timer should trigger.
* @param timer_callback The function to be called when the timer triggers.
* @param fram_address The address of the FRAM memory to store the timer state.
*/
ESPMega_Timer(uint8_t hour, uint8_t minute, void(*timer_callback)(), uint32_t fram_address);
/**
* @brief Set the hour and minute at which the timer should trigger.
*
* @param hour The hour at which the timer should trigger.
* @param minute The minute at which the timer should trigger.
*/
void set(uint8_t hour, uint8_t minute);
/**
* @brief Begin the timer.
*
*/
void begin();
private:
uint8_t today;
uint8_t timer_ran_today;
uint8_t hr;
uint8_t min;
uint32_t fram_address;
void (*timer_callback)();
};