24 CPhidgetEncoder_set_OnIndex_Handler(encoder_handle_,
IndexHandler,
this);
32 assert(ret == EPHIDGET_OK);
40 int ret = CPhidgetEncoder_getInputState(
encoder_handle_, index, &state);
42 assert(ret == EPHIDGET_OK);
44 return state == PTRUE;
52 assert(ret == EPHIDGET_OK);
60 int ret = CPhidgetEncoder_getPosition(
encoder_handle_, index, &position);
62 assert(ret == EPHIDGET_OK);
69 int ret = CPhidgetEncoder_setPosition(
encoder_handle_, index, position);
71 assert(ret == EPHIDGET_OK);
77 int ret = CPhidgetEncoder_getIndexPosition(
encoder_handle_, index, &position);
80 if (ret == EPHIDGET_UNKNOWNVAL)
return 0;
82 assert(ret == EPHIDGET_OK);
92 assert(ret == EPHIDGET_OK);
94 return enabled == PTRUE;
99 int ret = CPhidgetEncoder_setEnabled(
encoder_handle_, index, enabled ? PTRUE : PFALSE);
101 assert(ret == EPHIDGET_OK);
106 ((
Encoder*)userPtr)->inputChangeHandler(index, inputState);
112 ((
Encoder*)userPtr)->positionChangeHandler(index, time, positionChange);
118 ((
Encoder*)userPtr)->indexHandler(index, indexPosition);
CPhidgetEncoderHandle encoder_handle_
static int InputChangeHandler(CPhidgetEncoderHandle phid, void *userPtr, int index, int inputState)
virtual void registerHandlers()
virtual void indexHandler(int index, int indexPosition)
int getInputCount()
Gets the number of digital input channels supported by this board.
int getIndexPosition(int index)
Gets the position of an encoder the last time an index pulse occured. An index pulse in this context ...
virtual void inputChangeHandler(int index, int inputState)
void setEnabled(int index, bool enabled)
Set the powered state of an encoder. If an encoder is not enabled, it will not be given power...
int getEncoderCount()
Gets the number of encoder input channels supported by this board.
int getPosition(int index)
Reads the current position of an encoder.
static int PositionChangeHandler(CPhidgetEncoderHandle phid, void *userPtr, int index, int time, int positionChange)
bool getInputState(int index)
Reads the current state of a digital input.
static int IndexHandler(CPhidgetEncoderHandle phid, void *userPtr, int index, int indexPosition)
void setPosition(int index, int position)
Sets the offset of an encoder such that current position is the specified value.
void init(CPhidgetHandle handle)
bool getEnabled(int index)
Checks if an encoder is powered on and receiving events.
virtual void positionChangeHandler(int index, int time, int positionChange)