⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdcolor.c

📁 uCGUI
💻 C
字号:
/*************************************************************************************************************
                                                   uC/GUI
                                               嵌入式通用图形软件
File        : LCDColor.C
Purpose     : Color conversion routines for LCD-drivers
*************************************************************************************************************/
#define LCDCOLOR_C

#include <stddef.h>           /* needed for definition of NULL */
#include "GUI.h"
#include "LCD_Private.H"      /* inter modul definitions & Config */
#include "GUIDebug.h"


/*************************************************************************************************************
*Config defaults                                
*************************************************************************************************************/
#ifndef  LCD_SIZEOF_COLORCACHE
  #define LCD_SIZEOF_COLORCACHE 0
#endif

/*************************************************************************************************************
*Caching (optional)                              
*************************************************************************************************************/
#if  LCD_SIZEOF_COLORCACHE
  static  const LCD_LOGPALETTE * pLogPalCache;
#endif

/*************************************************************************************************************
  *Build color conversion table                   
*************************************************************************************************************/
static LCD_PIXELINDEX ConvTable[LCD_MAX_LOG_COLORS];

LCD_PIXELINDEX* LCD_GetpPalConvTableUncached(const LCD_LOGPALETTE*  pLogPal) 
{
/* Check if sufficient space is available */
  if (pLogPal->NumEntries > LCD_MAX_LOG_COLORS) 
  {
    return NULL;
  }
/* Build conversion table */
  {
    int i;
    int NumEntries = pLogPal->NumEntries;
    const LCD_COLOR* pPalEntry = &pLogPal->pPalEntries[0];
    for (i=0; i< NumEntries; i++) 
    {
      ConvTable[i] = LCD_Color2Index(*(pPalEntry+i));
    }
  }
  return &ConvTable[0];
}

LCD_PIXELINDEX* LCD_GetpPalConvTable(const LCD_LOGPALETTE*  pLogPal) 
{
/* Check cache */
  #if  LCD_SIZEOF_COLORCACHE
    if (pLogPalCache == pLogPal) 
    {
      return &ConvTable[0];
    }
    pLogPalCache = pLogPal;
  #endif
  return LCD_GetpPalConvTableUncached(pLogPal);
}

/*************************************************************************************************************
*            LCD_InitLUT                       
*************************************************************************************************************/
void LCD_InitLUT(void) {
  #if (LCD_BITSPERPIXEL <= 8)
    {
      int i;
      for (i=0; i < LCD_NUM_COLORS; i++) 
      {
        LCD_COLOR color = LCD_Index2Color((U8)i);
        #if LCD_REVERSE_LUT
          color ^= 0xffffff;    /* Invert R,G,B components */
        #endif
        LCD_L0_SetLUTEntry((U8)i, color);
      }
    }
  #endif
  #if (LCD_NUM_DISPLAYS > 1)
    #if (LCD_BITSPERPIXEL_1 <= 8)
    {
      int i;
      int DisplayOld = GUI_SelLCD(1);
      for (i=0; i < LCD_NUM_COLORS_1; i++) 
      {
        LCD_COLOR color = LCD_Index2Color((U8)i);
        #if LCD_REVERSE_LUT
          color ^= 0xffffff;    /* Invert R,G,B components */
        #endif
        LCD_L0_1_SetLUTEntry((U8)i, color);
      }
      GUI_SelLCD(DisplayOld);
    }
    #endif
  #endif
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -