setResetOperation

open fun setResetOperation(@NonNull resetOperation: IntBinaryOperator)

Defines the operation to perform when an encoder reset is executed.

For motor objects, it is often desired to switch to STOP_AND_RESET_ENCODER and back, not returning an offset for Encoder to use, and for other cases (including the default) it is desired to offset the current accumulation by the current value.

Parameters

resetOperation

A function that has inputs (currentResetVal, currentPosition) and should return (newResetVal) which will be used in the next reset operation. newResetVal will be subtracted from the current encoder accumulation, and sent into currentResetVal on the next reset. currentPosition is a fresh reading of the getPosition method at the time of invocation. Default behaviour is to sum the current position to the reset value (e.g. resetVal += currentPosition).