Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GUIDRV_Generic.h
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2018 SEGGER Microcontroller GmbH * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.48 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to Cypress Semiconductor Corporation, 00019 whose registered office is situated at 198 Champion Ct. San Jose, CA 00020 95134 USA solely for the purposes of creating libraries for Cypress 00021 PSoC3 and PSoC5 processor-based devices, sublicensed and distributed 00022 under the terms and conditions of the Cypress End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 Licensor: SEGGER Microcontroller Systems LLC 00030 Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA 00031 Licensed SEGGER software: emWin 00032 License number: GUI-00319 00033 License model: Services and License Agreement, signed June 10th, 2009 00034 Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) 00035 ---------------------------------------------------------------------- 00036 Support and Update Agreement (SUA) 00037 SUA period: 2009-06-12 - 2022-07-27 00038 Contact to extend SUA: sales@segger.com 00039 ---------------------------------------------------------------------- 00040 File : GUIDRV_Generic.h 00041 Purpose : Adapter to be able to use the display drivers with simple 00042 bus interface from emWin V4.18 00043 ---------------------------END-OF-HEADER------------------------------ 00044 */ 00045 00046 #include "LCD_ConfDefaults.h" 00047 00048 #if defined(LCD_CONTROLLER) 00049 00050 /********************************************************************* 00051 * 00052 * Defines 00053 * 00054 ********************************************************************** 00055 */ 00056 /********************************************************************* 00057 * 00058 * Remap old configuration macros to static data 00059 */ 00060 #define LCD_XSIZE _xSize 00061 #define LCD_YSIZE _ySize 00062 #define LCD_VXSIZE _vxSize 00063 #define LCD_VYSIZE _vySize 00064 #define LCD_XSIZE_PHYS _xSizePhys 00065 #define LCD_YSIZE_PHYS _ySizePhys 00066 00067 /********************************************************************* 00068 * 00069 * Required renaming operations 00070 */ 00071 #define LCD_On LCD_L0_On 00072 #define LCD_Off LCD_L0_Off 00073 00074 /********************************************************************* 00075 * 00076 * Prototypes of LCD_L0_xxx - functions 00077 */ 00078 void LCD_L0_SetPixelIndex(int x, int y, LCD_PIXELINDEX PixelIndex); 00079 LCD_PIXELINDEX LCD_L0_GetPixelIndex(int x, int y); 00080 void LCD_L0_XorPixel (int x, int y); 00081 void LCD_L0_DrawHLine (int x0, int y, int x1); 00082 void LCD_L0_DrawVLine (int x, int y0, int y1); 00083 void LCD_L0_FillRect (int x0, int y0, int x1, int y1); 00084 void LCD_L0_DrawBitmap (int x0, int y0, int xsize, int ysize, int BitsPerPixel, int BytesPerLine, const U8 * pData, int Diff, const LCD_PIXELINDEX * pTrans); 00085 void LCD_L0_SetOrg (int x, int y); 00086 void LCD_L0_On (void); 00087 void LCD_L0_Off (void); 00088 int LCD_L0_Init (void); 00089 void LCD_L0_SetLUTEntry (U8 Pos, LCD_COLOR Color); 00090 void (* LCD_L0_GetDevFunc (int Index))(void); 00091 00092 /********************************************************************* 00093 * 00094 * Prototypes of SIM_xxx - functions 00095 */ 00096 void SIM_SetVRAMSize(int LayerIndex, int xSize, int ySize); 00097 00098 /********************************************************************* 00099 * 00100 * Static data 00101 * 00102 ********************************************************************** 00103 */ 00104 static int _xSize; 00105 static int _ySize; 00106 static int _vxSize; 00107 static int _vySize; 00108 static int _xSizePhys; 00109 static int _ySizePhys; 00110 00111 /********************************************************************* 00112 * 00113 * Static code 00114 * 00115 ********************************************************************** 00116 */ 00117 /********************************************************************* 00118 * 00119 * __SetPixelIndex 00120 */ 00121 static void __SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, LCD_PIXELINDEX PixelIndex) { 00122 GUI_USE_PARA(pDevice); 00123 LCD_L0_SetPixelIndex(x, y, PixelIndex); 00124 } 00125 00126 /********************************************************************* 00127 * 00128 * __GetPixelIndex 00129 */ 00130 static LCD_PIXELINDEX __GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) { 00131 GUI_USE_PARA(pDevice); 00132 return LCD_L0_GetPixelIndex(x, y); 00133 } 00134 00135 /********************************************************************* 00136 * 00137 * __XorPixel 00138 */ 00139 static void __XorPixel(GUI_DEVICE * pDevice, int x, int y) { 00140 GUI_USE_PARA(pDevice); 00141 LCD_L0_XorPixel(x, y); 00142 } 00143 00144 /********************************************************************* 00145 * 00146 * __DrawHLine 00147 */ 00148 static void __DrawHLine(GUI_DEVICE * pDevice, int x0, int y, int x1) { 00149 GUI_USE_PARA(pDevice); 00150 LCD_L0_DrawHLine(x0, y, x1); 00151 } 00152 00153 /********************************************************************* 00154 * 00155 * __DrawVLine, not optimized 00156 */ 00157 static void __DrawVLine(GUI_DEVICE * pDevice, int x, int y0, int y1) { 00158 GUI_USE_PARA(pDevice); 00159 LCD_L0_DrawVLine(x, y0, y1); 00160 } 00161 00162 /********************************************************************* 00163 * 00164 * __FillRect 00165 */ 00166 static void __FillRect(GUI_DEVICE * pDevice, int x0, int y0, int x1, int y1) { 00167 GUI_USE_PARA(pDevice); 00168 LCD_L0_FillRect(x0, y0, x1, y1); 00169 } 00170 00171 /********************************************************************* 00172 * 00173 * __DrawBitmap 00174 */ 00175 static void __DrawBitmap(GUI_DEVICE * pDevice, int x0, int y0, 00176 int xSize, int ySize, 00177 int BitsPerPixel, 00178 int BytesPerLine, 00179 const U8 * pData, int Diff, 00180 const LCD_PIXELINDEX * pTrans) { 00181 GUI_USE_PARA(pDevice); 00182 LCD_L0_DrawBitmap(x0, y0, xSize, ySize, BitsPerPixel, BytesPerLine, pData, Diff, pTrans); 00183 } 00184 00185 /********************************************************************* 00186 * 00187 * __SetOrg 00188 */ 00189 static void __SetOrg(GUI_DEVICE * pDevice, int x, int y) { 00190 GUI_USE_PARA(pDevice); 00191 LCD_L0_SetOrg(x, y); 00192 } 00193 00194 /********************************************************************* 00195 * 00196 * _SetVSize 00197 */ 00198 static void _SetVSize(GUI_DEVICE * pDevice, int xSize, int ySize) { 00199 LCD_VXSIZE = xSize; 00200 LCD_VYSIZE = ySize; 00201 #if defined(WIN32) | defined(LCD_SIMCONTROLLER) 00202 SIM_SetVRAMSize(pDevice->LayerIndex, xSize, ySize); 00203 #else 00204 GUI_USE_PARA(pDevice); 00205 #endif 00206 } 00207 00208 /********************************************************************* 00209 * 00210 * _SetSize 00211 */ 00212 static void _SetSize(GUI_DEVICE * pDevice, int xSize, int ySize) { 00213 GUI_USE_PARA(pDevice); 00214 LCD_XSIZE = xSize; 00215 LCD_YSIZE = ySize; 00216 #if (LCD_SWAP_XY) 00217 _xSizePhys = ySize; 00218 _ySizePhys = xSize; 00219 #else 00220 _xSizePhys = xSize; 00221 _ySizePhys = ySize; 00222 #endif 00223 } 00224 00225 /********************************************************************* 00226 * 00227 * __ReadRect 00228 */ 00229 static void __ReadRect(GUI_DEVICE * pDevice, int x0, int y0, int x1, int y1, LCD_PIXELINDEX * pBuffer) { 00230 void (* pfReadRect)(int, int, int, int, LCD_PIXELINDEX *); 00231 00232 GUI_USE_PARA(pDevice); 00233 pfReadRect = (void (*)(int, int, int, int, LCD_PIXELINDEX *))LCD_L0_GetDevFunc(LCD_DEVFUNC_READRECT); 00234 pfReadRect(x0, y0, x1, y1, pBuffer); 00235 } 00236 00237 /********************************************************************* 00238 * 00239 * _GetReadRect 00240 */ 00241 static void (* _GetReadRect(void))(void) { 00242 if (LCD_L0_GetDevFunc(LCD_DEVFUNC_READRECT)) { 00243 return (void (*)(void))__ReadRect; 00244 } 00245 return NULL; 00246 } 00247 00248 /********************************************************************* 00249 * 00250 * __ControlCache 00251 */ 00252 static int __ControlCache(GUI_DEVICE * pDevice, int Cmd) { 00253 int (* pfControlCache)(int); 00254 00255 GUI_USE_PARA(pDevice); 00256 pfControlCache = (int (*)(int))LCD_L0_GetDevFunc(LCD_DEVFUNC_CONTROLCACHE); 00257 return pfControlCache(Cmd); 00258 } 00259 00260 /********************************************************************* 00261 * 00262 * _GetControlCache 00263 */ 00264 static void (* _GetControlCache(void))(void) { 00265 if (LCD_L0_GetDevFunc(LCD_DEVFUNC_CONTROLCACHE)) { 00266 return (void (*)(void))__ControlCache; 00267 } 00268 return NULL; 00269 } 00270 00271 /********************************************************************* 00272 * 00273 * __Refresh 00274 */ 00275 static void __Refresh(GUI_DEVICE * pDevice) { 00276 void (* pfRefresh)(void); 00277 00278 GUI_USE_PARA(pDevice); 00279 pfRefresh = (void (*)(void))LCD_L0_GetDevFunc(LCD_DEVFUNC_REFRESH); 00280 pfRefresh(); 00281 } 00282 00283 /********************************************************************* 00284 * 00285 * _GetRefresh 00286 */ 00287 static void (* _GetRefresh(void))(void) { 00288 if (LCD_L0_GetDevFunc(LCD_DEVFUNC_REFRESH)) { 00289 return (void (*)(void))__Refresh; 00290 } 00291 return NULL; 00292 } 00293 00294 /********************************************************************* 00295 * 00296 * _Init 00297 */ 00298 static int _Init(GUI_DEVICE * pDevice) { 00299 GUI_USE_PARA(pDevice); 00300 return LCD_L0_Init(); 00301 } 00302 00303 /********************************************************************* 00304 * 00305 * __GetDevFunc 00306 */ 00307 static void (* __GetDevFunc(GUI_DEVICE ** ppDevice, int Index))(void) { 00308 GUI_USE_PARA(ppDevice); 00309 switch (Index) { 00310 case LCD_DEVFUNC_CONTROLCACHE: 00311 return _GetControlCache(); 00312 case LCD_DEVFUNC_REFRESH: 00313 return _GetRefresh(); 00314 case LCD_DEVFUNC_READRECT: 00315 return _GetReadRect(); 00316 case LCD_DEVFUNC_SET_VSIZE: 00317 return (void (*)(void))_SetVSize; 00318 case LCD_DEVFUNC_SET_SIZE: 00319 return (void (*)(void))_SetSize; 00320 case LCD_DEVFUNC_INIT: 00321 return (void (*)(void))_Init; 00322 default: 00323 return (void (*)(void))LCD_L0_GetDevFunc(Index); 00324 } 00325 } 00326 00327 /********************************************************************* 00328 * 00329 * __GetDevProp 00330 */ 00331 static I32 __GetDevProp(GUI_DEVICE * pDevice, int Index) { 00332 GUI_USE_PARA(pDevice); 00333 switch (Index) { 00334 case LCD_DEVCAP_XSIZE: 00335 return LCD_XSIZE; 00336 case LCD_DEVCAP_YSIZE: 00337 return LCD_YSIZE; 00338 case LCD_DEVCAP_VXSIZE: 00339 return LCD_VXSIZE; 00340 case LCD_DEVCAP_VYSIZE: 00341 return LCD_VYSIZE; 00342 case LCD_DEVCAP_BITSPERPIXEL: 00343 return LCD_BITSPERPIXEL; 00344 case LCD_DEVCAP_NUMCOLORS: 00345 return 1 << LCD_BITSPERPIXEL; 00346 case LCD_DEVCAP_XMAG: 00347 return 1; 00348 case LCD_DEVCAP_YMAG: 00349 return 1; 00350 case LCD_DEVCAP_MIRROR_X: 00351 return LCD_MIRROR_X; 00352 case LCD_DEVCAP_MIRROR_Y: 00353 return LCD_MIRROR_Y; 00354 case LCD_DEVCAP_SWAP_XY: 00355 return LCD_SWAP_XY; 00356 case LCD_DEVCAP_SWAP_RB: 00357 return LCD_SWAP_RB; 00358 } 00359 return -1; 00360 } 00361 00362 /********************************************************************* 00363 * 00364 * __GetDevData 00365 */ 00366 static void * __GetDevData(GUI_DEVICE * pDevice, int Index) { 00367 GUI_USE_PARA(pDevice); 00368 #if GUI_SUPPORT_MEMDEV 00369 switch (Index) { 00370 case LCD_DEVDATA_MEMDEV: 00371 #if (LCD_BITSPERPIXEL == 1) 00372 return (void *)&GUI_MEMDEV_DEVICE_1; 00373 #elif (LCD_BITSPERPIXEL <= 8) 00374 return (void *)&GUI_MEMDEV_DEVICE_8; 00375 #elif (LCD_BITSPERPIXEL <= 16) 00376 return (void *)&GUI_MEMDEV_DEVICE_16; 00377 #else 00378 return (void *)&GUI_MEMDEV_DEVICE_32; 00379 #endif 00380 } 00381 #else 00382 GUI_USE_PARA(Index); 00383 #endif 00384 return NULL; 00385 } 00386 00387 /********************************************************************* 00388 * 00389 * __GetRect 00390 */ 00391 static void __GetRect(GUI_DEVICE * pDevice, LCD_RECT * pRect) { 00392 GUI_USE_PARA(pDevice); 00393 pRect->x0 = 0; 00394 pRect->y0 = 0; 00395 pRect->x1 = LCD_VXSIZE - 1; 00396 pRect->y1 = LCD_VYSIZE - 1; 00397 } 00398 00399 /********************************************************************* 00400 * 00401 * Public data 00402 * 00403 ********************************************************************** 00404 */ 00405 /********************************************************************* 00406 * 00407 * GUI_DEVICE_API structure 00408 */ 00409 const GUI_DEVICE_API DISPLAY_DRIVER_API = { 00410 // 00411 // Data 00412 // 00413 DEVICE_CLASS_DRIVER, 00414 // 00415 // Drawing functions 00416 // 00417 __DrawBitmap, 00418 __DrawHLine, 00419 __DrawVLine, 00420 __FillRect, 00421 __GetPixelIndex, 00422 __SetPixelIndex, 00423 __XorPixel, 00424 // 00425 // Set origin 00426 // 00427 __SetOrg, 00428 // 00429 // Request information 00430 // 00431 __GetDevFunc, 00432 __GetDevProp, 00433 __GetDevData, 00434 __GetRect, 00435 }; 00436 00437 #endif 00438 00439 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:40 by
