《LCD画线函数.docx》由会员分享,可在线阅读,更多相关《LCD画线函数.docx(2页珍藏版)》请在第一文库网上搜索。
1、Iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiihiiiiiiiiiiiiiiiiiiiiii/来自/画线程序,适合单色1CD屏/驱动板VT1335bVT6448bVT4832b/入口程序:draw1INE(unsignedintx1,y1,x2,y2);/起点(x1,y1),终点(x2,y2),以象素为单位/1CD屏左上角为坐标原点/Iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii#inc1ude#inc1ude#defineX.ADDRXBYTEOxOOOO#defineY.ADDRXBYTE0x01
2、00#defineCMDXBYTE0x0200#defineDATXBYTEOxO3OO声明程序draw_point(unsignedintx,unsignedinty);draw1INE(unsignedintx1,y1,x2,y2);draw1INE(unsignedintx1,unsignedinty1,unsignedintx2,unsignedinty2)(unsignedintx,y;unsignedintd_x,d_y;/d_x=x2-x1;d_y=y2-y1;interr=O;unsignedCHARTEMP=O:if(y2x2)x=x1;x1=x2;x2=x;Jfor(x=x
3、1;x=xDITEMP=Iidx=x2-x1Je1sed_x=x1-x2;x=x1;y=y1;draw_point(x,y);if(TEMP(dy=dx)whi1e(x!=x2)if(errd_x)whi1e(y!=y2)d_x=x2-x;d_y=y2-y;if(errO)x=x+1;y=y+1;err=err+d_y-d_x;)e1sey=y+1;err=err-d_x;Jdraw_point(x,y);e1seif(!TEMP&(d_y=d_x)whi1e(x!=x2)d_x=x-x2;d_y=y2-y;if(errd_x)whi1e(y!=y2)d_x=x-x2;d_y=y2-y;if(err255)CMD=0x14;eiseCMD=0x04;TEMP=DAT:i=Ox8O;i=(i(x%8);TEMP=(TEMPIi):Y_ADDR=y;X_ADDR=x/8;if(y255)CMD=0x14;e!seCMD=0x04;DAT=TEMP;/*draw1INEend*调用举例main()draw1INE(OO150J50);/(0,0)-(150,150)