apa102_rbpi 1.0.1 → 1.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/apa102_rbpi.gemspec +2 -0
- data/lib/apa102_rbpi/apa102.rb +1 -1
- data/lib/apa102_rbpi/strip.rb +46 -43
- data/lib/apa102_rbpi/version.rb +1 -1
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61bbbb496c64346da43a00d15ab618651ea5e11
|
4
|
+
data.tar.gz: 0b49de24035db3478f263fad0e4b6c72c79d5207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6728f8fc5c1dcca3ce6251ca443c4e98e9208b8b5af689a3a764b90164330da67d062a4689a194a734fa55bd90166dea1547c5cc180bab2c9ab39d82e5489539
|
7
|
+
data.tar.gz: ea8fa336f80abbd940a18b36365366fcc9974e1f637f09462a551d1331d50effada96ad5efa312aee5292d2b0c755c437d39a1b86f7a6a49e4a562683f1d9843
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/apa102_rbpi.gemspec
CHANGED
@@ -25,8 +25,10 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.3.0'
|
28
29
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
29
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'benchmark-perf', '~> 0.1.0'
|
30
32
|
spec.add_dependency 'pi_piper', '~> 1.9'
|
31
33
|
spec.add_dependency 'paint'
|
32
34
|
end
|
data/lib/apa102_rbpi/apa102.rb
CHANGED
data/lib/apa102_rbpi/strip.rb
CHANGED
@@ -3,10 +3,11 @@ module Apa102Rbpi
|
|
3
3
|
|
4
4
|
require 'set'
|
5
5
|
|
6
|
-
attr_reader :mirrors, :head, :tail, :num_leds
|
6
|
+
attr_reader :mirrors, :head, :tail, :num_leds, :base
|
7
7
|
attr_accessor :led_frame_rgb_offsets, :brightness
|
8
8
|
|
9
|
-
def initialize(len = base.num_leds, opts = {})
|
9
|
+
def initialize(len = Apa102Rbpi.base.num_leds, opts = {})
|
10
|
+
@base = Apa102Rbpi.base
|
10
11
|
if len.is_a?(Array)
|
11
12
|
@head = len[0]
|
12
13
|
@tail = len[1]
|
@@ -22,8 +23,8 @@ module Apa102Rbpi
|
|
22
23
|
|
23
24
|
@reverse = false
|
24
25
|
|
25
|
-
@led_frame_rgb_offsets = opts[:led_frame_rgb_offsets] || base.led_frame_rgb_offsets
|
26
|
-
@brightness = opts[:brightness] || base.brightness
|
26
|
+
@led_frame_rgb_offsets = opts[:led_frame_rgb_offsets] || @base.led_frame_rgb_offsets
|
27
|
+
@brightness = opts[:brightness] || @base.brightness
|
27
28
|
@mirrors = Set.new
|
28
29
|
end
|
29
30
|
|
@@ -45,40 +46,52 @@ module Apa102Rbpi
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def show!
|
48
|
-
base.show!
|
49
|
+
@base.show!
|
49
50
|
end
|
50
51
|
|
51
|
-
def set_pixel(pos, color, brightness =
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
def set_pixel(pos, color, brightness = nil)
|
53
|
+
is_hex = if color.is_a?(Integer)
|
54
|
+
true
|
55
|
+
elsif color.is_a?(Array)
|
56
|
+
false
|
57
|
+
else
|
58
|
+
raise 'Invalid color'
|
59
|
+
end
|
60
|
+
if @mirrors.empty?
|
61
|
+
set_color_helper(pos, color, is_hex, brightness || @brightness)
|
62
|
+
else
|
63
|
+
q = [self]
|
64
|
+
seen = Set.new([self])
|
65
|
+
while(substrip = q.pop)
|
66
|
+
substrip.mirrors.each do |mirror|
|
67
|
+
unless seen.include?(mirror)
|
68
|
+
q.push(mirror)
|
69
|
+
seen.add(mirror)
|
70
|
+
end
|
71
|
+
substrip.set_color_helper(pos, color, is_hex, brightness || substrip.brightness)
|
60
72
|
end
|
61
73
|
end
|
74
|
+
end
|
75
|
+
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
77
|
+
def set_color_helper(pos, color, is_hex, brightness)
|
78
|
+
led_frame_hdr = (brightness & 0b00011111) | 0b11100000
|
79
|
+
idx = if @reverse
|
80
|
+
4 * ((@tail - pos) % @base.num_leds)
|
81
|
+
else
|
82
|
+
4 * ((pos + @head) % @base.num_leds)
|
83
|
+
end
|
84
|
+
|
85
|
+
if is_hex
|
86
|
+
@base.led_frames[idx] = led_frame_hdr
|
87
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:red]] = (color & 0xFF0000) >> 16
|
88
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:green]] = (color & 0x00FF00) >> 8
|
89
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:blue]] = (color & 0x0000FF)
|
90
|
+
else
|
91
|
+
@base.led_frames[idx] = led_frame_hdr
|
92
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:red]] = color[0]
|
93
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:green]] = color[1]
|
94
|
+
@base.led_frames[idx + @led_frame_rgb_offsets[:blue]] = color[2]
|
82
95
|
end
|
83
96
|
end
|
84
97
|
|
@@ -108,15 +121,5 @@ module Apa102Rbpi
|
|
108
121
|
clear
|
109
122
|
show!
|
110
123
|
end
|
111
|
-
|
112
|
-
def led_frame_hdr(brightness = @brightness)
|
113
|
-
(brightness & 0b00011111) | 0b11100000
|
114
|
-
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
def base
|
119
|
-
Apa102Rbpi.base
|
120
|
-
end
|
121
124
|
end
|
122
125
|
end
|
data/lib/apa102_rbpi/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apa102_rbpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matl33t
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: benchmark-perf
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.0
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: pi_piper
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +103,7 @@ extra_rdoc_files: []
|
|
75
103
|
files:
|
76
104
|
- ".gitignore"
|
77
105
|
- ".rspec"
|
106
|
+
- ".travis.yml"
|
78
107
|
- AUTHORS
|
79
108
|
- CHANGELOG.md
|
80
109
|
- Gemfile
|
@@ -106,9 +135,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
135
|
version: '0'
|
107
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
137
|
requirements:
|
109
|
-
- - "
|
138
|
+
- - ">"
|
110
139
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
140
|
+
version: 1.3.1
|
112
141
|
requirements: []
|
113
142
|
rubyforge_project:
|
114
143
|
rubygems_version: 2.2.3
|