LCDColor.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:5k
源码类别:

uCOS

开发平台:

C/C++

  1. /*********************************************************************
  2. *                SEGGER MICROCONTROLLER SYSTEME GmbH                 *
  3. *        Solutions for real time microcontroller applications        *
  4. **********************************************************************
  5. *                                                                    *
  6. *        (c) 2002         SEGGER Microcontroller Systeme GmbH        *
  7. *                                                                    *
  8. *        Internet: www.segger.com    Support:  support@segger.com    *
  9. *                                                                    *
  10. **********************************************************************
  11. **** emWin/GSC Grafical user interface for embedded applications ****
  12. emWin is protected by international copyright laws. Knowledge of the
  13. source code may not be used to write a similar product. This file may
  14. only be used in accordance with a license and should not be re-
  15. distributed in any way. We appreciate your understanding and fairness.
  16. ----------------------------------------------------------------------
  17. File        : LCDColor.C
  18. Purpose     : Color conversion routines for LCD-drivers
  19. ---------------------------END-OF-HEADER------------------------------
  20. */
  21. #define LCDCOLOR_C
  22. #include <stddef.h>           /* needed for definition of NULL */
  23. #include "GUI.h"
  24. #include "LCD_Private.H"      /* inter modul definitions & Config */
  25. #include "GUIDebug.h"
  26. /*
  27.         *********************************************************
  28.         *                                                       *
  29.         *       Config defaults                                 *
  30.         *                                                       *
  31.         *********************************************************
  32. */
  33. #ifndef  LCD_SIZEOF_COLORCACHE
  34.   #define LCD_SIZEOF_COLORCACHE 0
  35. #endif
  36. /*
  37.         *********************************************************
  38.         *                                                       *
  39.         *       Caching (optional)                              *
  40.         *                                                       *
  41.         *********************************************************
  42. */
  43. #if  LCD_SIZEOF_COLORCACHE
  44.   static  const LCD_LOGPALETTE * pLogPalCache;
  45. #endif
  46.   /*
  47.           *********************************************************
  48.           *                                                       *
  49.           *       Build color conversion table                    *
  50.           *                                                       *
  51.           *********************************************************
  52.   */
  53. static LCD_PIXELINDEX ConvTable[LCD_MAX_LOG_COLORS];
  54. LCD_PIXELINDEX* LCD_GetpPalConvTableUncached(const LCD_LOGPALETTE*  pLogPal) {
  55. /* Check if sufficient space is available */
  56.   if (pLogPal->NumEntries > LCD_MAX_LOG_COLORS) {
  57.     return NULL;
  58.   }
  59. /* Build conversion table */
  60.   {
  61.     int i;
  62.     int NumEntries = pLogPal->NumEntries;
  63.     const LCD_COLOR* pPalEntry = &pLogPal->pPalEntries[0];
  64.     for (i=0; i< NumEntries; i++) {
  65.       ConvTable[i] = LCD_Color2Index(*(pPalEntry+i));
  66.     }
  67.   }
  68.   return &ConvTable[0];
  69. }
  70. LCD_PIXELINDEX* LCD_GetpPalConvTable(const LCD_LOGPALETTE*  pLogPal) {
  71. /* Check cache */
  72.   #if  LCD_SIZEOF_COLORCACHE
  73.     if (pLogPalCache == pLogPal) {
  74.       return &ConvTable[0];
  75.     }
  76.     pLogPalCache = pLogPal;
  77.   #endif
  78.   return LCD_GetpPalConvTableUncached(pLogPal);
  79. }
  80. /*
  81.         *********************************************************
  82.         *                                                       *
  83.         *                   LCD_InitLUT                         *
  84.         *                                                       *
  85.         *********************************************************
  86. */
  87. void LCD_InitLUT(void) {
  88.   #if (LCD_BITSPERPIXEL <= 8)
  89.     {
  90.       int i;
  91.       for (i=0; i < LCD_NUM_COLORS; i++) {
  92.         LCD_COLOR color = LCD_Index2Color((U8)i);
  93.         #if LCD_REVERSE_LUT
  94.           color ^= 0xffffff;    /* Invert R,G,B components */
  95.         #endif
  96.         LCD_L0_SetLUTEntry((U8)i, color);
  97.       }
  98.     }
  99.   #endif
  100.   #if (LCD_NUM_DISPLAYS > 1)
  101.     #if (LCD_BITSPERPIXEL_1 <= 8)
  102.     {
  103.       int i;
  104.       int DisplayOld = GUI_SelLCD(1);
  105.       for (i=0; i < LCD_NUM_COLORS_1; i++) {
  106.         LCD_COLOR color = LCD_Index2Color((U8)i);
  107.         #if LCD_REVERSE_LUT
  108.           color ^= 0xffffff;    /* Invert R,G,B components */
  109.         #endif
  110.         LCD_L0_1_SetLUTEntry((U8)i, color);
  111.       }
  112.       GUI_SelLCD(DisplayOld);
  113.     }
  114.     #endif
  115.   #endif
  116. }