#ifndef RTC_MODULE_H #define RTC_MODULE_H #include #include // RTC通信对象 extern ThreeWire myWire; extern RtcDS1302 Rtc; // 初始化RTC模块 void setupRTC() { Rtc.Begin(); RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__); if (!Rtc.IsDateTimeValid()) { Rtc.SetDateTime(compiled); } if (Rtc.GetIsWriteProtected()) { Rtc.SetIsWriteProtected(false); } if (!Rtc.GetIsRunning()) { Rtc.SetIsRunning(true); } } // 获取当前时间 RtcDateTime getRTCTime() { return Rtc.GetDateTime(); } // 设置RTC时间 void setRTCTime(int year, int month, int day, int hour, int minute, int second) { RtcDateTime newTime(year, month, day, hour, minute, second); Rtc.SetDateTime(newTime); } #endif