-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlcd.h
163 lines (100 loc) · 3.78 KB
/
lcd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/******************************************************************************
eXtreme Electronics xAPI(TM)
----------------------------
xAPI is a Powerful but easy to use C library to program the xBoard(TM)
series of AVR development board. The library has support for commonly use tasks
like:-
*LCD interfacing
*MUXED 7 segment displays.
*Remote Control
*Serial Communication
*DC Motor Controls with Speed Control
*Analog Measurement for Sensor Interface.
*Temperature Measurement.
*I2C Communication.
*EEPROM Interface
*Real Time Clock (RTC Interface)
The APIs are highly documented and easy to use even by a beginner.
Versions:
1.0 - Basic Lib
2.0 - Added Custom Char Support, Much flexible connection.
4 line LCD support.
For More Info Log On to
www.eXtremeElectronics.co.in
Copyright 2008-2009 eXtreme Electronics India
LCD Core
----------
This module is used for interfacing with Standard Alpha Numeric LCD Modules.
For More information please see supplied tutorials and videos.
NOTICE
--------
NO PART OF THIS WORK CAN BE COPIED, DISTRIBUTED OR PUBLISHED WITHOUT A
WRITTEN PERMISSION FROM EXTREME ELECTRONICS INDIA. THE LIBRARY, NOR ANY PART
OF IT CAN BE USED IN COMMERCIAL APPLICATIONS. IT IS INTENDED TO BE USED FOR
HOBBY, LEARNING AND EDUCATIONAL PURPOSE ONLY. IF YOU WANT TO USE THEM IN
COMMERCIAL APPLICATION PLEASE WRITE TO THE AUTHOR.
WRITTEN BY:
AVINASH GUPTA
*******************************************************************************/
#include <avr/io.h>
#include <util/delay.h>
#include "myutils.h"
#ifndef _LCD_H
#define _LCD_H
/*_________________________________________________________________________________________*/
/************************************************
LCD CONNECTIONS
*************************************************/
#define LCD_DATA B //Port PB0-PB3 are connected to D4-D7
#define LCD_DATA_POS 0
#define LCD_E B //Enable/strobe signal
#define LCD_E_POS PB4 //Position of enable in above port
#define LCD_RS D //RS SIGNAL
#define LCD_RS_POS PD3
#define LCD_RW D //RW SIGNAL
#define LCD_RW_POS PD6
/***********************************************
LCD Type Selection
Uncomment Just one of them
************************************************/
//#define LCD_TYPE_202 //For 20 Chars by 2 lines
//#define LCD_TYPE_204 //For 20 Chars by 4 lines
#define LCD_TYPE_162 //For 16 Chars by 2 lines
//#define LCD_TYPE_164 //For 16 Chars by 4 lines
//************************************************
//************************************************
#define LS_BLINK 0B00000001
#define LS_ULINE 0B00000010
#define LS_NONE 0B00000000
/***************************************************
F U N C T I O N S
****************************************************/
void LCDInit(uint8_t style);
void LCDWriteString(const char *msg);
void LCDWriteInt(int val,unsigned int field_length);
void LCDGotoXY(uint8_t x,uint8_t y);
//Low level
void LCDByte(uint8_t,uint8_t);
#define LCDCmd(c) (LCDByte(c,0))
#define LCDData(d) (LCDByte(d,1))
void LCDBusyLoop(void);
/***************************************************
F U N C T I O N S E N D
****************************************************/
/***************************************************
M A C R O S
***************************************************/
#define LCDClear() LCDCmd(0b00000001)
#define LCDHome() LCDCmd(0b00000010);
#define LCDWriteStringXY(x,y,msg) {\
LCDGotoXY(x,y);\
LCDWriteString(msg);\
}
#define LCDWriteIntXY(x,y,val,fl) {\
LCDGotoXY(x,y);\
LCDWriteInt(val,fl);\
}
/***************************************************/
/*_________________________________________________________________________________________*/
#endif