?? 12864.c
字號:
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*軟件延時 Delay()*/
void Delay(unsigned int count)
{
unsigned char i;
while(--count != 0)
{
for(i = 0; i < 125; i++); // ";" 表示空語句,CPU空轉。
} // i 從0加到125,在12M晶體下CPU大概耗時1毫秒
}
/*LCM12864測忙函數 LCM12864_TestBusy()*/
void LCM12864_TestBusy(void)
{
LCM12864_RW = 1;
LCM12864_RS = 0;
LCM12864_E = 0;
LCM12864_E = 1;
while(LCM12864_DB7_DB0 & LCM12864_STATUS_BUSY);
}
/*寫指令到LCM12864 LCM12864_WriteCMD()*/
void LCM12864_WriteCMD(unsigned char LCM12864_command)
{ //LCM12864_command 欲寫入指令
LCM12864_TestBusy();
LCM12864_RW = 0; LCM12864_RS = 0;
LCM12864_DB7_DB0 = LCM12864_command;
LCM12864_E = 0;
LCM12864_E = 1;
LCM12864_TestBusy();
}
/*寫數據到LCM12864 LCM12864_WriteData()*/
void LCM12864_WriteData(unsigned char LCM12864_data)
{ //LCM12864_command 欲寫入數據
LCM12864_RW = 0; LCM12864_RS = 1;
LCM12864_DB7_DB0 = LCM12864_data;
LCM12864_E = 0;
LCM12864_E = 1;
LCM12864_TestBusy(); //讀LCM忙
}
/*向LCM12864填充數據 LCM12864_Fill_Screen()*/
void LCM12864_Fill_Screen( unsigned char t, //設置涮屏速度(為1不涮屏,默認為60)
unsigned char LCM12864_FillData)//欲寫入的數據
{
unsigned char x,y;
LCM12864_CS1 = 0;LCM12864_CS2 = 0; // 選中左半屏及右半屏
LCM12864_WriteCMD(LCM12864_START_ROW+0); // 設置顯示起始行為0
for(x=0;x<8;x++)
{
Delay(t); // 涮屏速度延時
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+x); // 設置頁地址
// // 設置列地址
for(y=0;y<64;y++)
{
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+y);
LCM12864_WriteData(LCM12864_FillData);
}
}
LCM12864_CS1 = 1; // 不選中右半屏
LCM12864_CS2 = 1; // 不選中右半屏
}
/*LCM12864清屏 LCM12864_Clear_Screen()*/
void LCM12864_Clear_Screen(void)
{
LCM12864_Fill_Screen(60,0x00); //寫入0到每個顯示區
}
/*顯示128*64圖片 LCM12864_Disp_Bitmap_12864()*/
void LCM12864_Disp_Bitmap_12864( unsigned char t, //設置涮屏速度(為1不涮屏,默認為60)
unsigned char code *bitmap_12864)//128*64點陣圖像所在數組表
{
unsigned char j,k;
for(k=0;k<8;k++)
{ //設置8頁的顯示
Delay(t);
LCM12864_CS1 = 0;LCM12864_CS2 = 1; //半屏選中
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+k); //選中頁
//選中列
for(j=0;j<64;j++)
{
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+j);
LCM12864_WriteData(bitmap_12864[k*128+j]); //開始寫入數據
}
LCM12864_CS1 = 1;LCM12864_CS2 = 0;
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+k);
for(j=64;j<128;j++)
{
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+j-64);
LCM12864_WriteData(bitmap_12864[k*128+j]);
}
}
}
/*在LCM12864的指定點顯示16*16點陣漢字 LCM12864_Disp_Chinese_16_16()*/
void LCM12864_Disp_Char_x_16(
unsigned char t, //設置書寫速度(為1直接顯示,默認為12)
unsigned char b, //輸入8:8*16字符,16:16*16字符
unsigned char LCM12864_page, //LCM12864的頁地址(0~7)
unsigned char LCM12864_col, //LCM12864的列地址(0~128)注意:右半屏起始是64
unsigned char *Char_x_16) //16*16點陣漢字字模(縱向取模,字節倒序)
{
unsigned char j=0,i=0;
if(LCM12864_col < 64 )
{
LCM12864_CS1 = 0; LCM12864_CS2 = 1; //判斷屏幕使能
}
else
{
LCM12864_CS1 = 1; LCM12864_CS2 = 0;
LCM12864_col = LCM12864_col - 64;
}
for(j=0;j<2;j++)
{
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+LCM12864_page+j);
for(i=0;i<b;i++)
{
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+LCM12864_col+i);
LCM12864_WriteData(Char_x_16[b*j+i]);
Delay(t);
}
}
}
/*用一個一維數組time[]來存儲時間,時間格式00:00:00*/
/*void disbuftime(void)
{
time[7]=second%10;
time[6]=second/10;
time[5]=10;
time[4]=minute%10;
time[3]=minute/10;
time[2]=10;
time[1]=hour%10;
time[0]=hour/10;
}*/
/*寫時間*/
/*void distime(unsigned char timecode)
{
unsigned char j=0,i=0;
LCM12864_CS1 = 0; LCM12864_CS2 = 1; //左屏
disbuftime();
for(j=6;j<8;j++)//頁
{
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+j);
for(i=0;i<8;i++)
{
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+i);
LCM12864_WriteData(timecode[time[i]][16]);
}
}
} */
/*LCM12864初始化 LCM12864_Init()*/
void LCM12864_Init(void)
{
LCM12864_RESET = 0; //復位
Delay(300);
LCM12864_RESET = 1;
Delay(300);
LCM12864_Clear_Screen(); //清除屏幕
LCM12864_CS1 = 0; LCM12864_CS2 = 0; //選中雙屏
LCM12864_WriteCMD(LCM12864_DISP_OFF); //關顯示
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+0); //第0頁位置
LCM12864_WriteCMD(LCM12864_START_ROW+0); //第0行
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+0); //第0列
LCM12864_WriteCMD(LCM12864_DISP_ON); //開顯示
/* TMOD = 0x01; // 定時器0,, 16位定時方式
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
hour=00;
minute=00;
second=00;
EA=1;
ET0=1;
TR0=1; */
}
/* 以上是 LCM12864液晶模塊驅動程序*/
/*LCM12864液晶模塊驅動演示 main()*/
void main (void)
{
unsigned char /*lx = 32,*/i;
LCM12864_Init(); // LCM12864初始化
while(1)
{
LCM12864_Disp_Bitmap_12864(60,tuxin); //顯示圖像
Delay(3000); //延時3秒
LCM12864_Clear_Screen(); //清除屏幕
LCM12864_Disp_Char_x_16(12,16,0,5,chuang);
Delay(500);
LCM12864_Disp_Char_x_16(12,16,0,25,xin);
Delay(500);
LCM12864_Disp_Char_x_16(12,16,0,45,shi);
Delay(500);
LCM12864_Disp_Char_x_16(12,16,0,65,ya);
Delay(500);
LCM12864_Disp_Char_x_16(12,16,0,85,si);
Delay(500);
for(i=0;i<3;i++)
{ //顯示字符串“Dy1286
LCM12864_Disp_Char_x_16(1,16,2,32+16*i,nAsciiDot+32*i); //顯示"12864",從第二行32列開始
// Delay(1000);
}
for(i=0;i<15;i++)
{
LCM12864_Disp_Char_x_16(12,8,4,8*i,Tel+16*i);
Delay(100);
}
// LCM12864_Disp_Char_x_8(6,0,timecode[time[i]][16]);
//Delay(1000);
}
}
/*定時器中斷0的方式1來處理時鐘顯示*/
/*void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==18)//每進入一次為1秒
{
count=0;
second++;
if(second==60)
{
second=0;
minute++;
if(minute==60)
{
minute=0;
hour++;
if(hour==24)
{
hour=0;
}
}
}
}
} */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -