📄 color_lcd_test.c
字号:
/*********************************************************************************************
* File: color_lcd_test.c
* Author: Embest
* Desc: LCD control and display functions
* History:
*
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/#include <string.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "lcdlib.h"
#include "glib.h"
#include "lcd.h"
#include "demo256.h"
#define Ascii8x16
#define Hzk12
#define Hzk16
#define Hzk24
/*------------------------------------------------------------------------------------------*/
/* function declare */
/*------------------------------------------------------------------------------------------*/
#ifdef Ascii6x8
extern UINT8T g_auc_Ascii6x8[];
void Lcd_DspAscII6X8(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T * s);
#endif
#ifdef Ascii8x16
extern UINT8T g_auc_Ascii8x16[];
void Lcd_DspAscII8X16(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T * s);
void lcd_Disp_str16(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s);
#endif
#ifdef Hzk12
extern UINT8T g_auc_HZK12[];
void Lcd_DspHz12(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s);
#endif
#ifdef Hzk16
extern UINT8T g_auc_HZK16[];
void Lcd_DspHz16(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s);
#endif
#ifdef Hzk24
extern UINT8T g_auc_hzk24[];
void Lcd_DspHz24(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s);
#endif
#ifdef Hzk24s
extern UINT8T g_auc_HZK24s[];
void Lcd_DspHz24s(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s);
#endif
extern const UINT8T g_ucBitmap[][76800];
/*------------------------------------------------------------------------------------------*/
/* constant define */
/*------------------------------------------------------------------------------------------*/
#define LCD_BUF_SIZE (SCR_XSIZE_TFT_640480*SCR_YSIZE_TFT_640480/2)
#define LCD_ACTIVE_BUFFER (0x33800000)
#define LCD_VIRTUAL_BUFFER (0x33800000 + LCD_BUF_SIZE)
void Lcd_InitZK();
void Lcd_InitZK_End();
void lcd_clr_rect(INT16T usLeft, INT16T usTop, INT16T usRight, INT16T usBottom, UINT16T ucColor);
/*****************************************************************/
#define Ascii_W 8
#define XWIDTH 6
/*********************************************************************/
UINT8T ziku[224] =
{
0x00,0x08,0x7E,0x08,0x42,0x08,0x4A,0x08,0x4A,0xFE,0x4A,0x18,0x4A,0x18,0x4A,0x28,
0x4A,0x28,0x4A,0x48,0x08,0x48,0x14,0x88,0x12,0x08,0x23,0x08,0x42,0x28,0x80,0x10,
0x40,0x00,0x27,0xFE,0x24,0x40,0x04,0x80,0x85,0xFC,0x55,0x04,0x15,0xFC,0x15,0x04,
0x25,0xFC,0x24,0x20,0xC4,0xA8,0x44,0xA4,0x49,0x22,0x4A,0x22,0x50,0xA0,0x40,0x40,
0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x00,0x00,
0x01,0x10,0x41,0x10,0x21,0x10,0x37,0xFC,0x21,0x10,0x01,0x10,0x01,0x10,0xF7,0xFE,
0x11,0x10,0x11,0x10,0x12,0x10,0x12,0x10,0x14,0x10,0x28,0x00,0x47,0xFE,0x00,0x00,
0x00,0x00,0x40,0x80,0x30,0x80,0x10,0x80,0x0F,0xFC,0x00,0x80,0x00,0x80,0xE0,0x80,
0x21,0x40,0x21,0x20,0x22,0x18,0x24,0x0C,0x28,0x08,0x50,0x02,0x8F,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,
0x20,0x00,0x10,0x00,0x13,0xFC,0x00,0x40,0x88,0x40,0x48,0x40,0x50,0x40,0x10,0x40,
0x10,0x40,0x20,0x40,0xE0,0x40,0x20,0x40,0x20,0x40,0x2F,0xFE,0x20,0x00,0x00,0x00,
};
UINT8T ziku_depth[8]=
{
2, 4, 6, 8, 10, 12,14, 0
};
void Lcd_DisplayHZ(UINT16T usX0, UINT16T usY0, UINT8T *pucText, INT32T ulLen)
{
INT32T i, j;
UINT8T ucTemp;
for (i = 0; i < 16; i++)
{
for (j = 0; j < ulLen; j++)
{
ucTemp = *(pucText + i * ulLen / 8 + j /8);
if ((ucTemp & (0x80 >> (j%8))) == 0)
{
PutPixel(usX0 + j, usY0 + i, WHITE);
}
else
{
PutPixel(usX0 + j, usY0 + i, BLACK);
}
}
}
}
void Lcd_DspHZ(INT32T x, INT32T y, INT32T backcolor)
{
INT32T i, j, k;
UINT16T hztemp;
for (i = 0; i < 7; i++)
{
for (j = 0; j < 16; j++)
{
hztemp = (ziku[i * 32 + j * 2] << 8) + ziku[i * 32 + j * 2 + 1];
for (k = 0; k < 16; k++)
{
if ((hztemp & (0x8000 >> k)) == 0)
{
PutPixel((320-(x + i * (16+4) + k)), y + j, backcolor);
}
else
{
PutPixel((320-(x + i * (16 + 4) + k)), y + j, ziku_depth[i]);
}
}
}
}
}
/*********************************************************************************************
* name: Lcd_InitZK
* func: lcd application initialization code
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_InitZK()
{
Lcd_port_init();
Lcd_Init(MODE_TFT_16BIT_640480);
Glib_Init(MODE_TFT_16BIT_640480);
Glib_ClearScr(0, MODE_TFT_16BIT_640480);
Lcd_PowerEnable(0, 1);
Lcd_EnvidOnOff(1);
uart_printf("[TFT 64K COLOR(16bit/1pixel) LCD TEST]\n");
}
void Lcd_InitZK_End()
{
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: color_lcd_test()
* func: LCD test function
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void color_lcd_test(void)
{
INT32T x, y,i,j;
uart_printf("\n LCD display Test Example (please look at LCD screen)\n");
UINT8T e_info1[]={"提供嵌入式软硬件开发工具和系统解决方案及技术信"};
UINT8T e_info2[]={"息服务"};
i =20;
Lcd_InitZK();
BitmapViewTft16Bit_640480((UINT8T *)(g_ucBitmap));
Glib_Rectangle(5,5,635,475,GREEN);
Glib_Rectangle(10,10,630,470,RED);
Glib_Rectangle(15,15,625,465,BLUE);
Glib_Rectangle(20,20,620,460,GREEN);
#ifdef Hzk24
Lcd_DspHz24(180,i+=30,BLACK,"英蓓特信息技术有限公司");
Lcd_DspHz24(50,i+=30,BLACK,(UINT8T *) e_info1);
Lcd_DspHz24(50,i+=30,BLACK,(UINT8T *) e_info2);
Lcd_DspHz24(180,i+=60,BLACK,"英蓓特信息技术有限公司");
Lcd_DspHz24(180,i+=30,BLACK,"二十四点阵汉字");
#endif
#ifdef Hzk16
Lcd_DspHz16(180,i+=30,BLACK,"英蓓特信息技术有限公司");
Lcd_DspHz16(180,i+=20,BLACK,"十六点阵汉字");
#endif
#ifdef Hzk12
Lcd_DspHz12(180,i+=20,BLACK,"英蓓特信息技术有限公司");
Lcd_DspHz12(180,i+=20,BLACK,"十二点阵汉字");
#endif
#ifdef Ascii8x16
Lcd_DspAscII8X16(300,i+=30,BLACK,"Embest2410");
Lcd_DspAscII8X16(300,i+=30,BLACK,"8x16");
lcd_Disp_str16(75, 25, GREEN, "LCD display Test Example (please look at LCD screen)");
#endif
#ifdef Ascii6x8
Lcd_DspAscII6X8(500,i+=30,BLACK,"Embest2410");
Lcd_DspAscII6x8(550,i+=30,BLACK,"6x8");
#endif
while(1);
}
/*********************************************************************************************
* name: lcd_Disp_str16()
* func: display 8x16 ASCII character string and 16x16 chinese character string
* para: usX0,usY0 -- character string's start point coordinate
* ForeColor -- appointed color value
* pucChar -- ASCII character string
* ret: none
* modify:
* comment:
*********************************************************************************************/
INT32T f_nPadRow=20;
void lcd_Disp_str16(UINT16T x0, UINT16T y0, UINT16T ForeColor, UINT8T *s)
{
UINT16T i,j,k,x,y,xx=0,yy,ch=0;
UINT8T qm,wm; //quma weima
UINT32T ulOffset;
INT8T ywbuf[16],hzbuf[32]; //,temp[2];
for( i = 0; i < strlen((const char*)s); i++ )
{
if( ((UINT8T)(*(s+i))) < 161 )
{
ch++;
if(xx > 620) //space 20 pixel right
{
ch = 0;
x0 = 20; //space 20 pixel left
y0 += f_nPadRow;
}
qm = *(s+i);
ulOffset = (UINT32T)(qm) * 16; //Here to be changed tomorrow
for( j = 0; j < 16; j ++ )
{
ywbuf[j] = g_auc_Ascii8x16[ulOffset + j];
}
for( y = 0; y < 16; y++ )
{
for( x = 0; x < 8; x++ )
{
k = x % 8;
if( ywbuf[y] & (0x80 >> k) )
{
xx = x0 + x + ch*8;
yy = y + y0;
PutPixel(xx, yy, (UINT16T)ForeColor);
}
}
}
}
else
{
ch++;
if(xx > 588)
{
ch = 0;
x0 = 20;
y0 += f_nPadRow;
}
qm = *(s+i) - 161;
wm = *(s + i + 1) - 161;
ulOffset = (UINT32T)(qm * 94 + wm) * 32;
for( j = 0; j < 32; j ++ )
{
hzbuf[j] = g_auc_HZK16[ulOffset + j];
}
for( y = 0; y < 16; y++ )
{
for( x = 0; x < 16; x++ )
{
k = x % 8;
if( hzbuf[y * 2 + x / 8] & (0x80 >> k) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -