今日头条
3.5寸TFT:320*480点阵,是全视角IPS类型,显示效果极佳,秒杀其它普通TN类型的屏!
现在用STM32VCT6FSMC驱动3.5寸IPS全视角液晶屏如下:
//说明:IM0接地,IM1接IOVCC,IM2接地,选择16位接口
//使用STM32FSMC16bit
驱动代码:
/********************************* *************************************
* Copyright (c) 2017 金鑫液晶显示屏
* All rights reserved.
*
* 文件名 :TFTLCD_Init.c
* 描述 :屏驱动代码
*
* 當前版本 :V1.0
* 作 者 :CGY
* 完成日期 :2017-12-01
* 修改描述 :第一版本
* 微信号:wxjcgy20120815
* E-mail : 68771083@qq.com
* 淘宝显示屏范例屏: https://shop150276963.taobao.com ... 679131.d0011.pdIFpT
*******************************************************************************/
#include "TFTLCD_Init.h"
///////////////////////////
u8 lcd_id[12]; //存放LCD ID字符串
/*************以下初始化与相关设置代码*******************/
/*************************************/
void LCD_Init(void)
{
/*************对LCD初始化前进行复位*******************/
LCD_RESET(); //对显示屏务必上电复位
/*************对LCD复位*****************************/
/*************对LCD屏参数设置************************/
LCD_Set(); //设置显示屏参数 需要设置,显示功能都用到设置的.
/*************以下开始初始化*******************/
/*************以下开始初始化*******************/
ILI9481_CMI350IPS_Initial_Code(); //20180327 OK
/*************END******************/
/*************END******************/
}
/*************以下开始初始化*******************/
/*************以下开始初始化*******************/
////////////////////////////////////
#define LCD_ILI9481_CMD LCD_WR_8REG
#define LCD_ILI9481_INDEX LCD_WR_8DATA
#define delayms delay_ms
#define comm_out LCD_WR_8REG
#define data_out LCD_WR_8DATA
#define Delayms delay_ms
void ILI9481_CMI350IPS_Initial_Code(void)
{
//20180510 OK
//Void ILI9481_CMO3.5ips_Initial_Code(void)
LCD_ILI9481_CMD(0x11);
Delayms(20);
LCD_ILI9481_CMD(0xD0);
LCD_ILI9481_INDEX(0x07);//VC[2:0] Sets the ratio factor of Vci to generate the reference voltages Vci1.
LCD_ILI9481_INDEX(0x45);//BT[2:0] Sets the Step up factor and output voltage level from the reference voltages Vci1 42
LCD_ILI9481_INDEX(0x1B); //VRH[3:0]: Sets the factor to generate VREG1OUT from VCILVL.
LCD_ILI9481_CMD(0xD1);//VCOM Control
LCD_ILI9481_INDEX(0x00);//00
LCD_ILI9481_INDEX(0x0F);//14 VCM [6:0]
LCD_ILI9481_INDEX(0x1C);//1B VDV[4:0]
LCD_ILI9481_CMD(0xD2);
LCD_ILI9481_INDEX(0x01);
LCD_ILI9481_INDEX(0x12);
LCD_ILI9481_CMD(0xC0);
LCD_ILI9481_INDEX(0x00);//10//1//00 REV SM GS
LCD_ILI9481_INDEX(0x3B);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x02);
LCD_ILI9481_INDEX(0x01);
LCD_ILI9481_CMD(0xC5);
LCD_ILI9481_INDEX(0x03);
LCD_ILI9481_CMD(0xC8);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x46);
LCD_ILI9481_INDEX(0x44);
LCD_ILI9481_INDEX(0x50);
LCD_ILI9481_INDEX(0x04);
LCD_ILI9481_INDEX(0x16);
LCD_ILI9481_INDEX(0x33);
LCD_ILI9481_INDEX(0x13);
LCD_ILI9481_INDEX(0x77);
LCD_ILI9481_INDEX(0x05);
LCD_ILI9481_INDEX(0x0F);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_CMD(0x36);
LCD_ILI9481_INDEX(0x0A);//0a
LCD_ILI9481_CMD(0x3A);
LCD_ILI9481_INDEX(0x55);//66
LCD_ILI9481_CMD(0x2A);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x01);
LCD_ILI9481_INDEX(0x3F);
LCD_ILI9481_CMD(0x2B);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x00);
LCD_ILI9481_INDEX(0x01);
LCD_ILI9481_INDEX(0xDF);
Delayms(120);
LCD_ILI9481_CMD(0x29);
}
/**********************************************
函数名:Lcd块选函数
功能:选定Lcd上指定的矩形区域 选择设置三种中一种就可以
注意:xStart、yStart、Xend、Yend随着屏幕的旋转而改变,位置是矩形框的四个角
入口参数:xStart x方向的起始点
ySrart y方向的起始点
Xend y方向的终止点
Yend y方向的终止点
返回值:无
***********************************************/
void BlockWrite(unsigned int Xstart,unsigned int Xend,unsigned int Ystart,unsigned int Yend)
{
LCDBlockILI9481( Xstart,Xend,Ystart,Yend);
}
/*******************************************************************************/
///////////////各种IC窗口////////////////
void LCDBlockILI9481(unsigned int Xstart,unsigned int Xend,unsigned int Ystart,unsigned int Yend)
{
//ili9481 20180328
//LCD_WR_8REG(0x36);
//LCD_WR_8DATA(0x0B); //EC 2C
LCD_WR_8REG(lcddev.setxcmd);
LCD_WR_8DATA(Xstart>>8);
LCD_WR_8DATA(Xstart&0xff);
LCD_WR_8DATA(Xend>>8);
LCD_WR_8DATA(Xend&0xff);
LCD_WR_8REG(lcddev.setycmd);
LCD_WR_8DATA(Ystart>>8);
LCD_WR_8DATA(Ystart&0xff);
LCD_WR_8DATA(Yend>>8);
LCD_WR_8DATA(Yend&0xff);
LCD_WR_8REG(0x2C);
}
/*******************************************************************************
//从FSMC_8080.C移放置在TFTLCD_Init.c 20171120
//设置光标位置 选择设置二种中一种就可以
//Xpos:横坐标
//Ypos:纵坐标
*******************************************************************************/
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
LCD_ILI9481SetCursor(Xpos,Ypos); //ILI9481 OK 20180328
}
/*******************************************************************************/
///////////////光标////////////////
void LCD_ILI9481SetCursor(u16 Xpos, u16 Ypos) //ILI9481 20180511_OK
{
///20180511
//0-正装ok20180510
///正装设置OK 20180510 36H:0A
lcddev.width=320; //LCD 宽度
lcddev.height=480; //LCD 高度
lcddev.setxcmd=0X2A; //设置x坐标指令2A
lcddev.setycmd=0X2B; //设置y坐标指令2B
lcddev.wramcmd=0X2C; //开始写gram指令
LCD_WR_8REG(0x36);
LCD_WR_8DATA(0x0A); //0A
LCD_WR_8REG(lcddev.setxcmd);
LCD_WR_8DATA(Xpos>>8);
LCD_WR_8DATA(Xpos&0xff);
LCD_WR_8DATA(0x01);
LCD_WR_8DATA(0x3F);
LCD_WR_8REG(lcddev.setycmd);
LCD_WR_8DATA(Ypos>>8);
LCD_WR_8DATA(Ypos&0xff);
LCD_WR_8DATA(0x01);
LCD_WR_8DATA(0xDF);
LCD_WR_8REG(lcddev.wramcmd);
}
///===========END ==============//
例程效果展示:
显示的世界就是这么简单~
共勉:
没有横空出世的运气,只有脚踏实地的努力
可加微信:13410179961 一起聊显示世界~
全部0条评论
快来发表一下你的评论吧 !