blink1-patterns 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/blink1-patterns.rb +29 -27
- data/lib/blink1-patterns/version.rb +1 -1
- metadata +4 -4
data/lib/blink1-patterns.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "blink1"
|
2
|
-
|
3
1
|
module Blink
|
4
2
|
module Patterns
|
5
3
|
|
@@ -8,40 +6,44 @@ module Blink
|
|
8
6
|
interval = [1.5, 1.0, 1.0, 1.0, 1.2, 1.5, 1.2, 1.2, 1.2, 1.2, 1.2, 0.0]
|
9
7
|
stretch = length / interval.inject(:+)
|
10
8
|
|
11
|
-
|
12
|
-
(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
blink.play(0)
|
9
|
+
(0..11).each do |pos|
|
10
|
+
color = Blink::Patterns.darken(hex_color, (1 - brightness[pos]) * depth)
|
11
|
+
duration = stretch * interval[pos] * 1000
|
12
|
+
write_pattern_line(duration, *color, pos)
|
13
|
+
play
|
18
14
|
end
|
19
15
|
end
|
20
16
|
|
21
17
|
def self.police
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
blink.play(0)
|
36
|
-
end
|
18
|
+
write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 0)
|
19
|
+
write_pattern_line(100, *Blink::Patterns.to_rgb("#ff0000"), 1)
|
20
|
+
write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 2)
|
21
|
+
write_pattern_line(100, *Blink::Patterns.to_rgb("#0000ff"), 3)
|
22
|
+
write_pattern_line(0, 0, 0, 0, 4)
|
23
|
+
write_pattern_line(0, 0, 0, 0, 5)
|
24
|
+
write_pattern_line(0, 0, 0, 0, 6)
|
25
|
+
write_pattern_line(0, 0, 0, 0, 7)
|
26
|
+
write_pattern_line(0, 0, 0, 0, 8)
|
27
|
+
write_pattern_line(0, 0, 0, 0, 9)
|
28
|
+
write_pattern_line(0, 0, 0, 0, 10)
|
29
|
+
write_pattern_line(0, 0, 0, 0, 11)
|
30
|
+
play
|
37
31
|
end
|
38
32
|
|
39
33
|
def self.to_rgb(hex_color)
|
40
34
|
hex_color.gsub('#','').scan(/../).map {|color| color.hex}
|
41
35
|
end
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
def self.darken(hex_color, amount=0.4)
|
38
|
+
to_rgb(hex_color).map { |c| (c * (1 - amount)).round }
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.write_pattern_line(duration, r, g, b, pos)
|
42
|
+
`blink1-tool -m #{duration.to_i} --savergb #{r},#{g},#{b},#{pos}`
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.play
|
46
|
+
`blink1-tool --play 1,0`
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: blink1-patterns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Schmidt
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-blink1
|
@@ -62,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
segments:
|
64
64
|
- 0
|
65
|
-
hash:
|
65
|
+
hash: 349436783365008807
|
66
66
|
version: '0'
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
segments:
|
73
73
|
- 0
|
74
|
-
hash:
|
74
|
+
hash: 349436783365008807
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|