okapi::ADIEncoder class

Base classes

class ContinuousRotarySensor

Constructors, destructors, conversion operators

ADIEncoder(std::uint8_t iportTop, std::uint8_t iportBottom, bool ireversed = false)
An encoder in an ADI port.
ADIEncoder(std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> iports, bool ireversed = false)
An encoder in an ADI port.

Public functions

auto get() const -> double override
Get the current sensor value.
auto reset() -> std::int32_t override
Reset the sensor to zero.
auto controllerGet() -> double override
Get the sensor value for use in a control loop.

Protected variables

pros::c::ext_adi_encoder_t enc

Function documentation

okapi::ADIEncoder::ADIEncoder(std::uint8_t iportTop, std::uint8_t iportBottom, bool ireversed = false)

An encoder in an ADI port.

Parameters
iportTop The "top" wire from the encoder with the removable cover side up. This must be in port 1, 3, 5, or 7 (A, C, E, or G).
iportBottom The "bottom" wire from the encoder. This must be in port 2, 4, 6, or 8 (B, D, F, or H).
ireversed Whether the encoder is reversed.
auto enc = ADIEncoder('A', 'B', false);
auto reversedEnc = ADIEncoder('A', 'B', true);

okapi::ADIEncoder::ADIEncoder(std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> iports, bool ireversed = false)

An encoder in an ADI port.

Parameters
iports The ports the encoder is plugged in to in the order {smart port, top port, bottom port}. The smart port is the smart port number ([1, 21]). The top port is the "top" wire from the encoder with the removable cover side up. This must be in port 1, 3, 5, or 7 (A, C, E, or G). The bottom port is the "bottom" wire from the encoder. This must be in port 2, 4, 6, or 8 (B, D, F, or H).
ireversed Whether the encoder is reversed.
auto enc = ADIEncoder({1, 'A', 'B'}, false);
auto reversedEnc = ADIEncoder({1, 'A', 'B'}, true);

double okapi::ADIEncoder::get() const override

Get the current sensor value.

Returns the current sensor value, or PROS_ERR on a failure.

std::int32_t okapi::ADIEncoder::reset() override

Reset the sensor to zero.

Returns 1 on success, PROS_ERR on fail

double okapi::ADIEncoder::controllerGet() override

Get the sensor value for use in a control loop.

Returns the current sensor value, or PROS_ERR on a failure.

This method might be automatically called in another thread by the controller.