Class: Dino::Components::Servo
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Dino::Components::Servo
- Defined in:
- lib/dino/components/servo.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
Returns the value of attribute position.
Attributes inherited from BaseComponent
Instance Method Summary collapse
Methods inherited from BaseComponent
Constructor Details
This class inherits a constructor from Dino::Components::BaseComponent
Instance Attribute Details
#position ⇒ Object
Returns the value of attribute position.
4 5 6 |
# File 'lib/dino/components/servo.rb', line 4 def position @position end |
Instance Method Details
#after_initialize(options = {}) ⇒ Object
6 7 8 9 10 |
# File 'lib/dino/components/servo.rb', line 6 def after_initialize(={}) set_pin_mode(:out) board.servo_toggle(pin, 1) self.position = [:position] || 0 end |
#angle(value) ⇒ Object
16 17 18 |
# File 'lib/dino/components/servo.rb', line 16 def angle(value) value == 180 ? value : value % 180 end |