Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
phidgets::Encoder Class Referencefinal

#include <encoder.h>

Public Member Functions

 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)
 
uint32_t getDataInterval () const
 
bool getEnabled () const
 Checks if an encoder is powered on and receiving events. More...
 
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. More...
 
Phidget_EncoderIOMode getIOMode () const
 
int64_t getPosition () const
 Reads the current position of an encoder. More...
 
void positionChangeHandler (int position_change, double time, int index_triggered)
 
void setDataInterval (uint32_t data_interval_ms) const
 
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. More...
 
void setIOMode (Phidget_EncoderIOMode io_mode) const
 
void setPosition (int64_t position) const
 Sets the offset of an encoder such that current position is the specified value. More...
 
 ~Encoder ()
 

Static Private Member Functions

static void PositionChangeHandler (PhidgetEncoderHandle phid, void *ctx, int position_change, double time_change, int index_triggered)
 

Private Attributes

int channel_
 
PhidgetEncoderHandle encoder_handle_
 
std::function< void(int, int, double, int)> position_change_handler_
 

Detailed Description

Definition at line 41 of file encoder.h.

Constructor & Destructor Documentation

◆ Encoder()

phidgets::Encoder::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 
)
explicit

Definition at line 39 of file encoder.cpp.

◆ ~Encoder()

phidgets::Encoder::~Encoder ( )

Definition at line 66 of file encoder.cpp.

Member Function Documentation

◆ getDataInterval()

uint32_t phidgets::Encoder::getDataInterval ( ) const

Definition at line 166 of file encoder.cpp.

◆ getEnabled()

bool phidgets::Encoder::getEnabled ( ) const

Checks if an encoder is powered on and receiving events.

Definition at line 115 of file encoder.cpp.

◆ getIndexPosition()

int64_t phidgets::Encoder::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.

Definition at line 99 of file encoder.cpp.

◆ getIOMode()

Phidget_EncoderIOMode phidgets::Encoder::getIOMode ( ) const

Definition at line 142 of file encoder.cpp.

◆ getPosition()

int64_t phidgets::Encoder::getPosition ( ) const

Reads the current position of an encoder.

Definition at line 72 of file encoder.cpp.

◆ positionChangeHandler()

void phidgets::Encoder::positionChangeHandler ( int  position_change,
double  time,
int  index_triggered 
)

Definition at line 194 of file encoder.cpp.

◆ PositionChangeHandler()

void phidgets::Encoder::PositionChangeHandler ( PhidgetEncoderHandle  phid,
void *  ctx,
int  position_change,
double  time_change,
int  index_triggered 
)
staticprivate

Definition at line 200 of file encoder.cpp.

◆ setDataInterval()

void phidgets::Encoder::setDataInterval ( uint32_t  data_interval_ms) const

Definition at line 181 of file encoder.cpp.

◆ setEnabled()

void phidgets::Encoder::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
enabledThe new powered state of the encoder

Definition at line 130 of file encoder.cpp.

◆ setIOMode()

void phidgets::Encoder::setIOMode ( Phidget_EncoderIOMode  io_mode) const

Definition at line 155 of file encoder.cpp.

◆ setPosition()

void phidgets::Encoder::setPosition ( int64_t  position) const

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

Parameters
positionThe new value that should be returned by 'getPosition(index)' at the current position of the encoder

Definition at line 87 of file encoder.cpp.

Member Data Documentation

◆ channel_

int phidgets::Encoder::channel_
private

Definition at line 89 of file encoder.h.

◆ encoder_handle_

PhidgetEncoderHandle phidgets::Encoder::encoder_handle_
private

Definition at line 91 of file encoder.h.

◆ position_change_handler_

std::function<void(int, int, double, int)> phidgets::Encoder::position_change_handler_
private

Definition at line 90 of file encoder.h.


The documentation for this class was generated from the following files:


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Sun May 11 2025 02:20:27