Go to the documentation of this file.
41 int32_t serial_number,
int hub_port,
bool is_hub_port_device,
42 std::function<
void(
int,
int,
double,
int)> position_change_handler)
44 PhidgetReturnCode ret;
46 PhidgetEncoderHandle enc_handle;
48 ret = PhidgetEncoder_create(&enc_handle);
49 if (ret != EPHIDGET_OK)
52 "Failed to create Encoder handle for determining channel "
57 PhidgetHandle handle =
reinterpret_cast<PhidgetHandle
>(enc_handle);
60 is_hub_port_device, 0);
62 ret = Phidget_getDeviceChannelCount(handle, PHIDCHCLASS_ENCODER,
67 if (ret != EPHIDGET_OK)
69 throw Phidget22Error(
"Failed to get Encoder device channel count", ret);
75 encs_[i] = std::make_unique<Encoder>(serial_number, hub_port,
76 is_hub_port_device, i,
77 position_change_handler);
92 return encs_.at(index)->getPosition();
97 return encs_.at(index)->setPosition(position);
102 return encs_.at(index)->getIndexPosition();
107 return encs_.at(index)->getEnabled();
112 return encs_.at(index)->setEnabled(enabled);
117 return encs_.at(index)->getIOMode();
122 return encs_.at(index)->setIOMode(IOMode);
127 return encs_.at(index)->getDataInterval();
132 return encs_.at(index)->setDataInterval(data_interval_ms);
void setIOMode(int index, Phidget_EncoderIOMode io_mode) const
void setEnabled(int index, bool enabled) const
Set the powered state of an encoder. If an encoder is not enabled, it will not be given power,...
void setPosition(int index, int64_t position) const
Sets the offset of an encoder such that current position is the specified value.
Phidget_EncoderIOMode getIOMode(int index) const
void openWaitForAttachment(PhidgetHandle handle, int32_t serial_number, int hub_port, bool is_hub_port_device, int channel)
void closeAndDelete(PhidgetHandle *handle) noexcept
uint32_t getDataInterval(int index) const
std::vector< std::unique_ptr< Encoder > > encs_
uint32_t getEncoderCount() const
Gets the number of encoder input channels supported by this board.
int64_t getIndexPosition(int index) const
Gets the position of an encoder the last time an index pulse occured. An index pulse in this context ...
Encoders(int32_t serial_number, int hub_port, bool is_hub_port_device, std::function< void(int, int, double, int)> position_change_handler)
bool getEnabled(int index) const
Checks if an encoder is powered on and receiving events.
void setDataInterval(int index, uint32_t data_interval_ms) const
int64_t getPosition(int index) const
Reads the current position of an encoder.
phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Sun May 11 2025 02:20:27