Skip to main content

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
TypeNameDescription
System.TimeSpanrunTimeThe duration for which the motor should run.
Meadow.Peripherals.RotationDirectiondirectionThe rotation direction of the motor.
System.Threading.CancellationTokencancellationTokenOptional 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
TypeNameDescription
Meadow.Peripherals.RotationDirectiondirectionThe rotation direction of the motor.
System.Threading.CancellationTokencancellationTokenOptional 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
TypeNameDescription
System.Threading.CancellationTokencancellationTokenOptional cancellation token to stop the operation.