iot-firmware/src/espmega_iot_timer.hpp

48 lines
1.3 KiB
C++
Raw Normal View History

2023-09-29 17:37:31 +00:00
#pragma once
2023-11-15 09:55:43 +00:00
2023-09-29 17:37:31 +00:00
#include <ESPMegaPRO.h>
2023-11-15 09:55:43 +00:00
/**
* @brief Class representing a timer for ESPMega board.
*
*/
2023-09-29 17:56:25 +00:00
class ESPMega_Timer {
2023-09-29 17:37:31 +00:00
public:
2023-11-15 09:55:43 +00:00
/**
* @brief Loop function to be called in the main loop.
*
*/
2023-09-29 17:37:31 +00:00
void loop();
2023-11-15 09:55:43 +00:00
/**
* @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.
*
*/
2023-09-29 17:56:25 +00:00
void begin();
2023-11-15 09:55:43 +00:00
2023-09-29 17:37:31 +00:00
private:
uint8_t today;
uint8_t timer_ran_today;
uint8_t hr;
uint8_t min;
uint32_t fram_address;
void (*timer_callback)();
};