NextServo

open class NextServo(initializer: () -> ServoImplEx, val cacheTolerance: Double = 0.01)

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.

Inheritors

Constructors

Link copied to clipboard
constructor(initializer: () -> ServoImplEx, cacheTolerance: Double = 0.01)
constructor(module: LynxModule, port: Int, cacheTolerance: Double = 0.01)

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

constructor(name: String, cacheTolerance: Double = 0.01)

Properties

Link copied to clipboard
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.