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 |
|
2299 |
jacho |
6 |
//Propojení pinù modulu s LCD a ATmega8 (jejich nastavení se provádí v lcd.h) |
|
|
7 |
//PIN_D0 PC3 |
|
|
8 |
//PIN_D1 PB4 |
|
|
9 |
//PIN_D2 PB5 |
|
|
10 |
//PIN_D3 PB3 |
|
|
11 |
//PIN_E PB1 |
|
|
12 |
//PIN_RS PB2 |
|
|
13 |
|
2298 |
jacho |
14 |
#include <avr/io.h> |
|
|
15 |
#include <stdio.h> |
|
|
16 |
#include <avr/iom8.h> |
|
|
17 |
#include "lcd.h" |
|
|
18 |
#include "lcd.c" |
|
|
19 |
#include <util/delay.h> |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
#define MAXDISPLBUFFER 20 //buffer pro lcd display |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
//----------------------------------------------------------------------------- |
|
|
26 |
|
|
|
27 |
int main(void) |
|
|
28 |
{ |
|
|
29 |
|
|
|
30 |
LCD_init(); //Inicializace LCD |
|
|
31 |
|
|
|
32 |
char zasobnik[19]; |
|
|
33 |
|
|
|
34 |
sprintf(zasobnik,"LCD je OK"); //vlozi text do zasobnik |
|
|
35 |
LCD_gotoxy(0,0); //definuje kam se zacne zapisovat na LCD |
|
|
36 |
ProcesDispl(zasobnik); |
|
|
37 |
LCD_gotoxy(0,2); |
|
|
38 |
ProcesDispl(zasobnik); |
|
|
39 |
_delay_ms(1); |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
return 0; |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
void ProcesDispl(char *data) //zajiuje tisk øetìzce na lcd |
|
|
49 |
{ |
|
|
50 |
uint8_t a,b; |
|
|
51 |
|
|
|
52 |
for (a=0;a<MAXDISPLBUFFER;a++) |
|
|
53 |
{ |
|
|
54 |
switch (*(data+a)) |
|
|
55 |
{ |
|
|
56 |
case 0: *data = 0;return; |
|
|
57 |
case '\n': LCD_gotoxy(1,2);break; //posun na druhej øádek |
|
|
58 |
case '\r': LCD_gotoxy(1,1);break; |
|
|
59 |
case '\a': LCD_gotoxy(6,2);break; //posun na 2.øádek 6.políèko |
|
|
60 |
case '\f': LCD_gotoxy(1,1); |
|
|
61 |
for (b=0;b<8;b++) LCD_putc(0x20); |
|
|
62 |
LCD_gotoxy(1,2); |
|
|
63 |
for (b=0;b<8;b++) LCD_putc(0x20); |
|
|
64 |
LCD_gotoxy(1,1); |
|
|
65 |
break; |
|
|
66 |
default : LCD_putc(*(data+a)); |
|
|
67 |
} |
|
|
68 |
} |
|
|
69 |
*data = 0; |
|
|
70 |
} |