| ??? 06/08/11 14:15 Modified: 06/08/11 14:19 Read: times |
#182536 - C code Responding to: ???'s previous message |
Here I'm inserting part[1] of the code. The same is copied in part[2] & part[3] with only changes with respect to month & year limits.
if (time_pressed) // for setting time
set_time_flag;
while(time_flag) // here date setting is being done
{
up1: if (up_pressed) // is increment key pressed?
{ LCD_delay(200); // temp1 to display tens place
if(temp2>=9) // temp2 to display units place
{temp2=0; temp1++;}
else temp2++;
if (temp1>=3 && temp2>=2) // don't allow date to cross 31
{temp1=0; temp2=1;} // reset to 01
LCD_delay(200);
// clr_up_flag;
LCD_command(0x80);
send2lcd(temp1); // Show changed date on LCD : tens place
send2lcd(temp2); // Show changed date on LCD : units place
if(up_pressed) // is up key pressed?
goto up1;
if(dn_pressed) // is down key pressed?
goto dn1;
}
dn1: if (dn_pressed)
{ LCD_delay(200);
if(temp2<=0)
{temp2<=9; temp1--;}
else temp2--;
if (temp1<=0 && temp2<=0)// reset temp1 & temp2
{temp1=3; temp2=1;}
LCD_delay(200);
// clr_dn_flag;
LCD_command(0x80);
send2lcd(temp1); // Show changed date on LCD : tens place
send2lcd(temp2); // Show changed date on LCD : units place
if(up_pressed) // is up key pressed?
goto up1;
if(dn_pressed) // is down key pressed?
goto dn1;
}
}
|
| Topic | Author | Date |
| Compiler variations?? | 01/01/70 00:00 | |
| Fundamental philosophy of High-Level Languges (HLL) | 01/01/70 00:00 | |
| C code | 01/01/70 00:00 | |
| and so what | 01/01/70 00:00 | |
| Stop wondering about the compiler output | 01/01/70 00:00 | |
| Very nice to learn this important matter | 01/01/70 00:00 | |
| Exactly what you wrote | 01/01/70 00:00 | |
| volatile sbit may be the problem | 01/01/70 00:00 | |
| read up on (not) volatile | 01/01/70 00:00 | |
| Look at my profile | 01/01/70 00:00 | |
| Not offence intended | 01/01/70 00:00 | |
| defining P0_6 so that compiler doesn't treat it as volatile | 01/01/70 00:00 | |
| Skip the goto - almost always exists beautiful rewrites | 01/01/70 00:00 | |
| Goto really is a bastard code construct | 01/01/70 00:00 | |
| and therefore ... | 01/01/70 00:00 | |
Will come back with modified code | 01/01/70 00:00 | |
| Wonderful as always! | 01/01/70 00:00 |



