?? boat.h
字號:
//畫船函數(shù)
//液晶顯示基本函數(shù)
/***********************************************************************
公司名稱: 泰克通信
模 塊 名: 液晶顯示畫船操作 LCD 型號:NHC-01
創(chuàng) 建 人: 輸入輸出模塊組 日期:2004-03-17
修 改 人: 輸入輸出模塊組 日期:2004-03-23
功能描述: 1、在任意位置顯示三角形(船)
2、根據(jù)經(jīng)緯度差別和船的方向、偏轉(zhuǎn)角畫船
其他說明: 本程序在atmag128和nhc-01上調(diào)試通過,變量傳遞有問題,在改正中
版 本: alpha 0.01
**********************************************************************/
void showboat(char x,char y,int d,char i);//計算船的三個作標頂點
void displayboat(char i);//獲取其他船的航行角度、偏轉(zhuǎn)角已及和主船經(jīng)緯度差求船的作標
struct boatdata
{
int log;//船與主船的經(jīng)度差
int lang;//船與主船的維度差
float d;//航向角
float turn;//偏轉(zhuǎn)角
char x;//保存船在液晶上顯示的作標點
char y;
char x1;//保存船表示的三角形、方向角和轉(zhuǎn)向角的液晶作標,方便使用
char y1;
char x2;
char y2;
char x3;
char y3;
char x4;//船的方向直線
char y4;
char x5;//船的偏轉(zhuǎn)角直線
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個測試用數(shù)據(jù)
//boatdata tempboat[20];//用于保存船的數(shù)據(jù),用來判斷接收到數(shù)據(jù)前后的變化
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;//算法通過設(shè)置一個臨時作標點,該點與三角形的第一個頂點關(guān)于位置點對稱
char temp1,temp2;
if(td<0)
td+=360;
d=td;
if(d>90&&d<=180)//將角度td換算成第一象限對應(yīng)的角度
d=180-d;
else if(d>180&&d<=270)//將角度td換算成第一象限對應(yīng)的角度
d=td-180;
else if(d>270&&d<=360)//將角度td換算成第一象限對應(yīng)的角度
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;//三角形的第二、第三頂點連線和方向垂直,同時該兩點關(guān)于臨時點對稱
}
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)//獲取其他船的航行角度、偏轉(zhuǎn)角已及和主船經(jīng)緯度差求船的作標
{
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;//計算船的偏轉(zhuǎn)角
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);
showchars(30,56,name,1);//在白色顯示信息位置顯示船名
showchars(30,88,mmis,1);//在白色顯示信息位置顯示MMIS
showchars(30,120,huhao,1);//在白色顯示信息位置顯示呼號
showchars(30,152,boatclass,1);//在白色顯示信息位置顯示船的類型
showchars(30,184,size,1);//在白色顯示信息位置顯示船的大小
showchars(30,216,where,1);//在白色顯示信息位置顯示位參照
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -