class Artoo::Drivers::Wiichuck
Wiichuck
driver behaviors for i2c
Public Instance Methods
adjust_origins()
click to toggle source
Adjust x, y origin values
# 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)
click to toggle source
Update button and joystick values @param [Object] value
Calls superclass method
# File lib/artoo/drivers/wiichuck.rb, line 10 def update(value) begin super adjust_origins update_buttons update_joystick rescue Exception => e Logger.error "wiichuck update exception!" Logger.error e.message Logger.error e.backtrace.inspect end end
update_joystick()
click to toggle source
Publishes event for joystick
# 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
Private Instance Methods
get_defaults()
click to toggle source
# File lib/artoo/drivers/wiichuck.rb, line 44 def get_defaults { :sy_origin => nil, :sx_origin => nil } end
parse(value)
click to toggle source
# File lib/artoo/drivers/wiichuck.rb, line 51 def parse(value) return { :sx => decode_value(value, 0), :sy => decode_value(value, 1), :z => generate_bool(decode_value(value, 5) & 0x01), :c => generate_bool(decode_value(value, 5) & 0x02) } end