版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第页//lcd.h寄存器定义,参照上个程序
#include"lcd.h"void(*printf)(char*,...)=0x33f9291C;
staticunsignedshort*fb=0x32000000;//数据手册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();//画奥运5色环
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));//画奥运下面的正四方形
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));
//画奥运下面的斜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));//画纵坐标
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));
//画横坐标
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");
}//画点函数。参数:坐标,颜色
voiddraw_point(intx,inty,intclor)
{
fb[y*480+x]=clor;
}//画圆函数。参数:圆心,半径,颜色
//画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--;
}
}
}//画线。参数:起始坐标,终点坐标,颜色
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;
}
}
}
}
}//区域填色函数
//参数:开始列数,结束列数,开始行数,结束行数,颜色
voidfill_fb(intstart_x,intend_x,intstart_y,intend_y,unsignedshortval)
{
inti,j;
fo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年大学第二学年(眼科临床)诊疗技术阶段测试题及答案
- 2025年大学大四(餐饮管理)运营管理毕业测试试题及答案
- 2025年大学劳动与社会保障(社保研究)试题及答案
- 2025年中职(人力资源管理事务)员工关系管理试题及答案
- 2025年注册会计师(CPA)考试 会计科目全面解析试卷及答案
- 2026年当前房地产市场的监管政策解读
- 北京城市总体规划实施体检报告公众读本(2023年度)
- 2026江西九江市永修迎宾馆管理有限公司招聘劳务派遣制工作人员2人备考题库带答案详解
- 光伏培训课件教学
- 2026安徽亳州市蒙城县就业见习人员招募备考题库及答案详解(考点梳理)
- 假体隆胸后查房课件
- 2023年互联网新兴设计人才白皮书
- 河南省郑氏中原纤维素有限公司年产 0.2 万吨预糊化淀粉、0.5 万吨羧甲基纤维素钠、1.3 万吨羧甲基淀粉钠项目环境影响报告
- DB52-T 785-2023 长顺绿壳蛋鸡
- c语言知识点思维导图
- 关于地方储备粮轮换业务会计核算处理办法的探讨
- GB/T 40303-2021GH4169合金棒材通用技术条件
- GB/T 29319-2012光伏发电系统接入配电网技术规定
- GB/T 1773-2008片状银粉
- GB/T 12007.4-1989环氧树脂粘度测定方法
- (完整版)北京全套安全资料表格
评论
0/150
提交评论