?? calculateforangle.c
字號(hào):
#include "common.h"
void CalculateforAngle(void)
{
Xh=ADC_Xaxis*Xsf-Xoff;
Yh=ADC_Yaxis*Ysf-Yoff;
if(Xh==0)
{
if(Yh>0)
Angle=90;
else
Angle=270;
}
else
{
if(Xh>0)
{
if(Yh>=0)
Angle=atan(Yh/Xh)*(180/M_PI);
else
Angle=360-atan(-Yh/Xh)*(180/M_PI);
}
else
{
if(Yh>0)
Angle=180-atan(-Yh/Xh)*(180/M_PI);
else
Angle=180+atan(Yh/Xh)*(180/M_PI);
}
}
}
void GetCurrentPointer(void)
{
uint LED_number,Point_Angle;
Point_Angle=Angle;
Point_Angle<<=2;
Point_Angle/=30;
if((Point_Angle<=39)&(Point_Angle>=24))
{
LED_number=Point_Angle-24;
G2_1=0;
G2_2=1;
G2_3=1;
}
else if((Point_Angle<=23)&(Point_Angle>=8))
{
LED_number=Point_Angle-8;
G2_1=1;
G2_2=1;
G2_3=0;
}
else
{
if((Point_Angle<=7)&(Point_Angle>=0))
LED_number=Point_Angle+8;
else
LED_number=Point_Angle-40;
G2_1=1;
G2_2=0;
G2_3=1;
}
PORTD&=0xf0;
PORTD|=LED_number;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -