?? ht1622.bak
字號:
#include <stdio.h>
#include <intrins.h>
#include <reg52.h>
sbit CS1=P3^7;
sbit WRR=P3^6;
sbit DI=P2^1;
sbit GO1=P2^4;
sbit GO2=P2^5;
sbit SL=P2^3;
void Delay(unsigned int i)
{
unsigned char a;
unsigned int b;
for(b=0;b<i;b++)
for(a=0;a<255;a++);
}
bit Wait()
{
bit GO=0;
while(1)
{
if(GO1==0||GO2==0)
{
if(GO2==0)GO=1;
Delay(250);
while(GO1==0||GO2==0);
return GO;
}
}
}
Write()
{
WRR=1;
_nop_();
_nop_();
WRR=0;
_nop_();
_nop_();
}
void write_cmd(unsigned char cmd)
{
unsigned char j,mask;
CS1=0;
WRR=0;
DI=1;
Write();
DI=0;
Write();
DI=0;
Write();
for(j=0, mask=0x80; j<8; j++, mask>>=1 )
{
if( (cmd & mask) != 0 )
DI=1;
else
DI=0;
Write();
}
Write();
CS1=1;
}
void write_dat(unsigned char add,unsigned char dat)
{
unsigned char j,mask;
CS1=0;
WRR=0;
DI=1;
Write();
DI=0;
Write();
DI=1;
Write();
for(j=0, mask=0x20; j<6; j++, mask>>=1 )
{
if(( add & mask)!=0 )
DI=1;
else
DI=0;
Write();
}
for(j=0, mask=0x01; j<4; j++, mask<<=1 )
{
if(( dat & mask) != 0 )
DI=1;
else
DI=0;
Write();
}
CS1=1;
}
void ht1622initial(void)
{
write_cmd(0x01); //SYS EN
write_cmd(0x18); //RC 256k
write_cmd(0x03); //LCD ON
write_cmd(0xe3); //BIAS
}
void Display(unsigned char d)
{
unsigned char i;
for(i=0;i<64;i++)
write_dat(i,d);
}
display_point()
{
unsigned char n=0;
while(1)
{
Display(0x00);
write_dat(n/4,0x01<<(n%4));
if(Wait()==1)
if(n==0)n=255;
else n--;
else
if(n==255)n=0;
else n++ ;
}
}
void main(void)
{
ht1622initial();
if(SL==0)
{
Display(0xff);
Wait();
Display(0x00);
Wait();
display_point();
Wait();
}
else
{
Display1(0xff);
Wait();
Display1(0x00);
Wait();
Display_point1();
Wait();
}
while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -