Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
507 kaklik 1
/* ---------------------------------------------------------------------------
2
 * AVR_MLIB - HD 44780 LCD Display Driver Test Application
3
 * www.mlab.cz miho 2008
4
 * ---------------------------------------------------------------------------
5
 * Simple test application for lcd_hd44780.h LCD library. This code ilustates
6
 * how to use and configure the library functions.
7
 * ---------------------------------------------------------------------------
8
 * 00.00 2008/03/28 First Version
9
 * 00.01 2008/04/19 Improved
10
 * ---------------------------------------------------------------------------
11
 */
12
 
13
 
14
// Required Libraries
15
// ------------------
16
 
17
// Delay
18
 
19
#define F_CPU 1000000UL		// CPU Frequency
20
#include <util/delay.h>		// Delay Routines
21
 
22
// Standard Output Library
23
 
24
#include <stdio.h>			// For printf
25
 
26
 
27
// LCD Display Interface
28
// ---------------------
29
 
30
// LCD Port Settings
31
 
32
#define LCD_DATA			B		// 4 or 8 bits field (lsb port)
33
#define LCD_DATA_BIT			0
34
 
35
#define LCD_RS				D		// Register Select
36
#define LCD_RS_BIT			4		
37
 
38
#define LCD_E				D		// Enable
39
#define LCD_E_BIT			3
40
 
41
// LCD Display Parameters
42
 
43
#define LCD_INTERFACE_BITS	4		// 4 or 8 bit interface
44
#define LCD_LINES			2		// 1 or 2 or 4 lines
45
#define LCD_CHARS			16		// usualy 16 or 20, important for 4 line display only
46
 
47
// LCD Library
48
 
49
#include "lcd_hd44780.h"
50
 
51
 
52
// Test Application
53
// ----------------
54
 
55
 
56
// Define Output Stream to LCD
57
static FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putc_stream, NULL, _FDEV_SETUP_WRITE);
58
 
59
 
60
// Main Program
61
int main ()
62
{
63
	int i;
64
 
65
DDRB|= (1<<DDB6);
66
DDRB|= (1<<DDB7);
67
        PORTB &= ~(1<<PB6);
68
 
69
	stdout = &lcd_stream;		// Connect stdout to LCD Stream
70
 
71
	lcd_init();					// Init LCD (interface and display module)
72
	lcd_gotoxy(1,1);
73
	printf("stavebnice MLAB");
74
	_delay_ms(1000);
75
 
76
	while(1)
77
	{
78
	lcd_gotoxy(2,2);
79
	printf("demo aplikace");
80
	_delay_ms(1000);
81
	lcd_gotoxy(2,2);
82
	printf("              ");
83
 
84
	PORTB|= (1<<PB6);
85
        _delay_ms(500);
86
        PORTB &= ~(1<<PB6);
87
       	_delay_ms(5000);
88
 
89
	PORTB|= (1<<PB7);
90
        _delay_ms(500);
91
        PORTB &= ~(1<<PB7);
92
	_delay_ms(5000);
93
 
94
	}
95
}