BlinkyTape 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/BlinkyTape.rb +22 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
data.tar.gz: 2f9a345e5d87997de253147d0389d7da47051dc07a81de44bd2dcee2b39e18565bc4a44ce0a62cf750dc91ee69117b176d243e71226bcc8c4d6a82ce67ac5d8b
|
4
|
-
metadata.gz: a79b51b3ab6689f42eea3099b0d9400f4ef7c082a9906f2556da0d741d707b7854817b4b95b79686873b6c372f160d198a93baa82d38e3a04c74f026dab5ced8
|
5
2
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 9e2d56f7dc59aa1bae77e533e152f9232e6d6db3
|
4
|
+
metadata.gz: 92af65ecfcecee1493d165e9503c14062aebebd4
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: 5b82ba104954e6efe20bde6c071c76d1eb11187debfdb6ea25f6bd7fc32a53ff254f6b53cc7e0871f6a0ceffa55955ba917dc64cf3695b2c51ca11a2cccefbfa
|
7
|
+
metadata.gz: 8f91383ebab1254dd0766d3d44b9e52893393695cffa184ed31e9addf675d3699e2ac21949f672b7fea3c558935b8551b7ea862c7c2a7faca9a58030c4e55031
|
data/lib/BlinkyTape.rb
CHANGED
@@ -4,24 +4,41 @@ require 'rubygems'
|
|
4
4
|
require 'serialport'
|
5
5
|
|
6
6
|
class BlinkyTape
|
7
|
-
VERSION = '0.0.
|
7
|
+
VERSION = '0.0.2'
|
8
8
|
attr_accessor :port, :led_count, :serial
|
9
9
|
|
10
10
|
def initialize(port)
|
11
11
|
@port = port
|
12
12
|
@led_count = 60
|
13
|
-
|
14
|
-
|
15
|
-
raise "Cannot connect to #{@port}" if @serial.nil?
|
13
|
+
connect
|
16
14
|
show
|
17
15
|
end
|
18
16
|
|
17
|
+
def connect
|
18
|
+
# @serial = SerialPort.new(@port, 115200, 8, 1, SerialPort::NONE)
|
19
|
+
@serial = SerialPort.new(@port, 115200)
|
20
|
+
|
21
|
+
raise "Cannot connect to #{@port}" if @serial.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def reset
|
25
|
+
@serial.close
|
26
|
+
@serial = SerialPort.new(@port, 1200)
|
27
|
+
sleep 1
|
28
|
+
connect
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
@serial.close
|
33
|
+
end
|
34
|
+
|
19
35
|
def show
|
20
36
|
@serial.write 255.chr
|
21
37
|
@serial.flush
|
22
38
|
end
|
23
39
|
|
24
40
|
def send_pixel(r,g,b)
|
41
|
+
sleep 0.001
|
25
42
|
data = ""
|
26
43
|
r = 254 if r == 255
|
27
44
|
g = 254 if g == 255
|
@@ -32,7 +49,7 @@ class BlinkyTape
|
|
32
49
|
end
|
33
50
|
|
34
51
|
def display_color(r=255, g=255, b=255)
|
35
|
-
@led_count
|
52
|
+
0.upto(@led_count) do
|
36
53
|
send_pixel r,g,b
|
37
54
|
end
|
38
55
|
show
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BlinkyTape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Buser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-06 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: serialport
|