📄 lcd.c
字号:
int i,j,k=0;
Lcd_port_init();
Lcd_Palette8Bit_Init();
Lcd_Init(MODE_TFT_8BIT_240320);
Glib_Init(MODE_TFT_8BIT_240320);
Lcd_Lpc3600Enable(); // Enable LPC3600
Lcd_PowerEnable(0, 1);
//Lcd_PowerEnable(0, 1); // Enable LCD_PWREN
for(j=0;j<320;j++)
for(i=0;i<240;i++)
PutPixel(i,j,((int)DEMO256[k++]));
Lcd_EnvidOnOff(1); // Enable ENVID
uart_printf("Press any key to quit!\n");
uart_getch();
Glib_ClearScr(0, MODE_TFT_8BIT_240320);
delay(5000);
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: Test_Lcd_Tft_8Bit_240320_IntFr()
* func: test 8bpp 240*320 TFT LCD Frame interrupt
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Test_Lcd_Tft_8Bit_240320_IntFr(void)
{
int i,j,k=0;
Lcd_port_init();
Lcd_Palette8Bit_Init();
Lcd_Init(MODE_TFT_8BIT_240320);
Glib_Init(MODE_TFT_8BIT_240320);
Lcd_Lpc3600Enable(); // Enable LPC3600
Lcd_PowerEnable(0, 1);
rLCDCON5|=(1<<11); // 5:6:5 Palette Setting
for(j=0;j<320;j++)
for(i=0;i<240;i++)
PutPixel(i,j,((int)DEMO256[k++]));
//--------LCD frame interrupt test---------------------------------------------------START
//The content of GPG4 is changed to OUTPUT('01').
//We will check the frame interrupt with using Logic Analyzer.
rGPGUP=rGPGUP&(~(1<<4))|(1<<4); // Pull-up disable
rGPGDAT=rGPGDAT&(~(1<<4))|(1<<4); // GPG4=High
rGPGCON=rGPGCON&(~(3<<8))|(1<<8); // GPG4=Output
pISR_LCD=(unsigned)Lcd_Int_Frame;
rINTMSK=~(BIT_LCD);
rLCDINTMSK=(1<<2)|(0<<1)|(1); // 8Words Trigger Level,Unmask Frame int,mask Fifo int
//--------LCD frame interrupt test-----------------------------------------------------END
Lcd_EnvidOnOff(1); // Enable ENVID
uart_printf("Press any key to quit!\n");
uart_getch();
rLCDINTMSK|=3; // Mask LCD SUB Interrupt
rINTMSK|=(BIT_LCD); // Mask LCD INT
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: Test_Lcd_Tft_8Bit_240320_IntFi()
* func: test 8bpp 240*320 TFT LCD FiFo interrupt
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Test_Lcd_Tft_8Bit_240320_IntFi(void)
{
int i,j,k=0;
Lcd_port_init();
Lcd_Palette8Bit_Init();
Lcd_Init(MODE_TFT_8BIT_240320);
Glib_Init(MODE_TFT_8BIT_240320);
Lcd_Lpc3600Enable(); // Enable LPC3600
Lcd_PowerEnable(0, 1);
rLCDCON5|=(1<<11); // 5:6:5 Palette Setting
for(j=0;j<320;j++)
for(i=0;i<240;i++)
PutPixel(i,j,((int)DEMO256[k++]));
Lcd_EnvidOnOff(1); // Enable ENVID
//--------LCD FIFO interrupt test---------------------------------------------------START
pISR_LCD=(unsigned)Lcd_Int_Fifo;
rINTMSK=~(BIT_LCD);
rLCDINTMSK=(0<<2)|(1<<1)|(0); // 4Words Trigger Level,Mask Frame int,Unmask Fifo int
//--------LCD FIFO interrupt test-----------------------------------------------------END
uart_printf("Press any key to quit!\n");
uart_getch();
rLCDINTMSK|=3; // Mask LCD SUB Interrupt
rINTMSK|=(BIT_LCD); // Mask LCD INT
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: Lcd_Int_Fifo_640480()
* func: 640480 LCD Fifo interrupt
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_Int_Fifo_640480(void)
{
int i;
rLCDINTMSK|=3; // Mask LCD SUB Interrupt
// GPG4 is ....
rGPGDAT&=(~(1<<4)); // GPG4=Low
for(i=0;i<1;i++); // GPG4=Low
rGPGDAT|=(1<<4); //GPG4=High
rLCDSRCPND=1; // Clear LCD SUB Interrupt source pending
rLCDINTPND=1; // Clear LCD SUB Interrupt pending
rLCDINTMSK&=(~(1)); // Unmask LCD FRAME Interrupt
ClearPending(BIT_LCD);
}
/*********************************************************************************************
* name: Test_Lcd_Tft_1Bit_640480()
* func: test 1bpp TFT LCD
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Test_Lcd_Tft_1Bit_640480(void)
{
int i,j;
Lcd_Palette1Bit_Init();
Lcd_port_init();
Lcd_Init(MODE_TFT_1BIT_640480);
Glib_Init(MODE_TFT_1BIT_640480);
Lcd_PowerEnable(0, 1);
Lcd_EnvidOnOff(1);
uart_printf("[TFT Mono(1bit/1pixel) LCD TEST]\n");
Glib_ClearScr(0,MODE_TFT_1BIT_640480);
rTPAL = (1<<24)|((0xff)<<8); // Enable Temporary Palette : Green
uart_printf("TFT Mono mode test 1. Press any key!\n");
uart_getch();
rTPAL = 0;
Glib_FilledRectangle(0,0,639,239,1);
Glib_FilledRectangle(0,239,639,479,0);
uart_printf("TFT Mono mode test 2. Press any key!\n");
uart_getch();
Glib_FilledRectangle(0,0,319,479,1);
Glib_FilledRectangle(320,0,639,479,0);
uart_printf("TFT Mono mode test 3. Press any key!\n");
uart_getch();
for(j=0;j<LCD_YSIZE_TFT_640480;j+=20)
for(i=320;i<640;i+=20)
Glib_FilledRectangle(i,j,i+19,j+19,((j+i)/20)%2);
uart_printf("TFT Mono mode test 4. Press any key!\n");
uart_getch();
Glib_ClearScr(0, MODE_TFT_1BIT_640480);
Glib_FilledRectangle(0+320,0+240,1279-320,959-240,1);
// #0
// 00
Glib_Rectangle(0,0,639,479,1);
Glib_Line(0,0,639,479,1);
Glib_Line(0,479,639,0,1);
// 0#
// 00
Glib_Rectangle(0+640,0,639+640,479,1);
Glib_Line(0+640,0,639+640,479,1);
Glib_Line(0+640,479,639+640,0,1);
// 00
// #0
Glib_Rectangle(0,0+480,639,479+480,1);
Glib_Line(0,0+480,639,479+480,1);
Glib_Line(0,479+480,639,0+480,1);
// 00
// 0#
Glib_Rectangle(0+640,0+480,639+640,479+480,1);
Glib_Line(0+640,0+480,639+640,479+480,1);
Glib_Line(0+640,479+480,639+640,0+480,1);
Glib_Rectangle(50+640,50+480,639+640-50,479+480-50,1);
uart_printf("Virtual Screen Test(TFT 256 color). Press any key[ijkm\\r]!\n");
MoveViewPort(MODE_TFT_1BIT_640480);
Lcd_MoveViewPort(0,0,MODE_TFT_1BIT_640480);
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: Test_Lcd_Tft_1Bit_640480()
* func: test 8bpp TFT LCD
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Test_Lcd_Tft_8Bit_640480(void)
{
int i,j,k;
Lcd_Palette8Bit_Init();
Lcd_port_init();
Lcd_Init(MODE_TFT_8BIT_640480);
Glib_Init(MODE_TFT_8BIT_640480);
Lcd_PowerEnable(0, 1);
Lcd_EnvidOnOff(1);
uart_printf("[TFT 256 COLOR(8bit/1pixel) LCD TEST]\n");
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
rTPAL = (1<<24)|((0xff)<<0); // Enable Temporary Palette : Blue
uart_printf("TFT 256 color mode test 1. Press any key!\n");
uart_getch();
k=0;
for(i=0;i<640;i+=40)
for(j=0;j<480;j+=30)
{
Glib_FilledRectangle(i,j,i+39,j+29,(k%256));
k++;
}
rTPAL = 0;
uart_printf("TFT 256 color mode test 2. Press any key!\n");
uart_getch();
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
k=0;
for(i=0;i<640;i+=20)
for(j=0;j<480;j+=20)
{
Glib_FilledRectangle(i,j,i+19,j+19,(k%256));
k+=30;
}
uart_printf("TFT 256 color mode test 3. Press any key!\n");
uart_getch();
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
k=0;
for(i=160;i<480;i+=20)
for(j=120;j<360;j+=15)
{
Glib_FilledRectangle(i,j,i+19,j+14,k);
k++;
}
// #0
// 00
Glib_Rectangle(0,0,319,239,255);
Glib_Line(0,0,319,239,255);
Glib_Line(0,239,319,0,255);
// 0#
// 00
Glib_Rectangle(0+320,0,319+320,239,255);
Glib_Line(0+320,0,319+320,239,255);
Glib_Line(0+320,239,319+320,0,255);
// 00
// #0
Glib_Rectangle(0,0+240,319,239+240,255);
Glib_Line(0,0+240,319,239+240,255);
Glib_Line(0,239+240,319,0+240,255);
// 00
// 0#
Glib_Rectangle(0+320,0+240,319+320,239+240,255);
Glib_Line(0+320,0+240,319+320,239+240,255);
Glib_Line(0+320,239+240,319+320,0+240,255);
Glib_Rectangle(50+320,50+240,269+320,189+240,255);
uart_printf("TFT 256 color mode test 4. Press any key!\n");
uart_getch();
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
k=0;
for(i=320;i<960;i+=40)
for(j=240;j<720;j+=30)
{
Glib_FilledRectangle(i,j,i+39,j+29,(k%256));
k++;
}
// #0
// 00
Glib_Rectangle(0,0,639,479,255);
Glib_Line(0,0,639,479,255);
Glib_Line(0,479,639,0,255);
// 0#
// 00
Glib_Rectangle(0+640,0,639+640,479,255);
Glib_Line(0+640,0,639+640,479,255);
Glib_Line(0+640,479,639+640,0,255);
// 00
// #0
Glib_Rectangle(0,0+480,639,479+480,255);
Glib_Line(0,0+480,639,479+480,255);
Glib_Line(0,479+480,639,0+480,255);
// 00
// 0#
Glib_Rectangle(0+640,0+480,639+640,479+480,255);
Glib_Line(0+640,0+480,639+640,479+480,255);
Glib_Line(0+640,479+480,639+640,0+480,255);
Glib_Rectangle(50+640,50+480,639+640-50,479+480-50,255);
uart_printf("Virtual Screen Test(TFT 256 color). Press any key[ijkm\\r]!\n");
MoveViewPort(MODE_TFT_8BIT_640480);
Lcd_MoveViewPort(0,0,MODE_TFT_8BIT_640480);
Lcd_EnvidOnOff(0);
Lcd_Port_Return();
}
/*********************************************************************************************
* name: Test_Lcd_Tft_8Bit_640480_Palette()
* func: test 8bpp 640480 TFT Palette
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Test_Lcd_Tft_8Bit_640480_Palette(void)
{
int i,j,k;
unsigned char cdata, p_red, p_green, p_blue;
UINT32T *palette;
Lcd_Palette8Bit_Init();
Lcd_port_init();
Lcd_Init(MODE_TFT_8BIT_640480);
Glib_Init(MODE_TFT_8BIT_640480);
uart_printf("[TFT 256 COLOR(8bit/1pixel) Palette TEST]\n");
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
rTPAL = (1<<24)|((0xff)<<0); // Enable Temporary Palette : Blue
Lcd_PowerEnable(0, 1);
Lcd_EnvidOnOff(1);
uart_printf("Temporary palette test. Press any key!\n");
uart_getch();
k=0;
for(i=0;i<640;i+=40)
for(j=0;j<480;j+=30)
{
Glib_FilledRectangle(i,j,i+39,j+29,(k%256));
k++;
}
rTPAL = 0;
uart_printf("Press any key to test writing palette during non-active.\n");
palette=(UINT32T *)PALETTE;
for(cdata=0;cdata<255;cdata++)
{
p_red=(cdata | 0xe0);
p_green=(cdata | 0x1c);
p_blue=(cdata | 0x03);
while((rLCDCON5>>19)==2);
*palette++=((UINT32T)((p_red<<8)|(p_green<<6)|(p_blue<<3)));
uart_printf("VSTATUS=%x\n",(rLCDCON5>>19));
uart_printf("cdata=%d\n",(int)cdata);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -