Class: Phidgets::MotorControl::MotorControlEncoders
- Inherits:
-
Object
- Object
- Phidgets::MotorControl::MotorControlEncoders
- Defined in:
- lib/phidgets-ffi/motor_control.rb
Overview
This class represents an encoder for a PhidgetMotorControl. All the properties of an encoder are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetMotorControl
Instance Method Summary collapse
-
#index ⇒ Integer
Returns index of the digital input, or raises an error.
-
#inspect ⇒ Object
Displays data for the encoder.
-
#position ⇒ Integer
Returns the position of an encoder, or raises an error.
-
#position=(new_position) ⇒ Integer
Sets the position of an encoder, or raises an error.
Instance Method Details
#index ⇒ Integer
Returns index of the digital input, or raises an error.
419 420 421 |
# File 'lib/phidgets-ffi/motor_control.rb', line 419 def index @index end |
#inspect ⇒ Object
Displays data for the encoder
414 415 416 |
# File 'lib/phidgets-ffi/motor_control.rb', line 414 def inspect "#<#{self.class} @index=#{index}, @position=#{position}>" end |
#position ⇒ Integer
Returns the position of an encoder, or raises an error.
424 425 426 427 428 |
# File 'lib/phidgets-ffi/motor_control.rb', line 424 def position ptr = ::FFI::MemoryPointer.new(:int) Klass.getEncoderPosition(@handle, @index, ptr) ptr.get_int(0) end |
#position=(new_position) ⇒ Integer
Sets the position of an encoder, or raises an error.
433 434 435 436 |
# File 'lib/phidgets-ffi/motor_control.rb', line 433 def position=(new_position) Klass.setEncoderPosition(@handle, @index, new_position.to_i) new_position end |