internal async Task SetOutputStateAsyncInternal(MotorPort motorPort, short power, MotorModes motorMode, MotorRegulationMode motorRegulation, short turnRatio, MotorRunState runState, uint tachoLimit) { await brick.SendCommandAsyncInternal(RequestTelegram.SetOutputState(motorPort, power, motorMode, motorRegulation, turnRatio, runState, tachoLimit)); }
/// <summary> /// Sends a command to the motor connected to the specified port. /// </summary> /// <param name="motorPort">The port where the motor is connected to.</param> /// <param name="power"> /// Power (also referred as speed) set point. Range: -100-100. /// The absolute value of <paramref name="power"/> is used as a percentage of the full power capabilities of the motor. /// The sign of <paramref name="power"/> specifies rotation direction. /// Positive values for <paramref name="power"/> instruct the firmware to turn the motor forward, /// while negative values instruct the firmware to turn the motor backward. /// "Forward" and "backward" are relative to a standard orientation for a particular type of motor. /// Note that direction is not a meaningful concept for outputs like lamps. /// Lamps are affected only by the absolute value of <paramref name="power"/>. /// </param> /// <param name="mode">Motor mode (bit-field).</param> /// <param name="regulation">Regulation mode.</param> /// <param name="turnRatio"> /// This property specifies the proportional turning ratio for synchronized turning using two motors. Range: -100-100. /// <remarks> /// Negative <paramref name="turnRatio"/> values shift power towards the left motor, /// whereas positive <paramref name="turnRatio"/> values shift power towards the right motor. /// In both cases, the actual power applied is proportional to the <paramref name="power"/> set-point, /// such that an absolute value of 50% for <paramref name="turnRatio"/> normally results in one motor stopping, /// and an absolute value of 100% for <paramref name="turnRatio"/> normally results in the two motors /// turning in opposite directions at equal power. /// </remarks> /// </param> /// <param name="runState">Motor run state.</param> /// <param name="tachoLimit"> /// Tacho limit. This property specifies the rotational distance in /// degrees that you want to turn the motor. Range: 0-4294967295, O: run forever. /// The sign of the <paramref name="power"/> property specifies the direction of rotation. /// </param> public void SetOutputState(MotorPort motorPort, sbyte power, MotorModes mode, LegoRegulationMode regulation, sbyte turnRatio, RunState runState, UInt32 tachoLimit ) { var data = CommandHelper.InitializeData(LegoCommandCode.SetOutputState, CommandType.DirectCommandWithoutResponse, 13); data[ 2 ] = (byte) motorPort; data[ 3 ] = (byte) power; data[ 4 ] = (byte) mode; data[ 5 ] = (byte) regulation; data[ 6 ] = (byte) turnRatio; data[ 7 ] = (byte) runState; data[ 8 ] = (byte) ( tachoLimit & 0xFF ); // Byte 8-12: tacho limit ULONG data[ 9 ] = (byte) ( tachoLimit >> 8 ); data[ 10 ] = (byte) ( tachoLimit >> 16 ); data[ 11 ] = (byte) ( tachoLimit >> 24 ); Transmit( data ); // Return package: 0:0x02, 1:Command, 2:StatusByte }
SetOutputStateAsync(MotorPort motorPort, short power, MotorModes motorModes, MotorRegulationMode regulationMode, short turnRatio, MotorRunState runState, uint tachoLimit) { return SetOutputStateAsyncInternal(motorPort, power, motorModes, regulationMode, turnRatio, runState, tachoLimit) #if WINRT .AsAsyncAction() #endif ; }