LTPS C++ API
rtc.h
1 
6 #ifndef __LRTC_H__
7 #define __LRTC_H__
8 
9 #include <stdint.h>
10 
11 
17 struct RtcTime
18 {
19  // Seconds (0...59)
20  uint8_t sec;
21 
22  // Minutes (0...59)
23  uint8_t min;
24 
25  // Hours (0...23)
26  uint8_t hour;
27 
28  // Day of the week (1...7)
29  uint8_t wday;
30 
31  // Day of the month (1...31)
32  uint8_t mday;
33 
34  // Month (1...12)
35  uint8_t mon;
36 
37  // Year
38  int year;
39 
40  // Year in short notation (auto calculation)
41  uint8_t year_s;
42 
43  // Saylight saving time (0...1)
44  uint8_t isdst;
45 };
46 
47 
53 struct RtcAlarm
54 {
55  // Seconds (0...59)
56  uint8_t sec;
57 
58  // Minutes (0...59)
59  uint8_t min;
60 
61  // Hours (0...23)
62  uint8_t hour;
63 
64  // Day of the week (1...7) or day of the month (1...31)
65  uint8_t day;
66 };
67 
68 
74 struct RtcTemp
75 {
77  float temp;
78 
80  int status;
81 
83  const char* error;
84 };
85 
86 
92 struct RtcClock
93 {
96 
98  int status;
99 
101  const char* error;
102 };
103 
104 
111 {
113  bool seconds;
114 
116  bool minites;
117 
119  bool hours;
120 
122  bool days;
123 
125  bool wdays;
126 
128  int status;
129 
131  const char* error;
132 };
133 
134 
140 struct RtcResult
141 {
143  int status;
144 
146  const char* error;
147 };
148 
149 
156 {
158  bool triggered;
159 
161  int status;
162 
164  const char* error;
165 };
166 
167 
173 struct RtcSram
174 {
176  uint8_t address;
177 
179  uint8_t value;
180 
182  int status;
183 
185  const char* error;
186 };
187 
188 
194 class Rtc
195 {
196 public:
197 
198  Rtc();
199 
200  virtual ~Rtc();
201 
203 
207  void getTemperature(const char *socket, RtcTemp &temp);
208 
210 
214  void setTime(const char* socket, RtcClock &time);
215 
217 
221  void getTime(const char* socket, RtcClock &time);
222 
224 
229  void setAlarm1(const char* socket, RtcAlarm& alarm, RtcAlarmFlags& flags);
230 
232 
237  void setAlarm2(const char* socket, RtcAlarm& alarm, RtcAlarmFlags& flags);
238 
240 
245  void getAlarm1(const char* socket, RtcAlarm& alarm, RtcAlarmFlags& flags);
246 
248 
253  void getAlarm2(const char* socket, RtcAlarm& alarm, RtcAlarmFlags& flags);
254 
256 
262  void enableAlarms(const char* socket, bool alarm1, bool alarm2, RtcResult& result);
263 
265 
269  void stopAlarm1(const char* socket, RtcResult& result);
270 
272 
276  void stopAlarm2(const char* socket, RtcResult& result);
277 
279 
283  void isAlarm1Triggered(const char* socket, RtcAlarmsStatus& status);
284 
286 
290  void isAlarm2Triggered(const char* socket, RtcAlarmsStatus& status);
291 
293 
297  void setSramValue(const char* socket, RtcSram& sram);
298 
300 
304  void getSramValue(const char* socket, RtcSram& sram);
305 };
306 
307 #endif
bool days
Days (false to enable, true to disable)
Definition: rtc.h:122
void getAlarm1(const char *socket, RtcAlarm &alarm, RtcAlarmFlags &flags)
Get time for Alarm 1.
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:128
Struct with SRAM registers for RTC.
Definition: rtc.h:173
float temp
Temperature in C degrees.
Definition: rtc.h:77
bool triggered
Return true, if alarm is triggered.
Definition: rtc.h:158
void isAlarm2Triggered(const char *socket, RtcAlarmsStatus &status)
Check Alarm 2 triggered status.
Class for RTC tibbit control (Tibbit #42)
Definition: rtc.h:194
Struct with time for alarms in RTC Tibbit.
Definition: rtc.h:53
uint8_t value
Value.
Definition: rtc.h:179
RtcTime time
Time.
Definition: rtc.h:95
uint8_t address
SRAM address (256 bytes: 0x00...0xFF)
Definition: rtc.h:176
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:98
bool minites
Minutes (false to enable, true to disable)
Definition: rtc.h:116
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:185
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:80
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:83
void getSramValue(const char *socket, RtcSram &sram)
Get value from SRAM memory.
void getTime(const char *socket, RtcClock &time)
Get current time.
void setAlarm1(const char *socket, RtcAlarm &alarm, RtcAlarmFlags &flags)
Set time for Alarm 1.
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:146
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:164
void getAlarm2(const char *socket, RtcAlarm &alarm, RtcAlarmFlags &flags)
Get time for Alarm 2.
void setSramValue(const char *socket, RtcSram &sram)
Write value to SRAM memory.
Struct with alarms triggered status for RTC.
Definition: rtc.h:155
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:101
void stopAlarm1(const char *socket, RtcResult &result)
Clear Alarm 1 triggered status.
Struct with time for clock in RTC Tibbit.
Definition: rtc.h:17
bool seconds
Seconds (false to enable, true to disable) - does not matter for Alarm 2.
Definition: rtc.h:113
bool hours
Hours (false to enable, true to disable)
Definition: rtc.h:119
bool wdays
Day of week == true/day of month == false.
Definition: rtc.h:125
void enableAlarms(const char *socket, bool alarm1, bool alarm2, RtcResult &result)
Activate alarms pin (if slot activated, INT/MISO pin will be set to LOW when alarms triggered) ...
void setAlarm2(const char *socket, RtcAlarm &alarm, RtcAlarmFlags &flags)
Set time for Alarm 2.
void getTemperature(const char *socket, RtcTemp &temp)
Get current temperature in Celsius degrees.
void isAlarm1Triggered(const char *socket, RtcAlarmsStatus &status)
Check Alarm 1 triggered status.
const char * error
String error if something goes wrong (NULL for success)
Definition: rtc.h:131
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:182
Struct with alarm flags for RTC.
Definition: rtc.h:110
void setTime(const char *socket, RtcClock &time)
Set current time.
void stopAlarm2(const char *socket, RtcResult &result)
Clear Alarm 2 triggered status.
Struct with some operations result for RTC.
Definition: rtc.h:140
Struct with time for DS3234.
Definition: rtc.h:92
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:143
int status
Return status (EXIT_SUCCESS or EXIT_FAILURE)
Definition: rtc.h:161
Struct with temperature for DS3234.
Definition: rtc.h:74