#include #include #include #include "lcd.h" #include unsigned int sek=0; unsigned int min=15; unsigned int hour=15; unsigned int day=12; unsigned int mouth=11; unsigned int year=2012; unsigned char tex0[] ="!!!"; unsigned char tex1[] ="LCDcloc v1.0 by AT-09-2"; unsigned char buff[] =""; int cnt = 0; // Ïåðåìåííàÿ-ñ÷¸ò÷èê ISR(TIMER0_OVF_vect) { // Îáðàáîò÷èê ïðåðûâàíèÿ ïåðåïîëíåíèÿ òàéìåðà cnt++; // Óâåëè÷èì ïåðåìåííóþ-ñ÷¸ò÷èê if (cnt == 61) {// Åñëè äîñòèãëè íóæíîãî êîë-âà ïðåðûâàíèé, sek++; cloc(); // âûçîâåì íåêóþ ôóíêöèþ cnt = 0; } } void sdvig(char *a) //??? { unsigned int i=0;; for(i=0; i < strlen(a) ; i++) { lcd_clrscr(); lcd_gotoxy(0,0); lcd_puts(&a[i]); _delay_ms(700); } } //Beep(int period_ms) //{ // for (long i = 1; i < period * 1000; i++) // { // PORTB^= 0b10000000; // delay_us(500); // } //} //void obr_knopok() //{ //char prev_value; //char curr_value; // for (char index = 0; index < 10; index++) // { // curr_value = PINA; // _delay_ms(100); // char buttons = ~curr_value & prev_value; // prev_value = curr_value; // if (buttons) // break; // // } // if (~a == (!(~curr_value & prev_value))) // { // PORTB=0x00; // _delay_ms(5000); // } //} void cloc(void) { if (sek==60) { min++; sek=0; } if (min==60) { hour++; min=0; } if (hour==24) { day++; hour=0; } lcd_gotoxy(8,0); lcd_putc(hour/10 + 0x30); lcd_putc(hour%10 + 0x30); lcd_putc(':'); lcd_putc(min/10 + 0x30); lcd_putc(min%10 + 0x30); lcd_putc(':'); lcd_putc(sek/10 + 0x30); lcd_putc(sek%10 + 0x30); lcd_gotoxy(6,1); lcd_putc(day/10 + 0x30); lcd_putc(day%10 + 0x30); lcd_putc('.'); lcd_putc(mouth/10 + 0x30); lcd_putc(mouth%10 + 0x30); lcd_putc('.'); lcd_putc(year/1000 + 0x30); lcd_putc(((year/100)-10*(year/1000)) + 0x30); lcd_putc(((year%100-year%10)/10) + 0x30); lcd_putc(year%10 + 0x30); } void main() { lcd_init(LCD_DISP_ON); lcd_clrscr(); sdvig(tex1); lcd_clrscr(); sei(); TIMSK |= _BV(TOIE0); TCCR0 |= _BV(CS02); while(1) { } }