51單片機(jī)12864打點(diǎn)程序
void curve(unsigned char xlable,unsigned char ylable,bit dot)
{
unsigned char H[1]={0};//讀RAM寄存
unsigned char L[1]={0};
unsigned char xbuf;
w_com(0x01);
w_com(0x34);
w_com(0x36); //功能設(shè)置:一次送8位數(shù)據(jù),擴(kuò)展指令集
xlable=xlable+xoffset;//求相對(duì)零點(diǎn)
ylable=ylable+yoffset;
if(xlable<0)xlable=-1;//超出邊界處理
if(ylable<0)ylable=0;
if(ylable>64)ylable=65;
xbuf=xlable%16;
xlable=xlable/16;
if(ylable>32)//上半屏
{
ylable=64-ylable;//切換上下屏
xbuf=15-xbuf;//x坐標(biāo)歸位
w_com(0x80|ylable); //輸入垂直地址
w_com(0x80|xlable); //輸入水平地址
read_RAM();//屏蔽
if(xbuf>7)
{
if(dot==0)
H[0]=read_RAM()&(~(1<
H[0]=read_RAM()|1<
}
else
{
H[0]=read_RAM();//插點(diǎn),需要打的點(diǎn)
if(dot==0)
L[0]=read_RAM()&(~(1<
L[0]=read_RAM()|1<
w_com(0x80|ylable); //輸入垂直地址
w_com(0x80|xlable); //輸入水平地址
w_byte(H[0]);
w_byte(L[0]);
}
else //下半屏
{
ylable=32-ylable;
xbuf=15-xbuf;//x坐標(biāo)歸位
w_com(0x80|ylable); //輸入垂直地址
w_com(0x88|xlable); //輸入水平地址
read_RAM();//屏蔽
if(xbuf>7)
{
if(dot==0)
H[0]=read_RAM()&(~(1<
H[0]=read_RAM()|1<
}
else
{
H[0]=read_RAM();//插點(diǎn),需要打的點(diǎn)
if(dot==0)
L[0]=read_RAM()&(~(1<
L[0]=read_RAM()|1<
w_com(0x80|ylable); //輸入垂直地址
w_com(0x88|xlable); //輸入水平地址
w_byte(H[0]);
w_byte(L[0]);
}
}
//清除屏幕
void BMP_clear( void )
{
unsigned char i,j;unsigned char L[1]={0};
w_com(0x34); //8Bit擴(kuò)充指令集,即使是36H也要寫兩次
w_com(0x36); //繪圖ON,基本指令集里面36H不能開繪圖
for(i=0;i<32;i++) //12864實(shí)際為256x32
{
w_com(0x80|i); //行位置
w_com(0x80); //列位置
for(j=0;j<32;j++) //256/8=32 byte
w_byte(L[0]);
}
}