File tree 1 file changed +43
-11
lines changed
1 file changed +43
-11
lines changed Original file line number Diff line number Diff line change @@ -168,27 +168,59 @@ class AlarmMatch {
168
168
};
169
169
170
170
class RTClock {
171
- private:
171
+ private:
172
172
bool is_initialized;
173
173
174
- public:
175
- RTClock ();
176
- ~RTClock ();
177
-
178
- bool begin ();
179
-
180
- bool getTime (RTCTime &t);
174
+ public:
175
+ inline RTClock () : is_initialized(false ) {}
176
+ inline ~RTClock () {}
177
+
178
+ inline bool begin () {
179
+ if (openRtc ()) {
180
+ is_initialized = true ;
181
+ } else {
182
+ is_initialized = false ;
183
+ }
184
+ return is_initialized;
185
+ }
186
+
187
+ inline bool getTime (RTCTime &t) {
188
+ struct tm present;
189
+ if (is_initialized) {
190
+ if ( getRtcTime (present) ) {
191
+ t.setTM (present);
192
+ return true ;
193
+ }
194
+ }
195
+ return false ;
196
+ }
181
197
182
198
bool setPeriodicCallback (rtc_cbk_t fnc, Period p);
183
199
bool setAlarmCallback (rtc_cbk_t fnc, RTCTime &t, AlarmMatch &m);
184
- bool setAlarm (RTCTime &t, AlarmMatch &m);
200
+
201
+ inline bool setAlarm (RTCTime &t, AlarmMatch &m) {
202
+ return setAlarmCallback (nullptr , t, m);
203
+ }
204
+
205
+ inline bool isRunning () {
206
+ return isRtcRunning ();
207
+ }
185
208
186
- bool isRunning ();
187
209
bool setTime (RTCTime &t);
188
- bool setTimeIfNotRunning (RTCTime &t);
189
210
211
+ inline bool setTimeIfNotRunning (RTCTime &t) {
212
+ if (!isRunning ()) {
213
+ return setTime (t);
214
+ }
215
+ return false ;
216
+ }
190
217
};
191
218
219
+
220
+ #if RTC_HOWMANY > 0
221
+ extern RTClock RTC;
222
+ #endif
223
+
192
224
extern RTClock RTC;
193
225
194
226
#endif
You can’t perform that action at this time.
0 commit comments