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