CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

menu problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hmg



Joined: 04 Jun 2008
Posts: 1

View user's profile Send private message

menu problem
PostPosted: Wed Jun 04, 2008 1:07 am     Reply with quote

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);
   }
}
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 04, 2008 8:54 am     Reply with quote

Where is your call to rtc_set_datetime? It looks like right after you modify day in menu(), you're overwriting it with rtc_get_date().
_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group