久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
c51單片機測溫320x240TFT液晶顯示
[打印本頁]
作者:
木綿綿·
時間:
2018-6-26 16:45
標題:
c51單片機測溫320x240TFT液晶顯示
溫度測量液晶顯示
單片機源程序如下:
/*===================================================================================================
文件功能描述:320x240TFT驅(qū)動程序,控制TFT實現(xiàn)漢字,字符顯示,畫點功能。
====================================================================================================*/
//******************包含頭文件***************************
#include"NBCTFT.h"
#include"reg52.h"
//**************控制端口定義********************
#define DataPort P0 //數(shù)據(jù)口使用DataPort
sbit RS =P2^5; //數(shù)據(jù)/命令選擇
sbit RW =P2^4; //寫數(shù)據(jù)/命令
sbit nRD =P2^3; //讀控制
sbit CS =P2^2; //片選
sbit RES =P2^1; //復位
sbit LE =P2^0; //74HC573鎖存控制
//**************聲明外部函數(shù)和變量**************
extern unsigned int Device_code;
//================================================================================================
// 實現(xiàn)功能: 延時
// 輸入?yún)?shù): count 設(shè)置延時時間
//================================================================================================
void delayms(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<255;j++);
}
}
//================================================================================================
// 實現(xiàn)功能: 寫命令
// 輸入?yún)?shù): DH 需要輸入16bits命令的高8位
// DL 需要輸入16bits命令的低8位
//================================================================================================
void Write_Cmd(unsigned char DH,unsigned char DL)
{
CS=0;
RS=0;
nRD=1;
RW=0;
//注意:當使用8位數(shù)據(jù)口驅(qū)動16位數(shù)據(jù)模式時,使用74HC573作為IO擴展,程序如下
DataPort=DL; //送低8位命令給573待鎖存
LE=1; //鎖存位
LE=0; //斷開鎖存,位選573的Q7~Q0仍保持
DataPort=DH; //送高8位命令給TFT
/*
//如果使用16位數(shù)據(jù)口驅(qū)動16位數(shù)據(jù)模式,則無需IO擴展,直接將數(shù)據(jù)送到數(shù)據(jù)口即可
DataPort_L=DL;
DataPort_H=DH;
*/
RW=1;
CS=1;
}
//================================================================================================
// 實現(xiàn)功能: 寫數(shù)據(jù)(2*8bits)
// 輸入?yún)?shù): DH 需要輸入16bits數(shù)據(jù)的高8位
// DL 需要輸入16bits數(shù)據(jù)的低8位
//================================================================================================
void Write_Data(unsigned char DH,unsigned char DL)
{
CS=0;
RS=1;
//注意:當使用8位數(shù)據(jù)口驅(qū)動16位數(shù)據(jù)模式時,使用74HC573作為IO擴展,程序如下
DataPort=DL; //送低8位數(shù)據(jù)給573待鎖存
LE=1; //鎖存位
LE=0; //斷開鎖存,位選573的Q7~Q0仍保持
DataPort=DH; //送高8位數(shù)據(jù)給TFT
/*
//如果使用16位數(shù)據(jù)口驅(qū)動16位數(shù)據(jù)模式,則無需IO擴展,直接將數(shù)據(jù)送到數(shù)據(jù)口即可
DataPort_L=DL;
DataPort_H=DH;
*/
RW=0;
RW=1;
CS=1;
}
//================================================================================================
// 實現(xiàn)功能: 寫數(shù)據(jù)(16位)
// 輸入?yún)?shù): y 需要輸入16bits數(shù)據(jù)
//================================================================================================
void Write_Data_U16(unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Data(m,n);
}
//================================================================================================
// 實現(xiàn)功能: 向x寄存器寫入y數(shù)據(jù)
// 輸入?yún)?shù): x 需要輸入的命令 16位
// y 需要輸入的數(shù)據(jù) 16位
//================================================================================================
void Write_Cmd_Data (unsigned char x,unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Cmd(0x00,x);
Write_Data(m,n);
}
//================================================================================================
// 實現(xiàn)功能: TFT清屏
// 輸入?yún)?shù): bColor 清屏所使用的背景色
//================================================================================================
void CLR_Screen(unsigned int bColor)
{
unsigned int i,j;
LCD_SetPos(0,240,0,320);//320x240
for (i=0;i<320;i++)
{
for (j=0;j<240;j++)
Write_Data_U16(bColor);
}
}
//================================================================================================
// 實現(xiàn)功能: 顯示Ascii字符
// 輸入?yún)?shù): x 橫坐標
// y 縱坐標
// c 需要顯示的字符
// fColor 字符顏色
// bColor 字符背景顏色
//================================================================================================
#include "Ascii_8x16.h"
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor)
{
unsigned int i,j;
LCD_SetPos(x,x+8-1,y,y+16-1); //設(shè)置字符顯示位置
for(i=0; i<16;i++) { //循環(huán)寫入16字節(jié),一個字符為16字節(jié)
unsigned char m=Font8x16[(c-0x20)*16+i]; //提取c字符的第i個字節(jié)以,c減去0x20是由于Ascii碼庫中的0~1f被去掉
for(j=0;j<8;j++) { //循環(huán)寫入8位,一個字節(jié)為8位
if((m&0x80)==0x80) { //判斷最高位是否為1
Write_Data_U16(fColor); //最高位為1,寫入字符顏色
}
else {
Write_Data_U16(bColor); //最高位為0,寫入背景顏色
}
m<<=1; //左移1位,準備寫下一位
}
}
}
//================================================================================================
// 實現(xiàn)功能: 顯示16x16漢字
// 輸入?yún)?shù): x 橫坐標
// y 縱坐標
// g 需要顯示的字符編碼
// fColor 字符顏色
// bColor 字符背景顏色
//================================================================================================
#include "chinese.h" //包含16*16漢字字模
void Put16x16(unsigned short x, unsigned short y, unsigned char g[2], unsigned int fColor,unsigned int bColor)
{
unsigned int i,j,k;
LCD_SetPos(x, x+16-1,y, y+16-1); //設(shè)置漢字顯示位置
for (k=0;k<64;k++) //循環(huán)64次,查詢漢字字模位置
{
if ((ch16[k].GBK[0]==g[0])&&(ch16[k].GBK[1]==g[1])) //判斷第k個漢字的編碼是否與輸入漢字g[2]相等
{
for(i=0;i<32;i++) //如果相等,既已找到待顯示字模位置,循環(huán)寫入32字節(jié)
{
unsigned short m=ch16[k].hz16[i]; //讀取32字節(jié)中的第i字節(jié)
for(j=0;j<8;j++) //循環(huán)寫入8位數(shù)據(jù)
{
if((m&0x80)==0x80) Write_Data_U16(fColor); //判斷最高位是否為1,最高位為1,寫入字符顏色
else Write_Data_U16(bColor); //最高位為0,寫入背景顏色
m<<=1; //左移1位,準備寫下一位
}
}
}
}
}
//================================================================================================
// 實現(xiàn)功能: 顯示中英文字符串
// 輸入?yún)?shù): x 橫坐標
// y 縱坐標
// *s 待顯示的字符串,例如LCD_PutString(24,16,"123藍芯",White,Blue);即把"123藍芯"的第一個字符地址賦給指針變量s.
// bColor 字符背景顏色
//================================================================================================
void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor)
{
unsigned char l=0; //顯示屏位置增量
while(*s)
{
if( *s < 0x80) //判斷s指向的字符串中的某字符的編碼值是否小于128,如果小于,即為ASCII字符
{
LCD_PutChar(x+l*8,y,*s,fColor,bColor);//顯示該字符
s++;l++; //指針加1,位置加1
}
else
{
Put16x16(x+l*8,y,(unsigned char*)s,fColor,bColor);//顯示該漢字
s+=2;l+=2; //因為漢字為編碼為2字節(jié),指針加2,顯示16x16所以位置加2
}
}
}
//================================================================================================
// 實現(xiàn)功能: 指定位置顯示RGB顏色
// 輸入?yún)?shù): x0,y0 起始坐標
// x1,y1 結(jié)束坐標
// Color 背景顏色
//================================================================================================
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color)
{
unsigned int i,j;
LCD_SetPos(x0,x1,y0,y1); //設(shè)置顯示位置
for (i=y0;i<=y1;i++)
{
for (j=x0;j<=x1;j++)
Write_Data_U16(Color);
}
}
//================================================================================================
// 實現(xiàn)功能: TFT初始化
//================================================================================================
void TFT_Initial(void)
{
RES = 1;
delayms(1); // Delay 1ms
RES = 0;
delayms(10); // Delay 10ms
RES = 1;
delayms(50); // Delay 50 ms
if(Device_code==0x9320)
{
//************* Start Initial Sequence **********//
Write_Cmd_Data(0x00,0x0001); //Set the OSC bit as ‘1’ to start the internal oscillator
Write_Cmd_Data(0x01,0x0100); // set SS and SM bit
Write_Cmd_Data(0x02,0x0700); // set 1 line inversion
Write_Cmd_Data(0x03,0x1030); //set GRAM Write direction and BGR=1
Write_Cmd_Data(0x04,0x0000); // Resize register
Write_Cmd_Data(0x08,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x09,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x0A,0x0000); // FMARK function
Write_Cmd_Data(0x0C,0x0000); // RGB interface setting
Write_Cmd_Data(0x0D,0x0000); // Frame marker Position
Write_Cmd_Data(0x0F,0x0000); // RGB interface polarity
delayms(30);
//*************Power On sequence ****************//
Write_Cmd_Data(0x10, 0x16b0); // SAP, BT[3:0], AP, DSTB, SLP, STB
delayms(30);
Write_Cmd_Data(0x11, 0x0007); //Write final user’s setting values to VC bit
Write_Cmd_Data(0x12, 0x013a); // set Internal reference voltage
Write_Cmd_Data(0x13, 0x1a00); // VDV[4:0] for VCOM amplitude
delayms(30);
Write_Cmd_Data(0x29, 0x000c); // Set VCM[5:0] for VCOMH
delayms(30); // Delay 50ms
// ----------- Adjust the Gamma Curve ----------//
Write_Cmd_Data(0x0030, 0x0000);
Write_Cmd_Data(0x0031, 0x0505);
Write_Cmd_Data(0x0032, 0x0304);
Write_Cmd_Data(0x0035, 0x0006);
Write_Cmd_Data(0x0036, 0x0707);
Write_Cmd_Data(0x0037, 0x0105);
Write_Cmd_Data(0x0038, 0x0002);
Write_Cmd_Data(0x0039, 0x0707);
Write_Cmd_Data(0x003C, 0x0704);
Write_Cmd_Data(0x003D, 0x0807);
//------------------ Set GRAM area ---------------//
Write_Cmd_Data(0x0050, 0x0000); // Horizontal GRAM Start Address
Write_Cmd_Data(0x0051, 0x00EF); // Horizontal GRAM End Address
Write_Cmd_Data(0x0052, 0x0000); // Vertical GRAM Start Address
Write_Cmd_Data(0x0053, 0x013F); // Vertical GRAM Start Address
Write_Cmd_Data(0x0060, 0x2700); // Gate Scan Line
Write_Cmd_Data(0x0061, 0x0001); // NDL,VLE, REV
Write_Cmd_Data(0x006A, 0x0000); // set scrolling line
Write_Cmd_Data(0x20, 0x0000); // GRAM horizontal Address
Write_Cmd_Data(0x21, 0x0000); // GRAM Vertical Address
//-------------- Partial Display Control ---------//
Write_Cmd_Data(0x0080, 0x0000);
Write_Cmd_Data(0x0081, 0x0000);
Write_Cmd_Data(0x0082, 0x0000);
Write_Cmd_Data(0x0083, 0x0000);
Write_Cmd_Data(0x0084, 0x0000);
Write_Cmd_Data(0x0085, 0x0000);
//-------------- Panel Control ---------//
Write_Cmd_Data(0x90,0x0010); //Frame Cycle Contral
Write_Cmd_Data(0x92,0x0000); //Panel Interface Contral
Write_Cmd_Data(0x93,0x0003); //Panel Interface Contral 3.
Write_Cmd_Data(0x95,0x0110); //Frame Cycle Contral
Write_Cmd_Data(0x97,0x0000); //
Write_Cmd_Data(0x98,0x0000); //Frame Cycle Contral.
//-------------- Display on ---------//
Write_Cmd_Data(0x07,0x0173);
}
else if(Device_code==0x1505 )
{
//************* Start Initial Sequence **********//
Write_Cmd_Data(0x00,0x0001); //Set the OSC bit as ‘1’ to start the internal oscillator
Write_Cmd_Data(0x01,0x0100); // set SS and SM bit
Write_Cmd_Data(0x02,0x0700); // set 1 line inversion
Write_Cmd_Data(0x03,0x1030); //set GRAM Write direction and BGR=1
Write_Cmd_Data(0x04,0x0000); // Resize register
Write_Cmd_Data(0x08,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x09,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x0A,0x0000); // FMARK function
Write_Cmd_Data(0x0C,0x0000); // RGB interface setting
Write_Cmd_Data(0x0D,0x0000); // Frame marker Position
Write_Cmd_Data(0x0F,0x0000); // RGB interface polarity
delayms(30);
//*************Power On sequence ****************//
Write_Cmd_Data(0x10, 0x16b0); // SAP, BT[3:0], AP, DSTB, SLP, STB
delayms(30);
Write_Cmd_Data(0x11, 0x0007); //Write final user’s setting values to VC bit
Write_Cmd_Data(0x12, 0x013a); // set Internal reference voltage
Write_Cmd_Data(0x13, 0x1a00); // VDV[4:0] for VCOM amplitude
delayms(30);
Write_Cmd_Data(0x29, 0x000c); // Set VCM[5:0] for VCOMH
delayms(30); // Delay 50ms
// ----------- Adjust the Gamma Curve ----------//
Write_Cmd_Data(0x0030, 0x0000);
Write_Cmd_Data(0x0031, 0x0505);
Write_Cmd_Data(0x0032, 0x0304);
Write_Cmd_Data(0x0035, 0x0006);
Write_Cmd_Data(0x0036, 0x0707);
Write_Cmd_Data(0x0037, 0x0105);
Write_Cmd_Data(0x0038, 0x0002);
Write_Cmd_Data(0x0039, 0x0707);
Write_Cmd_Data(0x003C, 0x0704);
Write_Cmd_Data(0x003D, 0x0807);
//------------------ Set GRAM area ---------------//
Write_Cmd_Data(0x0050, 0x0000); // Horizontal GRAM Start Address
Write_Cmd_Data(0x0051, 0x00EF); // Horizontal GRAM End Address
Write_Cmd_Data(0x0052, 0x0000); // Vertical GRAM Start Address
Write_Cmd_Data(0x0053, 0x013F); // Vertical GRAM Start Address
Write_Cmd_Data(0x0060, 0x2700); // Gate Scan Line
Write_Cmd_Data(0x0061, 0x0001); // NDL,VLE, REV
Write_Cmd_Data(0x006A, 0x2700); // set scrolling line
Write_Cmd_Data(0x20, 0x0000); // GRAM horizontal Address
Write_Cmd_Data(0x21, 0x0000); // GRAM Vertical Address
//-------------- Partial Display Control ---------//
Write_Cmd_Data(0x0080, 0x0000);
Write_Cmd_Data(0x0081, 0x0000);
Write_Cmd_Data(0x0082, 0x0000);
Write_Cmd_Data(0x0083, 0x0000);
Write_Cmd_Data(0x0084, 0x0000);
Write_Cmd_Data(0x0085, 0x0000);
//-------------- Panel Control ---------//
Write_Cmd_Data(0x90,0x0010); //Frame Cycle Contral
Write_Cmd_Data(0x92,0x0000); //Panel Interface Contral
Write_Cmd_Data(0x93,0x0003); //Panel Interface Contral 3.
Write_Cmd_Data(0x95,0x0110); //Frame Cycle Contral
Write_Cmd_Data(0x97,0x0000); //
Write_Cmd_Data(0x98,0x0000); //Frame Cycle Contral.
//-------------- Display on ---------//
Write_Cmd_Data(0x07,0x0173);
}
else if(Device_code==0x9328)
{
//************* Start Initial Sequence **********//
Write_Cmd_Data(0x0001,0x0100); //set SS and SM bit //設(shè)置掃描方向
Write_Cmd_Data(0x0002,0x0700); //EOR=1 and B/C=1 to set the line inversion //設(shè)置行反轉(zhuǎn)
Write_Cmd_Data(0x0003,0x1030); //set Entry Mode //設(shè)置進入模式
Write_Cmd_Data(0x0004,0x0000); //
Write_Cmd_Data(0x00A4,0x0001);
Write_Cmd_Data(0x0008,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x0009,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x000A,0x0000); // FMARK function
Write_Cmd_Data(0x000C,0x0000); // RGB interface setting
Write_Cmd_Data(0x000D, 0x0000); // Frame marker Position
Write_Cmd_Data(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
Write_Cmd_Data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Write_Cmd_Data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Write_Cmd_Data(0x0012, 0x0000); // VREG1OUT voltage
Write_Cmd_Data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
delayms(30);
Write_Cmd_Data(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
Write_Cmd_Data(0x0011, 0x0227); // R11h=0x0221 at VCI=3.3V, DC1[2:0], DC0[2:0], VC[2:0]
delayms(30);
Write_Cmd_Data(0x0012, 0x001C); // External reference voltage= Vci;
delayms(30);
Write_Cmd_Data(0x0013, 0x1800); // R13=1200 when R12=009D;VDV[4:0] for VCOM amplitude
Write_Cmd_Data(0x0029, 0x001C); // R29=000C when R12=009D;VCM[5:0] for VCOMH
Write_Cmd_Data(0x002B, 0x000D); // Frame Rate = 91Hz
delayms(30);
Write_Cmd_Data(0x0020, 0x0000); // GRAM horizontal Address
Write_Cmd_Data(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
Write_Cmd_Data(0x0030, 0x0007);
Write_Cmd_Data(0x0031, 0x0302);
Write_Cmd_Data(0x0032, 0x0105);
Write_Cmd_Data(0x0035, 0x0206);
Write_Cmd_Data(0x0036, 0x0808);
Write_Cmd_Data(0x0037, 0x0206);
Write_Cmd_Data(0x0038, 0x0504);
Write_Cmd_Data(0x0039, 0x0007);
Write_Cmd_Data(0x003C, 0x0105);
Write_Cmd_Data(0x003D, 0x0808);
//------------------ Set GRAM area ---------------//
Write_Cmd_Data(0x0050, 0x0000); // Horizontal GRAM Start Address
Write_Cmd_Data(0x0051, 0x00EF); // Horizontal GRAM End Address
Write_Cmd_Data(0x0052, 0x0000); // Vertical GRAM Start Address
delayms(30);
Write_Cmd_Data(0x0053, 0x013F); // Vertical GRAM Start Address
delayms(30);
Write_Cmd_Data(0x0060, 0xA700); // Gate Scan Line
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
溫度測量液晶顯示1.rar
(64.38 KB, 下載次數(shù): 29)
2018-6-26 16:44 上傳
點擊文件名下載附件
單片機溫度液晶顯示
下載積分: 黑幣 -5
作者:
piplxh
時間:
2018-7-1 11:50
非常好!
作者:
yzhg
時間:
2019-9-15 21:30
感謝分享了,拿去做參考
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
日日射夜夜骑
|
亚洲日韩中文字幕一区
|
免费看91
|
欧美三区在线观看
|
麻豆一区二区三区
|
久久精品免费
|
欧美一二三
|
欧美三级久久久
|
www.久久.com
|
日韩精品在线视频免费观看
|
天天躁日日躁aaaa视频
|
不卡一区二区三区四区
|
亚洲性爰
|
久久国产高清视频
|
男女在线网站
|
久久久久久久久久久久久9999
|
亚洲精品一区在线观看
|
可以在线看的黄色网址
|
亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区
|
91精品国产综合久久久久久漫画
|
日韩av一区二区在线观看
|
羞羞羞视频
|
免费国产一区
|
久久大
|
91视频免费观看
|
久久久久久国产精品免费免费狐狸
|
91欧美激情一区二区三区成人
|
国产一区2区
|
国产一区二
|
香蕉一区二区
|
日韩欧美国产精品
|
欧美日韩成人在线观看
|
日日摸日日碰夜夜爽亚洲精品蜜乳
|
wwwww在线观看
|
一区二区三区四区在线
|
wwwsihu
|
国产精品18hdxxxⅹ在线
|
日韩一二三
|
日韩精品一区二区三区四区视频
|
中文字幕韩在线第一页
|
国产欧美一区二区久久性色99
|