📄 lcd_lpc1788.c
字号:
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
*/
#include "LCD_Private.h" /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCDConf.h"
#include "cpu.h"
/**********************************************************************/
#include "LPC177x_8x.h"
#include "lpc177x_8x_clkpwr.h"
#include "lpc177x_8x_pinsel.h"
#include "sdram_k4s561632j.h"
/**********************************************************************/
#if (LCD_CONTROLLER == lpc1788) \
&& (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
/*********************************************************************
*
* Macros
*
**********************************************************************
*/
#define WORDS_PER_LINE (LCD_VXSIZE * 3 /4)
#define Y2OFF(y) (WORDS_PER_LINE * y)
/*********************************************
*
* Macros for MIRROR_, SWAP_ and LUT_
*
**********************************************
*/
#if (!defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
#if (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) x
#define LOG2PHYS_Y(x, y) y
#elif (!LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) y
#define LOG2PHYS_Y(x, y) x
#elif (!LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) x
#define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
#elif (!LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
#define LOG2PHYS_Y(x, y) x
#elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
#define LOG2PHYS_Y(x, y) y
#elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
#define LOG2PHYS_Y(x, y) x
#elif ( LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
#define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
#define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
#elif ( LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
#error This combination of mirroring/swapping not yet supported
#endif
#else
#if ( defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
#define LOG2PHYS_X(x, y) x
#define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
#elif (!defined (LCD_LUT_COM) && defined(LCD_LUT_SEG))
#define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
#define LOG2PHYS_Y(x, y) y
#elif ( defined (LCD_LUT_COM) && defined(LCD_LUT_SEG))
#define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
#define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
#endif
#endif
/*********************************************************************************************************
** Function name : delay_Ns
** Function Description : delay time
** Input: idly the necessary time
** Output: none
*********************************************************************************************************/
void delay_Ns (int idly)
{
int i;
for(; idly > 0; idly--) {
for (i = 0; i < 5000; i++);
}
}
/*********************************************
*
* Draw Bitmap 1 BPP
*
**********************************************
*/
static void _DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
do {
LCD_L0_SetPixelIndex(x++, y, (*p & (0x80 >> Diff)) ? Index1 : Index0);
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
if (*p & (0x80 >> Diff))
LCD_L0_SetPixelIndex(x, y, Index1);
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_XOR:;
do {
if (*p & (0x80 >> Diff)) {
int Pixel = LCD_L0_GetPixelIndex(x, y);
LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - 1 - Pixel);
}
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
}
}
/*********************************************
*
* Draw Bitmap 2 BPP
*
**********************************************
*/
#if (LCD_MAX_LOG_COLORS > 2)
static void _DrawBitLine2BPP(int x, int y, U8 const * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixels = *p;
int CurrentPixel = Diff;
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x++, y, PixelIndex);
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
if (Index) {
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x, y, PixelIndex);
}
x++;
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
break;
}
}
#endif
/*********************************************
*
* Draw Bitmap 4 BPP
*
**********************************************
*/
#if (LCD_MAX_LOG_COLORS > 4)
static void _DrawBitLine4BPP(int x, int y, U8 const * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixels = *p;
int CurrentPixel = Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x++, y, PixelIndex);
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
if (Index) {
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x, y, PixelIndex);
}
x++;
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
break;
}
}
#endif
/*********************************************
*
* Draw Bitmap 8 BPP
*
**********************************************
*/
#if (LCD_MAX_LOG_COLORS > 16)
static void _DrawBitLine8BPP(int x, int y, U8 const * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixel;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, Pixel);
}
}
}
break;
}
}
#endif
/*********************************************
*
* Draw Bitmap 16 BPP
*
**********************************************
*/
#if (LCD_BITSPERPIXEL > 8)
static void DrawBitLine16BPP(int x, int y, U16 const * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX pixel;
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) == 0) {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
} else {
for (;xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
} else {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, pixel);
}
}
}
}
}
#endif
/*********************************************************************
*
* Exported functions
*
**********************************************************************
*/
/*********************************************
*
* LCD_L0_SetPixelIndex
*
**********************************************
Purpose:
Sets the index of the given pixel. The upper layers of emWin
calling this routine make sure that the coordinates are in range, so
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -