blink1-patterns 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ["lib"]
18
18
  gem.bindir = 'exe'
19
+
20
+ gem.add_dependency('rb-blink1')
19
21
  end
@@ -1,3 +1,5 @@
1
+ require "blink1"
2
+
1
3
  module Blink
2
4
  module Patterns
3
5
 
@@ -6,44 +8,40 @@ module Blink
6
8
  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]
7
9
  stretch = length / interval.inject(:+)
8
10
 
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
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)
14
18
  end
15
19
  end
16
20
 
17
21
  def self.police
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
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
31
37
  end
32
38
 
33
39
  def self.to_rgb(hex_color)
34
40
  hex_color.gsub('#','').scan(/../).map {|color| color.hex}
35
41
  end
36
42
 
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
43
+ def self.darken(hex_color, amount=0.4)
44
+ to_rgb(hex_color).map { |c| (c * (1 - amount)).round }
45
+ end
48
46
  end
49
47
  end
@@ -1,5 +1,5 @@
1
1
  module Blink
2
2
  module Patterns
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: blink1-patterns
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Schmidt
@@ -10,7 +10,23 @@ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
12
  date: 2013-02-18 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rb-blink1
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ prerelease: false
14
30
  description: Common Blink Patterns
15
31
  email:
16
32
  - michael.j.schmidt@gmail.com
@@ -46,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
62
  - !ruby/object:Gem::Version
47
63
  segments:
48
64
  - 0
49
- hash: 913660071390164681
65
+ hash: 1383845139701609875
50
66
  version: '0'
51
67
  required_rubygems_version: !ruby/object:Gem::Requirement
52
68
  none: false
@@ -55,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
71
  - !ruby/object:Gem::Version
56
72
  segments:
57
73
  - 0
58
- hash: 913660071390164681
74
+ hash: 1383845139701609875
59
75
  version: '0'
60
76
  requirements: []
61
77
  rubyforge_project: