Skip to content

Commit

Permalink
#109 line calendar
Browse files Browse the repository at this point in the history
close #111
doxygen
rtc refactor
  • Loading branch information
igors48 committed Jun 28, 2022
1 parent 7458c2b commit 0a8fb7c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
19 changes: 15 additions & 4 deletions src/core/watch/rtc.cpp
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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,
Expand All @@ -41,7 +52,7 @@ static void rtcSetDate(Date date)
RtcApi watchRtcApi()
{
return {
.getDate = rtcGetDate,
.setDate = rtcSetDate,
.getDate = getDate,
.setDate = setDate,
};
}
31 changes: 26 additions & 5 deletions src/core/watch/rtc.hpp
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();

0 comments on commit 0a8fb7c

Please sign in to comment.