-
Notifications
You must be signed in to change notification settings - Fork 0
/
myclock.h
46 lines (37 loc) · 1.43 KB
/
myclock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/***************************************************************************
* *
* Copyright (C) 2021 by Patrycja Rafalko *
* *
* https://github.com/prafalko *
* *
***************************************************************************/
#ifndef MYCLOCK_H
#define MYCLOCK_H
#include "mydatetime.h"
#include "settings.h"
extern "C"
{
#include <stdio.h>
}
class MyClock
{
public:
MyClock(const MyDateTime& dateTime = {});
MyClock(uint8_t month, uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds = 0);
void clockTick();
void setDateTime(const MyDateTime& dateTime);
const MyDateTime& getDateTime() const;
const uint8_t& getTimeSeconds() const;
bool operator<=(const MyDateTime& rmyClock) const;
bool operator>=(const MyDateTime& rmyClock) const;
private:
void updateClock();
MyDateTime mDateTime;
#if USE_SECONDS
uint8_t* mSecondsPtr = &mDateTime.myTime.seconds;
#else
uint8_t mSeconds; //MyDateTime doesn't keep seconds if USE_SECONDS is set to false, so we need a separate second counter to observe elapsing time
uint8_t* mSecondsPtr = &mSeconds;
#endif
};
#endif // MYCLOCK_H