Ticket #1749: usals.diff

File usals.diff, 1.3 KB (added by yeasah@…, 18 years ago)
  • libs/libmythtv/dvbdiseqc.cpp

     
    720720    if (prev_tuning.diseqc_pos != tuning.diseqc_pos)
    721721        VERBOSE(VB_CHANNEL, LOC + "DiSEqC Motor Moving");
    722722
    723     int CMD1=0x00 , CMD2=0x00;        // Bytes sent to motor
    724     double USALS=0.0;
    725     int DecimalLookup[10] =
    726         { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
     723    unsigned char CMD1=0x00 , CMD2=0x00;        // Bytes sent to motor
    727724
    728725    // Equation lifted from VDR rotor plugin by
    729726    // Thomas Bergwinkl <Thomas.Bergwinkl@t-online.de>
     
    744741    else
    745742        CMD1=0xD0;      // West
    746743
    747     USALS = fabs(Azimuth);
    748  
    749     while (USALS > 16)
    750     {
    751         CMD1++;
    752         USALS -=16;
    753     }
    754 
    755     while (USALS >= 1.0)
    756     {
    757         CMD2+=0x10;
    758         USALS--;
    759     }
    760 
    761     CMD2 += DecimalLookup[(int)round(USALS*10)];
     744    // CMD1 low nibble is angle / 16
     745    // CMD2 high nibble is angle % 16
     746    // CMD2 low nibble is (angle * 16) % 16
     747    unsigned int USALS = (unsigned int)(fabs(Azimuth) * 16.0);
     748    CMD1 |= (USALS >> 8) & 0x0f;
     749    CMD2 = USALS & 0xff;
    762750 
    763751    if (!DiseqcReset())
    764752    {