智能型充电器的设计 下载本文

潍坊学院本科毕业设计

break; }

PORTA &=~ (1<

PORTB=0xFF;

PORTA |= (1<

PORTC |= (1<

//读LCD数据

unsigned char ReadDat(unsigned char area,unsigned char dat) {

//area=0-->left;1-->mid;2-->right //area=[csa,csb]00:L 01:M 10:R unsigned char lcd_busy; switch(area) { case 0:

PORTA &=~ (1<

25

潍坊学院本科毕业设计

break; case 1:

PORTA &=~ (1<

PORTA |= (1<

PORTA |= (1<

PORTA &=~ (1<

PORTC &=~ (1<

PORTB=0xFF; PORTA |= (1<

PORTC |= (1<

26

潍坊学院本科毕业设计

return(dat); }

//LCD初始化 void lcd_ini(void) {

unsigned char i; for (i=0;i<3;i++) {

WriteCom(i,0xC0); WriteCom(i,0x3F); } }

//清除LCD屏 void lcd_clr() {

int r4,r3,a,area; int wData=0; r4=0; do{ a=r4; a=a|0xb8;

for(area=0;area<3;area++) WriteCom(area,a); for(area=0;area<3;area++) WriteCom(area,0x40); x40; do{

for(area=0;area<3;area++) WriteDat(area,wData); r3--;

27

潍坊学院本科毕业设计

}while(r3!=0); r4++; }while(r4!=8); }

void dis(int lr,int x,int y,int data) for (i=0;i<8;i++) for(j=0;j<8;j++)

oDat[i][j]=hz_matrix[8+j+16*(i+8)]; for (i=0;i<8;i++) {nDat[i]=0; for(j=0;j<8;j++)

nDat[i]=nDat[i]+oDat[j][i]*sgl(2,j); dis(lr,x+1,y+8+i,nDat[i]); wrleftcom(0x3f);} fclose (fp); free (hz_matrix); }

28