1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
3 * Author : MCD Application Team
4 * Date First Issued : 05/18/2006 : Version 1.0
5 * Description : This file includes the LCD driver for GXM12232-2SL liquid
6 * Crystal Display Module of STR75x-EVAL.
7 ********************************************************************************
9 * 05/24/2006 : Version 1.1
10 * 05/18/2006 : Version 1.0
11 ********************************************************************************
12 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
14 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
15 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
16 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
17 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 *******************************************************************************/
20 /* Includes ------------------------------------------------------------------*/
26 /* Private typedef -----------------------------------------------------------*/
27 static GPIO_InitTypeDef GPIO_InitStructure;
29 /* Private define ------------------------------------------------------------*/
30 /* Private macro -------------------------------------------------------------*/
31 /* Private variables ---------------------------------------------------------*/
32 /* Global variable to set the written text color: used for LCD_Printf */
33 TextColorMode_TypeDef TextMode=BlackText;
35 /* ASCII Table: each character is 7 column (7dots large) on two pages (16dots high) */
36 /* 7 column character: Two 8bit data to display one column*/
37 u8 AsciiDotsTable[1778] = {
38 /* ASCII 0 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
39 /* ASCII 1 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
40 /* ASCII 2 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
41 /* ASCII 3 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
42 /* ASCII 4 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
43 /* ASCII 5 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
44 /* ASCII 6 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
45 /* ASCII 7 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
46 /* ASCII 8 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
47 /* ASCII 9 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
48 /* ASCII 10 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
49 /* ASCII 11 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
50 /* ASCII 12 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
51 /* ASCII 13 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
52 /* ASCII 14 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
53 /* ASCII 15 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
54 /* ASCII 16 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
55 /* ASCII 17 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
56 /* ASCII 18 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
57 /* ASCII 19 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
58 /* ASCII 20 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
59 /* ASCII 21 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
60 /* ASCII 22 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
61 /* ASCII 23 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
62 /* ASCII 24 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
63 /* ASCII 25 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
64 /* ASCII 26 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
65 /* ASCII 27 */ 0x1f,0xe0,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x1f,0xe0,0x00,0x00,
66 /* ASCII 28 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
67 /* ASCII 29 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
68 /* ASCII 30 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
69 /* ASCII 31 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
70 /* ASCII 32 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
71 /* ASCII 33 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x13,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,
72 /* ASCII 34 */ 0x00,0x00,0x00,0xe0,0x00,0x20,0x00,0x00,0x00,0xe0,0x00,0x20,0x00,0x00,
73 /* ASCII 35 */ 0x00,0x00,0x35,0x00,0x0f,0x80,0x35,0x60,0x0f,0x80,0x05,0x60,0x00,0x00,
74 /* ASCII 36 */ 0x00,0x00,0x0d,0x80,0x0a,0x40,0x3a,0x60,0x06,0x40,0x00,0x00,0x00,0x00,
75 /* ASCII 37 */ 0x00,0x00,0x02,0x40,0x02,0xa0,0x0a,0x40,0x15,0x00,0x09,0x00,0x00,0x00,
76 /* ASCII 38 */ 0x00,0x00,0x0c,0x00,0x13,0x00,0x14,0x80,0x08,0x80,0x14,0x00,0x00,0x00,
77 /* ASCII 39 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,
78 /* ASCII 40 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x80,0x60,0x60,0x00,0x00,0x00,0x00,
79 /* ASCII 41 */ 0x00,0x00,0x00,0x00,0x60,0x60,0x1f,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
80 /* ASCII 42 */ 0x00,0x00,0x00,0x40,0x03,0x40,0x00,0xe0,0x03,0x40,0x00,0x40,0x00,0x00,
81 /* ASCII 43 */ 0x02,0x00,0x02,0x00,0x02,0x00,0x1f,0xc0,0x02,0x00,0x02,0x00,0x02,0x00,
82 /* ASCII 44 */ 0x00,0x00,0x00,0x00,0x60,0x00,0x38,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
83 /* ASCII 45 */ 0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,
84 /* ASCII 46 */ 0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
85 /* ASCII 47 */ 0x00,0x00,0x20,0x00,0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x60,0x00,0x00,
86 /* ASCII 48 */ 0x00,0x00,0x0f,0xc0,0x10,0x20,0x10,0x20,0x10,0x20,0x0f,0xc0,0x00,0x00,
87 /* ASCII 49 */ 0x00,0x00,0x10,0x00,0x10,0x20,0x1f,0xe0,0x10,0x00,0x10,0x00,0x00,0x00,
88 /* ASCII 50 */ 0x00,0x00,0x18,0x40,0x14,0x20,0x12,0x20,0x11,0x20,0x18,0xc0,0x00,0x00,
89 /* ASCII 51 */ 0x00,0x00,0x08,0x40,0x10,0x20,0x11,0x20,0x11,0x20,0x0e,0xc0,0x00,0x00,
90 /* ASCII 52 */ 0x00,0x00,0x06,0x00,0x05,0x00,0x04,0xc0,0x14,0x20,0x1f,0xe0,0x14,0x00,
91 /* ASCII 53 */ 0x00,0x00,0x08,0x00,0x11,0xe0,0x11,0x20,0x11,0x20,0x0e,0x20,0x00,0x00,
92 /* ASCII 54 */ 0x00,0x00,0x0f,0x80,0x11,0x40,0x11,0x20,0x11,0x20,0x0e,0x20,0x00,0x00,
93 /* ASCII 55 */ 0x00,0x00,0x00,0x60,0x00,0x20,0x18,0x20,0x07,0x20,0x00,0xe0,0x00,0x00,
94 /* ASCII 56 */ 0x00,0x00,0x0e,0xc0,0x11,0x20,0x11,0x20,0x11,0x20,0x0e,0xc0,0x00,0x00,
95 /* ASCII 57 */ 0x00,0x00,0x11,0xc0,0x12,0x20,0x12,0x20,0x0a,0x20,0x07,0xc0,0x00,0x00,
96 /* ASCII 58 */ 0x00,0x00,0x00,0x00,0x19,0x80,0x19,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
97 /* ASCII 59 */ 0x00,0x00,0x00,0x00,0x30,0x00,0x19,0x80,0x09,0x80,0x00,0x00,0x00,0x00,
98 /* ASCII 60 */ 0x02,0x00,0x05,0x00,0x05,0x00,0x08,0x80,0x10,0x40,0x10,0x40,0x00,0x00,
99 /* ASCII 61 */ 0x00,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x00,0x00,
100 /* ASCII 62 */ 0x10,0x40,0x10,0x40,0x08,0x80,0x05,0x00,0x05,0x00,0x02,0x00,0x00,0x00,
101 /* ASCII 63 */ 0x00,0x00,0x00,0x00,0x10,0x80,0x14,0x40,0x02,0x40,0x01,0x80,0x00,0x00,
102 /* ASCII 64 */ 0x00,0x00,0x1f,0xe0,0x20,0x10,0x23,0x10,0x24,0x90,0x17,0xe0,0x00,0x00,
103 /* ASCII 65 */ 0x10,0x00,0x1c,0x00,0x17,0xa0,0x04,0x60,0x17,0x80,0x1c,0x00,0x10,0x00,
104 /* ASCII 66 */ 0x10,0x20,0x1f,0xe0,0x11,0x20,0x11,0x20,0x11,0x20,0x0e,0xc0,0x00,0x00,
105 /* ASCII 67 */ 0x00,0x00,0x0f,0xc0,0x10,0x20,0x10,0x20,0x10,0x20,0x08,0x60,0x00,0x00,
106 /* ASCII 68 */ 0x10,0x20,0x1f,0xe0,0x10,0x20,0x10,0x20,0x08,0x40,0x07,0x80,0x00,0x00,
107 /* ASCII 69 */ 0x10,0x20,0x1f,0xe0,0x11,0x20,0x13,0xa0,0x10,0x20,0x18,0x60,0x00,0x00,
108 /* ASCII 70 */ 0x00,0x00,0x10,0x20,0x1f,0xe0,0x11,0x20,0x03,0xa0,0x00,0x20,0x00,0x60,
109 /* ASCII 71 */ 0x00,0x00,0x0f,0xc0,0x10,0x20,0x10,0x20,0x12,0x20,0x0e,0x60,0x02,0x00,
110 /* ASCII 72 */ 0x10,0x20,0x1f,0xe0,0x11,0x20,0x01,0x00,0x11,0x20,0x1f,0xe0,0x10,0x20,
111 /* ASCII 73 */ 0x00,0x00,0x10,0x20,0x10,0x20,0x1f,0xe0,0x10,0x20,0x10,0x20,0x00,0x00,
112 /* ASCII 74 */ 0x00,0x00,0x0e,0x00,0x10,0x20,0x10,0x20,0x0f,0xe0,0x00,0x20,0x00,0x00,
113 /* ASCII 75 */ 0x10,0x20,0x1f,0xe0,0x12,0x20,0x03,0x00,0x04,0xa0,0x18,0x60,0x10,0x20,
114 /* ASCII 76 */ 0x00,0x00,0x10,0x20,0x1f,0xe0,0x10,0x20,0x10,0x00,0x1c,0x00,0x00,0x00,
115 /* ASCII 77 */ 0x10,0x20,0x1f,0xe0,0x10,0xe0,0x03,0x00,0x10,0xe0,0x1f,0xe0,0x10,0x20,
116 /* ASCII 78 */ 0x10,0x20,0x1f,0xe0,0x10,0xe0,0x07,0x00,0x18,0x20,0x1f,0xe0,0x00,0x20,
117 /* ASCII 79 */ 0x00,0x00,0x0f,0xc0,0x10,0x20,0x10,0x20,0x10,0x20,0x0f,0xc0,0x00,0x00,
118 /* ASCII 80 */ 0x00,0x00,0x10,0x20,0x1f,0xe0,0x12,0x20,0x02,0x20,0x01,0xc0,0x00,0x00,
119 /* ASCII 81 */ 0x00,0x00,0x0f,0xc0,0x10,0x20,0x30,0x20,0x30,0x20,0x2f,0xc0,0x00,0x00,
120 /* ASCII 82 */ 0x10,0x20,0x1f,0xe0,0x12,0x20,0x02,0x20,0x06,0x20,0x09,0xc0,0x10,0x00,
121 /* ASCII 83 */ 0x00,0x00,0x18,0xc0,0x09,0x20,0x11,0x20,0x11,0x40,0x0e,0x60,0x00,0x00,
122 /* ASCII 84 */ 0x00,0x60,0x00,0x20,0x10,0x20,0x1f,0xe0,0x10,0x20,0x00,0x20,0x00,0x60,
123 /* ASCII 85 */ 0x00,0x20,0x0f,0xe0,0x10,0x20,0x10,0x00,0x10,0x20,0x0f,0xe0,0x00,0x20,
124 /* ASCII 86 */ 0x00,0x20,0x00,0xe0,0x07,0x20,0x18,0x00,0x07,0x20,0x00,0xe0,0x00,0x20,
125 /* ASCII 87 */ 0x00,0x20,0x0f,0xe0,0x10,0x20,0x0f,0x00,0x10,0x20,0x0f,0xe0,0x00,0x20,
126 /* ASCII 88 */ 0x10,0x20,0x18,0x60,0x04,0x80,0x03,0x00,0x04,0x80,0x18,0x60,0x10,0x20,
127 /* ASCII 89 */ 0x00,0x20,0x00,0x60,0x11,0xa0,0x1e,0x00,0x11,0xa0,0x00,0x60,0x00,0x20,
128 /* ASCII 90 */ 0x00,0x00,0x18,0x60,0x14,0x20,0x13,0x20,0x10,0xa0,0x18,0x60,0x00,0x00,
129 /* ASCII 91 */ 0x00,0x00,0x00,0x00,0x7f,0xe0,0x40,0x20,0x40,0x20,0x00,0x00,0x00,0x00,
130 /* ASCII 92 */ 0x00,0x00,0x00,0x20,0x01,0xc0,0x06,0x00,0x38,0x00,0x00,0x00,0x00,0x00,
131 /* ASCII 93 */ 0x00,0x00,0x00,0x00,0x40,0x20,0x40,0x20,0x7f,0xe0,0x00,0x00,0x00,0x00,
132 /* ASCII 94 */ 0x00,0x00,0x01,0x00,0x00,0x80,0x00,0x60,0x00,0x80,0x01,0x00,0x00,0x00,
133 /* ASCII 95 */ 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
134 /* ASCII 96 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x00,0x00,0x00,
135 /* ASCII 97 */ 0x00,0x00,0x0d,0x00,0x12,0x80,0x12,0x80,0x12,0x80,0x1f,0x00,0x10,0x00,
136 /* ASCII 98 */ 0x10,0x20,0x1f,0xe0,0x11,0x00,0x10,0x80,0x10,0x80,0x0f,0x00,0x00,0x00,
137 /* ASCII 99 */ 0x00,0x00,0x0f,0x00,0x10,0x80,0x10,0x80,0x10,0x80,0x09,0x80,0x00,0x00,
138 /* ASCII 100 */ 0x00,0x00,0x0f,0x00,0x10,0x80,0x10,0x80,0x11,0x20,0x1f,0xe0,0x10,0x00,
139 /* ASCII 101 */ 0x00,0x00,0x0f,0x00,0x12,0x80,0x12,0x80,0x12,0x80,0x13,0x00,0x00,0x00,
140 /* ASCII 102 */ 0x00,0x00,0x10,0x80,0x1f,0xc0,0x10,0xa0,0x10,0xa0,0x10,0xa0,0x00,0x00,
141 /* ASCII 103 */ 0x00,0x00,0x0f,0x00,0x50,0x80,0x50,0x80,0x51,0x00,0x3f,0x80,0x00,0x80,
142 /* ASCII 104 */ 0x10,0x20,0x1f,0xe0,0x11,0x00,0x00,0x80,0x10,0x80,0x1f,0x00,0x10,0x00,
143 /* ASCII 105 */ 0x00,0x00,0x10,0x80,0x10,0x80,0x1f,0xa0,0x10,0x00,0x10,0x00,0x00,0x00,
144 /* ASCII 106 */ 0x00,0x00,0x40,0x80,0x40,0x80,0x40,0xa0,0x3f,0x80,0x00,0x00,0x00,0x00,
145 /* ASCII 107 */ 0x10,0x20,0x1f,0xe0,0x02,0x00,0x16,0x80,0x19,0x80,0x10,0x80,0x00,0x00,
146 /* ASCII 108 */ 0x00,0x00,0x10,0x00,0x10,0x20,0x1f,0xe0,0x10,0x00,0x10,0x00,0x00,0x00,
147 /* ASCII 109 */ 0x10,0x80,0x1f,0x80,0x10,0x80,0x1f,0x00,0x10,0x80,0x1f,0x00,0x10,0x00,
148 /* ASCII 110 */ 0x10,0x80,0x1f,0x80,0x11,0x00,0x00,0x80,0x10,0x80,0x1f,0x00,0x10,0x00,
149 /* ASCII 111 */ 0x00,0x00,0x0f,0x00,0x10,0x80,0x10,0x80,0x10,0x80,0x0f,0x00,0x00,0x00,
150 /* ASCII 112 */ 0x40,0x80,0x7f,0x80,0x51,0x00,0x10,0x80,0x10,0x80,0x0f,0x00,0x00,0x00,
151 /* ASCII 113 */ 0x00,0x00,0x0f,0x00,0x10,0x80,0x10,0x80,0x51,0x00,0x7f,0x80,0x40,0x80,
152 /* ASCII 114 */ 0x00,0x00,0x10,0x80,0x1f,0x80,0x11,0x00,0x10,0x80,0x10,0x80,0x00,0x00,
153 /* ASCII 115 */ 0x00,0x00,0x19,0x00,0x12,0x80,0x12,0x80,0x12,0x80,0x0d,0x80,0x00,0x00,
154 /* ASCII 116 */ 0x00,0x00,0x00,0x80,0x0f,0xc0,0x10,0x80,0x10,0x80,0x10,0x80,0x08,0x00,
155 /* ASCII 117 */ 0x00,0x80,0x0f,0x80,0x10,0x00,0x10,0x00,0x08,0x80,0x1f,0x80,0x10,0x00,
156 /* ASCII 118 */ 0x00,0x80,0x03,0x80,0x0c,0x80,0x10,0x00,0x0c,0x80,0x03,0x80,0x00,0x80,
157 /* ASCII 119 */ 0x00,0x80,0x0f,0x80,0x10,0x80,0x0e,0x00,0x10,0x80,0x0f,0x80,0x00,0x80,
158 /* ASCII 120 */ 0x10,0x80,0x19,0x80,0x06,0x00,0x06,0x00,0x19,0x80,0x10,0x80,0x00,0x00,
159 /* ASCII 121 */ 0x00,0x80,0x41,0x80,0x46,0x80,0x78,0x00,0x4c,0x80,0x03,0x80,0x00,0x80,
160 /* ASCII 122 */ 0x00,0x00,0x19,0x80,0x14,0x80,0x12,0x80,0x11,0x80,0x18,0x80,0x00,0x00,
161 /* ASCII 123 */ 0x00,0x00,0x00,0x00,0x04,0x00,0x3b,0xc0,0x40,0x20,0x00,0x00,0x00,0x00,
162 /* ASCII 124 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,
163 /* ASCII 125 */ 0x00,0x00,0x00,0x00,0x40,0x20,0x3b,0xc0,0x04,0x00,0x00,0x00,0x00,0x00,
164 /* ASCII 126 */ 0x00,0x00,0x04,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x00,0x00};
166 /* Private function prototypes -----------------------------------------------*/
167 /* Private functions ---------------------------------------------------------*/
169 /*******************************************************************************
170 * Function Name : LCD_DataLinesConfig
171 * Description : Configure data lines D0~D7 (P8.0~P8.7) in Input Floating mode
172 * for read from LCD or in Output Push-Pull mode for write on LCD
173 * Input : - Mode: specifies the configuration mode for data lines D0~D7
174 * - Input: configure in Input Floating mode
175 * - Output: configure in Output Push-Pul mode
178 *******************************************************************************/
179 void LCD_DataLinesConfig(DataConfigMode_TypeDef Mode)
181 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
184 /* Configure D0~D7 lines (P8.0 ->P8.7) as Input */
185 GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
189 /* Configure D0~D7 lines in Output Push-Pull mode */
190 GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput ;
191 GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
193 GPIO_Init(GPIO8, &GPIO_InitStructure);
196 /*******************************************************************************
197 * Function Name : LCD_DataLinesWrite
198 * Description : Write a value on D0~D7 (P8.0~P8.7)
199 * Input : - GPIOx: GPIO port to write on. It could be
200 * - PortVal: value to write
203 *******************************************************************************/
204 void LCD_DataLinesWrite(GPIO_TypeDef* GPIOx, u32 PortVal)
206 GPIOx->DR[0x3FC] = PortVal;
209 /*******************************************************************************
210 * Function Name : LCD_CtrlLinesConfig
211 * Description : Configure control lines E2, E1, RW, DI (P9.4~P9.7) in
212 * Output Push-Pull mode.
216 *******************************************************************************/
217 void LCD_CtrlLinesConfig(void)
219 /* Configure E2, E1, RW, DI lines (P9.4~P9.7) in Output Push-Pull mode */
220 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
221 GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput ;
222 GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
223 GPIO_Init(GPIO9, &GPIO_InitStructure);
226 /*******************************************************************************
227 * Function Name : LCD_CtrlLinesWrite
228 * Description : Set or reset control lines E2, E1, RW, DI (P9.4~P9.7).
229 * Input : - GPIOx: where x can be 0,1 or 2 to select the GPIO peripheral.
230 * - CtrlPins: the Control line. This parameter can be:
231 * - CtrlPin_E2: Enabe clock signal for Slave
232 * - CtrlPin_E1: Enabe clock signal for Master
233 * - CtrlPin_RW: Read/Write control line
237 *******************************************************************************/
238 void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, u32 CtrlPins, BitAction BitVal)
240 /* Set or Reset the control line */
241 if(BitVal == Bit_SET)
243 GPIOx->DR[CtrlPins <<2] = CtrlPins;
247 GPIOx->DR[CtrlPins <<2] = 0x00;
251 /*******************************************************************************
252 * Function Name : LCD_CheckMasterStatus
253 * Description : Check whether master LCD is busy or not
257 *******************************************************************************/
258 void LCD_CheckMasterStatus(void)
262 /* Configure Data lines as Input */
263 LCD_DataLinesConfig(Input);
264 /* Start the master read sequence */
265 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
266 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_SET); /* RW = 1 */
267 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_RESET); /* DI = 0 */
268 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_SET); /* E1 = 1 */
269 MasterStatus = GPIO_Read(GPIO8);
270 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
272 /* Wait until BF is cleared */
273 while ((MasterStatus & 0x80))
276 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_SET); /* E1 = 1 */
277 MasterStatus = GPIO_Read(GPIO8);
278 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
282 /*******************************************************************************
283 * Function Name : LCD_CheckSlaveStatus
284 * Description : Check whether slave LCD is busy or not
288 *******************************************************************************/
289 void LCD_CheckSlaveStatus(void)
293 /* Configure Data lines as Input */
294 LCD_DataLinesConfig(Input);
295 /* Start the slave read sequence */
296 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
297 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_SET); /* RW = 1 */
298 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_RESET); /* DI = 0 */
299 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_SET); /* E2 = 1 */
300 SlaveStatus = GPIO_Read(GPIO8);
301 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
303 /* Wait until BF is cleared */
304 while ((SlaveStatus & 0x80))
307 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_SET); /* E2 = 1 */
308 SlaveStatus = GPIO_Read(GPIO8);
309 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
313 /*******************************************************************************
314 * Function Name : LCD_SendMasterCmd
315 * Description : Send one byte command to master LCD.
316 * Input : - Cmd: the user expected command to send to master LCD
319 *******************************************************************************/
320 void LCD_SendMasterCmd(u8 Cmd)
322 /* Check the master status */
323 LCD_CheckMasterStatus();
324 /* Configure Data lines as Output */
325 LCD_DataLinesConfig(Output);
326 /* Start the master send command sequence */
327 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
328 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_RESET); /* RW = 0 */
329 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_RESET); /* DI = 0 */
330 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_SET); /* E1 = 1 */
331 /* Write master command */
332 LCD_DataLinesWrite(GPIO8, (u32)Cmd);
333 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
336 /*******************************************************************************
337 * Function Name : LCD_SendSlaveCmd
338 * Description : Send one byte command to slave LCD
339 * Input : - Cmd: the user expected command to send to slave LCD.
342 *******************************************************************************/
343 void LCD_SendSlaveCmd(u8 Cmd)
345 /* Check the slave status */
346 LCD_CheckSlaveStatus();
347 /* Configure Data lines as Output */
348 LCD_DataLinesConfig(Output);
349 /* Start the slave send command sequence */
350 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
351 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_RESET); /* RW = 0 */
352 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_RESET); /* DI = 0 */
353 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_SET); /* E2 = 1 */
354 /* Write slave command */
355 LCD_DataLinesWrite(GPIO8, (u32)Cmd);
356 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
359 /*******************************************************************************
360 * Function Name : LCD_SendMasterData
361 * Description : Display one byte data to master LCD.
362 * Input : - Data: the user expected data to display on master LCD.
365 *******************************************************************************/
366 void LCD_SendMasterData(u8 Data)
368 /* Check the master status */
369 LCD_CheckMasterStatus();
370 /* Configure Data lines as Output */
371 LCD_DataLinesConfig(Output);
372 /* Start the master send data sequence */
373 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
374 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_RESET); /* RW = 0 */
375 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_SET); /* DI = 1 */
376 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_SET); /* E1 = 1 */
377 /* Write data to the master */
378 LCD_DataLinesWrite(GPIO8, (u32)Data);
379 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
382 /*******************************************************************************
383 * Function Name : LCD_ReadMasterData
384 * Description : Read master byte data displayed on master LCD.
388 *******************************************************************************/
389 u32 LCD_ReadMasterData(void)
393 /* Check the master status */
394 LCD_CheckMasterStatus();
395 /* Configure Data lines as Input */
396 LCD_DataLinesConfig(Input);
397 /* Start the master read data sequence */
398 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
399 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_SET); /* RW = 1 */
400 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_SET); /* DI = 1 */
401 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_SET); /* E1 = 1 */
402 /* Read data from the master */
403 MasterData = (GPIO_Read(GPIO8));
404 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
405 /* Read the master returned data */
409 /*******************************************************************************
410 * Function Name : LCD_SendSlaveData
411 * Description : Display one byte data to slave LCD.
412 * Input : - Data: the user expected data to display on slave LCD.
415 *******************************************************************************/
416 void LCD_SendSlaveData(u8 Data)
418 /* Check the slave status */
419 LCD_CheckSlaveStatus();
420 /* Configure Data lines as Output */
421 LCD_DataLinesConfig(Output);
422 /* Start the slave send data sequence */
423 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
424 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_RESET); /* RW = 0 */
425 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_SET); /* DI = 1 */
426 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_SET); /* E2 = 1 */
427 /* Write data to the slave */
428 LCD_DataLinesWrite(GPIO8, (u32)Data);
429 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
432 /*******************************************************************************
433 * Function Name : LCD_ReadSlaveData
434 * Description : Read slave byte data displayed on slave LCD.
438 *******************************************************************************/
439 u32 LCD_ReadSlaveData(void)
443 /* Check the slave status */
444 LCD_CheckSlaveStatus();
445 /* Configure Data lines as Input */
446 LCD_DataLinesConfig(Input);
447 /* Start the slave read data sequence */
448 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
449 LCD_CtrlLinesWrite(GPIO9, CtrlPin_RW, Bit_SET); /* RW = 1 */
450 LCD_CtrlLinesWrite(GPIO9, CtrlPin_DI, Bit_SET); /* DI = 1 */
451 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_SET); /* E2 = 1 */
452 /* Read data from the slave */
453 SlaveData = GPIO_Read(GPIO8);
454 LCD_CtrlLinesWrite(GPIO9, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
455 /* Read the slave returned data */
459 /*******************************************************************************
460 * Function Name : LCD_Init
461 * Description : Initialize master and slave LCD.
465 *******************************************************************************/
468 /* Enable GPIO Clock */
471 /* Configure control lines signals as output mode */
472 LCD_CtrlLinesConfig();
474 /* Master LCD Init */
475 LCD_SendMasterCmd(SOFTWARE_RESET);
476 LCD_SendMasterCmd(DISPLAY_OFF);
477 LCD_SendMasterCmd(DYNAMIC_DRIVE);
478 LCD_SendMasterCmd(DUTY_CYCLE);
479 LCD_SendMasterCmd(CLOCKWISE_OUTPUT);
480 LCD_SendMasterCmd(READ_MODIFY_WRITE_OFF);
481 LCD_SendMasterCmd(START_COLUMN); /* Set master column address to 0 */
482 LCD_SendMasterCmd(START_LINE); /* Set master display start line to 0 */
483 LCD_SendMasterCmd(DISPLAY_ON );
486 LCD_SendSlaveCmd(SOFTWARE_RESET);
487 LCD_SendSlaveCmd(DISPLAY_OFF);
488 LCD_SendSlaveCmd(DYNAMIC_DRIVE);
489 LCD_SendSlaveCmd(DUTY_CYCLE);
490 LCD_SendSlaveCmd(CLOCKWISE_OUTPUT);
491 LCD_SendSlaveCmd(READ_MODIFY_WRITE_OFF);
492 LCD_SendSlaveCmd(START_COLUMN ); /* Set slave column address to 0 */
493 LCD_SendSlaveCmd(START_LINE); /* Set slave display start line to 0 */
494 LCD_SendSlaveCmd(DISPLAY_ON);
498 /* Set current Page to 0 for Master and Slave LCDs */
500 LCD_SetMasterPage(0);
503 /*******************************************************************************
504 * Function Name : LCD_SetSlavePage
505 * Description : Set the display page of slave LCD, the page range is 0 to 3,
506 * make sure the input will not exceed this range ,otherwise it
507 * will reach a undecided result.
508 * Input : - Page: specifies the expected display page of slave LCD
511 *******************************************************************************/
512 void LCD_SetSlavePage(u8 Page)
514 static u8 ucLastPage = 255;
517 if( Page != ucLastPage )
519 LCD_SendSlaveCmd(0xB8|Page);
524 /*******************************************************************************
525 * Function Name : LCD_SetMasterPage
526 * Description : Set the display page of master LCD, the page range is 0 to 3,
527 * make sure the input will not exceed this range ,otherwise it
528 * will reach a undecided result.
529 * Input : - Page: specifies the expected display page of master LCD
532 *******************************************************************************/
533 void LCD_SetMasterPage(u8 Page)
535 static u8 ulLastPage = 255;
537 /* Set Master page */
538 if( Page != ulLastPage )
540 LCD_SendMasterCmd(0xB8|Page);
545 /*******************************************************************************
546 * Function Name : SetAddress
547 * Description : Set the display column of slave LCD. Column range is 0 to 61.
548 * Input : - Address: specifies the expected display column of slave LCD
551 *******************************************************************************/
552 void LCD_SetSlaveColumn(u8 Address)
554 /* Set Slave column address */
555 LCD_SendSlaveCmd(Address&0x7F);
558 /*******************************************************************************
559 * Function Name : LCD_SetMasterColumn
560 * Description : Set the display column of master LCD. Column range is 0 to 61.
561 * Input : - Address: specifies the expected display column of slave LCD
564 *******************************************************************************/
565 void LCD_SetMasterColumn(u8 Address)
567 /* Set Master column address */
568 LCD_SendMasterCmd(Address&0x7F);
571 /*******************************************************************************
572 * Function Name : LCD_SetTextColor
573 * Description : Set the text color for LCD.
574 * Input : - TextColor: BlackText: character on black, bottom on white.
575 * WhiteText: character on white, bottom on black.
578 *******************************************************************************/
579 void LCD_SetTextColor(TextColorMode_TypeDef TextColor)
583 /* Set White Text color */
588 /* Set Black Text color */
593 /*******************************************************************************
594 * Function Name : LCD_Clear
595 * Description : Clear the Master and Slave LCDs display.
599 *******************************************************************************/
602 u8 Page = 0, Column = 0;
604 /* Clear master and slave LCDs page by page */
605 for (Page=0; Page<4; Page++)
607 /* Set master and slave page by page */
608 LCD_SetMasterPage(Page);
609 LCD_SetSlavePage(Page);
610 /* Set master and slave column address */
611 LCD_SetMasterColumn(0);
612 LCD_SetSlaveColumn(0);
613 /* Send empty data to master and slave column address on the selected page */
614 for (Column=0; Column<61; Column++)
616 LCD_SendSlaveData(0);
617 LCD_SendMasterData(0);
622 /*******************************************************************************
623 * Function Name : LCD_ClearLine
624 * Description : Clear the selected line of the LCD.
625 * Input : - Line: the Line to clear.
626 * - Line1 (Page0&1): clear the first line
627 * - Line2 (Page2&3): clear the second line
630 *******************************************************************************/
631 void LCD_ClearLine(u8 Line)
633 u8 Page = 0, Column = 0;
635 /* Clear the slected master and slave line */
636 for (Page=Line; Page<Line+2; Page++)
638 /* Set master and slave page by page */
639 LCD_SetMasterPage(Page);
640 LCD_SetSlavePage(Page);
641 /* Set master and slave column address */
642 LCD_SetMasterColumn(0);
643 LCD_SetSlaveColumn(0);
644 /* Send empty data to master and slave column address on the selected page */
645 for (Column=0; Column<61; Column++)
647 LCD_SendSlaveData(0);
648 LCD_SendMasterData(0);
653 /*******************************************************************************
654 * Function Name : LCD_ClearMaster
655 * Description : Clear the master LCD.
659 *******************************************************************************/
660 void LCD_ClearMaster(void)
662 u8 Page = 0, Column = 0;
664 /* Clear all master LCD pages */
665 for (Page=0; Page<4; Page++)
667 /* Set master page by page */
668 LCD_SetMasterPage(Page);
669 /* Set master column address */
670 LCD_SetMasterColumn(0);
671 /* Send empty data to master column address on the selected page */
672 for (Column=0; Column<61; Column++)
674 LCD_SendMasterData(0);
679 /*******************************************************************************
680 * Function Name : LCD_ClearSlave
681 * Description : Clear the slave LCD.
685 *******************************************************************************/
686 void LCD_ClearSlave()
688 u8 Page = 0, Column = 0;
690 /* Clear all slave LCD pages */
691 for (Page=0; Page<4; Page++)
693 /* Set slave page by page */
694 LCD_SetSlavePage(Page);
695 /* Set slave column address */
696 LCD_SetSlaveColumn(0);
697 /* Send empty data to slave column address on the selected page */
698 for (Column=0; Column<61; Column++)
700 LCD_SendSlaveData(0);
705 /*******************************************************************************
706 * Function Name : LCD_DrawChar
707 * Description : Draw a character in LCD.
709 * the LCD can only display two line character,so page 0 and 1
710 * is to display the first line, page2 and page 3 is to display
712 * Input : - Line: the Line where to display the character shape .
713 * - Line1 (Page0&1): display character on the first line
714 * - Line2 (Page2&3): display character on the second line
715 * - Column: start column address.
716 * - Width: the number of column (dots) of a character width.
717 * - Bmp: the pointer of the dot matrix data.
720 *******************************************************************************/
721 void LCD_DrawChar(u8 Line, u8 Column, u8 Width, u8 *Bmp)
723 u8 X = 0, ActualColumn = 0, Window = 0, i = 0;
725 /* Draw the character column by column: width times */
726 for(X = Column; X<(Column+Width); X++)
730 /* Return if column exceeded 121 */
735 /* To be displayed on slave LCD (Window = 1) */
737 /* Get the Slave relative start column */
738 // ActualColumn = X%61;
739 ActualColumn = X - 61;
743 /* To be displayed on master LCD (Window = 0) */
747 /* Switch window, display the character upper part */
750 /* Display it on slave LCD */
751 LCD_SetSlavePage(Line);
752 LCD_SetSlaveColumn(ActualColumn);
753 LCD_SendSlaveData(Bmp[i]);
757 /* Display it on master LCD */
758 LCD_SetMasterPage(Line);
759 LCD_SetMasterColumn(ActualColumn);
760 LCD_SendMasterData(Bmp[i]);
762 /* Switch window, diplay the character lower part */
765 /* Display it on slave LCD */
766 LCD_SetSlavePage(Line+1);
767 LCD_SetSlaveColumn(ActualColumn);
768 LCD_SendSlaveData(Bmp[i+1]);
772 /* Display it on master LCD */
773 LCD_SetMasterPage(Line+1);
774 LCD_SetMasterColumn(ActualColumn);
775 LCD_SendMasterData(Bmp[i+1]);
777 /* Increment by 2 the character table index */
782 /*******************************************************************************
783 * Function Name : LCD_DisplayChar
784 * Description : Display one character (7dots large, 16dots high).
786 * the LCD can only display two line character,so page 0 and 1
787 * is to display the first line, page2 and page 3 is to display
789 * Input : - Line: the Line where to display the character.
790 * - Line1 (Page0&1): display character on the first line
791 * - Line2 (Page2&3): display character on the second line
792 * - Column: start column address.
793 * - Ascii: character ascii code.
794 * - CharMode: BlackText: character on black, bottom on white.
795 * WhiteText: character on white, bottom on black.
798 *******************************************************************************/
799 void LCD_DisplayChar(u8 Line, u8 Column, u8 Ascii, TextColorMode_TypeDef CharMode)
801 u8 DotBuffer[14], i = 0;
803 /* Display the character lower and upper 8bit parts (2*7columns) */
806 /* Character displayed as white Text on black buttom */
811 DotBuffer[i] = ~AsciiDotsTable[Ascii*14+i-1];
815 DotBuffer[i] = ~AsciiDotsTable[Ascii*14+i+1];
818 /* Character displayed as black Text on white buttom */
821 if( ( u8 ) i & 0x01 )
823 DotBuffer[i] = AsciiDotsTable[Ascii*14+i-1];
827 DotBuffer[i] = AsciiDotsTable[Ascii*14+i+1];
831 /* Display the asc code after conversion */
832 LCD_DrawChar(Line, Column, 7, DotBuffer);
835 /*******************************************************************************
836 * Function Name : LCD_HexToAsciiLow
837 * Description : This function is used to convert the low nibble of an
838 * unsigned byte (0-F hex) to ASCII.
839 * Input : - byte: byte to convert to ASCII.
841 * Return : ASCII value result of the conversion.
842 *******************************************************************************/
843 char LCD_HexToAsciiLow(u8 byte)
845 /* Keep lower nibble only */
847 /* If the ascii is a number */
850 /* Add 0x30 to its ascii */
855 /* Add 0x37 to its ascii */
856 return (byte + 0x37);
860 /*******************************************************************************
861 * Function Name : LCD_HexToAsciiHigh
862 * Description : This function is used to convert the high nibble of an
863 * unsigned byte (0-F hex) to ASCII.
864 * Input : - byte: byte to convert to ASCII.
866 * Return : ASCII value result of the conversion.
867 *******************************************************************************/
868 char LCD_HexToAsciiHigh(u8 byte)
870 /* Keep upper nibble only */
873 /* If the ascii is a number */
876 /* Add 0x30 to display its ascii */
881 /* Add 0x37 to display its ascii */
882 return (byte + 0x37);
886 /*******************************************************************************
887 * Function Name : LCD_DisplayString
888 * Description : This function is used to display a 17char max string of
889 * characters on the LCD display on the selected line.
891 * this function is the user interface to use the LCD driver.
892 * Input : - *ptr: pointer to string to display on LCD.
893 * - Line: the Line where to display the character.
894 * - Line1 (Page0&1): display character on the first line
895 * - Line2 (Page2&3): display character on the second line
898 *******************************************************************************/
899 void LCD_DisplayString(u8 Line, u8 *ptr, TextColorMode_TypeDef CharMode)
901 u8 RefColumn = 0, i = 0;
903 /* Send the string character by character on lCD */
904 while ((*ptr!=0)&(i<17))
908 /* Display one character on LCD */
909 LCD_DisplayChar(Line, RefColumn, *ptr, CharMode);
911 /* Increment the column position by 7 */
913 /* Point on the next character */
915 /* Increment the character counter */
917 /* If we reach the maximum Line character */
920 LCD_DisplayChar(Line, RefColumn-1, 0x1f, CharMode); /* Add missed columns */
925 /*******************************************************************************
926 * Function Name : LCD_Printf
927 * Description : This function is used to display a string of characters
928 * on the LCD display.
930 * this function is the user interface to use the LCD driver.
931 * Input : - *ptr: pointer to string to display on LCD.
934 *******************************************************************************/
935 void LCD_Printf(u8 *ptr, ...)
937 u8 RefColumn = 0, RefPage = 0, i = 0, c1 = 0;
938 u16 var = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
941 /* Store pointer on LCD_Printf second parameter (String) */
942 u8 *var_ptr=(u8 *)(&ptr+1);
948 /* Limited to AsciiDotsTable code table */
951 /* Carriage return */
958 else if( *ptr == '\n')
960 /* Point on the string to display */
963 LCD_ClearLine(Line2);
964 /* Point on first Line2 column */
966 /* Increment RefPage by 2 */
969 /* Display value on the passed format */
970 else if( *ptr == '%')
973 /* Display decimal value */
977 /* Get the word value to display */
978 WordVar = ((*var_ptr)|(*(var_ptr+1)<<8)|(*(var_ptr+2)<<16));
980 c2=(WordVar%10000)/1000;
981 c3=(WordVar%1000)/100;
984 /* Display the ten miles digit */
987 LCD_DisplayChar(RefPage, RefColumn, c1+0x30, TextMode);
990 /* Display the miles digit */
991 if (!((c1==0)&(c2==0)))
993 LCD_DisplayChar(RefPage, RefColumn, c2+0x30, TextMode);
996 /* Display the hundred digit */
997 if (!((c1==0)&(c2==0)&(c3==0)))
999 LCD_DisplayChar(RefPage, RefColumn, c3+0x30, TextMode);
1002 /* Display the tens digit */
1003 if (!((c1==0)&(c2==0)&(c3==0)&(c4==0)))
1005 LCD_DisplayChar(RefPage, RefColumn, c4+0x30, TextMode);
1008 /* Display the rest */
1009 LCD_DisplayChar(RefPage, RefColumn, c5+0x30, TextMode);
1012 /* Display 16bits Hex value */
1013 else if (*ptr == 'x')
1016 /* Display 8bits MSB */
1017 var_ptr = var_ptr +1;
1019 c1 = LCD_HexToAsciiHigh(var);
1020 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1022 c1 = LCD_HexToAsciiLow(var);
1023 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1025 /* Display 8bits LSB */
1026 var_ptr = var_ptr -1;
1028 var_ptr = var_ptr +4;
1029 c1 = LCD_HexToAsciiHigh(var);
1030 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1032 c1 = LCD_HexToAsciiLow(var);
1033 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1036 /* Display 32bits Hex value */
1037 else if (*ptr == 'w')
1040 /* Display 16bits MSB */
1041 var_ptr = var_ptr +3;
1043 c1 = LCD_HexToAsciiHigh(var);
1044 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1046 c1 = LCD_HexToAsciiLow(var);
1047 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1049 var_ptr = var_ptr -1;
1051 c1 = LCD_HexToAsciiHigh(var);
1052 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1054 c1 = LCD_HexToAsciiLow(var);
1055 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1057 /* Display 16bits LSB */
1058 var_ptr = var_ptr -1;
1060 var_ptr = var_ptr +4;
1061 c1 = LCD_HexToAsciiHigh(var);
1062 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1064 c1 = LCD_HexToAsciiLow(var);
1065 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1067 var_ptr = var_ptr -5;
1069 var_ptr = var_ptr +4;
1070 c1 = LCD_HexToAsciiHigh(var);
1071 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1073 c1 = LCD_HexToAsciiLow(var);
1074 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1079 /* Display '%' character which is followed by (d, x or w) */
1082 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1088 /* Add missed columns */
1089 LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
1097 /* Display characters different from (\r, \n, %) */
1098 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1104 /* Add missed columns */
1105 LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
1106 LCD_ClearLine(Line2);
1113 /* Display spaces if string doesn't reach the max LCD characters size */
1114 while(RefColumn<119)
1116 /* Display Spaces */
1117 LCD_DisplayChar(RefPage, RefColumn, 0x20, TextMode);
1119 /* Add missed columns */
1120 LCD_DisplayChar(RefPage, RefColumn, 0x1f, TextMode);
1124 /*******************************************************************************
1125 * Function Name : LCD_DrawMasterGraphic
1126 * Description : Draw a Graphic image on master LCD.
1127 * Input : - Bmp: the pointer of the dot matrix data.
1130 *******************************************************************************/
1131 void LCD_DrawMasterGraphic(u8 *Bmp)
1133 u8 j = 0, k = 0, ActPage = 0;
1135 /* Draw graphic on master: 61 Column *4 Pages */
1138 /* Draw on master page by page */
1139 LCD_SetMasterPage(ActPage);
1142 LCD_SetMasterColumn(k);
1143 LCD_SendMasterData(*Bmp++);
1150 /*******************************************************************************
1151 * Function Name : LCD_DrawSlaveGraphic
1152 * Description : Draw a Graphic image on slave LCD.
1153 * Input : - Bmp: the pointer of the dot matrix data.
1156 *******************************************************************************/
1157 void LCD_DrawSlaveGraphic(u8 *Bmp)
1159 u8 j = 0, k = 0, ActPage = 0;
1161 /* Draw graphic on slave: 61 Column *4 Pages */
1164 /* Draw on slave page by page */
1165 LCD_SetSlavePage(ActPage);
1168 LCD_SetSlaveColumn(k);
1169 LCD_SendSlaveData(*Bmp++);
1176 /*******************************************************************************
1177 * Function Name : LCD_DrawGraphic
1178 * Description : Draw a Graphic image on LCD.
1179 * Input : - Bmp: the pointer of the dot matrix data.
1182 *******************************************************************************/
1183 void LCD_DrawGraphic(u8 *Bmp)
1185 u8 Pos = 0, ActPage = 0;
1188 /* Draw graphic on LCD: 122 Column *4 Pages */
1193 /* Draw on master page by page */
1194 LCD_SetMasterPage(ActPage);
1197 LCD_SetMasterColumn(k);
1198 LCD_SendMasterData(*Bmp++);
1205 /* Draw on slave page by page */
1206 LCD_SetSlavePage(ActPage);
1209 LCD_SetSlaveColumn(k);
1210 LCD_SendSlaveData(*Bmp++);
1219 /*******************************************************************************
1220 * Function Name : LCD_ScrollGraphic
1221 * Description : Scroll a Graphic image on LCD.
1222 * Input : - Bmp: the pointer of the dot matrix data.
1223 * - nCount: specifies the delay time length.
1226 *******************************************************************************/
1227 void LCD_ScrollGraphic(u8 *Bmp, u32 nCount)
1229 u8 Pos = 0, ActPage = 0;
1233 /* Draw graphic on LCD: 122 Column *4 Pages */
1238 /* Draw on master page by page */
1239 LCD_SetMasterPage(ActPage);
1242 LCD_SetMasterColumn(k);
1243 LCD_SendMasterData(*Bmp++);
1246 for(; Counter != 0; Counter--);
1253 /* Draw on slave page by page */
1254 LCD_SetSlavePage(ActPage);
1257 LCD_SetSlaveColumn(k);
1260 for(; Counter != 0; Counter--);
1261 LCD_SendSlaveData(*Bmp++);
1270 /*******************************************************************************
1271 * Function Name : LCD_DrawPixel
1272 * Description : Draw a Graphic image on slave LCD.
1273 * Input : - XPos: the dot line number of the pixel.
1274 * - 1->61 : displayed on master LCD
1275 * - 62->122: displayed on slave LCD
1276 * - YPos: column address of the pixel from 1->32.
1277 * - Mode: Dot_On: Pixel turned on (black).
1278 * Dot_Off: Pixel turned off (black).
1281 *******************************************************************************/
1282 void LCD_DrawPixel(u8 XPos, u8 YPos, DotMode_TypeDef Mode)
1284 u8 Page = 0, Position = 0;
1286 u32 MasterDataIn = 0, MasterDataOut = 0, SlaveDataIn = 0, SlaveDataOut = 0;
1291 Position = (YPos-1)/61; /* 0:Master, 1:Slave */
1292 /* Mask for the pixel */
1293 Mask= 1<<((XPos-1)%8);
1294 /* If Position=0 draw pixel on master LCD */
1297 LCD_SetMasterPage(Page);
1298 LCD_SetMasterColumn(YPos-1);
1299 MasterDataIn = LCD_ReadMasterData();
1300 MasterDataIn = LCD_ReadMasterData();
1301 LCD_SetMasterColumn(YPos-1);
1304 MasterDataOut = MasterDataIn | Mask;
1308 MasterDataOut = MasterDataIn & (~Mask);
1310 LCD_SendMasterData(MasterDataOut);
1312 /* If Position=1 draw pixel on slave LCD */
1315 LCD_SetSlavePage(Page);
1316 LCD_SetSlaveColumn(YPos-62);
1317 SlaveDataIn = LCD_ReadSlaveData();
1318 SlaveDataIn = LCD_ReadSlaveData();
1319 LCD_SetSlaveColumn(YPos-62);
1322 SlaveDataOut = SlaveDataIn | Mask;
1326 SlaveDataOut = SlaveDataIn & (~Mask);
1328 LCD_SendSlaveData(SlaveDataOut);
1332 /*******************************************************************************
1333 * Function Name : LCD_DrawLine
1334 * Description : Draw a line on master and slave LCDs.
1335 * Input : - XPos1: the dot line number of the source point .
1336 * - XPos2: the dot line number of the destination point .
1337 * - YPos1: the dot column number of the source point.
1338 * - YPos2: the dot column number of the destination point.
1341 *******************************************************************************/
1342 void LCD_DrawLine(u8 XPos1, u8 YPos1, u8 XPos2, u8 YPos2)
1344 u8 XPos = 0, YPos = 0;
1346 /* Use XPos1, YPos1, XPos2 and YPos2 */
1347 if((XPos2>=XPos1)&(YPos2>=YPos1))
1349 for(XPos=XPos1; XPos<=XPos2; XPos++)
1351 for(YPos=YPos1; YPos<=YPos2; YPos++)
1353 LCD_DrawPixel(XPos, YPos, Dot_On);
1357 else if((XPos2<XPos1)&(YPos2>=YPos1))
1359 for(XPos=XPos2; XPos<=XPos1; XPos++)
1361 for(YPos=YPos1; YPos<=YPos2; YPos++)
1363 LCD_DrawPixel(XPos, YPos, Dot_On);
1367 else if((XPos2>=XPos1)&(YPos2<YPos1))
1369 for(XPos=XPos1; XPos<=XPos2; XPos++)
1371 for(YPos=YPos2; YPos<=YPos1; YPos++)
1373 LCD_DrawPixel(XPos, YPos, Dot_On);
1377 else /*if((XPos2<XPos1)&(YPos2<YPos1))*/
1379 for(XPos=XPos2; XPos<=XPos1; XPos++)
1381 for(YPos=YPos2; YPos<=YPos1; YPos++)
1383 LCD_DrawPixel(XPos, YPos, Dot_On);
1389 /*******************************************************************************
1390 * Function Name : LCD_DrawBox
1391 * Description : Draw a Box on master and slave LCDs.
1392 * Input : - XPos: the dot line number of the source point .
1393 * - YPos: the dot column number of the source point.
1398 *******************************************************************************/
1399 void LCD_DrawBox(u8 XPos, u8 YPos, u8 Dx, u8 Dy)
1401 /* Use XPos, YPos, Dx and Dy */
1402 LCD_DrawLine(XPos, YPos, XPos, YPos+Dy);
1403 LCD_DrawLine(XPos, YPos, XPos+Dx, YPos);
1404 LCD_DrawLine(XPos+Dx, YPos, XPos+Dx, YPos+Dy);
1405 LCD_DrawLine(XPos, YPos+Dy, XPos+Dx, YPos+Dy);
1408 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE******/