From 0a8fb7c130e41011409fb2fb0fc78b0628f8741c Mon Sep 17 00:00:00 2001 From: igors48 Date: Tue, 28 Jun 2022 08:15:30 +0300 Subject: [PATCH] #109 line calendar close #111 doxygen rtc refactor --- src/core/watch/rtc.cpp | 19 +++++++++++++++---- src/core/watch/rtc.hpp | 31 ++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/core/watch/rtc.cpp b/src/core/watch/rtc.cpp index de95e05..a0c82d3 100644 --- a/src/core/watch/rtc.cpp +++ b/src/core/watch/rtc.cpp @@ -1,7 +1,15 @@ +/** + * @file + * @author Igor Usenko (github: igors48) + * @brief RTC API implementation +*/ #include "rtc.hpp" #include "ttgo.hpp" -static Date rtcGetDate() +/** + * @copydoc RtcApi.getDate + */ +static Date getDate() { RTC_Date rtcDate = watch->rtc->getDateTime(); @@ -25,7 +33,10 @@ static Date rtcGetDate() }; } -static void rtcSetDate(Date date) +/** + * @copydoc RtcApi.setDate + */ +static void setDate(Date date) { RTC_Date rtcDate = RTC_Date( date.year, @@ -41,7 +52,7 @@ static void rtcSetDate(Date date) RtcApi watchRtcApi() { return { - .getDate = rtcGetDate, - .setDate = rtcSetDate, + .getDate = getDate, + .setDate = setDate, }; } \ No newline at end of file diff --git a/src/core/watch/rtc.hpp b/src/core/watch/rtc.hpp index d61bd68..8a8c389 100644 --- a/src/core/watch/rtc.hpp +++ b/src/core/watch/rtc.hpp @@ -1,5 +1,13 @@ +/** + * @file + * @author Igor Usenko (github: igors48) + * @brief RTC API definition +*/ #pragma once +/** + * @brief definition of Date + */ typedef struct { unsigned short year; @@ -11,13 +19,26 @@ typedef struct unsigned int dayOfWeek; } Date; -typedef Date (*DateFunc)(); // todo rename to GetDate #110 -typedef void (*SetDate)(Date date); - typedef struct { - DateFunc getDate; - SetDate setDate; + /** + * @brief returns the date from RTC + * + * @return date value + */ + Date (*getDate)(); + + /** + * @brief writes the date to RTC + * + * @param date date value + */ + void (*setDate)(Date date); } RtcApi; +/** + * @brief factory for RTC API + * + * @return RtcApi RTC API instance + */ RtcApi watchRtcApi(); \ No newline at end of file