Class: Tinkerforge::BrickletMotorizedLinearPoti
- Inherits:
-
Object
- Object
- Tinkerforge::BrickletMotorizedLinearPoti
- Defined in:
- lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb
Instance Method Summary collapse
-
#lock(position = nil) ⇒ Object
(also: #hold)
Locks the position of the potentiometer.
-
#position ⇒ Object
Returns the position of the potentiometer (an integer in the range 0..100).
-
#position=(position) ⇒ Object
(also: #move_to)
Moves the potentiometer to the given position.
-
#release(position = nil) ⇒ Object
Releases the potentiometer, so its position can be changed by hand.
-
#state ⇒ Object
Returns the device’s state.
Instance Method Details
#lock(position = nil) ⇒ Object Also known as: hold
Locks the position of the potentiometer. If a position is given, moves to that position first.
21 22 23 |
# File 'lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb', line 21 def lock(position=nil) set_motor_position( position || get_position, get_motor_position[1], true ) end |
#position ⇒ Object
Returns the position of the potentiometer (an integer in the range 0..100).
6 7 8 |
# File 'lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb', line 6 def position get_position end |
#position=(position) ⇒ Object Also known as: move_to
Moves the potentiometer to the given position.
If the potentiometer was locked before, it will be locked at the new position. The drive mode (speed) will be the same as the last time the position was set.
14 15 16 |
# File 'lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb', line 14 def position=(position) set_motor_position( position, *get_motor_position[1,2] ) end |
#release(position = nil) ⇒ Object
Releases the potentiometer, so its position can be changed by hand. If a position is given, moves to that position first.
28 29 30 |
# File 'lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb', line 28 def release(position=nil) set_motor_position( position || get_position, get_motor_position[1], false ) end |
#state ⇒ Object
Returns the device’s state.
33 34 35 36 37 38 |
# File 'lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb', line 33 def state super.merge( 'position' => get_position, 'motor_position' => get_motor_position, ) end |