📄 lcd.c
字号:
if(flag==0) {
LcdFGColorMap(1, 0xfc);
printf("Foreground Color Map is enabled\n");
flag=1;
}
else {
LcdFGColorMap(0, 0xfc);
flag=0;
printf("Foreground Color Map is disabled\n");
}
framecnt=0;
}
rINTSUBMSK|=BIT_SUB_LCD_VSYNC;
rINTMSK|=BIT_LCD;
LcdDisableFrameInterrupt();
printf("Press any key to continue\n");
getchar();
LcdFGColorMap(0, 0);
LcdOsdEnDiable(0);
}
void Test_Osd_240320_Blending(void)
{
int alpha;
unsigned int i,j,k;
unsigned int flag;
int topx, topy, botx, boty;
unsigned int key;
printf("OSD Blend Test!!\n");
printf("0: 8bpp Palette, 1: 8bpp Non-palette\n");
printf("2: 16bpp 551, 3: 16bpp 565\n");
printf("4: 18bpp\n");
printf("Select bpp type:");
key=GetIntNum();
switch(key) {
case 0:
PaletteInit(PAL_565_8BPPBG); // Initialize 256 palette
LcdBGInit(MODE_PAR_8BIT_240320);
GlibInit(MODE_PAR_8BIT_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,DEMO256[k++]);
PaletteInit(PAL_565_8BPPFG); // Initialize 256 palette
LcdFGInit(MODE_OSD_8BIT_240320);
GlibInit(MODE_OSD_8BIT_240320, FGBUFFER1);
GlibFilledRectangle(0, 0, FG_XSIZE_240320/2-1, FG_YSIZE_240320/2-1, 0x0);
GlibFilledRectangle(FG_XSIZE_240320/2, 0, FG_XSIZE_240320-1, FG_YSIZE_240320/2-1, 0x5f);
GlibFilledRectangle(0, FG_YSIZE_240320/2, FG_XSIZE_240320/2-1, FG_YSIZE_240320-1, 0xaf);
GlibFilledRectangle(FG_XSIZE_240320/2, FG_YSIZE_240320/2, FG_XSIZE_240320-1, FG_YSIZE_240320-1, 0xff);
break;
case 1:
break;
case 2:
LcdBGInit(MODE_PAR_16BIT5551_240320);
GlibInit(MODE_PAR_16BIT5551_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,sghx600qvga16[k++]);
LcdFGInit(MODE_OSD_16BIT5551_240320);
GlibInit(MODE_OSD_16BIT5551_240320, FGBUFFER1);
k=0;
for(j=0; j<FG_YSIZE_240320; j++)
for(i=0; i<FG_XSIZE_240320; i++)
PutPixel(i,j, sghx600iqqvga16[k++]);
break;
case 3:
LcdBGInit(MODE_PAR_16BIT565_240320);
GlibInit(MODE_PAR_16BIT565_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,sghx600qvga16[k++]);
LcdFGInit(MODE_OSD_16BIT565_240320);
GlibInit(MODE_OSD_16BIT565_240320, FGBUFFER1);
k=0;
for(j=0; j<FG_YSIZE_240320; j++)
for(i=0; i<FG_XSIZE_240320; i++)
PutPixel(i,j, sghx600iqqvga16[k++]);
break;
case 4:
default:
LcdBGInit(MODE_PAR_24BIT_240320);
GlibInit(MODE_PAR_24BIT_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,sghx600qvga18[k++]);
LcdFGInit(MODE_OSD_24BIT_240320);
GlibInit(MODE_OSD_24BIT_240320, FGBUFFER1);
k=0;
for(j=0; j<FG_YSIZE_240320; j++)
for(i=0; i<FG_XSIZE_240320; i++)
PutPixel(i,j, sghx600iqqvga18[k++]);
break;
}
printf("\n");
//avoid unexpected frame sync interrupt.
rSUBSRCPND|=BIT_SUB_LCD_VSYNC;
rSRCPND=BIT_LCD;
rINTPND=rINTPND;
pISR_LCD=(unsigned)Lcd_Int_DualBuffer;
rINTMSK &= ~(BIT_LCD);
rINTSUBMSK &= ~(BIT_SUB_LCD_VSYNC);
LcdOsdSelectFunction(OSD_BLENDING);
LcdOsdSetAlpha(0);
LcdOsdEnDiable(1);
LcdEnableFrameInterrupt(FRAMESEL0_VSYNC, FRAMESEL1_NONE);
framecnt=0;
alpha=0;
flag=0;
topx=topy=0;
botx=FG_XSIZE_240320-1;
boty=FG_YSIZE_240320-1;
while(!Uart_GetKey()) {
while(framecnt!=5);
LcdOsdSetAlpha((unsigned int)alpha);
LcdOsdChangeCoordination((unsigned int)topx, (unsigned int)topy, (unsigned int)botx, (unsigned int)boty);
//LcdOsdEnDiable(toggle);
framecnt=0;
alpha+=5;
if(alpha>=255) alpha=50;
if(flag==0) {
topx+=4;
botx+=4;
}
if(flag==1) {
topx -=4;
botx -=4;
}
if(botx>=BG_XSIZE_240320-1) {
flag=1;
topy +=4;
boty +=4;
}
if(topx<=0) {
flag=0;
topy+=4;
boty+=4;
}
if(botx>=BG_XSIZE_240320-1 && boty >=BG_YSIZE_240320-1) {
topx=topy=0;
botx=FG_XSIZE_240320-1;
boty=FG_YSIZE_240320-1;
flag=0;
}
printf("%d, %d, %d, %d, @0x%x\n", topx,topy, botx, boty, rLCDOSD1&0xff);
}
framecnt=0;
rINTSUBMSK|=BIT_SUB_LCD_VSYNC;
rINTMSK|=BIT_LCD;
LcdDisableFrameInterrupt();
printf("Press any key to continue\n");
getchar();
LcdOsdEnDiable(0);
}
void Test_Osd_16Bit565_240320_Colorkey(void)
{
int alpha;
unsigned int i,j,k;
int topx, topy, botx, boty;
LcdBGInit(MODE_PAR_16BIT565_240320);
GlibInit(MODE_PAR_16BIT565_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,sghx600iqvga16[k++]);
LcdFGInit(MODE_OSD_16BIT565_240320);
GlibInit(MODE_OSD_16BIT565_240320, FGBUFFER1);
GlibFilledRectangle(0,0, FG_XSIZE_240320/2-1, FG_YSIZE_240320/2-1, 0xf800);
GlibFilledRectangle(FG_XSIZE_240320/2,0, FG_XSIZE_240320-1, FG_YSIZE_240320/2-1, 0x7e0);
GlibFilledRectangle(0,FG_YSIZE_240320/2, FG_XSIZE_240320/2-1, FG_YSIZE_240320-1, 0x1f);
GlibFilledRectangle(FG_XSIZE_240320/2, FG_YSIZE_240320/2, FG_XSIZE_240320-1, FG_YSIZE_240320-1, 0xffff);
GlibRectangle(0, 0, FG_XSIZE_240320-1, FG_YSIZE_240320-1, 0x0);
rLCDCON1=(rLCDCON1&~(0x3<<28))|(0x2<<28);
topx=60;
topy=80;
botx=60+FG_XSIZE_240320-1;
boty=80+FG_YSIZE_240320-1;
LcdOsdChangeCoordination(topx,topy,botx, boty);
rLCDVSCRF1=(((FG_VXSIZE_240320-(botx-topx+1))*2)<<13)|((botx-topx+1)*2);
rLCDEADDRF1=LCDBASEL(LCDFRAMEBUFFERFG1+(FG_VXSIZE_240320*2)*(boty-topy+1));
LcdOsdSelectFunction(OSD_COLORKEY);
LcdOsdSetAlpha(0xff);
LcdColorKeyInit(MODE_OSD_16BIT565_240320);
LcdOsdEnDiable(1);
LcdEnvidOnOff(1);;
printf("i:upper, j:left, k:right,m:lower\n");
printf("a:decrement, s:increment\n");
while(1) {
switch(getchar()) {
case 'i':
topy-=4;
boty-=4;
break;
case 'j':
topx-=4;
botx-=4;
break;
case 'k':
topx+=4;
botx+=4;
break;
case 'm':
topy+=4;
boty+=4;
break;
case 'a':
alpha-=5;
break;
case 's':
alpha+=5;
break;
case '\r':
return;
default:
break;
}
if(topy<0) {
topy=0;
boty=FG_YSIZE_240320-1;
}
if(topx<0) {
topx=0;
botx=FG_XSIZE_240320-1;
}
if(botx>BG_XSIZE_240320-1) {
botx=BG_XSIZE_240320-1;
topx=BG_XSIZE_240320-FG_XSIZE_240320;
}
if(boty>BG_YSIZE_240320-1) {
boty=BG_YSIZE_240320-1;
topy=BG_YSIZE_240320-FG_YSIZE_240320;
}
printf("%d, %d, %d, %d\n", topx, topy, botx, boty);
LcdOsdChangeCoordination(topx,topy,botx, boty);
}
printf("Press any key to continue\n");
getchar();
LcdEnvidOnOff(0);
LcdOsdEnDiable(0);
}
void Test_Osd_16Bit565_240320_Compkey(void)
{
unsigned int toggle;
int alpha;
unsigned int i,j,k;
unsigned int flag;
int topx, topy, botx, boty;
unsigned int whichfunction;
LcdBGInit(MODE_PAR_16BIT565_240320);
GlibInit(MODE_PAR_16BIT565_240320, BGBUFFER1);
k=0;
for(j=0; j<BG_YSIZE_240320; j++)
for(i=0; i<BG_XSIZE_240320; i++)
PutPixel(i,j,sghx600iqvga16[k++]);
LcdFGInit(MODE_OSD_16BIT565_240320);
GlibInit(MODE_OSD_16BIT565_240320, FGBUFFER1);
k=0;
for(j=0; j<FG_YSIZE_240320; j+=20) {
for(i=0; i<FG_XSIZE_240320; i+=20) {
if(k%2)
GlibFilledRectangle(i, j, i+19, j+19, 0x0);
else
GlibFilledRectangle(i, j, i+19, j+19, 0xf800+k*4);
k++;
}
k++;
}
GlibRectangle(0, 0, FG_XSIZE_240320-1, FG_YSIZE_240320-1, 0x1f);
rLCDCON1=(rLCDCON1&~(0x3<<28))|(0x2<<28);
topx=60;
topy=80;
botx=60+FG_XSIZE_240320-1;
boty=80+FG_YSIZE_240320-1;
LcdOsdChangeCoordination(topx,topy,botx, boty);
rLCDVSCRF1=(((FG_VXSIZE_240320-(botx-topx+1))*2)<<13)|((botx-topx+1)*2);
rLCDEADDRF1=LCDBASEL(LCDFRAMEBUFFERFG1+(FG_VXSIZE_240320*2)*(boty-topy+1));
LcdOsdSelectFunction(OSD_COLORKEY);
LcdOsdSetAlpha(0xff);
LcdColorKeyInit(MODE_OSD_16BIT565_240320);
LcdSetColorKey(0, 0x3fffff, 0xffffff);
LcdOsdEnDiable(1);
LcdEnvidOnOff(1);;
printf("i:upper, j:left, k:right,m:lower\n");
printf("a:decrement, s:increment\n");
printf("d:osd blending, f:osd colorkey\n");
flag=0;
toggle=0;
whichfunction=OSD_COLORKEY;
alpha=0xff;
while(1) {
switch(getchar()) {
case 'i':
topy-=4;
boty-=4;
break;
case 'j':
topx-=4;
botx-=4;
break;
case 'k':
topx+=4;
botx+=4;
break;
case 'm':
topy+=4;
boty+=4;
break;
case 'a':
alpha-=5;
break;
case 's':
alpha+=5;
break;
case 'd':
whichfunction=OSD_BLENDING;
break;
case 'f':
whichfunction=OSD_COLORKEY;
break;
case '\r':
return;
default:
break;
}
if(topy<0) {
topy=0;
boty=FG_YSIZE_240320-1;
}
if(topx<0) {
topx=0;
botx=FG_XSIZE_240320-1;
}
if(botx>BG_XSIZE_240320-1) {
botx=BG_XSIZE_240320-1;
topx=BG_XSIZE_240320-FG_XSIZE_240320;
}
if(boty>BG_YSIZE_240320-1) {
boty=BG_YSIZE_240320-1;
topy=BG_YSIZE_240320-FG_YSIZE_240320;
}
if(alpha>255) alpha=255;
if(alpha<0) alpha=0;
printf("%d, %d, %d, %d, @%d\n", topx, topy, botx, boty, alpha);
LcdOsdChangeCoordination(topx,topy,botx, boty);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -