📄 lcd.c
字号:
//====================================================================
// File Name : lcd.c
// Function : S3C2412 LCD test code
// Date : Apr. 21, 2006
// Version : S3C2412
//====================================================================
#include <stdio.h>
#include <stdlib.h>
#include "def.h"
#include "2413addr.h"
#include "lcdlib.h"
#include "glib.h"
#include "lcd.h"
#include "sun240320_16bpp.h"
#include "sun320240_16bpp.h"
#include "sun320240_24bpp.h"
#include "flower8bpp.h"
#include "flower16bpp.h"
#include "demo256.h"
void * func_lcd_240320[][2]=
{
(void *)Test_Lcd_Tft_8Bit_240320, "TFT240320 8Bit ",
(void *)Test_Lcd_Tft_8Bit_240320_On, "TFT240320 8Bit free run ",
(void *)Test_Lcd_Tft_16Bit_240320, "TFT240320 16Bit ",
(void *)Test_Lcd_Tft_16Bit_240320_On, "TFT240320 16Bit free run ",
(void *)Test_Lcd_Tft_24Bit_240320, "TFT240320 24Bit ",
(void *)Test_Lcd_Tft_16Bit_240320_IntFrame, "TFT240320 16Bit Frame ",
(void *)Test_Lcd_Tft_16Bit_240320_IntFifo, "TFT240320 16Bit Fifo ",
(void *)Test_Lcd_Tft_16Bit_240320_Swap, "TFT240320 16Bit Swap ",
0,0
};
void * func_lcd_320240[][2]=
{
(void *)Test_Lcd_Tft_16Bit_320240, "TFT320240 16Bit free run ",
(void *)Test_Lcd_Tft_24Bit_320240, "TFT320240 24Bit free run ",
0,0
};
void * func_lcd_stn[][2]=
{
(void *)Test_Lcd_Stn_1Bit, "STN320240 Mono ",
(void *)Test_Lcd_Stn_2Bit, "STN320240 4-Gray ",
(void *)Test_Lcd_Stn_4Bit, "STN320240 16-Gray ",
0,0
};
void * func_lcd_cstn[][2]=
{
(void *)Test_Lcd_Cstn_1Bit, "CSTN320240 1Bit ",
(void *)Test_Lcd_Cstn_2Bit, "CSTN320240 2Bit ",
(void *)Test_Lcd_Cstn_4Bit, "CSTN320240 4Bit ",
(void *)Test_Lcd_Cstn_8Bit_P, "CSTN320240 8Bit P ",
(void *)Test_Lcd_Cstn_8Bit, "CSTN320240 8Bit ",
(void *)Test_Lcd_Cstn_12Bit, "CSTN320240 12Bit ",
(void *)Test_Lcd_Cstn_16Bit, "CSTN320240 16Bit ",
0,0
};
void * func_lcd_test[][2]=
{
// "0123456789012345" max 15磊 肺茄沥窍咯 comment窍技夸.
//LCD
(void *)Test_Lcd_240320, "Portrait 240x320 TFT LCD ",
(void *)Test_Lcd_320240, "Landscape 320x240 TFT LCD ",
(void *)Test_Lcd_stn, "Landscape 320x240 STN LCD ",
(void *)Test_Lcd_cstn, "Landscape 320x240 CSTN LCD ",
0,0
};
void Test_Lcd_240320(void)
{
int i;
printf("\n====== Portrait 240x320 LCD Test ======\n");
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_lcd_240320[i][1]);
i++;
if((int)(func_lcd_240320[i][0])==0)
{
printf("\n");
break;
}
if((i%4)==0)
printf("\n");
}
printf("\nPress only Enter key to exit : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_lcd_240320)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_lcd_240320[i][0]) )();
}
printf("\n====== Portrait 240x320 LCD Test end ======\n");
}
void Test_Lcd_320240(void)
{
int i;
printf("\n====== Landscape 320x240 LCD Test ======\n");
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_lcd_320240[i][1]);
i++;
if((int)(func_lcd_320240[i][0])==0)
{
printf("\n");
break;
}
if((i%4)==0)
printf("\n");
}
printf("\nPress only Enter key to exit : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_lcd_320240)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_lcd_320240[i][0]) )();
}
printf("\n====== Landscape 320x240 LCD Test end ======\n");
}
void Test_Lcd_stn(void)
{
int i;
printf("\n====== STN 320x240 LCD Test ======\n");
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_lcd_stn[i][1]);
i++;
if((int)(func_lcd_stn[i][0])==0)
{
printf("\n");
break;
}
if((i%2)==0)
printf("\n");
}
printf("\nPress only Enter key to exit : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_lcd_stn)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_lcd_stn[i][0]) )();
}
printf("\n====== STN 320x240 LCD Test end ======\n");
}
void Test_Lcd_cstn(void)
{
int i;
printf("\n====== CSTN 320x240 LCD Test ======\n");
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_lcd_cstn[i][1]);
i++;
if((int)(func_lcd_cstn[i][0])==0)
{
printf("\n");
break;
}
if((i%4)==0)
printf("\n");
}
printf("\nPress only Enter key to exit : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_lcd_cstn)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_lcd_cstn[i][0]) )();
}
printf("\n====== CSTN 320x240 LCD Test end ======\n");
}
void Ch14_Lcd(void)
{
int i;
printf("\n====== LCD Test program start ======\n");
while(1)
{
i=0;
printf("\n\n");
while(1)
{ //display menu
printf("%2d:%s",i,func_lcd_test[i][1]);
i++;
if((int)(func_lcd_test[i][0])==0)
{
printf("\n");
break;
}
if((i%2)==0)
printf("\n");
}
printf("\nPress only Enter key to exit : ");
i = GetIntNum();
if(i==-1) break; // return.
if(i>=0 && (i<((sizeof(func_lcd_test)-1)/8)) ) // select and execute...
( (void (*)(void)) (func_lcd_test[i][0]) )();
}
printf("\n====== LCD Test program end ======\n");
}
void Test_Lcd_Tft_8Bit_240320(void)
{
int i,j,k;
InitLDI_LTS222();
Lcd_Port_Init();
Lcd_PowerEnable(0, 1);
Lcd_Palette8Bit_Init();
Lcd_Init(MODE_TFT_8BIT_240320);
Glib_Init(MODE_TFT_8BIT_240320);
printf("[TFT 256 COLOR(8bit/1pixel) LCD TEST]\n");
rTPAL = (1<<24)|((0xff)<<16); // Enable Temporary Palette : Red
Lcd_EnvidOnOff(1); // Enable ENVID Bit
printf("TFT 256 color mode test 1. Press any key!\n");
getchar();
Glib_ClearScr(0, MODE_TFT_8BIT_240320); // Fill the LCD panel with Black Color
k=0;
for(i=0;i<320;i+=20)
for(j=0;j<240;j+=15)
{
Glib_FilledRectangle(j,i,j+14,i+19,(k%256));
k++;
}
rTPAL = 0; // Disable Temporary Palette
printf("TFT 256 color mode test 2. Press any key!\n");
getchar();
Glib_ClearScr(0, MODE_TFT_8BIT_240320); // Fill the LCD panel with Black Color
k=0;
for(i=0;i<320;i+=10)
for(j=0;j<240;j+=10)
{
Glib_FilledRectangle(j,i,j+9,i+9,(k%256));
k+=30;
}
printf("TFT 256 color mode test 3. Press any key!\n");
getchar();
Glib_ClearScr(0, MODE_TFT_8BIT_240320);
k=0;
for(i=80;i<240;i+=10)
{
for(j=60;j<180;j+=10)
{
Glib_FilledRectangle(j,i,j+9,i+9,k);
k++;
}
}
Glib_Rectangle(0,0,239,319,255);
Glib_Line(0,0,239,319,255);
Glib_Line(0,319,239,0,255);
Glib_Rectangle(0+240,0,239+240,319,255);
Glib_Line(0+240,0,239+240,319,255);
Glib_Line(0+240,319,239+240,0,255);
Glib_Rectangle(0,0+320,239,319+320,255);
Glib_Line(0,0+320,239,319+320,255);
Glib_Line(0,319+320,239,0+320,255);
Glib_Rectangle(0+240,0+320,239+240,319+320,255);
Glib_Line(0+240,0+320,239+240,319+320,255);
Glib_Line(0+240,319+320,239+240,0+320,255);
Glib_Rectangle(10+240,10+320,480-11,640-11,255);
printf("Virtual Screen Test(TFT 256 color). i: Upper, m: Lower, j: Left, l: right!\n");
printf("Press Enter to exit!\n");
MoveViewPort(MODE_TFT_8BIT_240320);
Lcd_MoveViewPort(0,0,MODE_TFT_8BIT_240320);
Lcd_EnvidOnOff(0);
Lcd_PowerEnable(0, 0);
Lcd_Port_Return();
}
void Test_Lcd_Tft_8Bit_240320_On(void)
{
int i,j,k;
InitLDI_LTS222();
Lcd_Port_Init();
Lcd_PowerEnable(0, 1);
Lcd_Palette8Bit_Init();
Lcd_Init(MODE_TFT_8BIT_240320);
Glib_Init(MODE_TFT_8BIT_240320);
printf("TFT 8bit Free Run Test!\n");
k=0;
for(j=0; j<320; j++)
for(i=0; i<240; i++)
PutPixel(i,j,DEMO256[k++]);
Lcd_EnvidOnOff(1);
}
void Test_Lcd_Tft_16Bit_240320_On(void)
{
int i,j,k;
InitLDI_LTS222();
Lcd_Port_Init();
Lcd_PowerEnable(0, 1);
Lcd_Init(MODE_TFT_16BIT_240320);
Glib_Init(MODE_TFT_16BIT_240320);
printf("TFT 16bit Free Run Test!\n");
k=0;
for(j=0; j<320; j++)
for(i=0; i<240; i++)
PutPixel(i,j,sun240320_16bpp[k++]);
Lcd_EnvidOnOff(1);
}
void Test_Lcd_Tft_24Bit_240320(void)
{
int i,j,k;
InitLDI_LTS222();
Lcd_Port_Init();
Lcd_PowerEnable(0, 1);
Lcd_Init(MODE_TFT_24BIT_240320);
Glib_Init(MODE_TFT_24BIT_240320);
Glib_ClearScr(0, MODE_TFT_24BIT_240320);
Lcd_EnvidOnOff(1);
printf("[TFT 16M COLOR(24bit/1pixel) LCD TEST]\n");
Glib_ClearScr(0, MODE_TFT_24BIT_240320);
Glib_FilledRectangle(0,0,119,159,0xff0000);
Glib_FilledRectangle(120,0,239,159,0xff00);
Glib_FilledRectangle(0,160,119,319,0xff);
Glib_FilledRectangle(120,160,239,319,0xffffff);
printf("TFT 16M color mode test 1. Press any key!\n");
getchar();
Glib_ClearScr(0, MODE_TFT_24BIT_240320);
Glib_Rectangle(0,0,239,319,0xff00);
Glib_FilledRectangle(0,0,20,20,0xffffff);
Glib_Rectangle(220,300,239,319,0xffffff);
Glib_Line(0,0,239,319,0xff0000);
Glib_Line(239,0,0,319,0xff);
printf("TFT 16M color mode test 2. Press any key!\n");
getchar();
Glib_ClearScr(0, MODE_TFT_24BIT_240320);
k=0;
for(i=80;i<240;i+=10)
{
for(j=60;j<180;j+=10)
{
Glib_FilledRectangle(j,i,j+9,i+9,k);
k++;
}
}
Glib_Rectangle(0,0,239,319,0xffffff);
Glib_Line(0,0,239,319,0xffffff);
Glib_Line(0,319,239,0,0xffffff);
Glib_Rectangle(0+240,0,239+240,319,0xff);
Glib_Line(0+240,0,239+240,319,0xff);
Glib_Line(0+240,319,239+240,0,0xff);
Glib_Rectangle(0,0+320,239,319+320,0xff00);
Glib_Line(0,0+320,239,319+320,0xff);
Glib_Line(0,319+320,239,0+320,0xff);
Glib_Rectangle(0+240,0+320,239+240,319+320,0xff0000);
Glib_Line(0+240,0+320,239+240,319+320,0xff);
Glib_Line(0+240,319+320,239+240,0+320,0xff);
Glib_Rectangle(40+240,40+320,480-41,640-41,0xff);
printf("Virtual Screen Test(TFT 16M color). i: Upper, m: Lower, j: Left, l: right!\n");
printf("Press Enter to exit!\n");
MoveViewPort(MODE_TFT_24BIT_240320);
Lcd_MoveViewPort(0,0,MODE_TFT_24BIT_240320);
Glib_ClearScr(0, MODE_TFT_24BIT_240320);
Lcd_EnvidOnOff(0);
Lcd_PowerEnable(0, 0);
Lcd_Port_Return();
}
void Test_Lcd_Tft_16Bit_240320(void)
{
int i,j,k;
InitLDI_LTS222();
Lcd_Port_Init();
Lcd_PowerEnable(0, 1);
Lcd_Init(MODE_TFT_16BIT_240320);
Glib_Init(MODE_TFT_16BIT_240320);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -