本帖最后由 野草 于 2017-6-4 12:08 编辑
void LX200(void)
{
u8 command[20] ;
u8 i=0,a;
static u8 ra_get_flag=0,dec_get_flag=0;
static u8 b;
while(data!=':') //look FOR HEAD
{
i++;
if(i>20)
{
break;
}
}
for(a=0;a<19;a++) //转存
{
command[a]=data;
i++;
}
/*ANALYZE AND REPLY*/
if (command[1]=='G'&&command[2]=='R') //GR 回复赤经 24h60m60s
{
current_ra=CURRENT_POS_RA(target_ra,ra_step);
CURRENT_RA();
DMA_SEND_DATA((u32)ra_out ,9);
}
if (command[1]=='G'&&command[2]=='D') //GD 回复赤纬 +-90:60:60
{
current_dec=CURRENT_POS_DEC(target_dec,dec_step);
CURRENT_DEC();
DMA_SEND_DATA((u32)dec_out ,10);
}
if (command[1]=='Q'&&command[5]=='r') //Sr 回复1
{
ra_in[0]=command[7];
ra_in[1]=command[8];
ra_in[2]=command[10];
ra_in[3]=command[11];
ra_in[4]=command[13];
ra_in[5]=command[14];
command[0]='1';
DMA_SEND_DATA((u32)command ,1);
if(b<2)
{
current_ra=RA_DEG_INTO_ARCSEC(ra_in);
target_ra=current_ra;
ra_step=0;
b++;
}
ra_get_flag=1;
}
if (command[1]=='S'&&command[2]=='d') //Sd 回复1
{
dec_in[0]=command[4];
dec_in[1]=command[5];
dec_in[2]=command[6];
dec_in[3]=command[8];
dec_in[4]=command[9];
dec_in[5]=command[11];
dec_in[6]=command[12];
command[0]='1';
DMA_SEND_DATA((u32)command ,1);
if(b<2)
{
current_dec=DEC_DEG_INTO_ARCSEC(dec_in);
target_dec=current_dec;
dec_step=0;
b++;
}
dec_get_flag=1;
}
if (command[1]=='M'&&command[2]=='r') //自定义命令Mr 回复1
{
ra_in[0]=command[4];
ra_in[1]=command[5];
ra_in[2]=command[7];
ra_in[3]=command[8];
ra_in[4]=command[10];
ra_in[5]=command[11];
command[0]='1';
DMA_SEND_DATA((u32)command ,1);
current_ra=RA_DEG_INTO_ARCSEC(ra_in);
target_ra=current_ra;
ra_step=0;
}
if (command[1]=='M'&&command[2]=='d') //自定义命令Md 回复1
{
dec_in[0]=command[4];
dec_in[1]=command[5];
dec_in[2]=command[6];
dec_in[3]=command[8];
dec_in[4]=command[9];
dec_in[5]=command[11];
dec_in[6]=command[12];
command[0]='1';
DMA_SEND_DATA((u32)command ,1);
current_dec=DEC_DEG_INTO_ARCSEC(dec_in);
target_dec=current_dec;
dec_step=0;
}
if (command[1]=='M'&&command[2]=='S') //Ms 回复0
{
command[0]='0';
DMA_SEND_DATA((u32)command ,1);
}
if (ra_get_flag==1&&dec_get_flag==1) //ra dec目标更新后进行解算
{
ra_get_flag=0; //清除更新标志
dec_get_flag=0;
goto_flag=1;
target_ra=RA_DEG_INTO_ARCSEC(ra_in);
target_dec=DEC_DEG_INTO_ARCSEC(dec_in);
ra_step=CALCULATE_RA(current_ra,target_ra);
dec_step=CALCULATE_DEC(current_dec,target_dec);
}
}
|