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.
@@ -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
- Blink1.open do |blink|
12
- (0..11).each do |pos|
13
- color = Blink::Patterns.darken(hex_color, (1 - brightness[pos]) * depth)
14
- duration = stretch * interval[pos] * 1000
15
- blink.write_pattern_line(duration, *color, pos)
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
- Blink1.open do |blink|
23
- blink.write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 0)
24
- blink.write_pattern_line(100, *Blink::Patterns.to_rgb("#ff0000"), 1)
25
- blink.write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 2)
26
- blink.write_pattern_line(100, *Blink::Patterns.to_rgb("#0000ff"), 3)
27
- blink.write_pattern_line(0, 0, 0, 0, 4)
28
- blink.write_pattern_line(0, 0, 0, 0, 5)
29
- blink.write_pattern_line(0, 0, 0, 0, 6)
30
- blink.write_pattern_line(0, 0, 0, 0, 7)
31
- blink.write_pattern_line(0, 0, 0, 0, 8)
32
- blink.write_pattern_line(0, 0, 0, 0, 9)
33
- blink.write_pattern_line(0, 0, 0, 0, 10)
34
- blink.write_pattern_line(0, 0, 0, 0, 11)
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
- def self.darken(hex_color, amount=0.4)
44
- to_rgb(hex_color).map { |c| (c * (1 - amount)).round }
45
- end
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
@@ -1,5 +1,5 @@
1
1
  module Blink
2
2
  module Patterns
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  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.1
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-17 00:00:00.000000000 Z
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: 1706872555753575638
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: 1706872555753575638
74
+ hash: 349436783365008807
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project: