1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
3 * Author : MCD Application Team
4 * Date First Issued : 03/10/2006
5 * Description : This file includes the LCD driver for GXM12232-2SL liquid
6 * Crystal Display Module of STR75x-EVAL.
7 ********************************************************************************
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 ------------------------------------------------------------------*/
23 /* Private typedef -----------------------------------------------------------*/
25 /* Peripherals InitStructure define */
26 GPIO_InitTypeDef GPIO_InitStructure;
28 /* Private define ------------------------------------------------------------*/
29 #define LCD_GPIO_Pins 0x3FC00
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 const 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 (P2.10~P2.17) 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_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 |
182 GPIO_Pin_14 | GPIO_Pin_15 | GPIO_Pin_16 | GPIO_Pin_17;
185 /* Configure D0~D7 lines (P2.10~2.17) in Input Floating mode */
186 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
190 /* Configure D0~D7 lines (P2.10~2.17) in Output Push-Pull mode */
191 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
193 GPIO_Init(GPIO2, &GPIO_InitStructure);
196 /*******************************************************************************
197 * Function Name : LCD_DataLinesWrite
198 * Description : Write a value on D0~D7 (P2.10~P2.17)
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)
208 /* Store the PM register value */
209 Tmp = GPIO_GetPortMask(GPIOx);
210 /* Mask the corresponding GPIO pins */
211 GPIO_PinMaskConfig(GPIOx, LCD_GPIO_Pins, DISABLE);
212 GPIO_PinMaskConfig(GPIOx, ~LCD_GPIO_Pins, ENABLE);
213 /* Write in the hole register */
214 GPIO_Write(GPIOx, (PortVal<<10));
216 GPIO_PinMaskConfig(GPIOx, ~LCD_GPIO_Pins, DISABLE);
217 /* Return the initial PM register value */
218 GPIO_PinMaskConfig(GPIOx, Tmp, ENABLE);
222 /*******************************************************************************
223 * Function Name : LCD_CtrlLinesConfig
224 * Description : Configure control lines E2, E1, RW, DI (P2.0~P2.3) in
225 * Output Push-Pull mode.
229 *******************************************************************************/
230 void LCD_CtrlLinesConfig(void)
232 /* Configure E2, E1, RW, DI lines (P2.0~2.3) in Output Push-Pull mode */
233 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
234 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
235 GPIO_Init(GPIO2, &GPIO_InitStructure);
238 /*******************************************************************************
239 * Function Name : LCD_CtrlLinesWrite
240 * Description : Set or reset control lines E2, E1, RW, DI (P2.0~P2.3).
241 * Input : - GPIOx: where x can be 0,1 or 2 to select the GPIO peripheral.
242 * - CtrlPins: the Control line. This parameter can be:
243 * - CtrlPin_E2: Enabe clock signal for Slave
244 * - CtrlPin_E1: Enabe clock signal for Master
245 * - CtrlPin_RW: Read/Write control line
249 *******************************************************************************/
250 void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, u32 CtrlPins, BitAction BitVal)
252 /* Set or Reset the control line */
253 if(BitVal != Bit_RESET)
255 GPIOx->PD |= CtrlPins;
259 GPIOx->PD &= ~CtrlPins;
263 /*******************************************************************************
264 * Function Name : LCD_CheckMasterStatus
265 * Description : Check whether master LCD is busy or not
269 *******************************************************************************/
270 void LCD_CheckMasterStatus(void)
274 /* Configure Data lines as Input */
275 LCD_DataLinesConfig(Input);
276 /* Start the master read sequence */
277 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
278 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_SET); /* RW = 1 */
279 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_RESET); /* DI = 0 */
280 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_SET); /* E1 = 1 */
281 MasterStatus = GPIO_Read(GPIO2);
282 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
284 /* Wait until BF is cleared: D7 line */
285 while ((MasterStatus & 0x20000))
287 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_SET); /* E1 = 1 */
288 MasterStatus = GPIO_Read(GPIO2);
289 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
293 /*******************************************************************************
294 * Function Name : LCD_CheckSlaveStatus
295 * Description : Check whether slave LCD is busy or not
299 *******************************************************************************/
300 void LCD_CheckSlaveStatus(void)
304 /* Configure Data lines as Input */
305 LCD_DataLinesConfig(Input);
306 /* Start the slave read sequence */
307 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
308 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_SET); /* RW = 1 */
309 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_RESET); /* DI = 0 */
310 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_SET); /* E2 = 1 */
311 SlaveStatus = GPIO_Read(GPIO2);
312 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
314 /* Wait until BF is cleared: D7 line */
315 while ((SlaveStatus & 0x20000))
317 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_SET); /* E2 = 1 */
318 SlaveStatus = GPIO_Read(GPIO2);
319 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
323 /*******************************************************************************
324 * Function Name : LCD_SendMasterCmd
325 * Description : Send one byte command to master LCD.
326 * Input : - Cmd: the user expected command to send to master LCD
329 *******************************************************************************/
330 void LCD_SendMasterCmd(u8 Cmd)
332 /* Check the master status */
333 LCD_CheckMasterStatus();
334 /* Configure Data lines as Output */
335 LCD_DataLinesConfig(Output);
336 /* Start the master send command sequence */
337 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
338 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_RESET); /* RW = 0 */
339 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_RESET); /* DI = 0 */
340 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_SET); /* E1 = 1 */
341 /* Write master command */
342 LCD_DataLinesWrite(GPIO2, (u32)Cmd);
343 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
346 /*******************************************************************************
347 * Function Name : LCD_SendSlaveCmd
348 * Description : Send one byte command to slave LCD
349 * Input : - Cmd: the user expected command to send to slave LCD.
352 *******************************************************************************/
353 void LCD_SendSlaveCmd(u8 Cmd)
355 /* Check the slave status */
356 LCD_CheckSlaveStatus();
357 /* Configure Data lines as Output */
358 LCD_DataLinesConfig(Output);
359 /* Start the slave send command sequence */
360 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
361 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_RESET); /* RW = 0 */
362 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_RESET); /* DI = 0 */
363 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_SET); /* E2 = 1 */
364 /* Write slave command */
365 LCD_DataLinesWrite(GPIO2, (u32)Cmd);
366 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
369 /*******************************************************************************
370 * Function Name : LCD_SendMasterData
371 * Description : Display one byte data to master LCD.
372 * Input : - Data: the user expected data to display on master LCD.
375 *******************************************************************************/
376 void LCD_SendMasterData(u8 Data)
378 /* Check the master status */
379 LCD_CheckMasterStatus();
380 /* Configure Data lines as Output */
381 LCD_DataLinesConfig(Output);
382 /* Start the master send data sequence */
383 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
384 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_RESET); /* RW = 0 */
385 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_SET); /* DI = 1 */
386 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_SET); /* E1 = 1 */
387 /* Write data to the master */
388 LCD_DataLinesWrite(GPIO2, (u32)Data);
389 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
392 /*******************************************************************************
393 * Function Name : LCD_ReadMasterData
394 * Description : Read master byte data displayed on master LCD.
398 *******************************************************************************/
399 u32 LCD_ReadMasterData(void)
403 /* Check the master status */
404 LCD_CheckMasterStatus();
405 /* Configure Data lines as Input */
406 LCD_DataLinesConfig(Input);
407 /* Start the master read data sequence */
408 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
409 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_SET); /* RW = 1 */
410 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_SET); /* DI = 1 */
411 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_SET); /* E1 = 1 */
412 /* Read data from the master */
413 MasterData = ((GPIO_Read(GPIO2)&0x3FC00)>>10);
414 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E1, Bit_RESET); /* E1 = 0 */
415 /* Read the master returned data */
419 /*******************************************************************************
420 * Function Name : LCD_SendSlaveData
421 * Description : Display one byte data to slave LCD.
422 * Input : - Data: the user expected data to display on slave LCD.
425 *******************************************************************************/
426 void LCD_SendSlaveData(u8 Data)
428 /* Check the slave status */
429 LCD_CheckSlaveStatus();
430 /* Configure Data lines as Output */
431 LCD_DataLinesConfig(Output);
432 /* Start the slave send data sequence */
433 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
434 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_RESET); /* RW = 0 */
435 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_SET); /* DI = 1 */
436 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_SET); /* E2 = 1 */
437 /* Write data to the slave */
438 LCD_DataLinesWrite(GPIO2, (u32)Data);
439 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
442 /*******************************************************************************
443 * Function Name : LCD_ReadSlaveData
444 * Description : Read slave byte data displayed on slave LCD.
448 *******************************************************************************/
449 u32 LCD_ReadSlaveData(void)
453 /* Check the slave status */
454 LCD_CheckSlaveStatus();
455 /* Configure Data lines as Input */
456 LCD_DataLinesConfig(Input);
457 /* Start the slave read data sequence */
458 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
459 LCD_CtrlLinesWrite(GPIO2, CtrlPin_RW, Bit_SET); /* RW = 1 */
460 LCD_CtrlLinesWrite(GPIO2, CtrlPin_DI, Bit_SET); /* DI = 1 */
461 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_SET); /* E2 = 1 */
462 /* Read data from the slave */
463 SlaveData = ((GPIO_Read(GPIO2)&0x3FC00)>>10);
464 LCD_CtrlLinesWrite(GPIO2, CtrlPin_E2, Bit_RESET); /* E2 = 0 */
465 /* Read the slave returned data */
469 /*******************************************************************************
470 * Function Name : LCD_Init
471 * Description : Initialize master and slave LCD.
475 *******************************************************************************/
478 /* Enable GPIO Clock */
479 MRCC_PeripheralClockConfig(MRCC_Peripheral_GPIO, ENABLE);
481 /* Configure control lines signals as output mode */
482 LCD_CtrlLinesConfig();
484 /* Master LCD Init */
485 LCD_SendMasterCmd(SOFTWARE_RESET);
486 LCD_SendMasterCmd(DISPLAY_OFF);
487 LCD_SendMasterCmd(DYNAMIC_DRIVE);
488 LCD_SendMasterCmd(DUTY_CYCLE);
489 LCD_SendMasterCmd(CLOCKWISE_OUTPUT);
490 LCD_SendMasterCmd(READ_MODIFY_WRITE_OFF);
491 LCD_SendMasterCmd(START_COLUMN); /* Set master column address to 0 */
492 LCD_SendMasterCmd(START_LINE); /* Set master display start line to 0 */
493 LCD_SendMasterCmd(DISPLAY_ON );
496 LCD_SendSlaveCmd(SOFTWARE_RESET);
497 LCD_SendSlaveCmd(DISPLAY_OFF);
498 LCD_SendSlaveCmd(DYNAMIC_DRIVE);
499 LCD_SendSlaveCmd(DUTY_CYCLE);
500 LCD_SendSlaveCmd(CLOCKWISE_OUTPUT);
501 LCD_SendSlaveCmd(READ_MODIFY_WRITE_OFF);
502 LCD_SendSlaveCmd(START_COLUMN ); /* Set slave column address to 0 */
503 LCD_SendSlaveCmd(START_LINE); /* Set slave display start line to 0 */
504 LCD_SendSlaveCmd(DISPLAY_ON);
508 /* Set current Page to 0 for Master and Slave LCDs */
510 LCD_SetMasterPage(0);
513 /*******************************************************************************
514 * Function Name : LCD_SetSlavePage
515 * Description : Set the display page of slave LCD, the page range is 0 to 3,
516 * make sure the input will not exceed this range ,otherwise it
517 * will reach a undecided result.
518 * Input : - Page: specifies the expected display page of slave LCD
521 *******************************************************************************/
522 void LCD_SetSlavePage(u8 Page)
525 LCD_SendSlaveCmd(0xB8|Page);
528 /*******************************************************************************
529 * Function Name : LCD_SetMasterPage
530 * Description : Set the display page of master LCD, the page range is 0 to 3,
531 * make sure the input will not exceed this range ,otherwise it
532 * will reach a undecided result.
533 * Input : - Page: specifies the expected display page of master LCD
536 *******************************************************************************/
537 void LCD_SetMasterPage(u8 Page)
539 /* Set Master page */
540 LCD_SendMasterCmd(0xB8|Page);
543 /*******************************************************************************
544 * Function Name : SetAddress
545 * Description : Set the display column of slave LCD. Column range is 0 to 61.
546 * Input : - Address: specifies the expected display column of slave LCD
549 *******************************************************************************/
550 void LCD_SetSlaveColumn(u8 Address)
552 /* Set Slave column address */
553 LCD_SendSlaveCmd(Address&0x7F);
556 /*******************************************************************************
557 * Function Name : LCD_SetMasterColumn
558 * Description : Set the display column of master LCD. Column range is 0 to 61.
559 * Input : - Address: specifies the expected display column of slave LCD
562 *******************************************************************************/
563 void LCD_SetMasterColumn(u8 Address)
565 /* Set Master column address */
566 LCD_SendMasterCmd(Address&0x7F);
569 /*******************************************************************************
570 * Function Name : LCD_SetTextColor
571 * Description : Set the text color for LCD.
572 * Input : - TextColor: BlackText: character on black, bottom on white.
573 * WhiteText: character on white, bottom on black.
576 *******************************************************************************/
577 void LCD_SetTextColor(TextColorMode_TypeDef TextColor)
581 /* Set White Text color */
586 /* Set Black Text color */
591 /*******************************************************************************
592 * Function Name : LCD_Clear
593 * Description : Clear the Master and Slave LCDs display.
597 *******************************************************************************/
600 u8 Page = 0, Column = 0;
602 /* Clear master and slave LCDs page by page */
603 for (Page=0; Page<4; Page++)
605 /* Set master and slave page by page */
606 LCD_SetMasterPage(Page);
607 LCD_SetSlavePage(Page);
608 /* Set master and slave column address */
609 LCD_SetMasterColumn(0);
610 LCD_SetSlaveColumn(0);
611 /* Send empty data to master and slave column address on the selected page */
612 for (Column=0; Column<61; Column++)
614 LCD_SendSlaveData(0);
615 LCD_SendMasterData(0);
620 /*******************************************************************************
621 * Function Name : LCD_ClearLine
622 * Description : Clear the selected line of the LCD.
623 * Input : - Line: the Line to clear.
624 * - Line1 (Page0&1): clear the first line
625 * - Line2 (Page2&3): clear the second line
628 *******************************************************************************/
629 void LCD_ClearLine(u8 Line)
631 u8 Page = 0, Column = 0;
633 /* Clear the slected master and slave line */
634 for (Page=Line; Page<Line+2; Page++)
636 /* Set master and slave page by page */
637 LCD_SetMasterPage(Page);
638 LCD_SetSlavePage(Page);
639 /* Set master and slave column address */
640 LCD_SetMasterColumn(0);
641 LCD_SetSlaveColumn(0);
642 /* Send empty data to master and slave column address on the selected page */
643 for (Column=0; Column<61; Column++)
645 LCD_SendSlaveData(0);
646 LCD_SendMasterData(0);
651 /*******************************************************************************
652 * Function Name : LCD_ClearMaster
653 * Description : Clear the master LCD.
657 *******************************************************************************/
658 void LCD_ClearMaster(void)
660 u8 Page = 0, Column = 0;
662 /* Clear all master LCD pages */
663 for (Page=0; Page<4; Page++)
665 /* Set master page by page */
666 LCD_SetMasterPage(Page);
667 /* Set master column address */
668 LCD_SetMasterColumn(0);
669 /* Send empty data to master column address on the selected page */
670 for (Column=0; Column<61; Column++)
672 LCD_SendMasterData(0);
677 /*******************************************************************************
678 * Function Name : LCD_ClearSlave
679 * Description : Clear the slave LCD.
683 *******************************************************************************/
684 void LCD_ClearSlave()
686 u8 Page = 0, Column = 0;
688 /* Clear all slave LCD pages */
689 for (Page=0; Page<4; Page++)
691 /* Set slave page by page */
692 LCD_SetSlavePage(Page);
693 /* Set slave column address */
694 LCD_SetSlaveColumn(0);
695 /* Send empty data to slave column address on the selected page */
696 for (Column=0; Column<61; Column++)
698 LCD_SendSlaveData(0);
703 /*******************************************************************************
704 * Function Name : LCD_DrawChar
705 * Description : Draw a character in LCD.
707 * the LCD can only display two line character,so page 0 and 1
708 * is to display the first line, page2 and page 3 is to display
710 * Input : - Line: the Line where to display the character shape .
711 * - Line1 (Page0&1): display character on the first line
712 * - Line2 (Page2&3): display character on the second line
713 * - Column: start column address.
714 * - Width: the number of column (dots) of a character width.
715 * - Bmp: the pointer of the dot matrix data.
718 *******************************************************************************/
719 void LCD_DrawChar(u8 Line, u8 Column, u8 Width, u8 *Bmp)
721 u8 X = 0, ActualColumn = 0, Window = 0, i = 0;
723 /* Draw the character column by column: width times */
724 for(X = Column; X<(Column+Width); X++)
728 /* Return if column exceeded 121 */
733 /* To be displayed on slave LCD (Window = 1) */
735 /* Get the Slave relative start column */
740 /* To be displayed on master LCD (Window = 0) */
744 /* Switch window, display the character upper part */
747 /* Display it on slave LCD */
748 LCD_SetSlavePage(Line);
749 LCD_SetSlaveColumn(ActualColumn);
750 LCD_SendSlaveData(Bmp[i]);
754 /* Display it on master LCD */
755 LCD_SetMasterPage(Line);
756 LCD_SetMasterColumn(ActualColumn);
757 LCD_SendMasterData(Bmp[i]);
759 /* Switch window, diplay the character lower part */
762 /* Display it on slave LCD */
763 LCD_SetSlavePage(Line+1);
764 LCD_SetSlaveColumn(ActualColumn);
765 LCD_SendSlaveData(Bmp[i+1]);
769 /* Display it on master LCD */
770 LCD_SetMasterPage(Line+1);
771 LCD_SetMasterColumn(ActualColumn);
772 LCD_SendMasterData(Bmp[i+1]);
774 /* Increment by 2 the character table index */
779 /*******************************************************************************
780 * Function Name : LCD_DisplayChar
781 * Description : Display one character (7dots large, 16dots high).
783 * the LCD can only display two line character,so page 0 and 1
784 * is to display the first line, page2 and page 3 is to display
786 * Input : - Line: the Line where to display the character.
787 * - Line1 (Page0&1): display character on the first line
788 * - Line2 (Page2&3): display character on the second line
789 * - Column: start column address.
790 * - Ascii: character ascii code.
791 * - CharMode: BlackText: character on black, bottom on white.
792 * WhiteText: character on white, bottom on black.
795 *******************************************************************************/
796 void LCD_DisplayChar(u8 Line, u8 Column, u8 Ascii, TextColorMode_TypeDef CharMode)
798 u8 DotBuffer[14], i = 0;
800 /* Display the character lower and upper 8bit parts (2*7columns) */
803 /* Character displayed as white Text on black buttom */
808 DotBuffer[i] = ~AsciiDotsTable[Ascii*14+i+1];
812 DotBuffer[i] = ~AsciiDotsTable[Ascii*14+i-1];
815 /* Character displayed as black Text on white buttom */
820 DotBuffer[i] = AsciiDotsTable[Ascii*14+i+1];
824 DotBuffer[i] = AsciiDotsTable[Ascii*14+i-1];
828 /* Display the asc code after conversion */
829 LCD_DrawChar(Line, Column, 7, DotBuffer);
832 /*******************************************************************************
833 * Function Name : LCD_HexToAsciiLow
834 * Description : This function is used to convert the low nibble of an
835 * unsigned byte (0-F hex) to ASCII.
836 * Input : - byte: byte to convert to ASCII.
838 * Return : ASCII value result of the conversion.
839 *******************************************************************************/
840 u8 LCD_HexToAsciiLow(u8 byte)
842 /* Keep lower nibble only */
844 /* If the ascii is a number */
847 /* Add 0x30 to its ascii */
852 /* Add 0x37 to its ascii */
853 return (byte + 0x37);
857 /*******************************************************************************
858 * Function Name : LCD_HexToAsciiHigh
859 * Description : This function is used to convert the high nibble of an
860 * unsigned byte (0-F hex) to ASCII.
861 * Input : - byte: byte to convert to ASCII.
863 * Return : ASCII value result of the conversion.
864 *******************************************************************************/
865 u8 LCD_HexToAsciiHigh(u8 byte)
867 /* Keep upper nibble only */
870 /* If the ascii is a number */
873 /* Add 0x30 to display its ascii */
878 /* Add 0x37 to display its ascii */
879 return (byte + 0x37);
883 /*******************************************************************************
884 * Function Name : LCD_DisplayString
885 * Description : This function is used to display a 17char max string of
886 * characters on the LCD display on the selected line.
888 * this function is the user interface to use the LCD driver.
889 * Input : - *ptr: pointer to string to display on LCD.
890 * - Line: the Line where to display the character.
891 * - Line1 (Page0&1): display character on the first line
892 * - Line2 (Page2&3): display character on the second line
895 *******************************************************************************/
896 void LCD_DisplayString(u8 Line, u8 *ptr, TextColorMode_TypeDef CharMode)
898 u8 RefColumn = 0, i = 0;
900 /* Send the string character by character on lCD */
901 while ((*ptr!=0)&(i<17))
903 /* Display one character on LCD */
904 LCD_DisplayChar(Line, RefColumn, *ptr, CharMode);
905 /* Increment the column position by 7 */
907 /* Point on the next character */
909 /* Increment the character counter */
911 /* If we reach the maximum Line character */
914 LCD_DisplayChar(Line, RefColumn-1, 0x1f, CharMode); /* Add missed columns */
919 /*******************************************************************************
920 * Function Name : LCD_Printf
921 * Description : This function is used to display a string of characters
922 * on the LCD display.
924 * this function is the user interface to use the LCD driver.
925 * Input : - *ptr: pointer to string to display on LCD.
928 *******************************************************************************/
929 void LCD_Printf(u8 *ptr, ...)
931 u8 RefColumn = 0, RefPage = 0, i = 0, c1 = 0;
932 u16 var = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
935 /* Store pointer on LCD_Printf second parameter (String) */
936 u8 *var_ptr=(u8 *)(&ptr+1);
942 /* Limited to AsciiDotsTable code table */
945 /* Carriage return */
952 else if( *ptr == '\n')
954 /* Point on the string to display */
957 LCD_ClearLine(Line2);
958 /* Point on first Line2 column */
960 /* Increment RefPage by 2 */
963 /* Display value on the passed format */
964 else if( *ptr == '%')
967 /* Display decimal value */
971 /* Get the word value to display */
972 WordVar = ((*var_ptr)|(*(var_ptr+1)<<8)|(*(var_ptr+2)<<16));
974 c2=(WordVar%10000)/1000;
975 c3=(WordVar%1000)/100;
978 /* Display the ten miles digit */
981 LCD_DisplayChar(RefPage, RefColumn, c1+0x30, TextMode);
984 /* Display the miles digit */
985 if (!((c1==0)&(c2==0)))
987 LCD_DisplayChar(RefPage, RefColumn, c2+0x30, TextMode);
990 /* Display the hundred digit */
991 if (!((c1==0)&(c2==0)&(c3==0)))
993 LCD_DisplayChar(RefPage, RefColumn, c3+0x30, TextMode);
996 /* Display the tens digit */
997 if (!((c1==0)&(c2==0)&(c3==0)&(c4==0)))
999 LCD_DisplayChar(RefPage, RefColumn, c4+0x30, TextMode);
1002 /* Display the rest */
1003 LCD_DisplayChar(RefPage, RefColumn, c5+0x30, TextMode);
1006 /* Display 16bits Hex value */
1007 else if (*ptr == 'x')
1010 /* Display 8bits MSB */
1011 var_ptr = var_ptr +1;
1013 c1 = LCD_HexToAsciiHigh(var);
1014 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1016 c1 = LCD_HexToAsciiLow(var);
1017 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1019 /* Display 8bits LSB */
1020 var_ptr = var_ptr -1;
1022 var_ptr = var_ptr +4;
1023 c1 = LCD_HexToAsciiHigh(var);
1024 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1026 c1 = LCD_HexToAsciiLow(var);
1027 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1030 /* Display 32bits Hex value */
1031 else if (*ptr == 'w')
1034 /* Display 16bits MSB */
1035 var_ptr = var_ptr +3;
1037 c1 = LCD_HexToAsciiHigh(var);
1038 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1040 c1 = LCD_HexToAsciiLow(var);
1041 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1043 var_ptr = var_ptr -1;
1045 c1 = LCD_HexToAsciiHigh(var);
1046 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1048 c1 = LCD_HexToAsciiLow(var);
1049 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1051 /* Display 16bits LSB */
1052 var_ptr = var_ptr -1;
1054 var_ptr = var_ptr +4;
1055 c1 = LCD_HexToAsciiHigh(var);
1056 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1058 c1 = LCD_HexToAsciiLow(var);
1059 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1061 var_ptr = var_ptr -5;
1063 var_ptr = var_ptr +4;
1064 c1 = LCD_HexToAsciiHigh(var);
1065 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1067 c1 = LCD_HexToAsciiLow(var);
1068 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1073 /* Display '%' character which is followed by (d, x or w) */
1076 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1082 /* Add missed columns */
1083 LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
1091 /* Display characters different from (\r, \n, %) */
1092 LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
1098 /* Add missed columns */
1099 LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
1100 LCD_ClearLine(Line2);
1107 /* Display spaces if string doesn't reach the max LCD characters size */
1108 while(RefColumn<119)
1110 /* Display Spaces */
1111 LCD_DisplayChar(RefPage, RefColumn, 0x20, TextMode);
1113 /* Add missed columns */
1114 LCD_DisplayChar(RefPage, RefColumn, 0x1f, TextMode);
1118 /*******************************************************************************
1119 * Function Name : LCD_DrawMasterGraphic
1120 * Description : Draw a Graphic image on master LCD.
1121 * Input : - Bmp: the pointer of the dot matrix data.
1124 *******************************************************************************/
1125 void LCD_DrawMasterGraphic(u8 *Bmp)
1127 u8 j = 0, k = 0, ActPage = 0;
1129 /* Draw graphic on master: 61 Column *4 Pages */
1132 /* Draw on master page by page */
1133 LCD_SetMasterPage(ActPage);
1136 LCD_SetMasterColumn(k);
1137 LCD_SendMasterData(*Bmp++);
1144 /*******************************************************************************
1145 * Function Name : LCD_DrawSlaveGraphic
1146 * Description : Draw a Graphic image on slave LCD.
1147 * Input : - Bmp: the pointer of the dot matrix data.
1150 *******************************************************************************/
1151 void LCD_DrawSlaveGraphic(u8 *Bmp)
1153 u8 j = 0, k = 0, ActPage = 0;
1155 /* Draw graphic on slave: 61 Column *4 Pages */
1158 /* Draw on slave page by page */
1159 LCD_SetSlavePage(ActPage);
1162 LCD_SetSlaveColumn(k);
1163 LCD_SendSlaveData(*Bmp++);
1170 /*******************************************************************************
1171 * Function Name : LCD_DrawGraphic
1172 * Description : Draw a Graphic image on LCD.
1173 * Input : - Bmp: the pointer of the dot matrix data.
1176 *******************************************************************************/
1177 void LCD_DrawGraphic(u8 *Bmp)
1179 u8 Pos = 0, ActPage = 0;
1182 /* Draw graphic on LCD: 122 Column *4 Pages */
1187 /* Draw on master page by page */
1188 LCD_SetMasterPage(ActPage);
1191 LCD_SetMasterColumn(k);
1192 LCD_SendMasterData(*Bmp++);
1199 /* Draw on slave page by page */
1200 LCD_SetSlavePage(ActPage);
1203 LCD_SetSlaveColumn(k);
1204 LCD_SendSlaveData(*Bmp++);
1213 /*******************************************************************************
1214 * Function Name : LCD_ScrollGraphic
1215 * Description : Scroll a Graphic image on LCD.
1216 * Input : - Bmp: the pointer of the dot matrix data.
1217 * - nCount: specifies the delay time length.
1220 *******************************************************************************/
1221 void LCD_ScrollGraphic(u8 *Bmp, u32 nCount)
1223 u8 Pos = 0, ActPage = 0;
1227 /* Draw graphic on LCD: 122 Column *4 Pages */
1232 /* Draw on master page by page */
1233 LCD_SetMasterPage(ActPage);
1236 LCD_SetMasterColumn(k);
1237 LCD_SendMasterData(*Bmp++);
1240 for(; Counter != 0; Counter--);
1247 /* Draw on slave page by page */
1248 LCD_SetSlavePage(ActPage);
1251 LCD_SetSlaveColumn(k);
1254 for(; Counter != 0; Counter--);
1255 LCD_SendSlaveData(*Bmp++);
1264 /*******************************************************************************
1265 * Function Name : LCD_DrawPixel
1266 * Description : Draw a Graphic image on slave LCD.
1267 * Input : - XPos: the dot line number of the pixel.
1268 * - 1->61 : displayed on master LCD
1269 * - 62->122: displayed on slave LCD
1270 * - YPos: column address of the pixel from 1->32.
1271 * - Mode: Dot_On: Pixel turned on (black).
1272 * Dot_Off: Pixel turned off (black).
1275 *******************************************************************************/
1276 void LCD_DrawPixel(u8 XPos, u8 YPos, DotMode_TypeDef Mode)
1278 u8 Page = 0, Position = 0;
1280 u32 MasterDataIn = 0, MasterDataOut = 0, SlaveDataIn = 0, SlaveDataOut = 0;
1285 Position = (YPos-1)/61; /* 0:Master, 1:Slave */
1286 /* Mask for the pixel */
1287 Mask= 1<<((XPos-1)%8);
1288 /* If Position=0 draw pixel on master LCD */
1291 LCD_SetMasterPage(Page);
1292 LCD_SetMasterColumn(YPos-1);
1293 MasterDataIn = LCD_ReadMasterData();
1294 MasterDataIn = LCD_ReadMasterData();
1295 LCD_SetMasterColumn(YPos-1);
1298 MasterDataOut = MasterDataIn | Mask;
1302 MasterDataOut = MasterDataIn & (~Mask);
1304 LCD_SendMasterData(MasterDataOut);
1306 /* If Position=1 draw pixel on slave LCD */
1309 LCD_SetSlavePage(Page);
1310 LCD_SetSlaveColumn(YPos-62);
1311 SlaveDataIn = LCD_ReadSlaveData();
1312 SlaveDataIn = LCD_ReadSlaveData();
1313 LCD_SetSlaveColumn(YPos-62);
1316 SlaveDataOut = SlaveDataIn | Mask;
1320 SlaveDataOut = SlaveDataIn & (~Mask);
1322 LCD_SendSlaveData(SlaveDataOut);
1326 /*******************************************************************************
1327 * Function Name : LCD_DrawLine
1328 * Description : Draw a line on master and slave LCDs.
1329 * Input : - XPos1: the dot line number of the source point .
1330 * - XPos2: the dot line number of the destination point .
1331 * - YPos1: the dot column number of the source point.
1332 * - YPos2: the dot column number of the destination point.
1335 *******************************************************************************/
1336 void LCD_DrawLine(u8 XPos1, u8 YPos1, u8 XPos2, u8 YPos2)
1338 u8 XPos = 0, YPos = 0;
1340 /* Use XPos1, YPos1, XPos2 and YPos2 */
1341 if((XPos2>=XPos1)&(YPos2>=YPos1))
1343 for(XPos=XPos1; XPos<=XPos2; XPos++)
1345 for(YPos=YPos1; YPos<=YPos2; YPos++)
1347 LCD_DrawPixel(XPos, YPos, Dot_On);
1351 else if((XPos2<XPos1)&(YPos2>=YPos1))
1353 for(XPos=XPos2; XPos<=XPos1; XPos++)
1355 for(YPos=YPos1; YPos<=YPos2; YPos++)
1357 LCD_DrawPixel(XPos, YPos, Dot_On);
1361 else if((XPos2>=XPos1)&(YPos2<YPos1))
1363 for(XPos=XPos1; XPos<=XPos2; XPos++)
1365 for(YPos=YPos2; YPos<=YPos1; YPos++)
1367 LCD_DrawPixel(XPos, YPos, Dot_On);
1371 else /*if((XPos2<XPos1)&(YPos2<YPos1))*/
1373 for(XPos=XPos2; XPos<=XPos1; XPos++)
1375 for(YPos=YPos2; YPos<=YPos1; YPos++)
1377 LCD_DrawPixel(XPos, YPos, Dot_On);
1383 /*******************************************************************************
1384 * Function Name : LCD_DrawBox
1385 * Description : Draw a Box on master and slave LCDs.
1386 * Input : - XPos: the dot line number of the source point .
1387 * - YPos: the dot column number of the source point.
1392 *******************************************************************************/
1393 void LCD_DrawBox(u8 XPos, u8 YPos, u8 Dx, u8 Dy)
1395 /* Use XPos, YPos, Dx and Dy */
1396 LCD_DrawLine(XPos, YPos, XPos, YPos+Dy);
1397 LCD_DrawLine(XPos, YPos, XPos+Dx, YPos);
1398 LCD_DrawLine(XPos+Dx, YPos, XPos+Dx, YPos+Dy);
1399 LCD_DrawLine(XPos, YPos+Dy, XPos+Dx, YPos+Dy);
1402 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE******/