久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
TFT2.4漢字2樣例程序 51單片機開發板程序
[打印本頁]
作者:
是不是傻
時間:
2017-4-25 23:32
標題:
TFT2.4漢字2樣例程序 51單片機開發板程序
單片機TFT2.4彩屏顯示程序.
0.png
(59.57 KB, 下載次數: 47)
下載附件
2017-4-26 02:00 上傳
完整源碼下載:
TFT2.4漢字2樣例程序.zip
(111.47 KB, 下載次數: 24)
2017-4-25 23:32 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
預覽:
#include "reg52.h"
#include "string.h"
#include "stdio.h"
char tempbuffer[10];
#define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set
#define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set
#define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set
#define WINDOW_YADDR_END 0x0053 // Vertical End Address Set
#define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set
#define GRAM_YADDR 0x0021 // GRAM Vertical Address Set
#define GRAMWR 0x0022 // memory write
/* LCD color */
#define White 0xFFFF
#define Black 0x0000
#define Blue 0x001F
#define Blue2 0x051F
#define Red 0xF800
#define Magenta 0xF81F
#define Green 0x07E0
#define Cyan 0x7FFF
#define Yellow 0xFFE0
sbit CS=P2^7; //片選
sbit RES=P2^5; //復位
sbit RS=P2^4; //數據/命令選擇
sbit RW=P2^3;
//數據口使用P1
//====================================================//
void main (void);
void ILI9325_Initial(void);
void show_colour_bar (void);
void Init_data(unsigned char x, unsigned int y);
void Write_Cmd(unsigned char DH,unsigned char DL);
void Write_Data(unsigned char DH,unsigned char DL);
void delayms(unsigned int tt);
void show_photo(void);
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color);
unsigned char code pic[];
void Write_Data_U16(unsigned int y);
static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1);
void ClearScreen(unsigned int bColor);
void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutString(unsigned short x, unsigned short y, char *s, unsigned int fColor, unsigned int bColor);
void LCD_PutChar8x8(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);
void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);
//================================================//
void main(void)
{
float j=80.12;
CS=1;
delayms(25);
RES=0;
delayms(150);
RES=1;
delayms(25);
ILI9325_Initial();
while(1)
{
sprintf(tempbuffer,"%4.5f",j);
ClearScreen(0x0);
//show_colour_bar();
//LCD_PutString(2,40," 周期",Red,Blue); ///前景顏色和背景顏色,可以直接預定義,也可以直接填入16進制數字
LCD_PutString(40,60,tempbuffer,Blue2,Yellow);
//LCD_PutString(40,80,"頻率",Magenta,Green);
LCD_PutString(40,100,"周期",0x07e0,0xf800);
//LCD_PutString(40,120,"專業開發板工控板",0xF800,Yellow);
LCD_PutString(40,140,"頻率",0xF800,Yellow);
//LCD_PutString(20,160,"abcdefghijklmnopqistuvwxyz",0xF800,Yellow);
LCD_PutString(20,180,"幅度值",0xF800,Yellow);
PutGB3232(20,200,"我",Blue,Yellow); //寫入32x32漢字
PutGB3232(60,200,"愛",Blue,Red);
PutGB3232(100,200,"單",Blue,Magenta);
PutGB3232(140,200,"片",Blue,Green);
PutGB3232(180,200,"機",Blue,Cyan);
//PutGB3232(20,240,"碩",Blue,0X00);
//PutGB3232(60,240,"耀",Blue,0X00);
//PutGB3232(100,240,"電",Blue,0X00);
//PutGB3232(140,240,"子",Blue,0X00);
//PutGB3232(180,240,"科",Blue,0X00);
//PutGB3232(20,280,"技",Blue,0X00);
//PutGB3232(60,280,"歡",Blue,0X00);
//PutGB3232(100,280,"迎",Blue,0X00);
//PutGB3232(140,280,"你",Blue,0X00);
//PutGB3232(180,280,"!",Blue,0X00);
// show_photo();
while(1);
}
}
void ClearScreen(unsigned int bColor)
{
unsigned int i,j;
LCD_SetPos(0,240,0,320);//320x240
for (i=0;i<325;i++)
{
for (j=0;j<240;j++)
Write_Data_U16(bColor);
}
}
/////////////////////////////////////////////////////////////
#include "8X16.h"
void LCD_PutChar8x16(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);
for(i=0; i<16;i++) {
unsigned char m=Font8x16[c*16+i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);
}
else {
Write_Data_U16(bColor);
}
m<<=1;
}
}
}
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) {
LCD_PutChar8x16( x, y, c, fColor, bColor );
}
#include "GB1616.h" //16*16漢字字模
void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
unsigned int i,j,k;
LCD_SetPos(x, x+16-1,y, y+16-1);
for (k=0;k<64;k++) { //64標示自建漢字庫中的個數,循環查詢內碼
if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){
for(i=0;i<32;i++) {
unsigned short m=codeGB_16[k].Msk[i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);
}
else {
Write_Data_U16(bColor);
}
m<<=1;
}
}
}
}
}
#include "GB3232.h" //32*32漢字字模
void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
unsigned int i,j,k;
LCD_SetPos(x, x+32-1,y, y+32-1);
for (k=0;k<15;k++) { //15標示自建漢字庫中的個數,循環查詢內碼
if ((codeGB_32[k].Index[0]==c[0])&&(codeGB_32[k].Index[1]==c[1])){
for(i=0;i<128;i++) {
unsigned short m=codeGB_32[k].Msk[i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);
}
else {
Write_Data_U16(bColor);
}
m<<=1;
}
}
}
}
}
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)
{
LCD_PutChar(x+l*8,y,*s,fColor,bColor);
s++;l++;
}
else
{
PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor);
s+=2;l+=2;
}
}
}
//==================== 顯示R G B 顔色 ====================//
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color)
{
unsigned int i,j;
//address_set();
LCD_SetPos(x0,x1,y0,y1);
for (i=y0;i<=y1;i++)
{
for (j=x0;j<=x1;j++)
Write_Data_U16(Color);
}
}
//====================== 顯示彩條 ======================//
void show_colour_bar (void)
{
int V,H;
LCD_SetPos(0,240,0,320);//320x240
for(H=0;H<240;H++)
{
for(V=0;V<40;V++)
Write_Data(0xf8,0x00);
}
for(H=0;H<240;H++)
{
for(V=40;V<80;V++)
Write_Data(0x07,0xe0);
}
for(H=0;H<240;H++)
{
for(V=80;V<120;V++)
Write_Data(0x00,0x1f);
}
for(H=0;H<240;H++)
{
for(V=120;V<160;V++)
Write_Data(0xff,0xe0);
}
for(H=0;H<240;H++)
{
for(V=160;V<200;V++)
Write_Data(0xf8,0x1f);
}
for(H=0;H<240;H++)
{
for(V=200;V<240;V++)
Write_Data(0x07,0xff);
}
for(H=0;H<240;H++)
{
for(V=240;V<280;V++)
Write_Data(0xff,0xff);
}
for(H=0;H<240;H++)
{
for(V=280;V<320;V++)
Write_Data(0x00,0x00);
}
}
void show_photo(void)
{
unsigned char j;
unsigned int i;
unsigned long s=0;
LCD_SetPos(0,240,0,320);//320x240
for (i=0;i<75;i++)
{
for (j=0;j<240;j++)
Write_Data(0xff,0xff);
}
for (i=0;i<170;i++)
{
for (j=0;j<55;j++)
Write_Data(0xff,0xff);
for (j=0;j<130;j++)
Write_Data(pic[s++],pic[s++]);
for (j=0;j<55;j++)
Write_Data(0xff,0xff);
}
for (i=0;i<75;i++)
{
for (j=0;j<240;j++)
Write_Data(0xff,0xff);
}
}
//=======================================================//
void Init_data (unsigned char x,unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Cmd(0x00,x);
Write_Data(m,n);
}
void Write_Data_U16(unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Data(m,n);
}
//====================== 寫命令 ==========================//
void Write_Cmd(unsigned char DH,unsigned char DL)
{
CS=0;
RS=0;
P1=DH;
RW=0;
RW=1;
P1=DL;
RW=0;
RW=1;
CS=1;
}
//===================== 寫數據 ===========================//
void Write_Data(unsigned char DH,unsigned char DL)
{
CS=0;
RS=1;
P1=DH;
RW=0;
RW=1;
P1=DL;
RW=0;
RW=1;
CS=1;
}
//=======================================================
void delayms(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<260;j++);
}
}
//===================== 初始化代碼 =======================//
void ILI9325_Initial(void)
{
//////////////////////////////////////////////////////////
delayms(150); //根據不同晶振速度可以調整延時,保障穩定顯示
Init_data(0x00E5, 0x8000); // Set the Vcore voltage and this setting is must.
Init_data(0x0000, 0x0001); // Start internal OSC.
Init_data(0x0001, 0x0100); // set SS and SM bit
Init_data(0x0002, 0x0700); // set 1 line inversion
Init_data(0x0003, 0x1090); // set GRAM write direction and BGR=0.
Init_data(0x0004, 0x0000); // Resize register
Init_data(0x0008, 0x0202); // set the back porch and front porch
Init_data(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
Init_data(0x000A, 0x0000); // FMARK function
Init_data(0x000C, 0x0000); // RGB interface setting
Init_data(0x000D, 0x0000); // Frame marker Position
Init_data(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
Init_data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Init_data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Init_data(0x0012, 0x0000); // VREG1OUT voltage
Init_data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
delayms(200); // Dis-charge capacitor power voltage
Init_data(0x0010, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
Init_data(0x0011, 0x0037); // DC1[2:0], DC0[2:0], VC[2:0]
delayms(50); // Delay 50ms
Init_data(0x0012, 0x013E); // VREG1OUT voltage
delayms(50); // Delay 50ms
Init_data(0x0013, 0x1F00); // VDV[4:0] for VCOM amplitude
Init_data(0x0029, 0x0013); // VCM[4:0] for VCOMH
delayms(50);
Init_data(0x0020, 0x0000); // GRAM horizontal Address
Init_data(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
Init_data(0x0030, 0x0000);
Init_data(0x0031, 0x0404);
Init_data(0x0032, 0x0404);
Init_data(0x0035, 0x0004);
Init_data(0x0036, 0x0404);
Init_data(0x0037, 0x0404);
Init_data(0x0038, 0x0404);
Init_data(0x0039, 0x0707);
Init_data(0x003C, 0x0500);
Init_data(0x003D, 0x0607);
//------------------ Set GRAM area ---------------//
Init_data(0x0050, 0x0000); // Horizontal GRAM Start Address
Init_data(0x0051, 0x00EF); // Horizontal GRAM End Address
Init_data(0x0052, 0x0000); // Vertical GRAM Start Address
Init_data(0x0053, 0x013F); // Vertical GRAM Start Address
Init_data(0x0060, 0x2700); // Gate Scan Line
Init_data(0x0061, 0x0001); // NDL,VLE, REV
Init_data(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
Init_data(0x0080, 0x0000);
Init_data(0x0081, 0x0000);
Init_data(0x0082, 0x0000);
Init_data(0x0083, 0x0000);
Init_data(0x0084, 0x0000);
Init_data(0x0085, 0x0000);
//-------------- Panel Control -------------------//
Init_data(0x0090, 0x0010);
Init_data(0x0092, 0x0000);
Init_data(0x0093, 0x0003);
Init_data(0x0095, 0x0110);
Init_data(0x0097, 0x0000);
Init_data(0x0098, 0x0000);
Init_data(0x0007, 0x0173); // 262K color and display ON
// Write_Cmd_Data(0x0022);//
}
/*===========================================================*/
/*************************************************************
函數名稱:LCD_DefineDispWindow
功 能:定義顯示窗體
參 數:x0: 窗體中X坐標中較小者
x1: 窗體中X坐標中較大者
y0: 窗體中Y坐標中較小者
y1: 窗體中Y坐標中較大者
返 回 值:無
*************************************************************/
static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
{
Init_data(WINDOW_XADDR_START,x0);
Init_data(WINDOW_XADDR_END,x1);
Init_data(WINDOW_YADDR_START,y0);
Init_data(WINDOW_YADDR_END,y1);
Init_data(GRAM_XADDR,x0);
Init_data(GRAM_YADDR,y0);
Write_Cmd (0x00,0x22);//LCD_WriteCMD(GRAMWR);
}
復制代碼
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
a级大片免费观看
|
色婷婷亚洲国产女人的天堂
|
能看的av网站
|
国产一级片一区二区三区
|
在线看亚洲
|
欧美一区二区三区久久精品视
|
日本不卡一区二区三区在线观看
|
日韩欧美三级
|
天堂久
|
成人免费观看视频
|
九色av
|
欧美不卡
|
中文字幕一区二区三区四区五区
|
久久99精品久久久久久国产越南
|
成人欧美
|
操视频网站
|
午夜欧美
|
91麻豆精品一区二区三区
|
亚洲精品免费视频
|
99资源
|
久久国产成人午夜av影院武则天
|
亚洲午夜网
|
91一区二区
|
涩在线
|
91久久久久久久久久久久久
|
天天天操天天天干
|
久久毛片
|
色在线看
|
日本电影韩国电影免费观看
|
黄网免费看
|
麻豆av在线
|
国产一区二区在线观看视频
|
国产精品久久久久久238
|
狠狠草视频
|
激情欧美一区二区三区中文字幕
|
亚洲 欧美 综合
|
免费观看一级特黄欧美大片
|
精品久久国产
|
日韩视频免费看
|
成av人电影在线
|
色www精品视频在线观看
|