Cosmetic change

This commit is contained in:
GOB
2026-02-26 20:46:53 +09:00
parent caa3a4aa93
commit d294659f8d
6 changed files with 66 additions and 61 deletions
+8 -7
View File
@@ -23,10 +23,11 @@ rtc_date_type RTCdate;
char str_buffer[64];
void setup() {
void setup()
{
M5.begin(true, false, true); // Init M5Atom. 初始化M5Atom
Serial.print("RTC");
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; // Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
@@ -43,12 +44,12 @@ void setup() {
M5.dis.fillpix(0x00ff00);
}
void loop() {
void loop()
{
RTC.getTime(&RTCtime); // To get the time. 获取时间
RTC.getDate(&RTCdate); // Get the date. 获取日期
Serial.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours,
RTCtime.Minutes, RTCtime.Seconds);
Serial.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n",
RTCdate.Year, RTCdate.Month, RTCdate.Date, RTCdate.WeekDay);
Serial.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
Serial.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year, RTCdate.Month, RTCdate.Date,
RTCdate.WeekDay);
delay(1000);
}
+8 -7
View File
@@ -23,12 +23,13 @@ rtc_date_type RTCdate;
char str_buffer[64];
void setup() {
void setup()
{
M5.begin(); // Init M5Stack. 初始化M5Stack
M5.Power.begin(); // Init power 初始化电源模块
M5.lcd.setTextSize(2); // Set the text size to 2. 设置文字大小为2
M5.Lcd.print(" RTC");
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; // Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
@@ -44,14 +45,14 @@ void setup() {
// 将设置的日期同步至RTC
}
void loop() {
void loop()
{
M5.Lcd.fillRect(0, 20, 320, 140, BLACK);
RTC.getTime(&RTCtime); // To get the time. 获取时间
RTC.getDate(&RTCdate); // Get the date. 获取日期
M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours,
RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n",
RTCdate.Year, RTCdate.Month, RTCdate.Date, RTCdate.WeekDay);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year, RTCdate.Month, RTCdate.Date,
RTCdate.WeekDay);
delay(1000);
}
+25 -26
View File
@@ -23,34 +23,33 @@ rtc_date_type RTCdate;
char str_buffer[64];
void setup() {
M5.begin(); //Init M5Core2. 初始化M5Core2
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
M5.Lcd.print(" RTC");
RTC.begin(); //Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; //Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
void setup()
{
M5.begin(); // Init M5Core2. 初始化M5Core2
M5.lcd.setTextSize(2); // Set the text size to 2. 设置文字大小为2
M5.Lcd.print(" RTC");
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; // Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
RTCdate.WeekDay = 4; //Set the RTC clock date. 设置RTC时钟日期
RTCdate.Month = 7;
RTCdate.Date = 15;
RTCdate.Year = 2021;
RTCdate.WeekDay = 4; // Set the RTC clock date. 设置RTC时钟日期
RTCdate.Month = 7;
RTCdate.Date = 15;
RTCdate.Year = 2021;
RTC.setTime(
&RTCtime); //Example Synchronize the set time to the RTC. 将设置的时间同步至RTC
RTC.setDate(
&RTCdate); //Synchronize the set date to the RTC. 将设置的日期同步至RTC
RTC.setTime(&RTCtime); // Example Synchronize the set time to the RTC. 将设置的时间同步至RTC
RTC.setDate(&RTCdate); // Synchronize the set date to the RTC. 将设置的日期同步至RTC
}
void loop() {
RTC.getTime(&RTCtime); //To get the time. 获取时间
RTC.getDate(&RTCdate); //Get the date. 获取日期
M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours,
RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year,
RTCdate.Month, RTCdate.Date, RTCdate.WeekDay);
delay(1000);
M5.Lcd.fillRect(0, 20, 320, 140, BLACK);
void loop()
{
RTC.getTime(&RTCtime); // To get the time. 获取时间
RTC.getDate(&RTCdate); // Get the date. 获取日期
M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year, RTCdate.Month, RTCdate.Date,
RTCdate.WeekDay);
delay(1000);
M5.Lcd.fillRect(0, 20, 320, 140, BLACK);
}
@@ -21,16 +21,17 @@ rtc_date_type rtc_date;
char str_buffer[64];
void showlog(rtc_time_type *rtc_time, rtc_date_type *rtc_date) {
sprintf(str_buffer, "RTC Time Now is %02d:%02d:%02d", rtc_time->Hours,
rtc_time->Minutes, rtc_time->Seconds);
void showlog(rtc_time_type *rtc_time, rtc_date_type *rtc_date)
{
sprintf(str_buffer, "RTC Time Now is %02d:%02d:%02d", rtc_time->Hours, rtc_time->Minutes, rtc_time->Seconds);
Serial.println(str_buffer);
sprintf(str_buffer, "RTC Date Now is %02d:%02d:%02d WeekDay:%02d",
rtc_date->Year, rtc_date->Month, rtc_date->Date, rtc_date->WeekDay);
sprintf(str_buffer, "RTC Date Now is %02d:%02d:%02d WeekDay:%02d", rtc_date->Year, rtc_date->Month, rtc_date->Date,
rtc_date->WeekDay);
Serial.println(str_buffer);
}
void setup() {
void setup()
{
RTC.begin();
Serial.begin(115200);
delay(10);
@@ -47,7 +48,8 @@ void setup() {
RTC.setDate(&rtc_date);
}
void loop() {
void loop()
{
RTC.getTime(&rtc_time);
RTC.getDate(&rtc_date);
@@ -23,11 +23,12 @@ rtc_date_type RTCdate;
char str_buffer[64];
void setup() {
void setup()
{
M5.begin(); // Init M5StickC. 初始化M5StickC
M5.Lcd.setRotation(3); // Rotating display. 旋转显示屏
M5.Lcd.print(" RTC");
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; // Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
@@ -43,14 +44,14 @@ void setup() {
// 将设置的日期同步至RTC
}
void loop() {
void loop()
{
RTC.getTime(&RTCtime); // To get the time. 获取时间
RTC.getDate(&RTCdate); // Get the date. 获取日期
M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours,
RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n",
RTCdate.Year, RTCdate.Month, RTCdate.Date, RTCdate.WeekDay);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year, RTCdate.Month, RTCdate.Date,
RTCdate.WeekDay);
delay(1000);
M5.Lcd.fillRect(0, 20, 320, 140, BLACK);
}
@@ -23,12 +23,13 @@ rtc_date_type RTCdate;
char str_buffer[64];
void setup() {
void setup()
{
M5.begin(); // Init M5StickCPlus. 初始化M5StickCPlus
M5.Lcd.setRotation(3); // Rotating display. 旋转显示屏
M5.Lcd.setTextSize(2); // Rotating display. 旋转显示屏
M5.Lcd.print(" RTC");
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTC.begin(); // Example Initialize the RTC clock. 初始化RTC时钟
RTCtime.Hours = 14; // Set the RTC clock time. 设置RTC时钟时间
RTCtime.Minutes = 40;
RTCtime.Seconds = 5;
@@ -44,14 +45,14 @@ void setup() {
// 将设置的日期同步至RTC
}
void loop() {
void loop()
{
RTC.getTime(&RTCtime); // To get the time. 获取时间
RTC.getDate(&RTCdate); // Get the date. 获取日期
M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours,
RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n",
RTCdate.Year, RTCdate.Month, RTCdate.Date, RTCdate.WeekDay);
M5.Lcd.printf("RTC Time Now is \n%02d:%02d:%02d\n", RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds);
M5.Lcd.printf("RTC Date Now is \n%02d:%02d:%02d WeekDay:%02d\n", RTCdate.Year, RTCdate.Month, RTCdate.Date,
RTCdate.WeekDay);
delay(1000);
M5.Lcd.fillRect(0, 20, 320, 140, BLACK);
}