nxtlib/src/Protocol.cs
/// <summary> 
/// [Native] Move NXT 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>
[Native] Move NXT motors, specifying whether to brake or coast.
[ Native ] Move NXT motors specifying whether to brake or coast .
public void MoveMotors(MotorPort port, int power, MotorStop stop)
        {
            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
            {
                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, MotorState.Running, (uint)0);
                SetOutputState(motors[1], (sbyte)power, mode,
                    MotorReg.Sync, 0, MotorState.Running, (uint)0);
            }
            return;
        }
public void MoveMotors ( MotorPort port , int power , MotorStop stop ) { 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 { 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 , MotorState . Running , ( uint ) 0 ) ; SetOutputState ( motors [ 1 ] , ( sbyte ) power , mode , MotorReg . Sync , 0 , MotorState . Running , ( uint ) 0 ) ; } return ; }
[Native] Move NXT motors, specifying whether to brake or coast.
[ Native ] Move NXT 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 .