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



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.



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



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



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



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



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.



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



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



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



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.



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.



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.



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



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



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



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



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



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.



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



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



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.



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



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



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