--- dvbstream.cpp.orig +++ dvbstream.cpp @@ -758,30 +758,26 @@ void DvbStream::gotoX( double azimuth ) { - double USALS=0.0; + int USALS; int CMD1=0x00, CMD2=0x00; int DecimalLookup[10] = { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E }; + //high nibble of CMD1 if ( azimuth>0.0 ) CMD1 = 0xE0; // East else CMD1 = 0xD0; // West - USALS = fabs( azimuth ); + USALS = ( fabs(azimuth)*10 + 0.5 ); // NB tenths of a degree - 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; + //low nibble of CMD1 : 16 degree steps + CMD1+=USALS/160; + + //high nibble of CMD2 : 1 degree steps + CMD2=((USALS%160)/10)*0x10; + + //low nibble of CMD2: 0.1 degree steps, coded as in DecimalLookup + int rd = USALS%10; CMD2+= DecimalLookup[rd]; rotorCommand( 12, CMD1, CMD2 );