Class: IoT::LED::RGB
- Inherits:
-
DigitalEffector
- Object
- Effector
- DigitalEffector
- IoT::LED::RGB
- Defined in:
- lib/iot/led_rgb.rb
Instance Method Summary collapse
- #all_off ⇒ Object
- #all_on ⇒ Object
- #blink(list = :all, repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
-
#initialize(red = 17, green = 27, blue = 22) ⇒ RGB
constructor
A new instance of RGB.
- #off(color = :all) ⇒ Object
- #on(color = :all) ⇒ Object
Methods inherited from DigitalEffector
Methods inherited from Effector
Constructor Details
#initialize(red = 17, green = 27, blue = 22) ⇒ RGB
Returns a new instance of RGB.
10 11 12 13 14 15 16 |
# File 'lib/iot/led_rgb.rb', line 10 def initialize(red = 17, green = 27, blue = 22) super({:red => red, :green => green, :blue => blue}, :low) @red = red @green = green @blue = blue self.name = 'RGB LED' end |
Instance Method Details
#all_off ⇒ Object
69 70 71 |
# File 'lib/iot/led_rgb.rb', line 69 def all_off off :all end |
#all_on ⇒ Object
65 66 67 |
# File 'lib/iot/led_rgb.rb', line 65 def all_on on :all end |
#blink(list = :all, repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/iot/led_rgb.rb', line 73 def blink(list = :all, repeat=3, switched_on=0.25, switched_off=0.5) colors = (list == :all) ? [:red, :green, :blue] : (list.class == Array ? list : [list]) repeat.times do |n| colors.each do |color| on color sleep switched_on off color sleep switched_off end end end |
#off(color = :all) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/iot/led_rgb.rb', line 41 def off(color=:all) color = :aoi if color == :aqua case color when :red super @red when :green super @green when :blue super @blue when :yellow super @red super @green when :aoi super @blue super @green when :all super @red super @green super @blue else all_off end end |
#on(color = :all) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/iot/led_rgb.rb', line 18 def on(color=:all) color = :aoi if color == :aqua case color when :red super @red when :green super @green when :blue super @blue when :yellow super @red super @green when :aoi super @blue super @green when :all super @red super @green super @blue else end end |