Class Encoder

Class Documentation

class Encoder

Public Functions

explicit Encoder(int32_t serial_number, int hub_port, bool is_hub_port_device, int channel, std::function<void(int, int, double, int)> position_change_handler)
~Encoder()
int32_t getSerialNumber() const noexcept
int64_t getPosition() const

Reads the current position of an encoder.

void setPosition(int64_t position) const

Sets the offset of an encoder such that current position is the specified value.

Parameters:

position – The new value that should be returned by ‘getPosition(index)’ at the current position of the encoder

int64_t getIndexPosition() const

Gets the position of an encoder the last time an index pulse occured. An index pulse in this context refers to an input from the encoder the pulses high once every revolution.

bool getEnabled() const

Checks if an encoder is powered on and receiving events.

void setEnabled(bool enabled) const

Set the powered state of an encoder. If an encoder is not enabled, it will not be given power, and events and changes in position will not be captured.

Parameters:

enabled – The new powered state of the encoder

void positionChangeHandler(int position_change, double time, int index_triggered)