class Artoo::Drivers::BlinkM

BlinkM LED driver behaviors for i2c

Constants

COMMANDS

Public Instance Methods

address() click to toggle source
# File lib/artoo/drivers/blink_m.rb, line 9
def address; 0x09; end
color() click to toggle source
# File lib/artoo/drivers/blink_m.rb, line 42
def color
  connection.i2c_write('g'.bytes.first)
  @data = connection.i2c_read(3)
  return nil if @data.nil? || @data.empty?
  return @data[0], @data[1], @data[2]
end
fade(r=0, g=0, b=0) click to toggle source
# File lib/artoo/drivers/blink_m.rb, line 30
def fade(r=0, g=0, b=0)
  connection.i2c_write('c'.bytes.first)
  connection.i2c_write(r, g, b)
end
firmware_version() click to toggle source
# File lib/artoo/drivers/blink_m.rb, line 35
def firmware_version
  connection.i2c_write('Z'.bytes.first)
  @data = connection.i2c_read(2)
  return nil if @data.nil? || @data.empty?
  return "#{@data[0]}.#{@data[1]}"
end
rgb(r=0, g=0, b=0) click to toggle source
# File lib/artoo/drivers/blink_m.rb, line 25
def rgb(r=0, g=0, b=0)
  connection.i2c_write('n'.bytes.first)
  connection.i2c_write(r, g, b)
end
start_driver() click to toggle source
Calls superclass method
# File lib/artoo/drivers/blink_m.rb, line 11
def start_driver
  begin
    connection.i2c_start(address)
    connection.i2c_write("o".bytes.first) # stops any scripts already running
    rgb(0, 0, 0)

    super
  rescue Exception => e
    Logger.error "Error starting BlinkM driver!"
    Logger.error e.message
    Logger.error e.backtrace.inspect
  end
end