Class: LED

Inherits:
BinaryEffector show all
Defined in:
lib/led.rb,
lib/led.rb,
lib/led_pwm.rb,
lib/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.



5
6
7
8
# File 'lib/led.rb', line 5

def initialize(pin)
  super(pin)
  self.name = 'LED'
end

Class Method Details

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



43
44
45
# File 'lib/led.rb', line 43

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



19
20
21
22
23
24
25
26
# File 'lib/led.rb', line 19

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



14
15
16
# File 'lib/led.rb', line 14

def off(pin=@pin)
  super(pin)
end

#off_for(seconds = 1) ⇒ Object



34
35
36
37
38
# File 'lib/led.rb', line 34

def off_for(seconds=1)
  off
  sleep seconds
  on
end

#on(pin = @pin) ⇒ Object



10
11
12
# File 'lib/led.rb', line 10

def on(pin=@pin)
  super(pin)
end

#on_for(seconds = 1) ⇒ Object



28
29
30
31
32
# File 'lib/led.rb', line 28

def on_for(seconds=1)
  on
  sleep seconds
  off
end

#включитьObject



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

def включить
  on
end

#выключитьObject



51
52
53
# File 'lib/led.rb', line 51

def выключить
  off
end

#мигать(repeat = 3, switched_on = 0.25, switched_off = 0.5) ⇒ Object



55
56
57
# File 'lib/led.rb', line 55

def мигать(repeat=3, switched_on=0.25, switched_off=0.5)
  blink(repeat, switched_on, switched_off)
end