Class: Phidgets::Stepper::StepperSteppers

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

Overview

This class represents a stepper motor of a PhidgetStepper. All the properties of a stepper motor are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetStepper

Instance Method Summary collapse

Instance Method Details

#accelerationFloat

Returns the acceleration of a stepper, in (micro)steps per second squared, or raises an error.

Returns:

  • (Float)

    returns the acceleration of a stepper, in (micro)steps per second squared, or raises an error.



163
164
165
166
167
# File 'lib/phidgets-ffi/stepper.rb', line 163

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

#acceleration=(new_acceleration) ⇒ Float

Sets the acceleration of a stepper, in (micro)steps per second squared, or raises an error.

Parameters:

  • new_acceleration (Integer)

    new acceleration

Returns:

  • (Float)

    returns acceleration of a servo, in degrees/second, or raises an error.



172
173
174
175
# File 'lib/phidgets-ffi/stepper.rb', line 172

def acceleration=(new_acceleration)
  Klass.setAcceleration(@handle, @index, new_acceleration.to_f)
	  new_acceleration
end

#acceleration_maxFloat

Returns the largest acceleration value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the largest acceleration value that the stepper will accept, or raises an error.



178
179
180
181
182
# File 'lib/phidgets-ffi/stepper.rb', line 178

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

#acceleration_minFloat

Returns the smallest acceleration value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the smallest acceleration value that the stepper will accept, or raises an error.



185
186
187
188
189
# File 'lib/phidgets-ffi/stepper.rb', line 185

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

#currentFloat

Returns the stepper’s current usage, in Amps, or raises an error.

Returns:

  • (Float)

    returns the stepper’s current usage, in Amps, or raises an error.



192
193
194
195
196
# File 'lib/phidgets-ffi/stepper.rb', line 192

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

#current_limitFloat

Returns the stepper’s current usage limit, in Amps, or raises an error.

Returns:

  • (Float)

    returns the stepper’s current usage limit, in Amps, or raises an error.



199
200
201
202
203
# File 'lib/phidgets-ffi/stepper.rb', line 199

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

#current_limit=(new_current_limit) ⇒ Float

Sets the stepper’s current usage limit, in Amps, or raises an error.

Parameters:

  • new_current_limit (Integer)

    new current limit

Returns:

  • (Float)

    returns current limit, in Amps, or raises an error.



208
209
210
211
# File 'lib/phidgets-ffi/stepper.rb', line 208

def current_limit=(new_current_limit)
  Klass.setCurrentLimit(@handle, @index, new_current_limit.to_f)
	  new_current_limit
end

#current_maxFloat

Returns the largest current value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the largest current value that the stepper will accept, or raises an error.



214
215
216
217
218
# File 'lib/phidgets-ffi/stepper.rb', line 214

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

#current_minFloat

Returns the smallest acceleration value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the smallest acceleration value that the stepper will accept, or raises an error.



221
222
223
224
225
# File 'lib/phidgets-ffi/stepper.rb', line 221

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

#current_positionInteger

Returns the stepper’s current position, in (micro)steps, or raises an error.

Returns:

  • (Integer)

    returns the stepper’s current position, in (micro)steps, or raises an error.



228
229
230
231
232
# File 'lib/phidgets-ffi/stepper.rb', line 228

def current_position
  ptr = ::FFI::MemoryPointer.new(:long_long)
  Klass.getCurrentPosition(@handle, @index, ptr)
  ptr.get_long_long(0)
end

#current_position=(new_current_position) ⇒ Integer

Sets the current position of a stepper, in (micro)steps, or raises an error.

Parameters:

  • new_current_position (Integer)

    new current position

Returns:

  • (Integer)

    returns the current position of a stepper, in (micro)steps, or raises an error.



237
238
239
240
# File 'lib/phidgets-ffi/stepper.rb', line 237

def current_position=(new_current_position)
  Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)
	  new_current_position
end

#engagedBoolean

Returns the engaged state of the stepper.

Returns:

  • (Boolean)

    returns the engaged state or raises an error



245
246
247
248
249
# File 'lib/phidgets-ffi/stepper.rb', line 245

def engaged
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getEngaged(@handle, @index, ptr)
  (ptr.get_int(0) == 0) ? false : true
end

#engaged=(new_state) ⇒ Boolean

Sets the engaged state of the Phidget.

Parameters:

  • new_state (Boolean)

    new engaged state

Returns:

  • (Boolean)

    returns the engaged state or raises an error



254
255
256
257
258
# File 'lib/phidgets-ffi/stepper.rb', line 254

def engaged=(new_state)
  tmp = new_state ? 1 : 0
  Klass.setEngaged(@handle, @index, tmp)
  new_state
end

#indexInteger

Returns index of the stepper, or raises an error.

Returns:

  • (Integer)

    returns index of the stepper, or raises an error.



158
159
160
# File 'lib/phidgets-ffi/stepper.rb', line 158

def index 
	@index
end

#inspectObject

Displays data for the stepper



152
153
154
155
# File 'lib/phidgets-ffi/stepper.rb', line 152

def inspect
  "#<#{self.class} @index=#{index}, @acceleration_min=#{acceleration_min}, @acceleration_max=#{acceleration_max}, @current_min=#{current_min}, @current_max=#{current_max}, @engaged=#{engaged}, @position_min=#{position_min}, @position_max=#{position_max}, @velocity_min=#{velocity_min}, @velocity_max=#{velocity_max}>"
	 
end

#position_maxInteger

Returns the largest position value that the stepper will accept, or raises an error.

Returns:

  • (Integer)

    returns the largest position value that the stepper will accept, or raises an error.



261
262
263
264
265
# File 'lib/phidgets-ffi/stepper.rb', line 261

def position_max
  ptr = ::FFI::MemoryPointer.new(:long_long)
  Klass.getPositionMax(@handle, @index, ptr)
  ptr.get_long_long(0)
end

#position_minInteger

Returns the smallest acceleration value that the stepper will accept, or raises an error.

Returns:

  • (Integer)

    returns the smallest acceleration value that the stepper will accept, or raises an error.



268
269
270
271
272
# File 'lib/phidgets-ffi/stepper.rb', line 268

def position_min
  ptr = ::FFI::MemoryPointer.new(:long_long)
  Klass.getPositionMin(@handle, @index, ptr)
  ptr.get_long_long(0)
end

#stoppedBoolean

Returns the stopped state of a stepper, or raises an error.

Returns:

  • (Boolean)

    returns the stopped state of a stepper, or raises an error.



275
276
277
278
279
# File 'lib/phidgets-ffi/stepper.rb', line 275

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

#target_positionInteger

Returns the stepper’s target position, in (micro)steps, in degrees/second, or raises an error.

Returns:

  • (Integer)

    returns the stepper’s target position, in (micro)steps, in degrees/second, or raises an error.



282
283
284
285
286
# File 'lib/phidgets-ffi/stepper.rb', line 282

def target_position
  ptr = ::FFI::MemoryPointer.new(:long_long)
  Klass.getTargetPosition(@handle, @index, ptr)
  ptr.get_long_long(0)
end

#target_position=(new_target_position) ⇒ Integer

Sets the target position of a stepper, in (micro)steps, or raises an error.

Parameters:

  • new_target_position (Integer)

    new target position

Returns:

  • (Integer)

    returns the target position of a stepper, in (micro)steps, or raises an error.



291
292
293
294
# File 'lib/phidgets-ffi/stepper.rb', line 291

def target_position=(new_target_position)
  Klass.setTargetPosition(@handle, @index, new_target_position.to_i)
	  new_target_position
end

#velocityFloat

Returns the stepper’s current velocity, in (micro)steps per second, or raises an error.

Returns:

  • (Float)

    returns the stepper’s current velocity, in (micro)steps per second, or raises an error.



297
298
299
300
301
# File 'lib/phidgets-ffi/stepper.rb', line 297

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

#velocity_limitFloat

Returns the stepper’s velocity limit, in (micro)steps per second, or raises an error.

Returns:

  • (Float)

    returns the stepper’s velocity limit, in (micro)steps per second, or raises an error.



304
305
306
307
308
# File 'lib/phidgets-ffi/stepper.rb', line 304

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

#velocity_limit=(new_velocity_limit) ⇒ Float

Sets the velocity limit of a stepper, in (micro)steps per second, or raises an error.

Parameters:

  • new_velocity_limit (Integer)

    new velocity limit

Returns:

  • (Float)

    returns the velocity limit of a stepper, in (micro)steps per second, or raises an error.



313
314
315
316
# File 'lib/phidgets-ffi/stepper.rb', line 313

def velocity_limit=(new_velocity_limit)
  Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)
	  new_velocity_limit
end

#velocity_maxFloat

Returns the largest velocity value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the largest velocity value that the stepper will accept, or raises an error.



319
320
321
322
323
# File 'lib/phidgets-ffi/stepper.rb', line 319

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

#velocity_minFloat

Returns the smallest velocity value that the stepper will accept, or raises an error.

Returns:

  • (Float)

    returns the smallest velocity value that the stepper will accept, or raises an error.



326
327
328
329
330
# File 'lib/phidgets-ffi/stepper.rb', line 326

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