Class: Artoo::Drivers::Wiichuck
- Defined in:
- lib/artoo/drivers/wiichuck.rb
Overview
Wiichuck driver behaviors for Firmata
Instance Attribute Summary
Attributes inherited from Wiidriver
Attributes inherited from Driver
Instance Method Summary collapse
Methods inherited from Wiidriver
#address, #initialize, #start_driver
Methods inherited from Driver
#connection, #event_topic_name, #initialize, #interval, #method_missing, #pin, #start_driver
Methods included from Celluloid
Constructor Details
This class inherits a constructor from Artoo::Drivers::Wiidriver
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Artoo::Drivers::Driver
Instance Method Details
#adjust_origins ⇒ Object
22 23 24 25 |
# File 'lib/artoo/drivers/wiichuck.rb', line 22 def adjust_origins set_joystick_default_value(:sy_origin, data[:sy]) set_joystick_default_value(:sx_origin, data[:sx]) end |
#update(value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/artoo/drivers/wiichuck.rb', line 7 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
27 28 29 30 |
# File 'lib/artoo/drivers/wiichuck.rb', line 27 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
32 33 34 |
# File 'lib/artoo/drivers/wiichuck.rb', line 32 def update_joystick publish(event_topic_name("joystick"), {:x => calculate_joystick_value(:sx, :sx_origin), :y => calculate_joystick_value(:sy, :sy_origin)}) end |