embed\vs2008_bsp\bsp\bsp160160.h.c模拟160160灰色屏幕
来源:互联网 发布:gdp有月度数据吗 编辑:程序博客网 时间:2024/06/11 20:12
//模拟COG显示屏
/*****************************************************************************************
模拟COG显示屏
文件:bsp160160.h
编者:张永辉 2013年9月3日
*****************************************************************************************/
#ifndef _BSP160160_H_
#define _BSP160160_H_
#include "basetype.h"
//*********************************配置***************************************************
#define COG_SIZE_X 160
#define COG_SIZE_Y 160
//***************************************函数声明*****************************************
void Bsp160160Test(void);
void Bsp160160Init(void);
//图像界面接口
void Bsp160160Point(u32 x,u32 y, bool Color); //画一个点
void Bsp160160LineH(u32 x0,u32 y0,u32 xlen,bool c); //画竖线
void Bsp160160LineL(u32 x0,u32 y0,u32 ylen,bool Color); //画横线
bool Bsp160160PointGet(u32 x,u32 y); //返回某点颜色
void Bsp160160Clear(void); //清屏函数
void Bsp160160DrawLine(int x1, int y1, int x2, int y2,bool color); //画直线
void Bsp160160DrawCircleFast(int xc , int yc , int r,bool color); //画圆
//****************************************************************************************
#endif
COG160160显示屏
文件:bsp160160.h
环境:vs2010
说明:使用电脑的320*320模拟真实的 160160界面
编者:张永辉 2013年9月3日
*****************************************************************************************/
#include "opengl2.h"
#include "bsp160160.h"
#include "bsptime.h"
/*****************************************************************************************
函数集
*****************************************************************************************/
void Bsp160160Test(void)
{
Bsp160160LineH(0,0,160,1);
Bsp160160LineH(0,159,160,1);
Bsp160160LineH(100,100,20,1);
Bsp160160LineL(100,100,20,1);
Bsp160160DrawLine(30,30,130,130,1);
Bsp160160DrawLine(30,30,50,130,1);
Bsp160160DrawCircleFast(80,80,25,1);
Bsp160160Point(2,2,1);
while(1)
{
BspTimeDlyMs(100);
}
}
//--------------------------------------基本函数-----------------------------------------
//初始化
void Bsp160160Init(void)
{
Gl2Init();
}
//画一个点
void Bsp160160Point(u32 x,u32 y, bool Color)
{
Gl2DisPoint(x*2 ,y*2 ,Color);
Gl2DisPoint(x*2 ,y*2+1,Color);
Gl2DisPoint(x*2+1,y*2 ,Color);
Gl2DisPoint(x*2+1,y*2+1,Color);
}
//返回某点颜色
bool Bsp160160PointGet(u32 x,u32 y)
{
if(Gl2DisPointGet(x*2 ,y*2)> 0)
{
return 1;
}
return 0;
}
//使用同一颜色画一横线
void Bsp160160LineH(u32 x0,u32 y0,u32 xlen,bool c)
{
for(;xlen >0;x0++,xlen--)
{
Bsp160160Point(x0,y0,c);
}
}
//使用同一颜色画一竖线
void Bsp160160LineL(u32 x0,u32 y0,u32 ylen,bool c)
{
for(;ylen >0;y0++,ylen--)
{
Bsp160160Point(x0,y0,c);
}
}
//清屏
void Bsp160160Clear(void)
{
Gl2DisClear();
}
//--------------------------------------画直线-------------------------------------------
void static SwapInt(int *x, int *y);
int static abs(int a);
//方法:Bresenham算法
//参数:x1 y1 第一个点
// x2 y2 第二个点
// color 颜色
void Bsp160160DrawLine(int x1, int y1, int x2, int y2,bool color)
{
int dx,dy,p,const1,const2,x,y,inc;
int steep = (abs(y2 - y1) > abs(x2 - x1)) ? 1 : 0;
if(steep == 1)
{
SwapInt(&x1, &y1);
SwapInt(&x2, &y2);
}
if(x1 > x2)
{
SwapInt(&x1, &x2);
SwapInt(&y1, &y2);
}
dx = abs(x2 - x1);
dy = abs(y2 - y1);
p = 2 * dy - dx;
const1 = 2 * dy;
const2 = 2 * (dy - dx);
x = x1;
y = y1;
inc = (y1 < y2) ? 1 : -1;
while(x <= x2)
{
if(steep == 1)
Bsp160160Point(y, x,color);
else
Bsp160160Point(x, y,color);
x++;
if(p<0)
p += const1;
else
{
p += const2;
y += inc;
}
}
}
//绝对值函数
int static abs(int a)
{
if(a<0)
{
return -a;
}
return a;
}
//值交换函数
void static SwapInt(int *x, int *y)
{
int a = *x;
*x = *y;
*y = a;
}
//--------------------------------------画圆---------------------------------------------
//方法:快速画圆
//参数:xc,yc 圆心坐标
// radius 半径
// color 颜色
void static Draw8points(int xc,int yc,int x,int y,bool c);
void Bsp160160DrawCircleFast(int xc , int yc , int r,bool color)
{
int x, y, d;
x = 0;
y = r;
d = -r / 2;
Draw8points(xc , yc , x , y,color);
if(r % 2 == 0)
{
while(x < y)
{
x++;
if(d < 0)
d += x;
else
{
y--;
d += x - y;
}
Draw8points(xc , yc , x , y,color);
}
}else
{
while(x < y)
{
x++;
if(d < 0)
d += x + 1;
else
{
y--;
d += x - y + 1;
}
Draw8points(xc , yc , x , y,color);
}
}
}
//按8分法,每次调用将画出8个对称的点
void static Draw8points(int xc,int yc,int x,int y,bool c)
{
Bsp160160Point(xc+x,yc+y,c);
Bsp160160Point(xc-x,yc+y,c);
Bsp160160Point(xc+x,yc-y,c);
Bsp160160Point(xc-x,yc-y,c);
Bsp160160Point(xc+y,yc+x,c);
Bsp160160Point(xc-y,yc+x,c);
Bsp160160Point(xc+y,yc-x,c);
Bsp160160Point(xc-y,yc-x,c);
}
- embed\vs2008_bsp\bsp\bsp160160.h.c模拟160160灰色屏幕
- embed\vs2008_ucos\bsp\bspm25p16.h.c bspm25p32.h.c--模拟M25P16\32读写
- embed\vs2008_ucos\bsp\bspThread.h.C
- vs2008\drivers\opengl2.h.c 模拟灰色320*320屏幕
- embed\vs2008_ucos\bsp\bspmem.h.c 动态内存申请与释放
- embed\app\LNG3A\main.c app_cfg.h os_cfg.h --ucosii移植在LPC1788--oart6
- 屏幕保护等待时间灰色
- lpc1788_ucos\cmsis\include.h bsp.h.c --ucosii移植在lpc1788--part7
- vs2008\bsp\bspeeprom.h.c__模拟2M EE储存器供针对FATFS的接口
- python3.5 EMBED in C
- Bsp 空间分割模拟实现
- Bsp 空间分割模拟实现
- Embed
- embed
- embed
- embed
- C++:模拟实现类似<time.h>的计时功能
- 嵌入式C语言之屏幕操作之 模拟MessageBox函数
- OpenCart布局(Layout)系统是如何工作的?
- 剑指offer--简易动态规划(3、10、20、26,61)
- java招聘试题
- UVALive 4050 Hanoi Towers
- automake,autoconf使用详解
- embed\vs2008_bsp\bsp\bsp160160.h.c模拟160160灰色屏幕
- hdu - 3572 - Task(最大流)
- static变量
- Eclipse插件安装svn、testng、junit插件
- ExtJs入门,类、语法、函数
- Java读取UTF-8格式txt文件第一行出现乱码——问号“?”及解决;Java读带有BOM的UTF-8文件乱码原因及解决方法
- MFC VS2008 常见 问题
- Mac OS X (Intel) 上安装 Oracle 10g
- 经典问题:前缀补全