<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)總線驅(qū)動(dòng)

          51單片機(jī)總線驅(qū)動(dòng)

          作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
          /*****************************************用畫(huà)點(diǎn)的方式畫(huà)豎線*****************************************/void erect(uchar y0,uchar y1,uchar x){uchar temp,n;if(y0>y1){temp=y0;y0=y1;y1=temp;}n=y1-y0;for(;n>0;n--){sel_point(x,y0+n);}}/*******************************************************布蘭森漢姆(Bresenham)算法畫(huà)線 兩端點(diǎn)(x0,y0) (x1,y1)*******************************************************/void Draw_line(uchar x0,uchar y0,uchar x1,uchar y1){int dx,dy; //定義X.Y軸上增加的變量值int sub;int temp; //起點(diǎn)、終點(diǎn)大小比較,交換數(shù)據(jù)時(shí)的中間變量uchar flag;if(x0>x1) //X軸上,起點(diǎn)大于終點(diǎn),交換數(shù)據(jù){temp=x1;x1=x0;x0=temp; temp=y1;y1=y0;y0=temp; } dx=x1-x0; //X軸方向上的增量dy=y1-y0; //Y軸方向上的增量if(dx==0) erect(y0,y1,x0);if(dy==0) rhorizontal(x0,x1,y0);if(dy>0)flag=1;elseflag=0;if((dx!=0)&&(dy!=0)){// 布蘭森漢姆(Bresenham)算法畫(huà)線 /if(flag==1){if(dx>=dy) //*近X軸{sub=2*dy-dx; //計(jì)算下個(gè)點(diǎn)的位置 while(x0!=x1){sel_point(x0,y0); //畫(huà)起點(diǎn)x0++; // X軸上加1if(sub>0) // 判斷下下個(gè)點(diǎn)的位置{y0++; // 為右上相鄰點(diǎn),即(x0+1,y0+1)sub+=2*dy-2*dx;}else sub+=2*dy; // 判斷下下個(gè)點(diǎn)的位置 }sel_point(x0,y0);}else{sub=2*dy-dx; //*近Y軸 while(y0!=y1){sel_point(x0,y0); //畫(huà)起點(diǎn)y0++; if(sub>0) //判斷下下個(gè)點(diǎn)的位置{x0++; sub+=2*dx-2*dy;}elsesub+=2*dx;}sel_point(x0,y0);}}else{dy=y0-y1;if(dx>=dy) //*近X軸{sub=2*dy-dx; //計(jì)算下個(gè)點(diǎn)的位置 while(x0!=x1){sel_point(x0,y0); //畫(huà)起點(diǎn)x0++; // X軸上加1if(sub>0) // 判斷下下個(gè)點(diǎn)的位置{y0--; // 為右上相鄰點(diǎn),即(x0+1,y0+1)sub+=2*dy-2*dx;}else sub+=2*dy; // 判斷下下個(gè)點(diǎn)的位置 }sel_point(x0,y0);}else{sub=2*dx-dy; //*近Y軸 while(y0!=y1){sel_point(x0,y0); //畫(huà)起點(diǎn)y0--; if(sub>0) //判斷下下個(gè)點(diǎn)的位置{x0++; sub+=2*dx-2*dy;}elsesub+=2*dx;}sel_point(x0,y0);}}} }/****************************************************畫(huà)圓 圓點(diǎn)(x,y) 半徑 r****************************************************/void draw_circle(int x, int y, int r){int a, b, num;a = 0;b = r;while(2 * b * b >= r * r) // 1/8圓即可{sel_point(x + a, y - b); // 0~1sel_point(x - a, y - b); // 0~7sel_point(x - a, y + b); // 4~5sel_point(x + a, y + b); // 4~3sel_point(x + b, y + a); // 2~3sel_point(x + b, y - a); // 2~1sel_point(x - b, y - a); // 6~7sel_point(x - b, y + a); // 6~5a++;num = (a * a + b * b) - r*r;if(num > 0){b--;a--;}}}void lcd_init(){lcd_writecom_two(0x00,0x00,0x24);lcd_writecom_two(0x00,0x00,0x21);lcd_writecom_two(0x00,0x00,0x42);lcd_writecom_two(0x28,0x00,0x43);//28lcd_writecom_two(0x00,0x00,0x40);lcd_writecom_two(0x01e,0x00,0x41);//1elcd_writecom(0xa0);lcd_writecom(0x98);lcd_writecom(0x80);}main(){unsigned char i;lcd_init();Draw_line(0,0,239,127);Draw_line(0,127,239,0);Draw_line(0,0,239,0);Draw_line(0,127,239,127);Draw_line(0,0,0,127);Draw_line(239,0,239,127);while(1){for(i=60;i<150;i++)draw_circle(i,64, 60);}}
          上一頁(yè) 1 2 3 4 下一頁(yè)

          關(guān)鍵詞: 51單片機(jī)總線驅(qū)

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();