Class: Artoo::Drivers::Sphero
- Inherits:
-
Driver
- Object
- Driver
- Artoo::Drivers::Sphero
show all
- 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]
Instance Attribute Summary
Attributes inherited from Driver
#parent
Instance Method Summary
collapse
Methods inherited from Driver
#connection, #event_topic_name, #initialize, #interval, #method_missing, #pin, #start_driver
Methods included from Celluloid
#timers
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
17
18
19
|
# File 'lib/artoo/drivers/sphero.rb', line 17
def clear_collisions
messages.clear if responses = messages
end
|
#collisions ⇒ Object
21
22
23
|
# File 'lib/artoo/drivers/sphero.rb', line 21
def collisions
matching_response_types messages, ::Sphero::Response::CollisionDetected
end
|
#color(*colors) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/artoo/drivers/sphero.rb', line 37
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
13
14
15
|
# File 'lib/artoo/drivers/sphero.rb', line 13
def detect_collisions(params={})
connection.configure_collision_detection 0x01, 0x20, 0x20, 0x20, 0x20, 0x50
end
|
#power_notifications ⇒ Object
25
26
27
|
# File 'lib/artoo/drivers/sphero.rb', line 25
def power_notifications
matching_response_types messages, ::Sphero::Response::PowerNotification
end
|
#sensor_data ⇒ Object
29
30
31
|
# File 'lib/artoo/drivers/sphero.rb', line 29
def sensor_data
matching_response_types messages, ::Sphero::Response::SensorData
end
|
#set_color(*colors) ⇒ Object
33
34
35
|
# File 'lib/artoo/drivers/sphero.rb', line 33
def set_color(*colors)
connection.rgb(*color(*colors))
end
|