📄 44blcd.c
字号:
#include "h\44blcd.h"
extern unsigned char *Buf;
void LcdInit(void)
{
Lcd_Init();
clrscreen();
}
void Lcd_Init(void)
{
// if((U32)frameBuffer256==0)
// {
(U32)frameBuffer256=0xc400000; //指示视频缓冲区在系统存储器的段地址
// }
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
// 256-color, LCDBANK, LCDBASEU
rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
//The following value has to be changed for better display.
rREDLUT =0xfdb96420;
rGREENLUT=0xfdb96420;
rBLUELUT =0xfb40;
rDITHMODE=0x0;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
}
void Lcd_C256_Bmp( U16 x0, U16 y0, U16 x1, U16 y1 , unsigned char bmp[] )
{
int x, y ;
int m = 0;
for( y = y0; y < y1; y++ ) //画16色图片
{
for( x = x0; x < x1; x++ )
{
PutPixelColor( x, y, High_Low( bmp[m] ) );
m++;
}
}
}
void PutPixelColor(U32 x,U32 y,U8 c)
{
if(x<SCR_XSIZE && y<SCR_YSIZE)
frameBuffer256[(y)][(x)/4]=( frameBuffer256[(y)][x/4] & ~(0xff000000>>((x)%4)*8) )
| ( (c)<<((4-1-((x)%4))*8) );
}
void clrscreen(void)
{
int i;
unsigned int *pbuffer;
pbuffer =(U32*) frameBuffer256;
for (i=0;i<38400;i++)
{
pbuffer[i] =0;//(0x0FFFFFFFF);
}
}
U8 High_Low( U8 x )
{
x = ( (x>>1)&0x1c ) | (x>>6) | (x<<5);
return x ;
}
void LCD_DrawHLine(U32 x1,U32 x2,U32 y,U8 c,U32 Width)
{
U32 len;
if(x2<x1)//swap x1,x2
{
x1=x1+x2;
x2=x1-x2;
x1=x1-x2;
}
while((Width--)>0)
{
len=x2-x1+1;
while((len--)>0)
{
PutPixelColor(x1+len,y,High_Low(c));
}
y++;
}
}
void LCD_DrawVLine(U32 y1,U32 y2,U32 x,U8 c,U32 Width)
{
U32 len;
if (y2<y1)
{
y1=y1+y2;
y2=y1-y2;
y1=y1-y2;
}
while((Width--)>0)
{
len=y2-y1+1;
while((len--)>0)
{
PutPixelColor(x,y1+len,c);
}
x++;
}
}
void LCD_DrawRectange(U32 left,U32 top,U32 right,U32 bottom,U8 c)
{
LCD_DrawHLine(left,right,top,c,1);
LCD_DrawHLine(left,right,bottom,c,1);
LCD_DrawVLine(top,bottom,left,c,1);
LCD_DrawVLine(top,bottom,right,c,1);
}
void LCD_DrawCircle(U32 x0,U32 y0,U32 r,U8 c)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -