Class: Phidgets::MotorControl::MotorControlAnalogSensors

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/motor_control.rb

Overview

This class represents an analog sensor for a PhidgetMotorControl. All the properties of an analog sensor are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetMotorControl

Instance Method Summary collapse

Instance Method Details

#indexInteger

Returns index of the analog input, or raises an error.

Returns:

  • (Integer)

    returns index of the analog input, or raises an error.



339
340
341
# File 'lib/phidgets-ffi/motor_control.rb', line 339

def index 
  @index
end

#inspectObject

Displays data for the analog sensor



334
335
336
# File 'lib/phidgets-ffi/motor_control.rb', line 334

def inspect
  "#<#{self.class} @value=#{value}, @raw_value=#{raw_value}>"
end

#raw_valueInteger

Returns raw value of the analog input, or raises an error.

Returns:

  • (Integer)

    returns raw value of the analog input, or raises an error.



352
353
354
355
356
# File 'lib/phidgets-ffi/motor_control.rb', line 352

def raw_value
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getSensorRawValue(@handle, @index, ptr)
  ptr.get_int(0)
end

#valueInteger Also known as: to_i

Returns value of the analog input, or raises an error.

Returns:

  • (Integer)

    returns value of the analog input, or raises an error.



344
345
346
347
348
# File 'lib/phidgets-ffi/motor_control.rb', line 344

def value
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getSensorValue(@handle, @index, ptr)
  ptr.get_int(0)
end