nxtlib/src/Protocol.cs
/// <summary> 
/// [Native] Smoothly start or stop motors, specifying whether to brake or coast.
/// </summary>
/// <param name="port">The ports of the selected motors.</param>
/// <param name="power">The power at which to move the motors, between -100 and 100.</param>
/// <param name="stop">Whether to brake or coast during operation.  Braking uses far more power.</param>
/// <param name="smooth">Whether to smoothly spin up or down the motors.</param>
/// <param name="degrees">The number of degrees the motor revolves until is it fully spun up or down.  Smaller values 
///  make the motors move more smoothly.  Set degrees to zero to run infinitely.</param>
[Native] Smoothly start or stop motors, specifying whether to brake or coast.
[ Native ] Smoothly start or stop motors specifying whether to brake or coast .
public void MoveMotors(MotorPort port, int power, MotorStop stop, MotorSmooth smooth, int degrees)
        {
            MotorMode mode = MotorMode.On_Regulated;
            if (stop == MotorStop.Coast)
            {
                mode = MotorMode.On_Regulated;
                if ((power < 75) && (power > -75)) { mode = MotorMode.MotorOn; }
            }
            if (stop == MotorStop.Brake)
            {
                mode = MotorMode.On_Brake_Regulated;
                if ((power < 75) && (power > -75)) { mode = MotorMode.On_Brake; }
            }
            if (port != MotorPort.AB && port != MotorPort.AC && port != MotorPort.BC)
            {
                SetOutputState((Motor)((byte)port), (sbyte)power, mode,
                    MotorReg.Speed, 0, MotorState.Running, 0);
            }
            else
            {
                MotorState state = MotorState.Rampup;
                if (smooth == MotorSmooth.Smooth_Stop)
                {
                    state = MotorState.RampDown;
                }
                Motor[] motors = new Motor[] { };
                if (port == MotorPort.AB) { motors = new Motor[] { Motor.A, Motor.B }; }
                if (port == MotorPort.AC) { motors = new Motor[] { Motor.A, Motor.C }; }
                if (port == MotorPort.BC) { motors = new Motor[] { Motor.B, Motor.C }; }
                SetOutputState(motors[0], (sbyte)power, mode,
                    MotorReg.Sync, 0, state, (uint)degrees);
                SetOutputState(motors[1], (sbyte)power, mode,
                    MotorReg.Sync, 0, state, (uint)degrees);
            }
            return;
        }
public void MoveMotors ( MotorPort port , int power , MotorStop stop , MotorSmooth smooth , int degrees ) { MotorMode mode = MotorMode . On_Regulated ; if ( stop == MotorStop . Coast ) { mode = MotorMode . On_Regulated ; if ( ( power < 75 ) && ( power > - 75 ) ) { mode = MotorMode . MotorOn ; } } if ( stop == MotorStop . Brake ) { mode = MotorMode . On_Brake_Regulated ; if ( ( power < 75 ) && ( power > - 75 ) ) { mode = MotorMode . On_Brake ; } } if ( port != MotorPort . AB && port != MotorPort . AC && port != MotorPort . BC ) { SetOutputState ( ( Motor ) ( ( byte ) port ) , ( sbyte ) power , mode , MotorReg . Speed , 0 , MotorState . Running , 0 ) ; } else { MotorState state = MotorState . Rampup ; if ( smooth == MotorSmooth . Smooth_Stop ) { state = MotorState . RampDown ; } Motor [ ] motors = new Motor [ ] { } ; if ( port == MotorPort . AB ) { motors = new Motor [ ] { Motor . A , Motor . B } ; } if ( port == MotorPort . AC ) { motors = new Motor [ ] { Motor . A , Motor . C } ; } if ( port == MotorPort . BC ) { motors = new Motor [ ] { Motor . B , Motor . C } ; } SetOutputState ( motors [ 0 ] , ( sbyte ) power , mode , MotorReg . Sync , 0 , state , ( uint ) degrees ) ; SetOutputState ( motors [ 1 ] , ( sbyte ) power , mode , MotorReg . Sync , 0 , state , ( uint ) degrees ) ; } return ; }
[Native] Smoothly start or stop motors, specifying whether to brake or coast.
[ Native ] Smoothly start or stop motors specifying whether to brake or coast .
port
MotorPort
The ports of the selected motors.
The ports of the selected motors .
power
int
The power at which to move the motors, between -100 and 100.
The power at which to move the motors between - 100 and 100 .
stop
MotorStop
Whether to brake or coast during operation.  Braking uses far more power.
Whether to brake or coast during operation . Braking uses far more power .
smooth
MotorSmooth
Whether to smoothly spin up or down the motors.
Whether to smoothly spin up or down the motors .
degrees
int
The number of degrees the motor revolves until is it fully spun up or down.  Smaller values
make the motors move more smoothly.  Set degrees to zero to run infinitely.
The number of degrees the motor revolves until is it fully spun up or down . Smaller values make the motors move more smoothly . Set degrees to zero to run infinitely .