| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LCDConf.c
Go to the documentation of this file.
1 /*********************************************************************
2 * SEGGER Microcontroller GmbH & Co. KG *
3 * Solutions for real time microcontroller applications *
4 **********************************************************************
5 * *
6 * (c) 1996 - 2012 SEGGER Microcontroller GmbH & Co. KG *
7 * *
8 * Internet: www.segger.com Support: support@segger.com *
9 * *
10 **********************************************************************
11
12 ** emWin V5.18 - Graphical user interface for embedded applications **
13 All Intellectual Property rights in the Software belongs to SEGGER.
14 emWin is protected by international copyright laws. Knowledge of the
15 source code may not be used to write a similar product. This file may
16 only be used in accordance with the following terms:
17
18 The software has been licensed to NXP Semiconductors USA, Inc. whose
19 registered office is situated at 1109 McKay Dr, M/S 76, San Jose,
20 CA 95131, USA solely for the purposes of creating libraries for
21 NXPs M0, M3/M4 and ARM7/9 processor-based devices, sublicensed and
22 distributed under the terms and conditions of the NXP End User License
23 Agreement.
24 Full source code is available at: www.segger.com
25
26 We appreciate your understanding and fairness.
27 ----------------------------------------------------------------------
28 File : LCDConf.c
29 Purpose : Display controller configuration (single layer)
30 ---------------------------END-OF-HEADER------------------------------
31 */
32
33 #include "GUI.h"
34 #include "GUIDRV_Lin.h"
35
36 /*********************************************************************
37 *
38 * Layer configuration (to be modified)
39 *
40 **********************************************************************
41 */
42 //
43 // Physical display size
44 //
45 #define XSIZE_PHYS 240
46 #define YSIZE_PHYS 320
47
48 //
49 // Color conversion
50 //
51 #define COLOR_CONVERSION GUICC_M565
52
53 #define DISPLAY_ORIENTATION (GUI_SWAP_XY | GUI_MIRROR_Y)
54
55 //
56 // Display driver
57 //
58 //#define DISPLAY_DRIVER GUIDRV_LIN_32
59 #if (DISPLAY_ORIENTATION == (GUI_MIRROR_X))
60 #define DISPLAY_DRIVER GUIDRV_LIN_OX_16
61 #elif (DISPLAY_ORIENTATION == (GUI_MIRROR_Y))
62 #define DISPLAY_DRIVER GUIDRV_LIN_OY_16
63 #elif (DISPLAY_ORIENTATION == (GUI_MIRROR_X | GUI_MIRROR_Y))
64 #define DISPLAY_DRIVER GUIDRV_LIN_OXY_16
65 #elif (DISPLAY_ORIENTATION == (GUI_SWAP_XY))
66 #define DISPLAY_DRIVER GUIDRV_LIN_OS_16
67 #elif (DISPLAY_ORIENTATION == (GUI_SWAP_XY | GUI_MIRROR_X))
68 #define DISPLAY_DRIVER GUIDRV_LIN_OSX_16
69 #elif (DISPLAY_ORIENTATION == (GUI_SWAP_XY | GUI_MIRROR_Y))
70 #define DISPLAY_DRIVER GUIDRV_LIN_OSY_16
71 #else
72 #define DISPLAY_DRIVER GUIDRV_LIN_16
73 #endif
74
75 //
76 // Touch screen
77 //
78 #define USE_TOUCH 1
79 //
80 // Touch screen calibration
81 #define TOUCH_X_MIN 0x00E0
82 #define TOUCH_X_MAX 0x0F40
83 #define TOUCH_Y_MIN 0x00C0
84 #define TOUCH_Y_MAX 0x0F60
85
86 //
87 // Buffers / VScreens
88 //
89 #define NUM_BUFFERS 1 // Number of multiple buffers to be used
90 #define NUM_VSCREENS 1 // Number of virtual screens to be used
91
92 /*********************************************************************
93 *
94 * Configuration checking
95 *
96 **********************************************************************
97 */
98 #ifndef VRAM_ADDR
99 #define VRAM_ADDR 0x28000000 // TBD by customer: This has to be the frame buffer start address
100 #endif
101 #ifndef XSIZE_PHYS
102 #error Physical X size of display is not defined!
103 #endif
104 #ifndef YSIZE_PHYS
105 #error Physical Y size of display is not defined!
106 #endif
107 #ifndef COLOR_CONVERSION
108 #error Color conversion not defined!
109 #endif
110 #ifndef DISPLAY_DRIVER
111 #error No display driver defined!
112 #endif
113 #ifndef NUM_VSCREENS
114 #define NUM_VSCREENS 1
115 #else
116 #if (NUM_VSCREENS <= 0)
117 #error At least one screeen needs to be defined!
118 #endif
119 #endif
120 #if (NUM_VSCREENS > 1) && (NUM_BUFFERS > 1)
121 #error Virtual screens and multiple buffers are not allowed!
122 #endif
123
124 #ifndef DISPLAY_ORIENTATION
125 #define DISPLAY_ORIENTATION 0
126 #endif
127
128 #if ((DISPLAY_ORIENTATION & GUI_SWAP_XY) != 0)
129 #define LANDSCAPE 1
130 #else
131 #define LANDSCAPE 0
132 #endif
133
134 #if (LANDSCAPE == 1)
135 #define WIDTH YSIZE_PHYS /* Screen Width (in pixels) */
136 #define HEIGHT XSIZE_PHYS /* Screen Hight (in pixels) */
137 #else
138 #define WIDTH XSIZE_PHYS /* Screen Width (in pixels) */
139 #define HEIGHT YSIZE_PHYS /* Screen Hight (in pixels) */
140 #endif
141
142 #if ((DISPLAY_ORIENTATION & GUI_SWAP_XY) != 0)
143 #if ((DISPLAY_ORIENTATION & GUI_MIRROR_X) != 0)
144 #define TOUCH_TOP TOUCH_X_MAX
145 #define TOUCH_BOTTOM TOUCH_X_MIN
146 #else
147 #define TOUCH_TOP TOUCH_X_MIN
148 #define TOUCH_BOTTOM TOUCH_X_MAX
149 #endif
150 #if ((DISPLAY_ORIENTATION & GUI_MIRROR_Y) != 0)
151 #define TOUCH_LEFT TOUCH_Y_MAX
152 #define TOUCH_RIGHT TOUCH_Y_MIN
153 #else
154 #define TOUCH_LEFT TOUCH_Y_MIN
155 #define TOUCH_RIGHT TOUCH_Y_MAX
156 #endif
157 #else
158 #if ((DISPLAY_ORIENTATION & GUI_MIRROR_X) != 0)
159 #define TOUCH_LEFT TOUCH_X_MAX
160 #define TOUCH_RIGHT TOUCH_X_MIN
161 #else
162 #define TOUCH_LEFT TOUCH_X_MIN
163 #define TOUCH_RIGHT TOUCH_X_MAX
164 #endif
165 #if ((DISPLAY_ORIENTATION & GUI_MIRROR_Y) != 0)
166 #define TOUCH_TOP TOUCH_Y_MAX
167 #define TOUCH_BOTTOM TOUCH_Y_MIN
168 #else
169 #define TOUCH_TOP TOUCH_Y_MIN
170 #define TOUCH_BOTTOM TOUCH_Y_MAX
171 #endif
172 #endif
173
174 /*********************************************************************
175 *
176 * Public code
177 *
178 **********************************************************************
179 */
180 /*********************************************************************
181 *
182 * LCD_X_Config
183 *
184 * Purpose:
185 * Called during the initialization process in order to set up the
186 * display driver configuration.
187 *
188 */
189 void LCD_X_Config(void) {
190 //
191 // At first initialize use of multiple buffers on demand
192 //
193 #if (NUM_BUFFERS > 1)
194 GUI_MULTIBUF_Config(NUM_BUFFERS);
195 #endif
196 //
197 // Set display driver and color conversion for 1st layer
198 //
199 GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);
200 //
201 // Display driver configuration, required for Lin-driver
202 //
203 if (LCD_GetSwapXY()) {
204 LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
205 LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS);
206 } else {
207 LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
208 LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS);
209 }
210 LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR);
211
212 #if (USE_TOUCH == 1)
213 //
214 // Set orientation of touch screen
215 //
216 GUI_TOUCH_SetOrientation(DISPLAY_ORIENTATION);
217 //
218 // Calibrate touch screen
219 //
220 GUI_TOUCH_Calibrate(GUI_COORD_X, 0, WIDTH - 1, TOUCH_LEFT, TOUCH_RIGHT);
221 GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, HEIGHT - 1, TOUCH_TOP, TOUCH_BOTTOM);
222 #endif
223
224 //
225 // Set user palette data (only required if no fixed palette is used)
226 //
227 #if defined(PALETTE)
228 LCD_SetLUTEx(0, PALETTE);
229 #endif
230 }
231
232 /*********************************************************************
233 *
234 * LCD_X_DisplayDriver
235 *
236 * Purpose:
237 * This function is called by the display driver for several purposes.
238 * To support the according task the routine needs to be adapted to
239 * the display controller. Please note that the commands marked with
240 * 'optional' are not cogently required and should only be adapted if
241 * the display controller supports these features.
242 *
243 * Parameter:
244 * LayerIndex - Index of layer to be configured
245 * Cmd - Please refer to the details in the switch statement below
246 * pData - Pointer to a LCD_X_DATA structure
247 *
248 * Return Value:
249 * < -1 - Error
250 * -1 - Command not handled
251 * 0 - Ok
252 */
253 int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
254 int r;
255
256 switch (Cmd) {
257 case LCD_X_INITCONTROLLER: {
258 //
259 // Called during the initialization process in order to set up the
260 // display controller and put it into operation. If the display
261 // controller is not initialized by any external routine this needs
262 // to be adapted by the customer...
263 //
264 // ...
265 return 0;
266 }
267 case LCD_X_SETVRAMADDR: {
268 //
269 // Required for setting the address of the video RAM for drivers
270 // with memory mapped video RAM which is passed in the 'pVRAM' element of p
271 //
272 //LCD_X_SETVRAMADDR_INFO * p;
273 //p = (LCD_X_SETVRAMADDR_INFO *)pData;
274 //...
275 return 0;
276 }
277 case LCD_X_SETORG: {
278 //
279 // Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p
280 //
281 //LCD_X_SETORG_INFO * p;
282 //p = (LCD_X_SETORG_INFO *)pData;
283 //...
284 return 0;
285 }
286 case LCD_X_SHOWBUFFER: {
287 //
288 // Required if multiple buffers are used. The 'Index' element of p contains the buffer index.
289 //
290 //LCD_X_SHOWBUFFER_INFO * p;
291 //p = (LCD_X_SHOWBUFFER_INFO *)pData;
292 //...
293 return 0;
294 }
295 case LCD_X_SETLUTENTRY: {
296 //
297 // Required for setting a lookup table entry which is passed in the 'Pos' and 'Color' element of p
298 //
299 //LCD_X_SETLUTENTRY_INFO * p;
300 //p = (LCD_X_SETLUTENTRY_INFO *)pData;
301 //...
302 return 0;
303 }
304 case LCD_X_ON: {
305 //
306 // Required if the display controller should support switching on and off
307 //
308 return 0;
309 }
310 case LCD_X_OFF: {
311 //
312 // Required if the display controller should support switching on and off
313 //
314 // ...
315 return 0;
316 }
317 default:
318 r = -1;
319 }
320 return r;
321 }
322
323 /*********************************************************************
324 *
325 * Global functions for GUI touch
326 *
327 ********************************************************************/
328
329 #if (USE_TOUCH == 1) // Used when touch screen support is enabled
330
331 /*********************************************************************
332 *
333 * GUI_TOUCH_X_ActivateX()
334 *
335 * Function decription:
336 * Called from GUI, if touch support is enabled.
337 * Switches on voltage on X-axis,
338 * prepares measurement for Y-axis.
339 * Voltage on Y-axis is switched off.
340 */
341 void GUI_TOUCH_X_ActivateX(void) {
342 }
343
344 /*********************************************************************
345 *
346 * GUI_TOUCH_X_ActivateY()
347 *
348 * Function decription:
349 * Called from GUI, if touch support is enabled.
350 * Switches on voltage on Y-axis,
351 * prepares measurement for X-axis.
352 * Voltage on X-axis is switched off.
353 */
354 void GUI_TOUCH_X_ActivateY(void) {
355 }
356
357 /*********************************************************************
358 *
359 * GUI_TOUCH_X_MeasureX()
360 *
361 * Function decription:
362 * Called from GUI, if touch support is enabled.
363 * Measures voltage of X-axis.
364 */
365 int GUI_TOUCH_X_MeasureX(void) {
366 return 0;
367 }
368
369 /*********************************************************************
370 *
371 * GUI_TOUCH_X_MeasureY()
372 *
373 * Function decription:
374 * Called from GUI, if touch support is enabled.
375 * Measures voltage of Y-axis.
376 */
377 int GUI_TOUCH_X_MeasureY(void) {
378 return 0;
379 }
380
381 #endif // USE_TOUCH
382
383 /*************************** End of file ****************************/