You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
// The following is going to execute after we load this current page:
|
|
//
|
|
// There is something strange when I read the RTC for the first time
|
|
// without a battery, or when you just inserted a battery for the first time.
|
|
// Some of the values are random generated and beyond the limits. For example, the
|
|
// day would show as 45, month as 20, minute as 65, etc. I was like: "What?!!!"
|
|
// And we can't modify them using normal buttons because they are coded to
|
|
// take to current value and increase or decrease that value, and the RTC
|
|
// don't take values beyond the limits. For that reason I am going to check
|
|
// if any of the components of the RTC are beyond the limits, and if they are
|
|
// I will take them to a valid value:
|
|
// This must run on "Postinitialize Event" on page 0.
|
|
if(rtc0>2099) // if year is above 2099
|
|
{
|
|
rtc0=2099 // set year as 2099
|
|
}
|
|
//
|
|
if(rtc1>12) // if month is above 12
|
|
{
|
|
rtc1=12 // set month as 12
|
|
}
|
|
//
|
|
if(rtc1==0) // if month is equal to 0
|
|
{
|
|
rtc1=1 // set month as 1
|
|
}
|
|
//
|
|
if(rtc2>31) // if day is above 31
|
|
{
|
|
rtc2=1 // set day as 1
|
|
}
|
|
//
|
|
if(rtc2==0) // if day is equal to 0
|
|
{
|
|
rtc2=1 // set day as 1
|
|
}
|
|
//
|
|
if(rtc3>23) // if hour is above 23
|
|
{
|
|
rtc3=23 // set hour as 23
|
|
}
|
|
//
|
|
if(rtc4>59) // if minute is above 59
|
|
{
|
|
rtc4=0 // set minute as 0
|
|
}
|
|
if(rtc5>59) // if second is above 59
|
|
{
|
|
rtc5=59 // set second as 59
|
|
}
|