Class: Artoo::Drivers::Wiichuck
- Defined in:
- lib/artoo/drivers/wiichuck.rb
Overview
Wiichuck driver behaviors for i2c
Instance Attribute Summary
Attributes inherited from Wiidriver
Instance Method Summary collapse
-
#adjust_origins ⇒ Object
Adjust x, y origin values.
-
#update(value) ⇒ Object
Update button and joystick values.
-
#update_buttons ⇒ Object
Publishes events for c and z buttons.
-
#update_joystick ⇒ Object
Publishes event for joystick.
Methods inherited from Wiidriver
#address, #initialize, #start_driver
Constructor Details
This class inherits a constructor from Artoo::Drivers::Wiidriver
Instance Method Details
#adjust_origins ⇒ Object
Adjust x, y origin values
26 27 28 29 |
# File 'lib/artoo/drivers/wiichuck.rb', line 26 def adjust_origins set_joystick_default_value(:sy_origin, data[:sy]) set_joystick_default_value(:sx_origin, data[:sx]) end |
#update(value) ⇒ Object
Update button and joystick values
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/artoo/drivers/wiichuck.rb', line 10 def update(value) begin super adjust_origins update_joystick rescue Exception => e Logger.error "wiichuck update exception!" Logger.error e. Logger.error e.backtrace.inspect end end |
#update_buttons ⇒ Object
Publishes events for c and z buttons
32 33 34 35 |
# File 'lib/artoo/drivers/wiichuck.rb', line 32 def publish(event_topic_name("c_button")) if data[:c] == true publish(event_topic_name("z_button")) if data[:z] == true end |
#update_joystick ⇒ Object
Publishes event for joystick
38 39 40 |
# File 'lib/artoo/drivers/wiichuck.rb', line 38 def update_joystick publish(event_topic_name("joystick"), {:x => calculate_joystick_value(:sx, :sx_origin), :y => calculate_joystick_value(:sy, :sy_origin)}) end |