Class: Denko::LED::RGB
Constant Summary
collapse
- COLORS =
{
red: [100, 000, 000],
green: [000, 100, 000],
blue: [000, 000, 100],
cyan: [000, 100, 100],
yellow: [100, 100, 000],
magenta: [100, 000, 100],
white: [100, 100, 100],
off: [000, 000, 000]
}
Behaviors::Lifecycle::CALLBACK_METHODS
Instance Attribute Summary
#pin, #pins, #proxies
#board, #params
#state
Instance Method Summary
collapse
#convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins
included
#initialize, #micro_delay
#update_state
Instance Method Details
#color=(color) ⇒ Object
36
37
38
39
|
# File 'lib/denko/led/rgb.rb', line 36
def color=(color)
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(r, g, b) ⇒ Object
24
25
26
27
28
|
# File 'lib/denko/led/rgb.rb', line 24
def write(r, g, b)
red.duty = r
green.duty = g
blue.duty = b
end
|
#write_8_bit(r, g, b) ⇒ Object
30
31
32
33
34
|
# File 'lib/denko/led/rgb.rb', line 30
def write_8_bit(r, g, b)
red.duty = ((r / 255.0) * 100).round
green.duty = ((g / 255.0) * 100).round
blue.duty = ((b / 255.0) * 100).round
end
|