Files

137 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2019-08-15 19:29:40 +08:00
## SetTime()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void SetTime(RTC_TimeTypeDef* RTC_TimeStruct)`
2019-08-15 19:29:40 +08:00
**Description:**
Set time with the value of the structure member variable
**Example:**
2021-02-26 17:27:20 +08:00
```clike
2019-08-15 19:29:40 +08:00
#include <M5StickC.h>
RTC_TimeTypeDef TimeStruct;
void setup() {
M5.begin();
TimeStruct.Hours = 18;
TimeStruct.Minutes = 56;
TimeStruct.Seconds = 10;
M5.Rtc.SetTime(&TimeStruct);
}
void loop(){};
```
## GetTime()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void GetTime(RTC_TimeTypeDef* RTC_TimeStruct)`
2019-08-15 19:29:40 +08:00
**Description:**
Get time with the value of the structure member variable
**Example:**
2021-02-26 17:27:20 +08:00
```clike
2019-08-15 19:29:40 +08:00
#include <M5StickC.h>
RTC_TimeTypeDef TimeStruct;
void setup() {
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(40, 0, 2);
M5.Lcd.println("RTC TEST");
TimeStruct.Hours = 18;
TimeStruct.Minutes = 56;
TimeStruct.Seconds = 10;
M5.Rtc.SetTime(&TimeStruct);
}
void loop() {
M5.Rtc.GetTime(&TimeStruct);
M5.Lcd.setCursor(0, 15);
M5.Lcd.printf("Time: %02d : %02d : %02d\n",TimeStruct.Hours, TimeStruct.Minutes, TimeStruct.Seconds);
delay(500);
}
```
## SetData()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void SetData(RTC_TimeTypeDef* RTC_DateStruct)`
2019-08-15 19:29:40 +08:00
**Description:**
Set date with the value of the structure member variable
**Example:**
2021-02-26 17:27:20 +08:00
```clike
2019-08-15 19:29:40 +08:00
#include <M5StickC.h>
RTC_TimeTypeDef TimeStruct;
RTC_DateTypeDef DateStruct;
void setup() {
M5.begin();
DateStruct.WeekDay = 3;
DateStruct.Month = 3;
DateStruct.Date = 22;
DateStruct.Year = 2019;
M5.Rtc.SetData(&DateStruct);
}
void loop(){};
```
## GetData()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void GetData(RTC_TimeTypeDef* RTC_DateStruct)`
2019-08-15 19:29:40 +08:00
**Description:**
Get date with the value of the structure member variable
**Example:**
2021-02-26 17:27:20 +08:00
```clike
2019-08-15 19:29:40 +08:00
#include <M5StickC.h>
RTC_DateTypeDef DateStruct;
void setup() {
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(40, 0, 2);
M5.Lcd.println("RTC TEST");
DateStruct.WeekDay = 3;
DateStruct.Month = 3;
DateStruct.Date = 22;
DateStruct.Year = 2019;
M5.Rtc.SetData(&DateStruct);
}
void loop() {
M5.Rtc.GetData(&DateStruct);
M5.Lcd.setCursor(0, 15);
M5.Lcd.printf("Data: %04d-%02d-%02d\n",DateStruct.Year, DateStruct.Month,DateStruct.Date);
M5.Lcd.printf("Week: %d\n",DateStruct.WeekDay);
delay(500);
}