WS_RTC.h 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _WS_RTC_H_
  2. #define _WS_RTC_H_
  3. #include <Wire.h>
  4. #include <NTPClient.h>
  5. #include <WiFiUdp.h>
  6. #include "WS_GPIO.h"
  7. #include "WS_Information.h"
  8. extern bool Relay_Flag[6]; // Relay current status flag
  9. #define RTC_Flag 1 // RTC Timing Switcher flag
  10. // #define RTC_OPEN_Time_Hour 16 // Time when the timing switch is enabled
  11. // #define RTC_OPEN_Time_Min 29 // Time when the timing switch is enabled
  12. // #define RTC_Closs_Time_Hour 16 // Time when the timing switch is off
  13. // #define RTC_Closs_Time_Min 30 // Time when the timing switch is off
  14. #define DS3231_I2C_ADDR 0x68
  15. #define I2C_SDA 4
  16. #define I2C_SCL 5
  17. #define RTC_OPEN_Hour (RTC_OPEN_Time_Hour%10 + RTC_OPEN_Time_Hour /10*16) // RTC Timing Switcher flag
  18. #define RTC_OPEN_Min (RTC_OPEN_Time_Min%10 + RTC_OPEN_Time_Min /10*16) // RTC Timing Switcher flag
  19. #define RTC_Closs_Hour (RTC_Closs_Time_Hour%10 + RTC_Closs_Time_Hour /10*16) // RTC Timing Switcher flag
  20. #define RTC_Closs_Min (RTC_Closs_Time_Min%10 + RTC_Closs_Time_Min /10*16) // RTC Timing Switcher flag
  21. void RTC_Init();
  22. void DS3231_ReadTime() ; // Get current time
  23. void DS3231_SetTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t dayOfWeek, uint8_t day, uint8_t month, uint8_t year);
  24. uint8_t DecToBcd(uint8_t val);
  25. void Acquisition_time(); // Get the network time and set it to DS3231 to be called after the WIFI connection is successful
  26. void RTC_Loop(); // Check whether the relay start-stop time has been reached
  27. #endif