class Artoo::Drivers::Neomatrix

Constants

COMMANDS

Attributes

height[R]
registered[R]
width[R]

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method
# File lib/artoo/drivers/neomatrix.rb, line 10
def initialize(params = {})
  @is_on = Hash.new(false)
  additional_params = params.fetch(:additional_params) { Hash.new }
  @width = additional_params.fetch(:width)
  @height = additional_params.fetch(:height)
  @registered = false
  super
end

Public Instance Methods

off(x, y) click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 32
def off(x, y)
  change_state(x, y, 0, 0, 0)
  @is_on[[x,y]] = false
end
off?(x,y) click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 23
def off?(x,y)
  !on?([x,y])
end
on(x, y, red, green, blue) click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 27
def on(x, y, red, green, blue)
  change_state(x, y, red, green, blue)
  @is_on[[x,y]] = true
end
on?(x,y) click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 19
def on?(x,y)
  @is_on[[x,y]]
end

Private Instance Methods

change_state(x, y, red, green, blue) click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 39
def change_state(x, y, red, green, blue)
  ensure_registered
  connection.neomatrix(x, y, red, green, blue)
end
ensure_registered() click to toggle source
# File lib/artoo/drivers/neomatrix.rb, line 44
def ensure_registered
  unless registered
    connection.register_neomatrix(pin, width, height)
    @registered = true
  end
end