@@ -758,31 +758,20 @@
void DvbStream::gotoX( double azimuth )
{
- double USALS=0.0;
+ unsigned long USALS;
int CMD1=0x00, CMD2=0x00;
- int DecimalLookup[10] = { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
+ //rotation direction
if ( azimuth>0.0 )
CMD1 = 0xE0; // East
else
CMD1 = 0xD0; // West
- USALS = fabs( azimuth );
-
- while (USALS > 16) {
- CMD1++;
- USALS-= 16;
- }
- while (USALS >= 1.0) {
- CMD2+=0x10;
- USALS--;
- }
- USALS*= 10.0;
- int rd = (int)USALS;
- USALS-= rd;
- if ( USALS>0.5 )
- ++rd;
- CMD2+= DecimalLookup[rd];
+ //angle : 12 bits with a precision of 1/16th of a degree
+ //a true binary fraction, NOT binary coded decimal
+ USALS = ( fabs(azimuth)*16 + 0.5 );
+ CMD1 |= (USALS & 0xf00) >> 8;
+ CMD2 = (USALS & 0x0ff);
rotorCommand( 12, CMD1, CMD2 );
}