STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
GUIDRV_Template.c
Go to the documentation of this file.
1 /*********************************************************************
2 * Portions COPYRIGHT 2015 STMicroelectronics *
3 * Portions SEGGER Microcontroller GmbH & Co. KG *
4 * Solutions for real time microcontroller applications *
5 **********************************************************************
6 * *
7 * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
8 * *
9 * Internet: www.segger.com Support: support@segger.com *
10 * *
11 **********************************************************************
12 
13 ** emWin V5.28 - Graphical user interface for embedded applications **
14 All Intellectual Property rights in the Software belongs to SEGGER.
15 emWin is protected by international copyright laws. Knowledge of the
16 source code may not be used to write a similar product. This file may
17 only be used in accordance with the following terms:
18 
19 The software has been licensed to STMicroelectronics International
20 N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
21 les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
22 purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
23 troller products commercialized by Licensee only, sublicensed and dis_
24 tributed under the terms and conditions of the End User License Agree_
25 ment supplied by STMicroelectronics International N.V.
26 Full source code is available at: www.segger.com
27 
28 We appreciate your understanding and fairness.
29 ----------------------------------------------------------------------
30 File : GUIDRV_Template.c
31 Purpose : Template driver, could be used as starting point for new
32  simple display drivers supporting only one color depth.
33 ---------------------------END-OF-HEADER------------------------------
34 */
35 
55 #include <stddef.h>
56 
57 #include "LCD_Private.h"
58 #include "GUI_Private.h"
59 #include "LCD_ConfDefaults.h"
60 
61 /*********************************************************************
62 *
63 * Defines
64 *
65 **********************************************************************
66 */
67 /*********************************************************************
68 *
69 * Macros for MIRROR_, SWAP_ and LUT_
70 */
71 #if (!defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
72  #if (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
73  #define LOG2PHYS_X(x, y) x
74  #define LOG2PHYS_Y(x, y) y
75  #elif (!LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
76  #define LOG2PHYS_X(x, y) y
77  #define LOG2PHYS_Y(x, y) x
78  #elif (!LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
79  #define LOG2PHYS_X(x, y) x
80  #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
81  #elif (!LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
82  #define LOG2PHYS_X(x, y) y
83  #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
84  #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
85  #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
86  #define LOG2PHYS_Y(x, y) y
87  #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
88  #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
89  #define LOG2PHYS_Y(x, y) x
90  #elif ( LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
91  #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
92  #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
93  #elif ( LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
94  #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
95  #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
96  #endif
97 #else
98  #if ( defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
99  #define LOG2PHYS_X(x, y) x
100  #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
101  #elif (!defined (LCD_LUT_COM) && defined(LCD_LUT_SEG))
102  #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
103  #define LOG2PHYS_Y(x, y) y
104  #elif ( defined (LCD_LUT_COM) && defined(LCD_LUT_SEG))
105  #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
106  #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
107  #endif
108 #endif
109 
110 /*********************************************************************
111 *
112 * Types
113 *
114 **********************************************************************
115 */
116 typedef struct {
118  int xSize, ySize;
119  int vxSize, vySize;
123 
124 /*********************************************************************
125 *
126 * Static functions
127 *
128 **********************************************************************
129 */
130 /*********************************************************************
131 *
132 * _SetPixelIndex
133 *
134 * Purpose:
135 * Sets the index of the given pixel. The upper layers
136 * calling this routine make sure that the coordinates are in range, so
137 * that no check on the parameters needs to be performed.
138 */
139 static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, int PixelIndex) {
140  //
141  // Convert logical into physical coordinates (Dep. on LCDConf.h)
142  //
143  #if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
144  int xPhys, yPhys;
145 
146  xPhys = LOG2PHYS_X(x, y);
147  yPhys = LOG2PHYS_Y(x, y);
148  #else
149  #define xPhys x
150  #define yPhys y
151  #endif
152  GUI_USE_PARA(pDevice);
153  GUI_USE_PARA(x);
154  GUI_USE_PARA(y);
155  GUI_USE_PARA(PixelIndex);
156  {
157  //
158  // Write into hardware ... Adapt to your system
159  //
160  // TBD by customer...
161  //
162  }
163  #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
164  #undef xPhys
165  #undef yPhys
166  #endif
167 }
168 
169 /*********************************************************************
170 *
171 * _GetPixelIndex
172 *
173 * Purpose:
174 * Returns the index of the given pixel. The upper layers
175 * calling this routine make sure that the coordinates are in range, so
176 * that no check on the parameters needs to be performed.
177 */
178 static unsigned int _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) {
179  unsigned int PixelIndex;
180  //
181  // Convert logical into physical coordinates (Dep. on LCDConf.h)
182  //
183  #if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
184  int xPhys, yPhys;
185 
186  xPhys = LOG2PHYS_X(x, y);
187  yPhys = LOG2PHYS_Y(x, y);
188  #else
189  #define xPhys x
190  #define yPhys y
191  #endif
192  GUI_USE_PARA(pDevice);
193  GUI_USE_PARA(x);
194  GUI_USE_PARA(y);
195  {
196  //
197  // Write into hardware ... Adapt to your system
198  //
199  // TBD by customer...
200  //
201  PixelIndex = 0;
202  }
203  #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
204  #undef xPhys
205  #undef yPhys
206  #endif
207  return PixelIndex;
208 }
209 
210 /*********************************************************************
211 *
212 * _XorPixel
213 */
214 static void _XorPixel(GUI_DEVICE * pDevice, int x, int y) {
215  LCD_PIXELINDEX PixelIndex;
216  LCD_PIXELINDEX IndexMask;
217 
218  PixelIndex = _GetPixelIndex(pDevice, x, y);
219  IndexMask = pDevice->pColorConvAPI->pfGetIndexMask();
220  _SetPixelIndex(pDevice, x, y, PixelIndex ^ IndexMask);
221 }
222 
223 /*********************************************************************
224 *
225 * _FillRect
226 */
227 static void _FillRect(GUI_DEVICE * pDevice, int x0, int y0, int x1, int y1) {
228  LCD_PIXELINDEX PixelIndex;
229  int x;
230 
231  PixelIndex = LCD__GetColorIndex();
233  for (; y0 <= y1; y0++) {
234  for (x = x0; x <= x1; x++) {
235  _XorPixel(pDevice, x, y0);
236  }
237  }
238  } else {
239  for (; y0 <= y1; y0++) {
240  for (x = x0; x <= x1; x++) {
241  _SetPixelIndex(pDevice, x, y0, PixelIndex);
242  }
243  }
244  }
245 }
246 
247 /*********************************************************************
248 *
249 * _DrawHLine
250 */
251 static void _DrawHLine(GUI_DEVICE * pDevice, int x0, int y, int x1) {
252  _FillRect(pDevice, x0, y, x1, y);
253 }
254 
255 /*********************************************************************
256 *
257 * _DrawVLine, not optimized
258 */
259 static void _DrawVLine(GUI_DEVICE * pDevice, int x, int y0, int y1) {
260  _FillRect(pDevice, x, y0, x, y1);
261 }
262 
263 /*********************************************************************
264 *
265 * Draw Bitmap 1 BPP
266 */
267 static void _DrawBitLine1BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
268  LCD_PIXELINDEX IndexMask, Index0, Index1, Pixel;
269 
270  Index0 = *(pTrans + 0);
271  Index1 = *(pTrans + 1);
272  x += Diff;
274  case 0:
275  do {
276  _SetPixelIndex(pDevice, x++, y, (*p & (0x80 >> Diff)) ? Index1 : Index0);
277  if (++Diff == 8) {
278  Diff = 0;
279  p++;
280  }
281  } while (--xsize);
282  break;
283  case LCD_DRAWMODE_TRANS:
284  do {
285  if (*p & (0x80 >> Diff))
286  _SetPixelIndex(pDevice, x, y, Index1);
287  x++;
288  if (++Diff == 8) {
289  Diff = 0;
290  p++;
291  }
292  } while (--xsize);
293  break;
295  case LCD_DRAWMODE_XOR:
296  IndexMask = pDevice->pColorConvAPI->pfGetIndexMask();
297  do {
298  if (*p & (0x80 >> Diff)) {
299  Pixel = _GetPixelIndex(pDevice, x, y);
300  _SetPixelIndex(pDevice, x, y, Pixel ^ IndexMask);
301  }
302  x++;
303  if (++Diff == 8) {
304  Diff = 0;
305  p++;
306  }
307  } while (--xsize);
308  break;
309  }
310 }
311 
312 /*********************************************************************
313 *
314 * Draw Bitmap 2 BPP
315 */
316 static void _DrawBitLine2BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
317  LCD_PIXELINDEX Pixels, PixelIndex;
318  int CurrentPixel, Shift, Index;
319 
320  Pixels = *p;
321  CurrentPixel = Diff;
322  x += Diff;
324  case 0:
325  if (pTrans) {
326  do {
327  Shift = (3 - CurrentPixel) << 1;
328  Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
329  PixelIndex = *(pTrans + Index);
330  _SetPixelIndex(pDevice, x++, y, PixelIndex);
331  if (++CurrentPixel == 4) {
332  CurrentPixel = 0;
333  Pixels = *(++p);
334  }
335  } while (--xsize);
336  } else {
337  do {
338  Shift = (3 - CurrentPixel) << 1;
339  Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
340  _SetPixelIndex(pDevice, x++, y, Index);
341  if (++CurrentPixel == 4) {
342  CurrentPixel = 0;
343  Pixels = *(++p);
344  }
345  } while (--xsize);
346  }
347  break;
348  case LCD_DRAWMODE_TRANS:
349  if (pTrans) {
350  do {
351  Shift = (3 - CurrentPixel) << 1;
352  Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
353  if (Index) {
354  PixelIndex = *(pTrans + Index);
355  _SetPixelIndex(pDevice, x, y, PixelIndex);
356  }
357  x++;
358  if (++CurrentPixel == 4) {
359  CurrentPixel = 0;
360  Pixels = *(++p);
361  }
362  } while (--xsize);
363  } else {
364  do {
365  Shift = (3 - CurrentPixel) << 1;
366  Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
367  if (Index) {
368  _SetPixelIndex(pDevice, x, y, Index);
369  }
370  x++;
371  if (++CurrentPixel == 4) {
372  CurrentPixel = 0;
373  Pixels = *(++p);
374  }
375  } while (--xsize);
376  }
377  break;
378  }
379 }
380 
381 /*********************************************************************
382 *
383 * Draw Bitmap 4 BPP
384 */
385 static void _DrawBitLine4BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
386  LCD_PIXELINDEX Pixels, PixelIndex;
387  int CurrentPixel, Shift, Index;
388 
389  Pixels = *p;
390  CurrentPixel = Diff;
391  x += Diff;
393  case 0:
394  if (pTrans) {
395  do {
396  Shift = (1 - CurrentPixel) << 2;
397  Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
398  PixelIndex = *(pTrans + Index);
399  _SetPixelIndex(pDevice, x++, y, PixelIndex);
400  if (++CurrentPixel == 2) {
401  CurrentPixel = 0;
402  Pixels = *(++p);
403  }
404  } while (--xsize);
405  } else {
406  do {
407  Shift = (1 - CurrentPixel) << 2;
408  Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
409  _SetPixelIndex(pDevice, x++, y, Index);
410  if (++CurrentPixel == 2) {
411  CurrentPixel = 0;
412  Pixels = *(++p);
413  }
414  } while (--xsize);
415  }
416  break;
417  case LCD_DRAWMODE_TRANS:
418  if (pTrans) {
419  do {
420  Shift = (1 - CurrentPixel) << 2;
421  Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
422  if (Index) {
423  PixelIndex = *(pTrans + Index);
424  _SetPixelIndex(pDevice, x, y, PixelIndex);
425  }
426  x++;
427  if (++CurrentPixel == 2) {
428  CurrentPixel = 0;
429  Pixels = *(++p);
430  }
431  } while (--xsize);
432  } else {
433  do {
434  Shift = (1 - CurrentPixel) << 2;
435  Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
436  if (Index) {
437  _SetPixelIndex(pDevice, x, y, Index);
438  }
439  x++;
440  if (++CurrentPixel == 2) {
441  CurrentPixel = 0;
442  Pixels = *(++p);
443  }
444  } while (--xsize);
445  }
446  break;
447  }
448 }
449 
450 /*********************************************************************
451 *
452 * Draw Bitmap 8 BPP
453 */
454 static void _DrawBitLine8BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
455  LCD_PIXELINDEX Pixel;
456 
458  case 0:
459  if (pTrans) {
460  for (; xsize > 0; xsize--, x++, p++) {
461  Pixel = *p;
462  _SetPixelIndex(pDevice, x, y, *(pTrans + Pixel));
463  }
464  } else {
465  for (; xsize > 0; xsize--, x++, p++) {
466  _SetPixelIndex(pDevice, x, y, *p);
467  }
468  }
469  break;
470  case LCD_DRAWMODE_TRANS:
471  if (pTrans) {
472  for (; xsize > 0; xsize--, x++, p++) {
473  Pixel = *p;
474  if (Pixel) {
475  _SetPixelIndex(pDevice, x, y, *(pTrans + Pixel));
476  }
477  }
478  } else {
479  for (; xsize > 0; xsize--, x++, p++) {
480  Pixel = *p;
481  if (Pixel) {
482  _SetPixelIndex(pDevice, x, y, Pixel);
483  }
484  }
485  }
486  break;
487  }
488 }
489 
490 /*********************************************************************
491 *
492 * Draw Bitmap 16 BPP, not optimized
493 *
494 * Purpose:
495 * Drawing of 16bpp high color bitmaps.
496 * Only required for 16bpp color depth of target. Should be removed otherwise.
497 */
498 static void _DrawBitLine16BPP(GUI_DEVICE * pDevice, int x, int y, U16 const GUI_UNI_PTR * p, int xsize) {
499  for (;xsize > 0; xsize--, x++, p++) {
500  _SetPixelIndex(pDevice, x, y, *p);
501  }
502 }
503 
504 /*********************************************************************
505 *
506 * Draw Bitmap 32 BPP, not optimized
507 *
508 * Purpose:
509 * Drawing of 32bpp true color bitmaps.
510 * Only required for 32bpp color depth of target. Should be removed otherwise.
511 */
512 static void _DrawBitLine32BPP(GUI_DEVICE * pDevice, int x, int y, U32 const GUI_UNI_PTR * p, int xsize) {
513  for (;xsize > 0; xsize--, x++, p++) {
514  _SetPixelIndex(pDevice, x, y, *p);
515  }
516 }
517 
518 /*********************************************************************
519 *
520 * _DrawBitmap
521 */
522 static void _DrawBitmap(GUI_DEVICE * pDevice, int x0, int y0,
523  int xSize, int ySize,
524  int BitsPerPixel,
525  int BytesPerLine,
526  const U8 GUI_UNI_PTR * pData, int Diff,
527  const LCD_PIXELINDEX * pTrans) {
528  int i;
529 
530  switch (BitsPerPixel) {
531  case 1:
532  for (i = 0; i < ySize; i++) {
533  _DrawBitLine1BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
534  pData += BytesPerLine;
535  }
536  break;
537  case 2:
538  for (i = 0; i < ySize; i++) {
539  _DrawBitLine2BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
540  pData += BytesPerLine;
541  }
542  break;
543  case 4:
544  for (i = 0; i < ySize; i++) {
545  _DrawBitLine4BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
546  pData += BytesPerLine;
547  }
548  break;
549  case 8:
550  for (i = 0; i < ySize; i++) {
551  _DrawBitLine8BPP(pDevice, x0, i + y0, pData, xSize, pTrans);
552  pData += BytesPerLine;
553  }
554  break;
555  //
556  // Only required for 16bpp color depth of target. Should be removed otherwise.
557  //
558  case 16:
559  for (i = 0; i < ySize; i++) {
560  _DrawBitLine16BPP(pDevice, x0, i + y0, (const U16 *)pData, xSize);
561  pData += BytesPerLine;
562  }
563  break;
564  //
565  // Only required for 32bpp color depth of target. Should be removed otherwise.
566  //
567  case 32:
568  for (i = 0; i < ySize; i++) {
569  _DrawBitLine32BPP(pDevice, x0, i + y0, (const U32 *)pData, xSize);
570  pData += BytesPerLine;
571  }
572  break;
573  }
574 }
575 
576 /*********************************************************************
577 *
578 * _InitOnce
579 *
580 * Purpose:
581 * Allocates a fixed block for the context of the driver
582 *
583 * Return value:
584 * 0 on success, 1 on error
585 */
586 static int _InitOnce(GUI_DEVICE * pDevice) {
587  DRIVER_CONTEXT_TEMPLATE * pContext;
588 
589  if (pDevice->u.pContext == NULL) {
591  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
592  pContext->BitsPerPixel = LCD__GetBPP(pDevice->pColorConvAPI->pfGetIndexMask());
593  }
594  return pDevice->u.pContext ? 0 : 1;
595 }
596 
597 /*********************************************************************
598 *
599 * _GetDevProp
600 */
601 static I32 _GetDevProp(GUI_DEVICE * pDevice, int Index) {
602  DRIVER_CONTEXT_TEMPLATE * pContext;
603 
604  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
605  switch (Index) {
606  case LCD_DEVCAP_XSIZE:
607  return pContext->xSize;
608  case LCD_DEVCAP_YSIZE:
609  return pContext->ySize;
610  case LCD_DEVCAP_VXSIZE:
611  return pContext->vxSize;
612  case LCD_DEVCAP_VYSIZE:
613  return pContext->vySize;
615  return pContext->BitsPerPixel;
617  return 0;
618  case LCD_DEVCAP_XMAG:
619  return 1;
620  case LCD_DEVCAP_YMAG:
621  return 1;
622  case LCD_DEVCAP_MIRROR_X:
623  return 0;
624  case LCD_DEVCAP_MIRROR_Y:
625  return 0;
626  case LCD_DEVCAP_SWAP_XY:
627  return 0;
628  }
629  return -1;
630 }
631 
632 /*********************************************************************
633 *
634 * _GetDevData
635 */
636 static void * _GetDevData(GUI_DEVICE * pDevice, int Index) {
637  GUI_USE_PARA(pDevice);
638  #if GUI_SUPPORT_MEMDEV
639  switch (Index) {
640  case LCD_DEVDATA_MEMDEV:
641  return (void *)&GUI_MEMDEV_DEVICE_16; // TBD: Has to be adapted to the right memory device depending on the used color depth!
642  }
643  #else
644  GUI_USE_PARA(Index);
645  #endif
646  return NULL;
647 }
648 
649 /*********************************************************************
650 *
651 * _GetRect
652 */
653 static void _GetRect(GUI_DEVICE * pDevice, LCD_RECT * pRect) {
654  DRIVER_CONTEXT_TEMPLATE * pContext;
655 
656  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
657  pRect->x0 = 0;
658  pRect->y0 = 0;
659  pRect->x1 = pContext->vxSize - 1;
660  pRect->y1 = pContext->vySize - 1;
661 }
662 
663 /*********************************************************************
664 *
665 * _SetOrg
666 */
667 static void _SetOrg(GUI_DEVICE * pDevice, int x, int y) {
668  LCD_X_SETORG_INFO Data = {0};
669 
670  Data.xPos = x;
671  Data.yPos = y;
672  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETORG, (void *)&Data);
673 }
674 
675 /*********************************************************************
676 *
677 * Static code: Functions available by _GetDevFunc()
678 *
679 **********************************************************************
680 */
681 /*********************************************************************
682 *
683 * _SetVRAMAddr
684 */
685 static void _SetVRAMAddr(GUI_DEVICE * pDevice, void * pVRAM) {
686  DRIVER_CONTEXT_TEMPLATE * pContext;
687  LCD_X_SETVRAMADDR_INFO Data = {0};
688 
689  _InitOnce(pDevice);
690  if (pDevice->u.pContext) {
691  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
692  pContext->VRAMAddr = (U32)pVRAM;
693  Data.pVRAM = pVRAM;
694  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETVRAMADDR, (void *)&Data);
695  }
696 }
697 
698 /*********************************************************************
699 *
700 * _SetVSize
701 */
702 static void _SetVSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
703  DRIVER_CONTEXT_TEMPLATE * pContext;
704 
705  _InitOnce(pDevice);
706  if (pDevice->u.pContext) {
707  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
708  pContext->vxSize = xSize;
709  pContext->vySize = ySize;
710  pContext->vxSizePhys = xSize;
711  }
712 }
713 
714 /*********************************************************************
715 *
716 * _SetSize
717 */
718 static void _SetSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
719  DRIVER_CONTEXT_TEMPLATE * pContext;
720  LCD_X_SETSIZE_INFO Data = {0};
721 
722  _InitOnce(pDevice);
723  if (pDevice->u.pContext) {
724  pContext = (DRIVER_CONTEXT_TEMPLATE *)pDevice->u.pContext;
725  pContext->vxSizePhys = (pContext->vxSizePhys == 0) ? xSize : pContext->vxSizePhys;
726  pContext->xSize = xSize;
727  pContext->ySize = ySize;
728  Data.xSize = xSize;
729  Data.ySize = ySize;
730  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETSIZE, (void *)&Data);
731  }
732 }
733 /*********************************************************************
734 *
735 * _Init
736 */
737 static int _Init(GUI_DEVICE * pDevice) {
738  int r;
739 
740  r = _InitOnce(pDevice);
742  return r;
743 }
744 
745 /*********************************************************************
746 *
747 * _On
748 */
749 static void _On (GUI_DEVICE * pDevice) {
751 }
752 
753 /*********************************************************************
754 *
755 * _Off
756 */
757 static void _Off (GUI_DEVICE * pDevice) {
759 }
760 
761 /*********************************************************************
762 *
763 * _SetLUTEntry
764 */
765 static void _SetLUTEntry(GUI_DEVICE * pDevice, U8 Pos, LCD_COLOR Color) {
766  LCD_X_SETLUTENTRY_INFO Data = {0};
767 
768  Data.Pos = Pos;
769  Data.Color = Color;
770  LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETLUTENTRY, (void *)&Data);
771 }
772 
773 /*********************************************************************
774 *
775 * _GetDevFunc
776 */
777 static void (* _GetDevFunc(GUI_DEVICE ** ppDevice, int Index))(void) {
778  GUI_USE_PARA(ppDevice);
779  switch (Index) {
781  return (void (*)(void))_SetVRAMAddr;
783  return (void (*)(void))_SetVSize;
785  return (void (*)(void))_SetSize;
786  case LCD_DEVFUNC_INIT:
787  return (void (*)(void))_Init;
788  case LCD_DEVFUNC_ON:
789  return (void (*)(void))_On;
790  case LCD_DEVFUNC_OFF:
791  return (void (*)(void))_Off;
793  return (void (*)(void))_SetLUTEntry;
794  }
795  return NULL;
796 }
797 
798 /*********************************************************************
799 *
800 * Public data
801 *
802 **********************************************************************
803 */
804 /*********************************************************************
805 *
806 * GUI_DEVICE_API structure
807 */
809  //
810  // Data
811  //
813  //
814  // Drawing functions
815  //
816  _DrawBitmap,
817  _DrawHLine,
818  _DrawVLine,
819  _FillRect,
820  _GetPixelIndex,
821  _SetPixelIndex,
822  _XorPixel,
823  //
824  // Set origin
825  //
826  _SetOrg,
827  //
828  // Request information
829  //
830  _GetDevFunc,
831  _GetDevProp,
832  _GetDevData,
833  _GetRect,
834 };
835 
836 /*************************** End of file ****************************/
GUI_SADDR GUI_CONTEXT * GUI_pContext
#define LCD_X_SETSIZE
Definition: LCD.h:520
#define LCD__GetColorIndex()
Definition: GUI_Private.h:588
#define LCD_DEVCAP_MIRROR_Y
Definition: LCD.h:351
tLCDDEV_GetIndexMask * pfGetIndexMask
Definition: LCD.h:139
#define LCD_DEVDATA_MEMDEV
Definition: LCD.h:457
#define LCD_DEVFUNC_OFF
Definition: LCD.h:423
const GUI_DEVICE_API GUI_MEMDEV_DEVICE_16
#define LCD_DEVCAP_NUMCOLORS
Definition: LCD.h:347
#define GUI_USE_PARA(para)
#define U32
Definition: Global.h:50
#define LCD_DEVFUNC_SET_SIZE
Definition: LCD.h:419
#define LCD_DEVCAP_BITSPERPIXEL
Definition: LCD.h:346
#define LCD_DEVCAP_VYSIZE
Definition: LCD.h:342
Definition: LCD.h:102
#define LCD_X_ON
Definition: LCD.h:518
const GUI_DEVICE_API GUIDRV_Template_API
I32 LCD__GetBPP(U32 IndexMask)
#define LCD_PIXELINDEX
#define LCD_DEVFUNC_SETLUTENTRY
Definition: LCD.h:424
#define LCD_DEVFUNC_SET_VSIZE
Definition: LCD.h:418
union GUI_DEVICE::@32 u
#define GUI_UNI_PTR
#define LCD_X_INITCONTROLLER
Definition: LCD.h:514
#define LCD_DEVCAP_VXSIZE
Definition: LCD.h:341
void * pContext
Definition: GUI.h:179
#define LCD_DEVCAP_XSIZE
Definition: LCD.h:339
I16 y0
Definition: LCD.h:102
#define LCD_X_OFF
Definition: LCD.h:519
#define LCD_DEVCAP_XMAG
Definition: LCD.h:348
#define NULL
Definition: usbd_def.h:53
int LayerIndex
Definition: GUI.h:187
I16 y1
Definition: LCD.h:102
U8 DrawMode
Definition: GUI.h:214
#define LCD_DEVCAP_SWAP_XY
Definition: LCD.h:352
#define LCD_DRAWMODE_TRANS
Definition: LCD.h:87
#define LCD_DRAWMODE_XOR
Definition: LCD.h:86
#define LCD_DEVFUNC_INIT
Definition: LCD.h:420
U32 LCD_COLOR
Definition: LCD.h:95
LCD_COLOR Color
Definition: LCD.h:473
#define yPhys
const LCD_API_COLOR_CONV * pColorConvAPI
Definition: GUI.h:185
#define LCD_DEVFUNC_ON
Definition: LCD.h:422
#define LCD_X_SETVRAMADDR
Definition: LCD.h:515
#define LCD_DEVFUNC_SET_VRAM_ADDR
Definition: LCD.h:417
#define LOG2PHYS_Y(x, y)
#define LCD_X_SETORG
Definition: LCD.h:516
#define LOG2PHYS_X(x, y)
void * GUI_ALLOC_GetFixedBlock(GUI_ALLOC_DATATYPE Size)
#define LCD_DEVCAP_MIRROR_X
Definition: LCD.h:350
#define LCD_X_SETLUTENTRY
Definition: LCD.h:517
I16 x1
Definition: LCD.h:102
#define U16
Definition: Global.h:47
I16 x0
Definition: LCD.h:102
#define LCD_DEVCAP_YSIZE
Definition: LCD.h:340
#define LCD_DEVCAP_YMAG
Definition: LCD.h:349
#define xPhys
#define I32
Definition: Global.h:59
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void *pData)
This function is called by the display driver for several purposes. To support the according task the...
Definition: LCDConf.c:857
#define U8
Definition: Global.h:44