hmg
Joined: 04 Jun 2008 Posts: 1
|
menu problem |
Posted: Wed Jun 04, 2008 1:07 am |
|
|
I have just join this forum. I am learning ccs c. Day by day progress.
I have done a clock (ds1302-ds18b20 and 2x16 lcd). It's classic but I'm learning. I did time and temperature problem. But I didn't know how can I change variables (hour,minute,day,month,year,daysofweek). I want to use 3 buttons to change variables. (adjust,reverse,forward ) When I push adjust button a cursor come or blink variable. Then I want use change variable with reverse and forward buttons. Then when I push again adjust; cursor goes to other variable .
My trial time and temp. ok but variable don't change. Thank you for your help.
Code: | #include <16f876.h>
#use delay (clock=4000000)
#include <flexyLCD1.c>
#use fast_io(c)
#include <DS1302.c>
#include <ds18b20.c>
int8 second,minute,hour,day,month,year,day_ofweek;
float temperature;
void menu(){
lcd_setcursor_vb(1,0);
if(!input(pin_c1))
{delay_ms(20);
while(!input(pin_c1));
day--;}
if(!input(pin_c2)){delay_ms(20);
while(!input(pin_c2));
day++;}
}
void main ( )
{
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_CCP1(CCP_OFF);
lcd_init();
rtc_init();
while(1)
{
if(!input(pin_c0))menu();
temperature = ds1820_read();
rtc_get_time(hour,minute,second);
rtc_get_date(day,month,year,dayof_week);
lcd_gotoxy(1,2);
printf(lcd_putc,"%02d/%02d/20%02d "day,month,year);
switch(dayof_week)
{
case 1: printf(lcd_putc," SUN"); break;
case 2: printf(lcd_putc," MON"); break;
case 3: printf(lcd_putc," TUE"); break;
case 4: printf(lcd_putc," WED"); break;
case 5: printf(lcd_putc," THU"); break;
case 6: printf(lcd_putc,"FRI "); break;
case 7: printf(lcd_putc," SAT"); break;
}
lcd_gotoxy(1,1);
printf(lcd_putc,"%02d:%02d:%02d %3.1f'C.",hour,minute,second,temperature);
delay_ms(1000);
}
} |
|
|