heat control  r71
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lcd_lib.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // File Name : 'lcd_lib.h'
4 // Title : 8 and 4 bit LCd interface + mixed pins modes
5 // Author : Scienceprog.com - Copyright (C) 2007
6 // Created : 2007-03-29
7 // Revised : 2011-12-13
8 // Version : 2.0
9 // Target MCU : Atmel AVR series
10 //
11 // This code is distributed under the GNU Public License
12 // which can be found at http://www.gnu.org/licenses/gpl.txt
13 //
14 //*****************************************************************************
15 #ifndef LCD_LIB
16 #define LCD_LIB
17 
18 #include <inttypes.h>
19 
20 
21 //Uncomment one of these if
22 //LCD 4 bit interface is used (single port pins)
23 #define LCD_4BIT
24 //LCD 8 bit interface is used (single port pins)
25 //#define LCD_8BIT
26 //LCD 4 bit interface is used (mixed port pins)
27 //#define LCD_4BIT_M
28 //LCD 8 bit interface is used (mixed port pins)
29 //#define LCD_8BIT_M
30 //******************************************************
31 
32 //progress bar usage (uncomment to use)
33 //#define USE_PROGBAR
34 
35 //******************************************************
36 
37 #define LCD_RS 0 //define MCU pin connected to LCD RS
38 #define LCD_RW 1 //define MCU pin connected to LCD R/W
39 #define LCD_E 2 //define MCU pin connected to LCD E
40 #define LCD_D0 0 //define MCU pin connected to LCD D0
41 #define LCD_D1 0 //define MCU pin connected to LCD D1
42 #define LCD_D2 0 //define MCU pin connected to LCD D2
43 #define LCD_D3 0 //define MCU pin connected to LCD D3
44 #define LCD_D4 4 //define MCU pin connected to LCD D4
45 #define LCD_D5 5 //define MCU pin connected to LCD D5
46 #define LCD_D6 6 //define MCU pin connected to LCD D6
47 #define LCD_D7 7 //define MCU pin connected to LCD D7
48 
49 
50 
51 #if defined (LCD_4BIT_M) || defined (LCD_8BIT_M)
52 #define LDPRS PORTB //RS pin assignment
53 #define LDDRS DDRB
54 #define LDPRW PORTD //RW pin assignment
55 #define LDDRW DDRD
56 #define LDPE PORTD //E pin assignment
57 #define LDDE DDRD
58 #define LDPD0 PORTC //D0 pin assignment
59 #define LDDD0 DDRC
60 #define LDPD1 PORTD //D1 pin assignment
61 #define LDDD1 DDRD
62 #define LDPD2 PORTC //D2 pin assignment
63 #define LDDD2 DDRC
64 #define LDPD3 PORTB //D3 pin assignment
65 #define LDDD3 DDRB
66 #define LDPD4 PORTD //D4 pin assignment
67 #define LDDD4 DDRD
68 #define LDPD5 PORTC //D5 pin assignment
69 #define LDDD5 DDRC
70 #define LDPD6 PORTD //D6 pin assignment
71 #define LDDD6 DDRD
72 #define LDPD7 PORTB //D7 pin assignment
73 #define LDDD7 DDRB
74 #endif
75 
76 #if defined (LCD_4BIT) || defined (LCD_8BIT) //if aligned mode
77 #define LDP PORTA //define MCU port connected to LCD data pins
78 #define LCP PORTA //define MCU port connected to LCD control pins
79 #define LDDR DDRA //define MCU direction register for port connected to LCD data pins
80 #define LCDR DDRA //define MCU direction register for port connected to LCD control pins
81 #endif
82 
83 
84 #define LCD_CLR 0 //DB0: clear display
85 #define LCD_HOME 1 //DB1: return to home position
86 #define LCD_ENTRY_MODE 2 //DB2: set entry mode
87 #define LCD_ENTRY_INC 1 //DB1: increment
88 #define LCD_ENTRY_SHIFT 0 //DB2: shift
89 #define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on
90 #define LCD_ON_DISPLAY 2 //DB2: turn display on
91 #define LCD_ON_CURSOR 1 //DB1: turn cursor on
92 #define LCD_ON_BLINK 0 //DB0: blinking cursor
93 #define LCD_MOVE 4 //DB4: move cursor/display
94 #define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)
95 #define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)
96 #define LCD_FUNCTION 5 //DB5: function set
97 #define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)
98 #define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)
99 #define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)
100 #define LCD_CGRAM 6 //DB6: set CG RAM address
101 #define LCD_DDRAM 7 //DB7: set DD RAM address
102 // reading:
103 #define LCD_BUSY 7 //DB7: LCD is busy
104 #define LCD_LINES 2 //visible lines
105 #define LCD_LINE_LENGTH 16 //line length (in characters)
106 // cursor position to DDRAM mapping
107 #define LCD_LINE0_DDRAMADDR 0x00
108 #define LCD_LINE1_DDRAMADDR 0x40
109 #define LCD_LINE2_DDRAMADDR 0x14
110 #define LCD_LINE3_DDRAMADDR 0x54
111 // progress bar defines
112 #define PROGRESSPIXELS_PER_CHAR 6
113 
114 
115 void LCDsendChar(uint8_t); //forms data ready to send to LCD
116 void LCDsendCommand(uint8_t); //forms data ready to send to LCD
117 void LCDinit(void); //Initializes LCD
118 void LCDclr(void); //Clears LCD
119 void LCDhome(void); //LCD cursor home
120 void LCDstring(uint8_t*); //Outputs string to LCD
121 void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
122 void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD at x,y
123 void LCDdefinechar(const uint8_t *,uint8_t);//write CHAR to LCD CGRAM
124 void LCDshiftRight(uint8_t); //shift by n characters Right
125 void LCDshiftLeft(uint8_t); //shift by n characters Left
126 void LCDcursorOn(void); //Underline cursor ON
127 void LCDcursorOnBlink(void); //Underline blinking cursor ON
128 void LCDcursorOFF(void); //Cursor OFF
129 void LCDblank(void); //LCD blank but not cleared
130 void LCDvisible(void); //LCD visible
131 void LCDcursorLeft(uint8_t); //Shift cursor left by n
132 void LCDcursorRight(uint8_t); //shif cursor right by n
133 // displays a horizontal progress bar at the current cursor location
134 // <progress> is the value the bargraph should indicate
135 // <maxprogress> is the value at the end of the bargraph
136 // <length> is the number of LCD characters that the bargraph should cover
137 //adapted from AVRLIB - displays progress only for 8 bit variables
138 void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length);
139 
140 
141 #endif
142 
void CopyStringtoLCD(const uint8_t *, uint8_t, uint8_t)
Definition: lcd_lib.c:401
void LCDcursorOFF(void)
Definition: lcd_lib.c:458
void LCDcursorOnBlink(void)
Definition: lcd_lib.c:454
void LCDclr(void)
Definition: lcd_lib.c:361
void LCDhome(void)
Definition: lcd_lib.c:365
void LCDdefinechar(const uint8_t *, uint8_t)
Definition: lcd_lib.c:425
void LCDcursorLeft(uint8_t)
Definition: lcd_lib.c:470
void LCDcursorOn(void)
Definition: lcd_lib.c:450
void LCDsendChar(uint8_t)
Definition: lcd_lib.c:262
void LCDshiftLeft(uint8_t)
Definition: lcd_lib.c:436
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length)
Definition: lcd_lib.c:485
void LCDvisible(void)
Definition: lcd_lib.c:466
void LCDshiftRight(uint8_t)
Definition: lcd_lib.c:443
void LCDblank(void)
Definition: lcd_lib.c:462
void LCDsendCommand(uint8_t)
Definition: lcd_lib.c:318
void LCDinit(void)
Definition: lcd_lib.c:80
void LCDcursorRight(uint8_t)
Definition: lcd_lib.c:477
void LCDGotoXY(uint8_t, uint8_t)
Definition: lcd_lib.c:382
void LCDstring(uint8_t *)
Definition: lcd_lib.c:369