新聞中心

ks0108驅動

作者: 時間:2016-11-29 來源:網(wǎng)絡 收藏
/**********************************************************************************************5*8ascii 點整
***********************************************************************************************/ void write_english5_8(uchar x, uchar y,uchar ascii) { uchar n,*p; p = (unsigned char*)chardot_5x8[ascii- ]; y= y+x/21; x = x%21; if(x!=10) { if(x<10){choose(0);x*=6;} else {choose(1);x=x*6-64;} lcd_code(0xb8+y); lcd_code(0x40+x); lcd_wram(0x00); for(n=0;n<5;n++) { lcd_wram(*p++); } } else { choose(0); lcd_code(0xb8+y); lcd_code(0x40+60); lcd_wram(0x00); for(n=0;n<3;n++) { lcd_wram(*p++); } choose(1); lcd_code(0xb8+y); lcd_code(0x40); lcd_wram(*p++); lcd_wram(*p++); } } void Display_Locate(uchar x,uchar y,uchar dat) { uchar y_temp,x_temp; y_temp = y+(x/128); x_temp = x&0x7f; if(x_temp>63){choose(1);x_temp -=64;} else choose(0); lcd_code(0xb8+y_temp); lcd_code(0x40+x_temp); lcd_wram(dat); } void write_word8_8(uchar page, uchar row, uchar *adr) { uchar n; if(row>15){page=page+row/16;row=row%16;} if(row<8){choose(0); row=row<<3; } else {choose(1);row=(row-8)<<3; } lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<8;n++) { lcd_wram(*(adr+n)); } } void write_word16_16(uchar page, uchar row, uchar *adr) { uchar n; if(row>7){page=page+row/8;row=row%8;} { if(row<4){choose(0); row=row<<4; } else {choose(1);row=(row-4)<<4; } page=page<<1; // 4 兩行顯示一字 lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<16;n++) lcd_wram(*(adr+n)); //上半部分 lcd_code(0xb9+page); lcd_code(0x40+row); for(n=16;n<32;n++) lcd_wram(*(adr+n)); } //下半部分 } void write_word8_16(uchar page, uchar row, uchar *adr) { uchar n; if(row>15){page=page+row/16;row=row%16;} if(row<8){choose(0); row=row<<3; } else {choose(1);row=(row-8)<<3; } page=page<<1; // 4 兩行顯示一字 lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<8;n++) { lcd_wram(*(adr+n)); } //上半部分 lcd_code(0xb9+page); lcd_code(0x40+row); for(n=8;n<16;n++) { lcd_wram(*(adr+n)); } } void lcd_busy(void) { unsigned char ac; RS(0); RW(1); E(0); LATD = 0X00; PORTDD_IN; do { E(1); Delay_us(1); ac=PORTD_IN; ac&=0x80; ac&=0x80;////////////延時 E(0); }while(ac==0x80); E(0); } void lcd_code(char Data) { lcd_busy(); E(0); RS(0); RW(0); PORTDD_OUT; E(1); PORT_D=Data; Delay_us(1); E(0); } void lcd_wram(char Data) { lcd_busy(); E(0); RS(1); RW(0); PORTDD_OUT; E(1); PORT_D=Data; Delay_us(1); E(0); LATD = 0X00; } uchar lcd_rram(uchar page,uchar arrange) //page頁地址.arrange列地址) { uchar dat; lcd_code(page+0xb8); lcd_code(arrange+0x40); E(0); RW(1); RS(1); LATD = 0X00; PORTDD_IN; E(1); Delay_us(2); E(0); //12864讀數(shù)據(jù)時第二次讀才有效,第一次讀取的值不采集 Delay_us(2); E(1); dat=PORTD_IN; Delay_us(2); E(0); return(dat); } void choose(uchar n) { switch(n) { case 0:C1(0);C2(1);break; case 1:C1(1);C2(0);break; case 2:C1(0);C2(0);break; default:break; } } void clear12864(void) // 清屏 { uchar page,row; choose(2); for(page=0xb8;page<0xc0;page++) { lcd_code(page); lcd_code(0x40); for(row=0;row<64;row++) { lcd_wram(0x00); } } } void write_word8_16(uchar page, uchar row, uchar *adr) { uchar n; if(row>15){page=page+row/16;row=row%16;} if(row<8){choose(0); row=row<<3; } else {choose(1);row=(row-8)<<3; } page=page<<1; // 4 兩行顯示一字 lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<8;n++) { lcd_wram(*(adr+n)); } //上半部分 lcd_code(0xb9+page); lcd_code(0x40+row); for(n=8;n<16;n++) { lcd_wram(*(adr+n)); } } void write_word8_8(uchar page, uchar row, uchar *adr) { uchar n; if(row>15){page=page+row/16;row=row%16;} if(row<8){choose(0); row=row<<3; } else {choose(1);row=(row-8)<<3; } lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<8;n++) { lcd_wram(*(adr+n)); } } void write_word16_16(uchar page, uchar row, uchar *adr) { uchar n; if(row>7){page=page+row/8;row=row%8;} { if(row<4){choose(0); row=row<<4; } else {choose(1);row=(row-4)<<4; } page=page<<1; // 4 兩行顯示一字 lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<16;n++) lcd_wram(*(adr+n)); //上半部分 lcd_code(0xb9+page); lcd_code(0x40+row); for(n=16;n<32;n++) lcd_wram(*(adr+n)); } //下半部分 } /*void write_word32(uchar page, uchar row, uchar *adr) { uchar n; if(row>3){page=page+row/4;row=row%4;} if(row<2) { row=row<<5; choose(0);} else {choose(1); row=(row-2)<<5; } page=page<<2; lcd_code(0xb8+page); lcd_code(0x40+row); for(n=0;n<32;n++) lcd_wram(*(adr+n)); lcd_code(0xb9+page); lcd_code(0x40+row); for(n=32;n<64;n++) lcd_wram(*(adr+n)); lcd_code(0xba+page); lcd_code(0x40+row); for(n=64;n<96;n++) lcd_wram(*(adr+n)); lcd_code(0xbb+page); lcd_code(0x40+row); for(n=96;n<128;n++) lcd_wram(*(adr+n)); } */ /*void play_photos(char *adr) { uchar n,z; clear12864(); for(z=0;z<8;z++) { for(n=0;n<128;n++) { if(n<64) { choose(0); lcd_code(0x40+n); lcd_code(0xb8+z); lcd_wram(*(adr+n+(z<<7))); } else { choose(1); lcd_code(0x40+n-64); lcd_code(0xb8+z); lcd_wram(*(adr+n+(z<<7))); } } } } */ //顯示一個點x=0~127 y=0~63; void display1(uchar x,uchar y) { uchar dat; if(x>63){choose(1);x=x-64;} else{choose(0);} dat =lcd_rram(y/8,x); lcd_code(0xb8+y/8); lcd_code(0x40+x); lcd_wram(dat|(1<63){choose(1);x=x-64;} else{choose(0);} dat =lcd_rram(y/8,x); lcd_code(0xb8+y/8); lcd_code(0x40+x); lcd_wram(dat&(~(1<
上一頁 1 2 下一頁

關鍵詞: ks0108驅

評論


技術專區(qū)

關閉