Rev Author Line No. Line
2298 jacho 1 //Program pro vyzkouseni funkcnosti modulu s LCD a mikropocitacem ATmega8
2 //MLAB 21.11.2011 (JACHO)
3  
4 //vytvoreno v programu AVR studio 4
5  
6 #include <avr/io.h>
7 #include <stdio.h>
8 #include <avr/iom8.h>
9 #include "lcd.h"
10 #include "lcd.c"
11 #include <util/delay.h>
12  
13  
14 #define MAXDISPLBUFFER 20 //buffer pro lcd display
15  
16  
17 //-----------------------------------------------------------------------------
18  
19 int main(void)
20 {
21  
22 LCD_init(); //Inicializace LCD
23  
24 char zasobnik[19];
25  
26 sprintf(zasobnik,"LCD je OK"); //vlozi text do zasobnik
27 LCD_gotoxy(0,0); //definuje kam se zacne zapisovat na LCD
28 ProcesDispl(zasobnik);
29 LCD_gotoxy(0,2);
30 ProcesDispl(zasobnik);
31 _delay_ms(1);
32  
33  
34 return 0;
35  
36  
37  
38 }
39  
40 void ProcesDispl(char *data) //zajišuje tisk øetìzce na lcd
41 {
42 uint8_t a,b;
43  
44 for (a=0;a<MAXDISPLBUFFER;a++)
45 {
46 switch (*(data+a))
47 {
48 case 0: *data = 0;return;
49 case '\n': LCD_gotoxy(1,2);break; //posun na druhej øádek
50 case '\r': LCD_gotoxy(1,1);break;
51 case '\a': LCD_gotoxy(6,2);break; //posun na 2.øádek 6.políèko
52 case '\f': LCD_gotoxy(1,1);
53 for (b=0;b<8;b++) LCD_putc(0x20);
54 LCD_gotoxy(1,2);
55 for (b=0;b<8;b++) LCD_putc(0x20);
56 LCD_gotoxy(1,1);
57 break;
58 default : LCD_putc(*(data+a));
59 }
60 }
61 *data = 0;
62 }