saramah
Member level 3
Hi,
In software side, it is multiplex, xc8 comp to disp HH:MM:SEC, mcu reading from rtc readng at 24hrs format and then in software it is converted to 12hrs farmat under main().
H/W, 7seg CC, RTC1307.
All are working correctly , now I want to add a feature that is, when the time reach at 2:30 (at night)the disp will be turned OFF and after 2:32 (at night) the disp will turn ON. The code attched here is working all the said time(ie, as every 2.30 start OFF and evert 2.32 start ON), whereas i need only at night, so if 1st time turned OFF and ON then for 2nd time(which is day time) no need ON-OFF and vice-versa, and 3rd. time what was in 1st time.
As per code attached here, Once turned OFF at said time at 2.30 & it ON at 2.32, when it ON then i set the time by BUTTON once to keep ON(as it is day time) the disp for this 2nd. time but it going OFF again.and all the 2.30 it is going off and on at 2.32.
So, is the code ok or what should i modify either at BUTTON routine or Main routine.
Code is under at Main()
// Here TIME FORMAT 24 to 12 HRS conversion
Sub routine for BUTTON
tnx
In software side, it is multiplex, xc8 comp to disp HH:MM:SEC, mcu reading from rtc readng at 24hrs format and then in software it is converted to 12hrs farmat under main().
H/W, 7seg CC, RTC1307.
All are working correctly , now I want to add a feature that is, when the time reach at 2:30 (at night)the disp will be turned OFF and after 2:32 (at night) the disp will turn ON. The code attched here is working all the said time(ie, as every 2.30 start OFF and evert 2.32 start ON), whereas i need only at night, so if 1st time turned OFF and ON then for 2nd time(which is day time) no need ON-OFF and vice-versa, and 3rd. time what was in 1st time.
As per code attached here, Once turned OFF at said time at 2.30 & it ON at 2.32, when it ON then i set the time by BUTTON once to keep ON(as it is day time) the disp for this 2nd. time but it going OFF again.and all the 2.30 it is going off and on at 2.32.
So, is the code ok or what should i modify either at BUTTON routine or Main routine.
Code is under at Main()
// Here TIME FORMAT 24 to 12 HRS conversion
Code:
if (hour <= 12)
{
hour = hour;
PowerSave = 1;
}
else
{
PowerSave = 0;
hour = (hour - 12);
}
// For particular time display to be TURNED OFF and Again ON
if (PowerSave == 1)
{
if ((hour == 2 && min >= 30) && (hour == 2 && min <= 31))
{
INTCONbits.T0IE = 0;
}
else
INTCONbits.T0IE = 1;
}
Sub routine for BUTTON
Code:
uint8_t edit(uint8_t parameter)
{
while(debounce()); // call debounce function (wait for B1 to be released)
while(1)
{
while(!BUTTON2) // if button B2 is pressed
{
parameter++;
__delay_ms(300); //this delay for prevent several count on one press
if (i == 0 && parameter <= 12)
PowerSave &= 0x01;
if(i == 0 && parameter > 12) // if hours > 23 ==> hours = 0
parameter = 1;
if(i == 1 && parameter > 59) // if minutes > 59 ==> minutes = 0
parameter = 0;
if (i == 0)
{
hour_1 = (parameter % 10);
hour_10 = (parameter / 10);
__delay_ms(10);
}
if (i == 1)
{
min_1 = (parameter % 10);
min_10 = (parameter / 10);
__delay_ms(10);
}
}
if(!BUTTON1) // if button B1 is pressed
if(debounce()) // call debounce function (make sure if B1 is pressed)
{
i++; // increment 'i' for the next parameter
return parameter; // return parameter value and exit
}
}
}
tnx