?? ag12864c.txt
字號:
set_adr(j,0);
for(k=0;k<64;k++)
{
wdata((*np&rbits)|(~rbits&fdata),0,1);
np++;
}
}
rbits =0xff;
np -=0x400;
delay(0x4000);
}
}
void wcode(unsigned char c,bit cs1,bit cs2)
{
CS1 =cs1;
CS2 =cs2;
RS =0;
RW =0;
Ena =0;
Databus =c;
Ena =1;
_nop_();
Ena =0;
_nop_();
}
void wdata(unsigned char c,bit cs1,bit cs2)
{
CS1 =cs1;
CS2 =cs2;
RS =1;
RW =0;
Ena =0;
Databus =c;
Ena =1;
_nop_();
Ena =0;
_nop_();
}
void set_startline(unsigned char i)
{
i +=0xc0;
wcode(i,1,1);
}
void set_adr(unsigned char x,unsigned char y)
{
x +=0xb8;
y +=0x40;
wcode(x,1,1);
wcode(y,1,1);
}
二:
//這是點陣LCD顯示程序。
#include <REG52.h>
#include <absacc.h>
#include <INTRINS.H>
#include <ZIMO.H> //字庫
//===世紀開發網出品,請尊重作者,轉載請保持以下信息。=====
//==神龍編寫:世紀開發網(http://www.21kf.com)=============
//========================================================
struct
{unsigned char db;
} dbao[6];
struct
{unsigned char df;
} dbuf[6];
//unsigned char d1,d2,d3,d4,d5,d6;
//unsigned char dbuf1,dbuf2,dbuf3,dbuf4,dbuf5,dbuf6;
unsigned int count_int;
sfr databus =0x90; //P1口腳;
sbit resetpin=P3^2; //復位腳;
sbit cs2pin =P3^3; //IC2的片選信號腳;
sbit cs1pin =P3^4; //IC1的片選信號腳;
sbit epin =P3^5; //使能腳;
sbit r_wpin =P3^6; //讀;
sbit d_ipin =P3^7; //寫;
sbit cso1 =P0^0; //--IC1-- 送數據片選信號位
sbit cso2 =P0^1; //--IC2-- 送數據片選信號位
sbit cso3 =P0^2; //--IC3-- 送數據片選信號位
sbit sw =P0^3; //按鍵
//---------------------------------------
/*****************************這是一MS的延時程序。****************/
//延時子程序。
void delay(unsigned int v) // 10us delay
{
while(v!=0) v--;
}
/*-----------------------------------------------------------------------------*/
//延時程序///////////////////////////////////////////////////
void Delay2 (unsigned int x)
{
unsigned char y;
while(x--)
{
for(y=0;y<=120;y++);
}
}
//######################################################################
//以下寫LCD子程序
//----------復位信號子程序。
void reset()
{resetpin=0;delay(20);resetpin=1;delay(20);}
//----------寫代碼(命令)指令子程序.
void wcode(unsigned char c,cs1,cs2)
{
cs1pin=cs1; cs2pin=cs2; d_ipin=0; r_wpin=0; databus=c;
epin=0; delay(5); epin=1; delay(5); epin=0;
}
//----------寫數據指令子程序.
void wdata(unsigned char c,cs1,cs2)
{
cs1pin=cs1; cs2pin=cs2; d_ipin=1; r_wpin=0; databus=c;
epin=0; delay(5); epin=1; delay(5); epin=0;
}
//----------設置顯示開始子程序.
void set_startline(unsigned char i)
{
i=0xc0+i;
wcode(i,1,1);
}
//-----------設置顯示具體子程序.
void set_adr(unsigned char x,y)
{
x=x+0xb8;y=y+0x40;
wcode(x,1,1);
wcode(y,1,1);
}
//-----------顯示ON/OFF子程序.
void dison_off(unsigned char o)
{
o=o+0x3e;
wcode(o,1,1);
}
//====================================
/* x---------行數據(最大值是64/16=4行). (調用值:0~3)
Y---------列數據(最大值是128個字). (調用值:0~128)
P---------指向寫入數據首地址指針. (調用值:數組名)
longness--寫入字的個數 (調用值漢字最大8,數字最大16)
falg1-----寫入漢字\數字、字母標記 (漢字 1, 字或字母 0)
flag2-----反白標記 (正常 0, 反白顯示 1) */
void write_lcd(unsigned char x,
unsigned char y,
unsigned char *p,
unsigned char longness,
unsigned char flag1,
unsigned char flag2 )
{
unsigned char c,d;
flag1=8+8*flag1;
d=y;
for(;longness!=0;longness--) //longness是寫入字的個數,即是程序執行的次數
{
if(y>=64)
{d=y-64;}
set_adr(x*2,d); //設置要寫的地址,即X頁Y列
for(c=0;c<flag1;c++) //
{ //
if(y>=64) //
{ //
// if(flag2) {wdata(~(*(p++)),0,1);} //----IC2--右-----反白
// else{
wdata(*(p++),0,1);
//} //
} //
else { //
// if(flag2) {wdata(~(*(p++)),1,0);} // 反白
// else{
wdata(*(p++),1,0);
// } //寫入IC1即左半屏
} //
} //字的上半部分
//-----------------------------------------------
set_adr(x*2+1,d); // //這是寫入一個漢字
for(c=0;c<flag1;c++) //
{ //
if(y>=64) //
{ //
// if(flag2) {wdata(~(*(p++)),0,1);} //----IC2---右-------反白
// else{
wdata(*(p++),0,1);
// } //
} //
else { //
// if(flag2) {wdata(~(*(p++)),1,0);} //---反白
// else {
wdata(*(p++),1,0);
// } //寫入IC1 即左半屏
} //
} //字的下半部分
y=y+flag1;
d=d+flag1;
}
dison_off(1);
}
//===============================================
//以下查數字顯示表.
void writenum0_9(unsigned char x,unsigned char y,unsigned char num,unsigned char l,unsigned char k,unsigned char j)
{
switch(num)
{
case 0: {write_lcd(x, y, num_0, l, k,j);} break;
case 1: {write_lcd(x, y, num_1, l, k,j);} break;
case 2: {write_lcd(x, y, num_2, l, k,j);} break;
case 3: {write_lcd(x, y, num_3, l, k,j);} break;
case 4: {write_lcd(x, y, num_4, l, k,j);} break;
case 5: {write_lcd(x, y, num_5, l, k,j);} break;
case 6: {write_lcd(x, y, num_6, l, k,j);} break;
case 7: {write_lcd(x, y, num_7, l, k,j);} break;
case 8: {write_lcd(x, y, num_8, l, k,j);} break;
case 9: {write_lcd(x, y, num_9, l, k,j);} break;
default: {write_lcd(x, y, num_0, l, k,j);} break;
}
}
//#########################################################
//界面1每行處理子程序(共4行)以下是頁面1處理子程序.
void line_1_1() //----------2-line
{
write_lcd (0,0, nian, 1, 1, 0); //--電 16
write_lcd (0,24, ri, 1, 1, 0); //--壓 32
write_lcd (0,40, e1, 1, 1, 0); //--: 48
write_lcd (0,47,bc0, 1, 0, 0); //--|
write_lcd (1,0,AA2, 1, 0, 0); //--A 48
write_lcd (1,8,b1, 1, 1, 0); //--、
writenum0_9(1,16, 2, 1, 0, 0); //--2
writenum0_9(1,24, 2, 1, 0, 0); //--2
writenum0_9(1,32,0, 1, 0, 0); //--0 16
write_lcd (1,40,V1, 1, 0, 0); //--v
write_lcd (1,47,bc0, 1, 0, 0); //--|
write_lcd (2,0,AB2, 1, 0, 0); //--B 48
write_lcd (2,8,b1, 1, 1, 0); //--、
writenum0_9(2,16, 2, 1, 0, 0); //--2
writenum0_9(2,24, 2, 1, 0, 0); //--2
writenum0_9(2,32,0, 1, 0, 0); //--0 16
write_lcd (2,40,V1, 1, 0, 0); //--v
write_lcd (2,47,bc0, 1, 0, 0); //--|
write_lcd (3,0,AC2, 1, 0, 0); //--C 48
write_lcd (3,8,b1, 1, 1, 0); //--、
writenum0_9(3,16, 2, 1, 0, 0); //--2
writenum0_9(3,24, 2, 1, 0, 0); //--2
writenum0_9(3,32,0, 1, 0, 0); //--0 16
write_lcd (3,40,V1, 1, 0, 0); //--V
write_lcd (3,47,bc0, 1, 0, 0); //--|
}
//111111111111111111111
//以下是頁面1處理子程序.
void page_1_dispose()
{
line_1_1();
dison_off(1);
}
//#####################
//33333333333333333333333333333333333333333333333333333333333333333333333333333
//33333333333333333333333333333333333333333333333333333333333333333333333333333
//---------------------------
void clsall (unsigned char y) //清屏子程序。
{
unsigned char x;
for(;y<4;y++)
{
for(x=0;x<129;x+=16)
{
write_lcd (y,x, not, 1, 1, 0); //空0.5格 16
}
}
}
//============================================================
//---------------------------
//---------------------------
void Display_v (unsigned char x,unsigned char y)
//調用類型,X,代表第幾個橫,Y代表顯示多少。
{
unsigned char vo,vl,nt,nt1;
unsigned char xy,yx;
if(x==1){yx=56;}
if(x==2){yx=68;}
if(x==3){yx=80;}
if(x==4){yx=92;}
if(x==5){yx=104;}
if(x==6){yx=116;}
vo=y/4;
vl=y%4;
nt=vo;
for(;nt<4;nt++)
{nt1=3-nt;
write_lcd (nt1,yx,notn, 1, 0, 0);
}
xy=3;
if(vo==1){write_lcd (3,yx,bc1, 1, 0, 0);xy=2;}
if(vo==2){write_lcd (2,yx,bc1, 1, 0, 0);xy=1;}
if(vo==3){write_lcd (1,yx,bc1, 1, 0, 0);xy=0;}
if(vo==4){write_lcd (0,yx,bc1, 1, 0, 0);}
//=================
if(vl==1){write_lcd (xy,yx,bc4, 1, 0, 0);}
if(vl==2){write_lcd (xy,yx,bc3, 1, 0, 0);}
if(vl==3){write_lcd (xy,yx,bc2, 1, 0, 0);}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -