




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
第頁//lcd.h寄存器定義,參照上個程序
#include"lcd.h"void(*printf)(char*,...)=0x33f9291C;
staticunsignedshort*fb=0x32000000;//數(shù)據(jù)手冊413頁
//5:6:5格式,去除低位可以減少誤差
#defineRGB565(r,g,b)((r>>3)<<11|(g>>2)<<5|(b>>3))voidclr_fb(void);
voidfill_fb(intstart_x,intend_x,intstart_y,intend_y,unsignedshortval);
voiddraw_point(intx,inty,intclor);
voiddraw_line(intx1,inty1,intx2,inty2,intcolor);
voiddraw_circle(intx,inty,intr,intcolor);void_start(void)
{
//LCD初始化,參照上個程序
init_lcd();//startlcd
LCDCON1|=ENVID(1);
LCDCON5|=PWREN(1);//清屏幕
clr_fb();//畫奧運(yùn)5色環(huán)
draw_circle(35,35,35,RGB565(0,0,255));
draw_circle(115,35,35,RGB565(0,255,255));
draw_circle(195,35,35,RGB565(255,0,0));
draw_circle(70,70,35,RGB565(255,255,0));
draw_circle(150,70,35,RGB565(0,255,0));//畫奧運(yùn)下面的正四方形
draw_line(90,150,140,150,RGB565(255,0,255));
draw_line(90,150,90,200,RGB565(255,0,255));
draw_line(90,200,140,200,RGB565(255,0,255));
draw_line(140,150,140,200,RGB565(255,0,255));
//畫奧運(yùn)下面的斜45度四方形
draw_line(115,140,80,175,RGB565(255,0,255));
draw_line(80,175,115,210,RGB565(255,0,255));
draw_line(115,210,150,175,RGB565(255,0,255));
draw_line(150,175,115,140,RGB565(255,0,255));//畫縱坐標(biāo)
draw_line(250,250,479,250,RGB565(255,255,0));
draw_line(479,250,465,240,RGB565(255,255,0));
draw_line(479,250,465,260,RGB565(255,255,0));
//畫橫坐標(biāo)
draw_line(250,1,250,250,RGB565(255,255,0));
draw_line(250,1,240,15,RGB565(255,255,0));
draw_line(250,1,260,15,RGB565(255,255,0));//畫條形
fill_fb(280,320,100,250,RGB565(255,0,0));
fill_fb(320,340,120,250,RGB565(0,200,0));fill_fb(380,420,50,250,RGB565(255,0,255));
fill_fb(420,440,150,250,RGB565(0,255,255));
printf("hellolcd\n");
}//畫點函數(shù)。參數(shù):坐標(biāo),顏色
voiddraw_point(intx,inty,intclor)
{
fb[y*480+x]=clor;
}//畫圓函數(shù)。參數(shù):圓心,半徑,顏色
//畫1/8圓然后其他7/8對稱畫
//>X
//|(0,0)0
//|71
//|62
//|53
//(Y)V4
//
//L=x^2+y^2-r^2
voiddraw_circle(intx,inty,intr,intcolor)
{
inta,b,num;
a=0;
b=r;
while(2*b*b>=r*r)//1/8圓即可
{
draw_point(x+a,y-b,color);//0~1
draw_point(x-a,y-b,color);//0~7
draw_point(x-a,y+b,color);//4~5
draw_point(x+a,y+b,color);//4~3draw_point(x+b,y+a,color);//2~3
draw_point(x+b,y-a,color);//2~1
draw_point(x-b,y-a,color);//6~7
draw_point(x-b,y+a,color);//6~5
a++;
num=(a*a+b*b)-r*r;
if(num>0)
{
b--;
a--;
}
}
}//畫線。參數(shù):起始坐標(biāo),終點坐標(biāo),顏色
voiddraw_line(intx1,inty1,intx2,inty2,intcolor)
{
intdx,dy,e;
dx=x2-x1;
dy=y2-y1;
if(dx>=0)
{
if(dy>=0)//dy>=0
{
if(dx>=dy)//1/8octant
{
e=dy-dx/2;
while(x1<=x2)
{
draw_point(x1,y1,color);
if(e>0){y1+=1;e-=dx;}
x1+=1;
e+=dy;
}
}
else//2/8octant
{
e=dx-dy/2;
while(y1<=y2)
{
draw_point(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else//dy<0
{
dy=-dy;//dy=abs(dy)
if(dx>=dy)//8/8octant
{
e=dy-dx/2;
while(x1<=x2)
{
draw_point(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1+=1;
e+=dy;
}
}
else//7/8octant
{
e=dx-dy/2;
while(y1>=y2)
{
draw_point(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
else//dx<0
{
dx=-dx;//dx=abs(dx)
if(dy>=0)//dy>=0
{
if(dx>=dy)//4/8octant
{
e=dy-dx/2;
while(x1>=x2)
{
draw_point(x1,y1,color);
if(e>0){y1+=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else//3/8octant
{
e=dx-dy/2;
while(y1<=y2)
{
draw_point(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else//dy<0
{
dy=-dy;//dy=abs(dy)
if(dx>=dy)//5/8octant
{
e=dy-dx/2;
while(x1>=x2)
{
draw_point(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else//6/8octant
{
e=dx-dy/2;
while(y1>=y2)
{
draw_point(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
}//區(qū)域填色函數(shù)
//參數(shù):開始列數(shù),結(jié)束列數(shù),開始行數(shù),結(jié)束行數(shù),顏色
voidfill_fb(intstart_x,intend_x,intstart_y,intend_y,unsignedshortval)
{
inti,j;
fo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 樓盤特價活動方案
- 歌詞活動教育活動方案
- 泉州版畫活動方案
- 植樹作文系列活動方案
- 桂林蛋糕活動策劃方案
- 樓盤植物活動方案
- 求婚鉆戒活動方案
- 檢修期間活動方案
- 民謠故事會交友活動方案
- 武館開學(xué)儀式活動方案
- GB/T 16451-2008天然脂肪醇
- GB 5013.2-1997額定電壓450/750V及以下橡皮絕緣電纜第2部分:試驗方法
- 山東省中小學(xué)校檔案管理暫行辦法
- 普通高中物理課程標(biāo)準(zhǔn)
- 國家開放大學(xué)《監(jiān)督學(xué)》形考任務(wù)( 1-4)試題和答案解析
- 完工付款最終付款申請表
- 人工動靜脈內(nèi)瘺
- 新版(七步法案例)PFMEA
- 慢阻肺隨訪記錄表正式版
- 廣西大學(xué)數(shù)學(xué)建模競賽選拔賽題目
- 受戒申請表(共3頁)
評論
0/150
提交評論