Class: Denko::LED::RGB

Inherits:
Object
  • Object
show all
Includes:
Behaviors::MultiPin
Defined in:
lib/denko/led/rgb.rb

Constant Summary collapse

COLORS =

Format: [R, G, B]

{
  red:     [255, 000, 000],
  green:   [000, 255, 000],
  blue:    [000, 000, 255],
  cyan:    [000, 255, 255],
  yellow:  [255, 255, 000],
  magenta: [255, 000, 255],
  white:   [255, 255, 255],
  off:     [000, 000, 000]
}

Instance Attribute Summary

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Attributes included from Behaviors::Component

#board

Instance Method Summary collapse

Methods included from Behaviors::MultiPin

#before_initialize, #convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins

Methods included from Behaviors::Component

#initialize, #micro_delay

Methods included from Behaviors::State

#initialize, #state

Instance Method Details

#color=(color) ⇒ Object



30
31
32
33
34
35
# File 'lib/denko/led/rgb.rb', line 30

def color=(color)
  return write(color) if color.class == Array

  color = color.to_sym
  write(COLORS[color]) if COLORS.include? color
end

#initialize_pins(options = {}) ⇒ Object



6
7
8
9
10
# File 'lib/denko/led/rgb.rb', line 6

def initialize_pins(options={})
  proxy_pin :red,   LED::Base
  proxy_pin :green, LED::Base
  proxy_pin :blue,  LED::Base
end

#write(array) ⇒ Object



24
25
26
27
28
# File 'lib/denko/led/rgb.rb', line 24

def write(array)
  red.write   array[0]
  green.write array[1]
  blue.write  array[2]
end