Class: IoT::LED
- Inherits:
-
BinaryEffector
- Object
- Effector
- DigitalEffector
- BinaryEffector
- IoT::LED
- Defined in:
- lib/iot/led.rb,
lib/iot/led.rb,
lib/iot/led_pwm.rb,
lib/iot/led_rgb.rb
Overview
Experimental methods with names in Russian
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#blink(repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
Repeat ‘repeat’ times: light the LED for ‘switched_on’ secs, then pause for ‘switched_off’ secs.
-
#initialize(pin) ⇒ LED
constructor
A new instance of LED.
-
#off(pin = @pin) ⇒ Object
Turn off the LED.
-
#off_for(seconds = 1) ⇒ Object
Turn the LED off for N seconds.
-
#on(pin = @pin) ⇒ Object
Turn on the LED.
-
#on_for(seconds = 1) ⇒ Object
Turn the LED on for N seconds.
- #включить ⇒ Object
- #выключить ⇒ Object
- #мигать(repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
Methods inherited from DigitalEffector
Methods inherited from Effector
Constructor Details
#initialize(pin) ⇒ LED
Returns a new instance of LED.
6 7 8 9 |
# File 'lib/iot/led.rb', line 6 def initialize(pin) super(pin) self.name = 'LED' end |
Class Method Details
Instance Method Details
#blink(repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
Repeat ‘repeat’ times: light the LED for ‘switched_on’ secs, then pause for ‘switched_off’ secs
22 23 24 25 26 27 28 29 |
# File 'lib/iot/led.rb', line 22 def blink(repeat=3, switched_on=0.25, switched_off=0.5) repeat.times do |n| on sleep switched_on off sleep switched_off end end |
#off(pin = @pin) ⇒ Object
Turn off the LED.
17 18 19 |
# File 'lib/iot/led.rb', line 17 def off(pin=@pin) super(pin) end |
#off_for(seconds = 1) ⇒ Object
Turn the LED off for N seconds.
39 40 41 42 43 |
# File 'lib/iot/led.rb', line 39 def off_for(seconds=1) off sleep seconds on end |
#on(pin = @pin) ⇒ Object
Turn on the LED.
12 13 14 |
# File 'lib/iot/led.rb', line 12 def on(pin=@pin) super(pin) end |
#on_for(seconds = 1) ⇒ Object
Turn the LED on for N seconds.
32 33 34 35 36 |
# File 'lib/iot/led.rb', line 32 def on_for(seconds=1) on sleep seconds off end |
#включить ⇒ Object
52 53 54 |
# File 'lib/iot/led.rb', line 52 def включить on end |
#выключить ⇒ Object
56 57 58 |
# File 'lib/iot/led.rb', line 56 def выключить off end |
#мигать(repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object
60 61 62 |
# File 'lib/iot/led.rb', line 60 def мигать(repeat=3, switched_on=0.25, switched_off=0.5) blink(repeat, switched_on, switched_off) end |