resources/libtiny/Servo.cpp
//=============================================================================
// FUNCTION:    void setServoPulseLength(uint8_t servoNumber, uint16_t newLengthInMicroseconds)
//
// DESCRIPTION: Updates a servo slots with a new pulse length.
//              Only works on allocated slots.
//
// INPUT:       servoNumber - the slot number to update
//              newLengthInMicroseconds - the new pulse length to set
//
// RETURNS:     Nothing
//=============================================================================
void setServoPulseLength(uint8_t servoNumber, uint16_t newLengthInMicroseconds)
DESCRIPTION: Updates a servo slots with a new pulse length.
Only works on allocated slots.

the slot number to update
newLengthInMicroseconds - the new pulse length to set

Nothing
void setServoPulseLength ( uint8_t servoNumber uint16_t newLengthInMicroseconds ) DESCRIPTION : Updates a servo slots with a new pulse length . Only works on allocated slots . the slot number to update newLengthInMicroseconds - the new pulse length to set Nothing
void ServoSequencer::setServoPulseLength(uint8_t servoNumber, uint16_t newLengthInMicroseconds)
{
    if( (servoNumber < MAX_SERVOS      ) &&
        (servoRegistry[servoNumber].slotOccupied == true)   )
    {
        int16_t newLengthInClockTicks = newLengthInMicroseconds / 8;
        newLengthInClockTicks -= 64;
        if( (newLengthInClockTicks > -1) && (newLengthInClockTicks < 256) )
        {
            servoRegistry[servoNumber].pulseLengthInTicks = static_cast<uint8_t>(newLengthInClockTicks);
        }
        else
        {
        }
    }
    else
    {
    }
}
void ServoSequencer :: setServoPulseLength ( uint8_t servoNumber , uint16_t newLengthInMicroseconds ) { if ( ( servoNumber < MAX_SERVOS ) && ( servoRegistry [ servoNumber ] . slotOccupied == true ) ) { int16_t newLengthInClockTicks = newLengthInMicroseconds / 8 ; newLengthInClockTicks -= 64 ; if ( ( newLengthInClockTicks > -1 ) && ( newLengthInClockTicks < 256 ) ) { servoRegistry [ servoNumber ] . pulseLengthInTicks = static_cast < uint8_t > ( newLengthInClockTicks ) ; } else { } } else { } }
FUNCTION:    void setServoPulseLength(uint8_t servoNumber, uint16_t newLengthInMicroseconds)
DESCRIPTION: Updates a servo slots with a new pulse length.
FUNCTION : void setServoPulseLength ( uint8_t servoNumber uint16_t newLengthInMicroseconds ) DESCRIPTION : Updates a servo slots with a new pulse length .
//make sure we got a valid slot number and the slot is registered to a servo //Convert the servo pulse length into timer ticks. //Each timer tick is 8 microseconds. //subtract the pulse offset //make sure the length of this pulse is within the acceptable range //Programing note: If pulseLengthInTicks is ever changed to be larger than 1 byte in size then //                 interrupts would need to be disabled when updating it to a new value. //The new pulse length is too short or long than what we can generate //Servo number is out of range or is not allocate to a servo. Do nothing.