Class: Artoo::Drivers::Sphero
- Defined in:
- lib/artoo/drivers/sphero.rb
Overview
The Sphero driver behaviors
Constant Summary collapse
- RED =
[255, 0, 0]
- GREEN =
[0, 255, 0]
- YELLOW =
[255, 255, 0]
- BLUE =
[0, 0, 255]
- WHITE =
[255, 255, 255]
- COMMANDS =
[:detect_collisions, :clear_collisions, :collisions, :power_notifications, :sensor_data, :set_color, :color].freeze
Instance Attribute Summary
Attributes inherited from Driver
Instance Method Summary collapse
-
#clear_collisions ⇒ Object
Clears collisions.
-
#collisions ⇒ CollisionDetected
Collision.
-
#color(*colors) ⇒ Object
Retrieves color.
-
#detect_collisions(params = {}) ⇒ Object
Detects collisions.
-
#power_notifications ⇒ PowerNotification
Power notification.
-
#sensor_data ⇒ SensorData
Sensor data.
-
#set_color(*colors) ⇒ Object
Set color.
Methods inherited from Driver
#command, #commands, #connection, #event_topic_name, #initialize, #interval, #known_command?, #method_missing, #pin, #start_driver
Constructor Details
This class inherits a constructor from Artoo::Drivers::Driver
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Artoo::Drivers::Driver
Instance Method Details
#clear_collisions ⇒ Object
Clears collisions
24 25 26 |
# File 'lib/artoo/drivers/sphero.rb', line 24 def clear_collisions .clear if responses = end |
#collisions ⇒ CollisionDetected
Returns collision.
29 30 31 |
# File 'lib/artoo/drivers/sphero.rb', line 29 def collisions matching_response_types , ::Sphero::Response::CollisionDetected end |
#color(*colors) ⇒ Object
Retrieves color
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/artoo/drivers/sphero.rb', line 51 def color(*colors) case colors.first when :red then RED when :green then GREEN when :yellow then YELLOW when :blue then BLUE when :white then WHITE else colors end end |
#detect_collisions(params = {}) ⇒ Object
Detects collisions
19 20 21 |
# File 'lib/artoo/drivers/sphero.rb', line 19 def detect_collisions(params={}) connection.configure_collision_detection 0x01, 0x20, 0x20, 0x20, 0x20, 0x50 end |
#power_notifications ⇒ PowerNotification
Returns power notification.
34 35 36 |
# File 'lib/artoo/drivers/sphero.rb', line 34 def power_notifications matching_response_types , ::Sphero::Response::PowerNotification end |
#sensor_data ⇒ SensorData
Returns sensor data.
39 40 41 |
# File 'lib/artoo/drivers/sphero.rb', line 39 def sensor_data matching_response_types , ::Sphero::Response::SensorData end |
#set_color(*colors) ⇒ Object
Set color
45 46 47 |
# File 'lib/artoo/drivers/sphero.rb', line 45 def set_color(*colors) connection.rgb(*color(*colors)) end |