📄 drv_lcd.c
字号:
#include "..\include\dlcd.h"
#include "cBType.h"
#include "drv_lcd.h"
#include "guiGhldrv.h"
#include "appres.h"
unsigned char self_refresh;
unsigned short tlp;
//extern unsigned char current_common;
extern unsigned long v_lcdram_addr;
extern unsigned char current_common;
/* Prototype */
//void init_hsdma3(unsigned short *add);
//void init_timer3_8bit();
//extern void save_psr(void);
//extern void restore_psr(void);
void init_dlcd_hardware()
{
int i;
//加入初始化LCD时需要的代码。
_init_lcdc(LCLG_dt2);
//9) delay
for (i=100000; i>0; i--);
//10) set P15 high(power on)
SET_P15_L;
//delay
for (i=100000; i>0; i--);
//set P16 high(display on)
SET_P16_L;
lcd_FillRect(0, 0, 320, 240, 0xffff);
// lcd_SetImage( 0, 0, 319, 239, (unsigned short *)pdeskBmp ,320*2);
}
/*
//-------------------------------------------------------------------------
// seDrawPixel()
//
// This function sets the pixel at the specified coordinates to specified color.
// ColorIndex is interrupted by HAL.GPC can use function seRGBtoIndex to convert a RGB value to a color index
//
// Parameters:
// X: the x-coordinate , in pixel , of the point to be painted
// Y: the y-coordinate , in pixel , of the point to be painted
// c : color of the Pixel
//
// Returns:
//
//-------------------------------------------------------------------------
void seDrawPixel(T_GAL_pGC pGC, int x, int y, int c)
{
//加入在LCD上显示一个点的代码。
return;
}
//-------------------------------------------------------------------------
// seReadPixel()
//
// This function retrives the color value of the pixel at the specifie
//
// Parameters:
// X: the x-coordinate , in pixel , of the point to be examined
// Y: the y-coordinate , in pixel , of the point to be examined
//
// Returns:
// int
//-------------------------------------------------------------------------
T_GHL_Pixel seReadPixel(T_GAL_pGC pGC, int x, int y)
{
T_GHL_Pixel thispixel ; //用来记录该点色彩信息的变量
thispixel= 0;
return thispixel;
}
//-------------------------------------------------------------------------
// seDrawVLine()
//
// draws a vertic line (x1=x2)
//
// Parameters:
// x1,y1:specified the coordinate of the lines start point in pixel
// x2,y2:specified the coordinate of the lines end point in pixel
// ColoeIndex : color of the line
//
//
// Returns:
//
//-------------------------------------------------------------------------
void seDrawVLine( S16 x1, S16 y1, S16 x2, S16 y2,U16 ColorIndex ){
S16 sCnt;
if (y1 > y2) {
sCnt = y1;
y1 = y2;
y2 = sCnt;
}
for (sCnt=y1;sCnt<=y2;sCnt++)
seDrawPixel(x1,sCnt,ColorIndex);
}
//-------------------------------------------------------------------------
// seDrawHLine()
//
// draws a horizontal line (y1=y2)
//
// Parameters:
// x1,y1:specified the coordinate of the lines start point in pixel
// x2,y2:specified the coordinate of the lines end point in pixel
// ColoeIndex : color of the line
//
//
// Returns:
//
//-------------------------------------------------------------------------
void seDrawHLine(S16 x1, S16 y1, S16 x2, S16 y2,U16 ColorIndex){
S16 sCnt ;
if (x1 > x2) {
sCnt = x1;
x1 = x2;
x2 = sCnt;
}
for (sCnt=x1;sCnt<=x2;sCnt++)
seDrawPixel(sCnt,y1,ColorIndex);
}
//-------------------------------------------------------------------------
// fnIHL_DlcdShowCoordinate
//
// draws a horizontal line (y1=y22)
//
// Parameters:
// x,y : specified the coordinate of the Coordinate's Origin
// c : color of the coordinate
//
//
// Returns:
//
//-------------------------------------------------------------------------
void fnIHL_DlcdShowCoordinate(int x,int y,short c)
{
short Temp;
seDrawHLine(x-5, y, x+5, y, c);
seDrawVLine(x, y-5, x, y+5, c);
}
/*
//-------------------------------------------------------------------------
// seDrawLine()
//
// draws a line
//
// Parameters:
// x1,y1:specified the coordinate of the lines start point in pixel
// x2,y2:specified the coordinate of the lines end point in pixel
// ColoeIndex : color of the line
// mask: line style mask
//
// Returns:
//
//-------------------------------------------------------------------------
void seDrawLine( S16 x1, S16 y1, S16 x2, S16 y2, U16 ColorIndex, U16 mask )
{
S16 dx,dy,incrE,incrNE,d,x,y;
S16 x0, y0;
S16 index;
if (x2==x1)
{//write stright line
if (mask == GHL_SOLID_LINE)
{
//vDisableInterrupt();
seDrawVLine(x1,y1,x2,y2,ColorIndex);
//vEnableInterrupt();
}
else
{
if (y1<y2)
{
for (y=y1;y<=y2;y++)
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x1,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
else
{ for (y=y2;y<=y1;y++)
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x1,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
}
}
else if (y2==y1)
{//write horizental line
if (mask == GHL_SOLID_LINE)
{
//vDisableInterrupt();
seDrawHLine(x1,y1,x2,y2,ColorIndex);
//vEnableInterrupt();
}
else
{
if (x1<x2)
{
for (x=x1;x<=x2;x++)
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y1,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
else
{
for (x=x2;x<=x1;x++)
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y1,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
}
}
}
else
{// start point definition
if (x1<x2)
{ x0=x1;
y0=y1;
x1=x2;
y1=y2;
}
else
{ x0=x2;
y0=y2;
}
dx=x1-x0;
if (y0<y1)
{
dy=y1-y0;
if (dy<dx)
{ d=-(2*dy-dx); //初始化判别式d
incrE=-2*dy; //取像素E时判别式的增量
incrNE=-2*(dy-dx); //取像素NE时判别式的增量
x=x0,y=y0;
while (x<=x1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) //取像素E
{
d+=incrE;
x++;
}
else //取像素NE
{
d+=incrNE;
x++;
y++;
}
}
}
else
{ d=-(2*dx-dy); //初始化判别式d
incrE=-2*dx; //取像素E时判别式的增量/
incrNE=-2*(dx-dy); //取像素NE时判别式的增量/
x=x0,y=y0;
while (y<=y1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
y++;
}
else /*取像素NE//
{ d+=incrNE;
y++;
x++;
}
}
}
}
else
{ dy=y0-y1;
if (dy<dx)
{ d=-(2*dy-dx); /*初始化判别式d//
incrE=-2*dy; /*取像素E时判别式的增量//
incrNE=-2*(dy-dx); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (x<=x1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
x++;
}
else /*取像素NE//
{ d+=incrNE;
x++;
y--;
}
}
}
else
{ d=-(2*dx-dy); /*初始化判别式d//
incrE=-2*dx; /*取像素E时判别式的增量//
incrNE=-2*(dx-dy); /*取像素NE时判别式的增量//
x=x0,y=y0;
while (y>=y1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seDrawPixel(x,y,ColorIndex);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E//
{ d+=incrE;
y--;
}
else /*取像素NE//
{ d+=incrNE;
y--;
x++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -