📄 boat._h
字号:
//画船函数
//液晶显示基本函数
/***********************************************************************
公司名称: 泰克通信
模 块 名: 液晶显示画船操作 LCD 型号:NHC-01
创 建 人: 输入输出模块组 日期:2004-03-17
修 改 人: 输入输出模块组 日期:2004-03-23
功能描述: 1、在任意位置显示三角形(船)
2、根据经纬度差别和船的方向、偏转角画船
其他说明: 本程序在atmag128和nhc-01上调试通过,变量传递有问题,在改正中
版 本: alpha 0.01
**********************************************************************/
void showboat(char x,char y,int d,char i);//计算船的三个作标顶点
void displayboat(char i);//获取其他船的航行角度、偏转角已及和主船经纬度差求船的作标
struct boatdata
{
int log;//船与主船的经度差
int lang;//船与主船的维度差
float d;//航向角
float turn;//偏转角
char x;//保存船在液晶上显示的作标点
char y;
char x1;//保存船表示的三角形、方向角和转向角的液晶作标,方便使用
char y1;
char x2;
char y2;
char x3;
char y3;
char x4;//船的方向直线
char y4;
char x5;//船的偏转角直线
char y5;
};
char a[]="52.53";//用于显示的字符串,测试用
char name[]="tec-dingki";
char mmis[]="00151014";
char huhao[]="12345";
char boatclass[]="warship";
char size[]="so big";
char where[]="china";
struct boatdata boat[20];//先定义20个测试用数据
//boatdata tempboat[20];//用于保存船的数据,用来判断接收到数据前后的变化
char showk=1;//显示比例
/******************液晶上显示船只**********************/
void showboat(char x,char y,int td,char i)//计算船的几个主要作标
{
char csinx[18]={0,1,2,3,4,5,5,6,6,7,8,8,9,9,9,9,10,10};//将第一象限角度建表,减少符点运算
int d;
char tx,ty;//算法通过设置一个临时作标点,该点与三角形的第一个顶点关于位置点对称
char temp1,temp2;
if(td<0)
td+=360;
d=td;
if(d>90&&d<=180)//将角度td换算成第一象限对应的角度
d=180-d;
else if(d>180&&d<=270)//将角度td换算成第一象限对应的角度
d=td-180;
else if(d>270&&d<=360)//将角度td换算成第一象限对应的角度
d=360-td;
d=d/5;
if(d==18)
d=17;
temp2=csinx[d];
temp1=csinx[17-d];
if(td>90&&td<270)
{
boat[i].x1=x-temp1;
tx=x+temp1;
}
else
{
boat[i].x1=x+temp1;
tx=x-temp1;
}
if(td>0&&td<180)
{
boat[i].y1=y-temp2;
ty=y+temp2;
boat[i].x2=tx-temp2/2;//通过该临时点计算三角形的第二和第三个顶点
boat[i].x3=tx+temp2/2;//三角形的第二、第三顶点连线和方向垂直,同时该两点关于临时点对称
}
else
{
boat[i].y1=y+temp2;
ty=y-temp2;
boat[i].x2=tx-temp2/2;
boat[i].x3=tx+temp2/2;
}
if(td<90||(td<270&&td>180))
{
boat[i].y2=ty-temp1/2;
boat[i].y3=ty+temp1/2;
}
else
{
boat[i].y2=ty+temp1/2;
boat[i].y3=ty-temp1/2;
}
}
void displayboat(char i)//获取其他船的航行角度、偏转角已及和主船经纬度差求船的作标
{
int td;
boat[i].x=(char)(120+boat[i].log*showk);//计算船在液晶的显示比例
boat[i].y=(char)(120+boat[i].lang*showk);
td=(int)(boat[i].d-boat[i].turn);
showboat(boat[i].x,boat[i].y,td,i);
boat[i].x5=2*boat[i].x1-boat[i].x;//计算船的偏转角
boat[i].y5=2*boat[i].y1-boat[i].y;
showboat(boat[i].x,boat[i].y,boat[i].d,i);//计算船的三个顶点
boat[i].x4=2*boat[i].x1-boat[i].x;//计算船的方向角
boat[i].y4=2*boat[i].y1-boat[i].y;
linex(boat[1].x2,boat[1].y2,boat[1].x3,boat[1].y3,7);
linex(boat[1].x1,boat[1].y1,boat[1].x2,boat[1].y2,7);
linex(boat[1].x1,boat[1].y1,boat[1].x3,boat[1].y3,7);
linex(boat[1].x,boat[1].y,boat[1].x4,boat[1].y4,7);//画船的方向
xuline(boat[1].x,boat[1].y,boat[1].x5,boat[1].y5,7);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -