NextAnalogInput

open class NextAnalogInput @JvmOverloads constructor(initializer: () -> AnalogInput, val customTransformation: (Double) -> Double = { n: Double -> n }, maxVoltage: Voltage = 3.3.volts) : AnalogFeedback

A wrapper around an AnalogInput that provides convenient access to raw voltage readings as well as a normalized, optionally transformed value.

The hardware device is resolved lazily, so constructing an instance of this class does not require the hardware map to be ready yet.

Inherits from AnalogFeedback so that any NextAnalogInput can also be used directly as a by-delegate returning an angle in radians (e.g. for feedback CR servos).

Parameters

initializer

A lambda that resolves and returns the underlying AnalogInput.

customTransformation

An optional transformation applied to the normalized voltage ratio (raw voltage divided by maxVoltage) before it is exposed via value. Defaults to the identity function.

maxVoltage

The voltage that corresponds to a normalized value of 1.0. Defaults to 3.3 volts.

Constructors

Link copied to clipboard
constructor(initializer: () -> AnalogInput, customTransformation: (Double) -> Double = { n: Double -> n }, maxVoltage: Voltage = 3.3.volts)
constructor(name: String, customTransformation: (Double) -> Double = { n: Double -> n }, maxVoltage: Voltage = 3.3.volts)

Creates a NextAnalogInput by looking up the AnalogInput in the hardware map by its configured name.

constructor(module: NextLynxModule, channel: Int, customTransformation: (Double) -> Double = { n: Double -> n }, maxVoltage: Voltage = 3.3.volts)

Creates a NextAnalogInput directly from a NextLynxModule and analog channel number, bypassing the hardware map.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The raw, untransformed voltage currently read from the analog input.

Link copied to clipboard

The normalized reading from the analog input, computed as rawVoltage divided by maxVoltage and passed through customTransformation.

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): Double