-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeSablier.h
203 lines (170 loc) · 5.06 KB
/
LeSablier.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/**
* \file LeSablier.h
* \brief Main file
* \author Theophile `TWal` Wallez
*/
/**
* \mainpage LeSablier API reference
* \section Requirements
* * Arduino: http://arduino.cc
* * Le Sablier: http://shop.snootlab.com/lang-en/snootlab-shields/203-le-sablier.html
* \section Examples
* * SerialClock: a clock communicating via serial port
* * DeuligneClock: a clock displaying the time with the Deuligne
* * SetTime: Change the time via serial port
* * Language: Demonstration of LeSablier's language support
* \section Installation
* Like every other arduino library: http://arduino.cc/en/Hacking/Libraries
*/
#ifndef LESABLIER_H
#define LESABLIER_H
#include <Arduino.h>
#include "LeSablierConfig.h"
/**
* \class LeSablier_
* \brief The class that communicate with LeSablier
/!\ Don't instanciate it! Use LeSablier object instead (note the trailing underscore in the class name)
*/
class LeSablier_ {
public:
/**
* \brief Begin the communication with LeSablier
*/
void begin();
/**
* \brief End the communication with LeSablier
*/
void end();
/**
* \brief Force update (request the time frop LeSablier) (internal)
*/
void update();
/**
* \brief Force update, but only if required (internal)
*/
void fastUpdate();
/**
* \brief Update the temperature (internal)
*/
void updateTemp();
/**
* \brief Request the current year. Range: 0-99. 0 is year 2000
* \return The current year
*/
uint8_t getYear();
/**
* \brief Request the current month. Range: 1-12. 1 is January
* \return The current month
*/
uint8_t getMonth();
/**
* \brief Request the current day of the week. Range: 1-7. 1 is Monday
* \return The current day of the week
*/
uint8_t getDay();
/**
* \brief Request the current day of the month. Range: 1-31.
* \return The current day of the month
*/
uint8_t getDate();
/**
* \brief Request the current hour. Range: 0-23.
* \return The current hour
*/
uint8_t getHours();
/**
* \brief Request the current minute. Range: 0-59.
* \return The current minute
*/
uint8_t getMinutes();
/**
* \brief Request the current second. Range: 0-59.
* \return The current second
*/
uint8_t getSeconds();
/**
* \brief Request the current temperature. /!\ Update every 64s
* \return The current temperature
*/
float getTemp();
/**
* \brief Change the year
* \param year The year
*/
void setYear(uint8_t year);
/**
* \brief Change the month
* \param month The month
*/
void setMonth(uint8_t month);
/**
* \brief Change the day of the week
* \param day The day of the week
*/
void setDay(uint8_t day);
/**
* \brief Change the day of the month
* \param date The day of the month
*/
void setDate(uint8_t date);
/**
* \brief Change the hour
* \param hours The hour
*/
void setHours(uint8_t hours);
/**
* \brief Change the minute
* \param minutes The minute
*/
void setMinutes(uint8_t minutes);
/**
* \brief Change the second
* \param seconds The second
*/
void setSeconds(uint8_t seconds);
/**
* \brief Change all the parameters!
* \param day The day of the week
* \param date The day of the month
* \param month The month
* \param year The year
* \param hours The hour
* \param minutes The minute
* \param seconds The second
*/
void setAll(uint8_t day, uint8_t date, uint8_t month, uint8_t year, uint8_t hours, uint8_t minutes, uint8_t seconds);
#ifdef LESABLIER_DAY_NAMES
/**
* \brief Request the current day of the week, as string.
Change the language trough LeSablierConfig.h
* \return The current day of the week as string
*/
const char* getDayStr();
#endif
#ifdef LESABLIER_MONTH_NAMES
/**
* \brief Request the current month, as string.
Change the language trough LeSablierConfig.h
* \return The current month as string
*/
const char* getMonthStr();
#endif
private:
uint8_t _year;
uint8_t _month;
uint8_t _day;
uint8_t _date;
uint8_t _hours;
uint8_t _minutes;
uint8_t _seconds;
float _temp;
unsigned long _lastUpdate;
uint8_t _bcd2dec(uint8_t bcd);
uint8_t _dec2bcd(uint8_t dec);
};
/**
* \var LeSablier
* \brief The object to use to communicate with LeSablier
*/
extern LeSablier_ LeSablier;
#endif