@@ -8,7 +8,7 @@ namespace espp {
88// / @brief The BM8563 RTC driver.
99// / @details This driver is for the BM8563 RTC chip.
1010// /
11- // / \section Example
11+ // / \section bm8563_ex1 Example
1212// / \snippet bm8563_example.cpp bm8563 example
1313class Bm8563 : public BasePeripheral <> {
1414public:
@@ -21,19 +21,56 @@ class Bm8563 : public BasePeripheral<> {
2121 uint8_t month; // /< The month.
2222 uint8_t weekday; // /< The day of the week.
2323 uint8_t day; // /< The day of the month.
24+
25+ // / @brief Equality operator.
26+ // / @param other The other date.
27+ // / @return True if equal, false otherwise.
28+ bool operator ==(const Date &other) const {
29+ return year == other.year && month == other.month && weekday == other.weekday &&
30+ day == other.day ;
31+ }
32+
33+ // / @brief Inequality operator.
34+ // / @param other The other date.
35+ // / @return True if not equal, false otherwise.
36+ bool operator !=(const Date &other) const { return !(*this == other); }
2437 };
2538
2639 // / @brief The time structure.
2740 struct Time {
2841 uint8_t hour; // /< The hour.
2942 uint8_t minute; // /< The minute.
3043 uint8_t second; // /< The second.
44+
45+ // / @brief Equality operator.
46+ // / @param other The other time.
47+ // / @return True if equal, false otherwise.
48+ bool operator ==(const Time &other) const {
49+ return hour == other.hour && minute == other.minute && second == other.second ;
50+ }
51+
52+ // / @brief Inequality operator.
53+ // / @param other The other time.
54+ // / @return True if not equal, false otherwise.
55+ bool operator !=(const Time &other) const { return !(*this == other); }
3156 };
3257
3358 // / @brief The date and time structure.
3459 struct DateTime {
3560 Date date; // /< The date.
3661 Time time; // /< The time.
62+
63+ // / @brief Equality operator.
64+ // / @param other The other date and time.
65+ // / @return True if equal, false otherwise.
66+ bool operator ==(const DateTime &other) const {
67+ return date == other.date && time == other.time ;
68+ }
69+
70+ // / @brief Inequality operator.
71+ // / @param other The other date and time.
72+ // / @return True if not equal, false otherwise.
73+ bool operator !=(const DateTime &other) const { return !(*this == other); }
3774 };
3875
3976 // / @brief The configuration structure.
@@ -180,32 +217,6 @@ class Bm8563 : public BasePeripheral<> {
180217};
181218} // namespace espp
182219
183- // / @brief Compare two Date objects.
184- // / @param lhs The left hand side.
185- // / @param rhs The right hand side.
186- // / @return True if the objects are equal.
187- [[maybe_unused]] static bool operator ==(const espp::Bm8563::Date &lhs,
188- const espp::Bm8563::Date &rhs) {
189- return lhs.year == rhs.year && lhs.month == rhs.month && lhs.weekday == rhs.weekday &&
190- lhs.day == rhs.day ;
191- }
192-
193- // / @brief Compare two Time objects.
194- // / @param lhs The left hand side.
195- // / @param rhs The right hand side.
196- [[maybe_unused]] static bool operator ==(const espp::Bm8563::Time &lhs,
197- const espp::Bm8563::Time &rhs) {
198- return lhs.hour == rhs.hour && lhs.minute == rhs.minute && lhs.second == rhs.second ;
199- }
200-
201- // / @brief Compare two DateTime objects.
202- // / @param lhs The left hand side.
203- // / @param rhs The right hand side.
204- // / @return True if the objects are equal.
205- [[maybe_unused]] static bool operator ==(const espp::Bm8563::DateTime &lhs,
206- const espp::Bm8563::DateTime &rhs) {
207- return lhs.date == rhs.date && lhs.time == rhs.time ;
208- }
209220// for allowing easy serialization/printing of the
210221// espp::Bm8563::Date, espp::Bm8563::Time, and espp::Bm8563::DateTime
211222template <> struct fmt ::formatter<espp::Bm8563::Date> {
0 commit comments