📄 tft240320-40rj-a.c
字号:
/********************************************************
Initialization for 65K color TFT and CSTN LCD of Truly
Main LCD Driver IC : SSD1289Z
TFT PANEL:
PRO:
DATE:
*******************************************************/
/*-------file needed to be included-----------*/
#include <reg51.h>
/*-----------User define------------*/
#define Uchar unsigned char
//unsigned char MainLCDIsPowerOn = 0;
/*--------------I/O interface defined------------*/
sbit main_cs=P3^4;
sbit rst=P3^3;
sbit rs=P3^2;
sbit wrb=P3^0;
sbit e_rd=P3^1;
//
sbit KEY=P1^7;
sbit upctra=P1^5;
sbit downctra=P1^6;
sbit mainbl=P1^3;
/*************************function defined declaring**************************/
void Delayus(int value);
void Delayms(int value);
void WaitKey(void); /*wait to press key for the programm continuing */
void LCD_HardwareReset(void); /*hardware reset*/
void MainLCD_Init(void); /*Initialize Main LCD driver IC*/
void MainLCD_WCom(char cmd2,char cmd1); /*write instruction to Main LCD's driver IC */
void MainLCD_WData(char data2,char data1); /*write data to GGRAM of Main LCD's driver IC*/
void MainLCD_DisplaySingleColor(char data1,char data2); /*write single color to defined area*/
void MainLCD_DispalyRGBW(void);
void DispHGrey(void);
void TestCross(void);
void MainLCD_GradualColor(char gradual_color[]); /*write gradual color*/
void MainLCD_DisplayPicture(void); /*write image data to GGRAM*/
void MainLCD_DisplayOff(void);
void backlightcontrol(int value); /*black control*/
/*-----------array defined declaring----------*/
char code Pic1[]; //image data
/****************************************************************************************/
void main(void)
{
LCD_HardwareReset();
MainLCD_Init();
backlightcontrol(31);
while(1)
{
MainLCD_DisplaySingleColor(0x7b,0xef);
WaitKey();
MainLCD_DisplaySingleColor(0xff,0xff);
WaitKey();
MainLCD_DisplaySingleColor(0x00,0x00);
WaitKey();
MainLCD_DisplaySingleColor(0xf8,0x00);
WaitKey();
MainLCD_DisplaySingleColor(0x07,0xe0);
WaitKey();
MainLCD_DisplaySingleColor(0x00,0x1f);
WaitKey();
MainLCD_DispalyRGBW();
WaitKey();
// DispHGrey();
//WaitKey();
// TestCross();
// WaitKey();
MainLCD_DisplayPicture();
MainLCD_DisplayPicture();
MainLCD_DisplayPicture();
MainLCD_DisplayPicture();
WaitKey();
} //end of while
}
/******************************************************************************************/
void LCD_HardwareReset(void)
{
rst=0;
Delayms(100);
rst=1;
Delayms(100);
}
void Delayus(int value)
{
while(value)
{
value--; /*delay 1us*/
}
}
void Delayms(int value)
{
while(value)
{
Delayus(99); /*delay 1ms*/
value--;
}
}
void WaitKey(void)
{
KEY=1;
upctra=1;
downctra=1;
Delayms(300);
while(KEY)
{
if(!upctra)
{
;
}
if(!downctra)
{
;
}
}
}
/*主屏显示单色 */ /*2byte = 1pixel, RGBRGB... */
void MainLCD_DisplaySingleColor(char data1,char data2)
{
int i,j;
MainLCD_WCom(0x00,0x22);
for(i=0;i<320;i++)
for(j=0;j<240;j++)
MainLCD_WData(data1,data2);
}
void MainLCD_DispalyRGBW(void)
{
char data1,data2;
int i,j;
data1=0xF8;
data2=0x00;
MainLCD_WCom(0x00,0x22);
for(i=0;i<80;i++)
for(j=0;j<240;j++)
MainLCD_WData(data1,data2);
data1=0x07;
data2=0xE0;
for(i=0;i<80;i++)
for(j=0;j<240;j++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -