def main(argv): print "=== Real Time Clock Baackup Battery mode ===" print "*************************************" RTC = rtc.MCP79410() #create RTCC object if (RTC.IsVBatEnabled()): print "Battery mode Enabled.\r\n" else: print "Battery mode Disabled. Enabling ..\r\n" RTC.MCP79410_EnableVbat() powerDown_Time = RTC.GetPowerDownTime() print "Power down time: " + str(powerDown_Time.month) + ":" + str( powerDown_Time.date) + ":" + str(powerDown_Time.hour) + ":" + str( powerDown_Time.min) powerUp_Time = RTC.GetPowerUpTime() print "Power up time: " + str(powerUp_Time.month) + ":" + str( powerUp_Time.date) + ":" + str(powerUp_Time.hour) + ":" + str( powerUp_Time.min) if (RTC.CheckPowerFailure() == True): print "There was a power failure.\r\n" else: print "No power failure.\r\n" while True: rtcTime = RTC.GetTime() #get time tmr = "Time is: " + str(rtcTime.hour) + ":" + str( rtcTime.min) + ":" + str( rtcTime.sec) #convert to string and print it print tmr time.sleep(1)
def main(argv): print "=== Real Time Clock and Calendar ===" print "*************************************" RTC = rtc.MCP79410() #create RTCC object userTime = rtc.RTCC_Struct(2, 20, 11, 2, 2, 2, 15) RTC.SetTime(userTime) while True: rtcTime = RTC.GetTime() #get time tmr = "Time is: " + str(rtcTime.hour) + ":" + str( rtcTime.min) + ":" + str( rtcTime.sec) #convert to string and print it print tmr dat = "Date is: " + str(rtcTime.year) + "/" + str( rtcTime.month) + "/" + str( rtcTime.date) #convert to string and print it print dat time.sleep(1)
#!/usr/bin/python import sys import smbus import time import MCP79410RTCC as rtc print "=== Real Time Clock and Calendar ===" print "*************************************" RTC = rtc.MCP79410( ) #create RTCC object, initialize RTCC with system time and date Alarm = rtc.Alarm() Match = rtc.Match() Polarity = rtc.Polarity() Mode = rtc.Mode() RTC.ClearInterruptFlag(Alarm.ZERO) alarm_time = rtc.RTCC_Struct(0, 59, 0, 0, 0, 0, 0) RTC.SetAlarmTime(alarm_time, Alarm.ZERO) #Set alarm time RTC.SetAlarmMatch(Match.MINUTES_MATCH, Alarm.ZERO) #Alarm ZERO will trigger on minutes match RTC.SetAlarmMFPPolarity(Polarity.LOWPOL, Alarm.ZERO) #Configure Alarm pin polarity as HIGH RTC.SetMFP_Functionality(Mode.ALARM_INTERRUPT) #Set alaram interrupt pval = RTC.ReadPinStatus(MPL_PIN) print "MPL pin level is %d\r\n" % pval while True: