smart_alarm/alarm.h
2025-10-04 22:25:57 +02:00

40 lines
1.5 KiB
C++

#ifndef SMART_ALARM_PERSISTANCE_H
#define SMART_ALARM_PERSISTANCE_H
#include <array>
#include <cstdint>
#include <vector>
#include "pico/types.h"
struct alarm
{
private:
uint8_t scheduled; // BITs used to mark days 1 ring on that day 0 dosn't ring on that day last bit marks if it should rind only every other week, if all BITs are 0 it will ring only once
uint8_t hours_and_stuff_store; // if every other week is selected it will check first bit of this if it is 1 it will ring on even weeks and if 0 it will ring on odd week next 1 is enabled flags, next BIT is reserved rest is hours
uint8_t minutes_store;
public:
alarm(uint8_t hours, uint8_t minutes, const std::array<bool, 7> &days_enabled, bool every_other_week, bool even_week);
[[nodiscard]] uint8_t minutes() const;
[[nodiscard]] uint8_t hours() const;
[[nodiscard]] std::array<bool, 7> days_enabled() const;
[[nodiscard]] bool every_other_week() const;
[[nodiscard]] bool even_week() const;
[[nodiscard]] bool enabled() const;
void get_next_ring_time(datetime_t &ret) const;
// Enable/disable methods
void enable();
void disable();
void set_state(bool enabled);
void set_minutes(uint8_t minutes);
void set_hours(uint8_t hours);
void set_days_enabled(const std::array<bool, 7>& days_enabled);
void set_every_other_week(bool every_other_week);
void set_even_week(bool even_week);
};
extern std::vector<alarm> alarms;
void rearm_alarm_timers();
#endif //SMART_ALARM_PERSISTANCE_H