/* Using the 8051SBC as the terminal for time setting the Realtime Controller The onboard two button switches are used to set Hour and Min Copyright (C) 2006-2007 Wichit Sirichote, kswichit@kmitl.ac.th */ #include #include xdata char GPIO2 _at_ 0x200; char *Puts(char *str); InitLcd(void); goto_xy(char x,char y); void putch_lcd(char ch); char hour_press, min_press; print_text() { char buffer[10]; if(RI) { gets(buffer,10); goto_xy(0,1); Puts(buffer); } } get_character() { char c; if (RI) { c = getchar(); if(c < ' ') goto_xy(0,1); putch_lcd(c); } } set_hour() { if((GPIO2 & 0x10)==0 && hour_press == 0) { putchar('h'); hour_press=1; } } set_min() { if((GPIO2 & 0x20)==0 && (min_press == 0)) { putchar('m'); min_press = 1; } } key_released() { if((GPIO2 & 0xf0) == 0xf0) { min_press=0; hour_press = 0; } } main() { InitLcd(); Puts("RTC TERMINAL"); hour_press = min_press = 0; RI = 0; while(1) { get_character(); set_hour(); set_min(); key_released(); } }