Class: Phidgets::Spatial::SpatialCompassAxes

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

Overview

This class represents an axis of compass for a PhidgetSpatial. All the properties of an compass axis are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetSpatial

Instance Method Summary collapse

Instance Method Details

#indexInteger

Returns index of the compass axis, or raises an error.

Returns:

  • (Integer)

    returns index of the compass axis, or raises an error.



229
230
231
# File 'lib/phidgets-ffi/spatial.rb', line 229

def index 
	@index
end

#inspectObject

Displays data for the compass axis



224
225
226
# File 'lib/phidgets-ffi/spatial.rb', line 224

def inspect
     "#<#{self.class} @magnetic_field=#{magnetic_field}, @magnetic_field_max=#{magnetic_field_max}, @magnetic_field_min=#{magnetic_field_min}>"
end

#magnetic_fieldFloat

Returns the magnetic field strength of the axis, in Gauss, or raises an error.

Returns:

  • (Float)

    returns the magnetic field strength of the axis, in Gauss, or raises an error.



234
235
236
237
238
# File 'lib/phidgets-ffi/spatial.rb', line 234

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

#magnetic_field_maxFloat

Returns the maximum magnetic field strength measurable by the compass axis, or raises an error.

Returns:

  • (Float)

    returns the maximum magnetic field strength measurable by the compass axis, or raises an error.



241
242
243
244
245
# File 'lib/phidgets-ffi/spatial.rb', line 241

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

#magnetic_field_minFloat

Returns the minimum magnetic field strength measurable by the compass axis, or raises an error.

Returns:

  • (Float)

    returns the minimum magnetic field strength measurable by the compass axis, or raises an error.



248
249
250
251
252
# File 'lib/phidgets-ffi/spatial.rb', line 248

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