⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tft.c

📁 IC: NT39102的彩屏的驱动
💻 C
字号:
//DJN Co.,LTD.
//LCM operation code
//Driver IC: NT39102
//Panel: AUO 1.77
#include "reg52.h"
#include <absacc.h>
#include"bmp.h"
unsigned char xdata bmpr[40960];
/********************************************************************************
  DESCRIPTION:
 LCM initialization sequence.
  PARAMETERS:
  RETURNS:
  REMARKS:
*********************************************************************************/ 
void LCD_WRITE_A0(unsigned char cmd)
{
   XBYTE[0xe000]=cmd;
}
void LCD_WRITE_A1(unsigned char DATA)
{
   XBYTE[0xe001]=DATA;
}
void Delayms(unsigned char ms)
{
   unsigned char a,b;
   for(;ms>0;ms--)
    for(a=0;a<10;a++)
	  for(b=0;b<100;b++);
}


void init_lcd()
{
  P3=0XFF;
  Delayms(200);
  P3=0X00;
  Delayms(200);
  P3=0XFF;
  LCD_WRITE_A0(0x0001); LCD_WRITE_A1(0x0002); /* 7-6=00: panel resolution 128x160, 4-2=000: 16 bit color mod, 1=0: power on, 0=0: out of range data white */ \
  LCD_WRITE_A0(0x0002); LCD_WRITE_A1(0x0012); /* 7=0: sub panel off (CSV=1), 5=0: line inversion, 4=1: sub panel off, 3=0: main panel on */                  \
  LCD_WRITE_A0(0x0003); LCD_WRITE_A1(0x0020); /* 7-6=01: 16 bit mode, 5-4=10: 16 bit transfer, 18 bit data (BODR=10) */                                      \
  LCD_WRITE_A0(0x0005); LCD_WRITE_A1(0x0008); /* 4-3=01: typical bias, 5,2-0=0,00: 1.82MHz */                                                                \
  LCD_WRITE_A0(0x0008); LCD_WRITE_A1(0x000C); /* 6-0=0001100: VCOM_L 0.197 V */                                                                              \
  LCD_WRITE_A0(0x0007); LCD_WRITE_A1(0x007f); /* 6-0=1110100: VCOM_H 4.003 V */                                                                              \
  LCD_WRITE_A0(0x0021); LCD_WRITE_A1(0x0000); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0022); LCD_WRITE_A1(0x0000); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0023); LCD_WRITE_A1(0x0024); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0024); LCD_WRITE_A1(0x001B); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0025); LCD_WRITE_A1(0x0009); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0026); LCD_WRITE_A1(0x0000); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0027); LCD_WRITE_A1(0x0000); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0028); LCD_WRITE_A1(0x0000); /* gamma adjustment 2.0 */                                                                                     \
  LCD_WRITE_A0(0x0006); LCD_WRITE_A1(0x00C7);  /* 7=1: internal register, 6=1: power on */
}
void set_windows(unsigned char x_s,unsigned char x_e,unsigned char y_s,unsigned char y_e)
{
   LCD_WRITE_A0(0x0009); LCD_WRITE_A1(x_s); 
   LCD_WRITE_A0(0x0011); LCD_WRITE_A1(x_e); 
   LCD_WRITE_A0(0x0010); LCD_WRITE_A1(y_s); 
   LCD_WRITE_A0(0x0012); LCD_WRITE_A1(y_e); 
}

/********************************************************************************
  DESCRIPTION:
 LCM display window setting.
  PARAMETERS:
 xs: Horizontal Address Start Position
 xe: Horizontal Address End Position
 ys: Vertical Address Start Position
 ye: Vertical Address End Position
  RETURNS:
  REMARKS:
*********************************************************************************/

 main()
 {
 unsigned int a=0;
 init_lcd();
 for(a=0;a<40960;a++)
 {
   bmpr[a]=bmp[a];
 }
 set_windows(0,127,0,159);
 for(a=0;a<128*160;a++)
 {
  LCD_WRITE_A1(bmpr[a*2+1]);
  LCD_WRITE_A1(bmpr[a*2]);
  }
 while(1);
}
/********************************************************************************
  DESCRIPTION:
 LCM enter_sleep_mode sequence.
  PARAMETERS:
  RETURNS:
  REMARKS:
 1) This command has no effect when module is already in sleep in mode. 
Sleep In Mode can only be exit by the Sleep Out Command (11h).
 2) It will be necessary to wait 5msec before sending next command, 
this is to allow time for the supply voltages and clock circuits to stabilize.
 3) It will be necessary to wait 120msec after sending Sleep Out command 
(when in Sleep In Mode) before Sleep In command can be sent.
*********************************************************************************/ 

 
/********************************************************************************
  DESCRIPTION:
 LCM exit_sleep_mode sequence.
  PARAMETERS:
  RETURNS:
  REMARKS:
 1) This command has no effect when module is already in sleep out mode. 
Sleep Out Mode can only be exit by the Sleep In Command (10h).
 2) It will be necessary to wait 5msec before sending next command.
*********************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -