Interface IMotor
Represents an interface for controlling a motor.
Assembly: Meadow.Contracts.dll
View Source
Declaration
public interface IMotor
Properties
Direction
Gets the current rotation direction of the motor.
View Source
Declaration
RotationDirection Direction { get; }
IsMoving
Gets a value indicating whether the motor is currently in motion.
View Source
Declaration
bool IsMoving { get; }
Methods
RunFor(TimeSpan, RotationDirection, CancellationToken)
Runs the motor for a specified duration with the given parameters.
View Source
Declaration
Task RunFor(TimeSpan runTime, RotationDirection direction, CancellationToken cancellationToken = default)
Returns
System.Threading.Tasks.Task
: A task representing the asynchronous operation.
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | runTime | The duration for which the motor should run. |
Meadow.Peripherals.RotationDirection | direction | The rotation direction of the motor. |
System.Threading.CancellationToken | cancellationToken | Optional cancellation token to stop the operation. |
Run(RotationDirection, CancellationToken)
Runs the motor continuously with the given parameters.
View Source
Declaration
Task Run(RotationDirection direction, CancellationToken cancellationToken = default)
Returns
System.Threading.Tasks.Task
: A task representing the asynchronous operation.
Parameters
Type | Name | Description |
---|---|---|
Meadow.Peripherals.RotationDirection | direction | The rotation direction of the motor. |
System.Threading.CancellationToken | cancellationToken | Optional cancellation token to stop the operation. |
Stop(CancellationToken)
Stops the motor.
View Source
Declaration
Task Stop(CancellationToken cancellationToken = default)
Returns
System.Threading.Tasks.Task
: A task representing the asynchronous operation.
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | Optional cancellation token to stop the operation. |