Class: IoT::LED

Inherits:
BinaryEffector show all
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

Classes: PWM, RGB

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DigitalEffector

off, #off?, on, #on?

Methods inherited from Effector

#model_name, #name

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

.создать(pin = 25) ⇒ Object



48
49
50
# File 'lib/iot/led.rb', line 48

def LED.создать(pin = 25)
  LED.new(pin)
end

Instance Method Details

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