Line No. | Rev | Author | Line |
---|---|---|---|
1 | 3 | kaklik | //////////////////////////////////////////////////////////////// |
2 | // Program pro otestovani funkci knihovny KBD.C |
||
3 | // Jde o pouziti funkci bez prerusovacich rutin |
||
4 | // Pro casovani je pouzita hlavni smycka programu |
||
5 | //////////////////////////////////////////////////////////////// |
||
6 | // |
||
7 | // (c) PEFI 2003 |
||
8 | // Verze 0.00 - uvodni verze |
||
9 | // |
||
10 | //////////////////////////////////////////////////////////////// |
||
11 | |||
12 | #include <16F876.h> |
||
13 | #use delay(clock=4000000,RESTART_WDT) |
||
14 | #fuses XT,WDT,NOBROWNOUT,NOPROTECT,NOLVP |
||
15 | |||
16 | // prepinace programu |
||
17 | #define FCE_GETC |
||
18 | //#define FCE_WAITC // pouzijeme funkci, ktera ceka na klavesu a spi |
||
19 | //#define FCE_TIMEOUTC // pouzije funkci, ktera ceka na klavesu jen po urcitou dobu |
||
20 | |||
21 | |||
22 | // LCD Display |
||
23 | #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
||
24 | #define LCD_E PIN_B3 // enable LCD displeje |
||
25 | #define LCD_DATA_LSB PIN_A0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
||
26 | #include <lcd.c> |
||
27 | |||
28 | |||
29 | // klavesnice |
||
30 | #define KBD_WDT 1 // zapina realizaci kbd_waitc pomoci WDT timeru |
||
31 | #include <kbd.c> |
||
32 | |||
33 | /*************************************************/ |
||
34 | /********* HLAVNI SMYCKA PROGRAMU ****************/ |
||
35 | /*************************************************/ |
||
36 | |||
37 | void main() { |
||
38 | |||
39 | int c; |
||
40 | |||
41 | setup_timer_0(RTCC_INTERNAL | WDT_36MS); |
||
42 | |||
43 | lcd_init(); |
||
44 | kbd_init(); |
||
45 | |||
46 | #ifdef FCE_GETC |
||
47 | printf(lcd_putc,"Loop: kbd_getc "); |
||
48 | #endif |
||
49 | #ifdef FCE_WAITC |
||
50 | printf(lcd_putc,"Loop: kbd_waitc "); |
||
51 | #endif |
||
52 | #ifdef FCE_TIMEOUTC |
||
53 | printf(lcd_putc,"Loop:kbd_timeoutc"); |
||
54 | #endif |
||
55 | |||
56 | while(1) |
||
57 | { |
||
58 | #ifdef FCE_GETC |
||
59 | kbd_pullkbd(); |
||
60 | delay_ms(20); |
||
61 | kbd_ticktimer(); |
||
62 | c=kbd_getc(); |
||
63 | #endif |
||
64 | |||
65 | #ifdef FCE_WAITC |
||
66 | c=kbd_waitc(); |
||
67 | #endif |
||
68 | |||
69 | #ifdef FCE_TIMEOUTC |
||
70 | delay_ms(1000); |
||
71 | lcd_gotoxy(1,2); |
||
72 | printf(lcd_putc,"Ceka na stisk "); |
||
73 | c=kbd_timeoutc(0x30); |
||
74 | #endif |
||
75 | |||
76 | if (c!=0) |
||
77 | { |
||
78 | lcd_gotoxy(1,2); |
||
79 | printf(lcd_putc,"Stisknuto %2X ",c); // vypise kod klavesy |
||
80 | } |
||
81 | #ifdef FCE_TIMEOUTC |
||
82 | else { |
||
83 | lcd_gotoxy(1,2); |
||
84 | printf(lcd_putc,"timeout vyprsel "); // vypise kod klavesy |
||
85 | } |
||
86 | #endif |
||
87 | } |
||
88 | } |
||
89 | |||
90 | // End of File |
Powered by WebSVN v2.8.3