interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{
if(++time.second > 59) // if seconds = 60
{
time.second = 0; // set seconds to 0
if(++time.minute > 59) // if minutes = 60
{
time.minute = 0; // set minutes to 0
if(++time.hour > 12) // if hours = 13
{
if(dayornight == 0) // if AM
{
dayornight = 1; // change to PM
}
else
dayornight = 0; // make AM because already PM
time.hour = 1; // change to 1 O'clock
}
}
}
/*** Definitions for printf() statements***/
// 20 scroll off so when at bottom row goes to top
// 17 set cursor postion
// 4 go to column 5
// 3 go to row 4
if (timedisplay == 1)
{
if (dayornight == 0)
{
printf("%c%c%c%c%02u:%02u:%02u AM",20,17,4,3,time.hour,time.minute,time.second);
}
else
{
printf("%c%c%c%c%02u:%02u:%02u PM",20,17,4,3,time.hour,time.minute,time.second);
}
}
if (timedisplayset == 1) //to display first feeding time set when setting
{
if (dayornightset == 0)
{
printf("%c%c%c%c %02u:%02u AM",20,17,4,3,timeset.hourset,timeset.minuteset);
}
else
{
printf("%c%c%c%c %02u:%02u PM",20,17,4,3,timeset.hourset,timeset.minuteset,);
}
}
if (timedisplayset2 == 1)
{
if (dayornightset2 == 0)
{
printf("%c%c%c%c %02u:%02u AM",20,17,4,3,timeset2.hourset2,timeset2.minuteset2,);
}
else
{
printf("%c%c%c%c %02u:%02u PM",20,17,4,3,timeset2.hourset2,timeset2.minuteset2,);
}
}
}