Class: Phidgets::Accelerometer::AccelerometerAxes

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

Overview

This class represents an axis of acceleration for a PhidgetAccelerometer. All the properties of an accelerometer axis are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetAccelerometer

Instance Method Summary collapse

Instance Method Details

#accelerationFloat

Returns the acceleration value of the axis, or raises an error.

Returns:

  • (Float)

    returns the acceleration value of the axis, or raises an error.



83
84
85
86
87
# File 'lib/phidgets-ffi/accelerometer.rb', line 83

def acceleration
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getAcceleration(@handle, @index, ptr)
	  ptr.get_double(0)
end

#acceleration_maxFloat

Returns the largest acceleration value that the axis will return, or raises an error.

Returns:

  • (Float)

    returns the largest acceleration value that the axis will return, or raises an error.



90
91
92
93
94
# File 'lib/phidgets-ffi/accelerometer.rb', line 90

def acceleration_max
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getAccelerationMax(@handle, @index, ptr)
  ptr.get_double(0)
end

#acceleration_minFloat

Returns the largest(negative) acceleration value that the axis will return, or raises an error.

Returns:

  • (Float)

    returns the largest(negative) acceleration value that the axis will return, or raises an error.



97
98
99
100
101
# File 'lib/phidgets-ffi/accelerometer.rb', line 97

def acceleration_min
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getAccelerationMin(@handle, @index, ptr)
  ptr.get_double(0)
end

#indexInteger

Returns index of the axis, or raises an error.

Returns:

  • (Integer)

    returns index of the axis, or raises an error.



78
79
80
# File 'lib/phidgets-ffi/accelerometer.rb', line 78

def index 
	@index
end

#inspectObject

Displays data for the axis



73
74
75
# File 'lib/phidgets-ffi/accelerometer.rb', line 73

def inspect
     "#<#{self.class} @acceleration=#{acceleration}, @acceleration_max=#{acceleration_max}, @acceleration_min=#{acceleration_min}, @sensitivity=#{sensitivity}>"
end

#sensitivityFloat

Returns sensitivity of the acceleration data for the axis, or raises an error.

Returns:

  • (Float)

    returns sensitivity of the acceleration data for the axis, or raises an error.



112
113
114
115
116
# File 'lib/phidgets-ffi/accelerometer.rb', line 112

def sensitivity
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getAccelerationChangeTrigger(@handle, @index, ptr)
  ptr.get_double(0)
end

#sensitivity=(new_sensitivity) ⇒ Float

Sets the sensitivity of the acceleration data for the axis, or raises an error.

Parameters:

  • new_sensitivity (Float)

    new sensitivity

Returns:

  • (Float)

    returns sensitivity of the acceleration data for the axis, or raises an error.



106
107
108
109
# File 'lib/phidgets-ffi/accelerometer.rb', line 106

def sensitivity=(new_sensitivity)
  Klass.setAccelerationChangeTrigger(@handle, @index, new_sensitivity.to_f)
  new_sensitivity.to_f
end