NextServo

open class NextServo @JvmOverloads constructor(initializer: () -> ServoImplEx, val cacheTolerance: Double = 0.01, direction: NextMotor.Direction = NextMotor.Direction.FORWARD)

Lightweight wrapper around a ServoImplEx that provides a more user-friendly interface for controlling servo position and PWM range. controls how sensitive the position caching delegate is to small changes.

Example:

val servo = NextServo("armServo")
servo.position = 0.5
servo.setPwmRange(500.0, 2500.0)

Parameters

initializer

A function returning the backing ServoImplEx. It will be invoked lazily the first time the servo is accessed.

cacheTolerance

Tolerance used by the Caching delegate for position updates; defaults to 0.01.

direction

The initial direction of the servo defined by the user as a NextMotor.Direction which defaults to NextMotor.Direction.FORWARD

Inheritors

Constructors

Link copied to clipboard
constructor(initializer: () -> ServoImplEx, cacheTolerance: Double = 0.01, direction: NextMotor.Direction = NextMotor.Direction.FORWARD)
constructor(module: NextLynxModule, port: Int, cacheTolerance: Double = 0.01, direction: NextMotor.Direction = NextMotor.Direction.FORWARD)

Constructor to create a NextServo using a LynxModule and port number.

constructor(name: String, cacheTolerance: Double = 0.01, direction: NextMotor.Direction = NextMotor.Direction.FORWARD)

Constructor to create a NextServo using configuration name

Properties

Link copied to clipboard
Link copied to clipboard

Allows user to change servo's direction configuration

Link copied to clipboard

The commanded servo position in the range [0.0, 1.0].

Link copied to clipboard

Provides access to the servo's PWM range configuration.

Functions

Link copied to clipboard
fun disable()

Disables PWM output for the underlying servo.

Link copied to clipboard
fun enable()

Enables PWM output for the underlying servo.

Link copied to clipboard
fun setPwmRange(lower: Double, upper: Double)

Sets the PWM range of the associated servo.