betabrite 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/{History.txt → CHANGELOG.rdoc} +6 -0
- data/Manifest.txt +3 -3
- data/{README.txt → README.rdoc} +9 -4
- data/Rakefile +5 -7
- data/lib/betabrite.rb +1 -1
- data/lib/betabrite/{base.rb → device.rb} +2 -2
- data/lib/betabrite/files/dots.rb +2 -2
- data/lib/betabrite/files/string.rb +2 -2
- data/lib/betabrite/files/text.rb +4 -4
- data/lib/betabrite/memory.rb +2 -2
- data/lib/betabrite/serial.rb +1 -1
- data/lib/betabrite/usb.rb +5 -5
- data/test/helper.rb +0 -4
- data/test/test_many_mem.rb +2 -6
- data/test/test_memory.rb +1 -7
- data/test/test_set_string.rb +1 -7
- data/test/test_string.rb +0 -6
- data/test/test_text_file.rb +0 -6
- data/test/test_usb_betabrite.rb +0 -2
- metadata +41 -22
data/.gemtest
ADDED
File without changes
|
data/Manifest.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
.autotest
|
2
|
+
CHANGELOG.rdoc
|
2
3
|
EXAMPLES
|
3
|
-
History.txt
|
4
4
|
LICENSE
|
5
5
|
Manifest.txt
|
6
|
-
README.
|
6
|
+
README.rdoc
|
7
7
|
Rakefile
|
8
8
|
lib/betabrite.rb
|
9
9
|
lib/betabrite/autotest.rb
|
10
|
-
lib/betabrite/
|
10
|
+
lib/betabrite/device.rb
|
11
11
|
lib/betabrite/files.rb
|
12
12
|
lib/betabrite/files/dots.rb
|
13
13
|
lib/betabrite/files/file_dsl.rb
|
data/{README.txt → README.rdoc}
RENAMED
@@ -27,7 +27,7 @@ file displayed on the sign is labeled 'A'.
|
|
27
27
|
|
28
28
|
Here is an example of modifying the default sign text:
|
29
29
|
|
30
|
-
bb = BetaBrite::
|
30
|
+
bb = BetaBrite::USB.new do |sign|
|
31
31
|
sign.textfile do
|
32
32
|
print ARGV[0]
|
33
33
|
end
|
@@ -35,6 +35,7 @@ Here is an example of modifying the default sign text:
|
|
35
35
|
bb.write!
|
36
36
|
|
37
37
|
== Autotest Support
|
38
|
+
|
38
39
|
Here is an example of a .autotest file using the BetaBrite module:
|
39
40
|
|
40
41
|
require 'betabrite/autotest'
|
@@ -48,13 +49,14 @@ You don't need to give the hook method a block, but you can if you'd like to
|
|
48
49
|
customize your messages.
|
49
50
|
|
50
51
|
== Allocating Memory
|
52
|
+
|
51
53
|
The memory in the BetaBrite sign should be configured before anything is
|
52
54
|
written to it. You only have to configure the memory once before writing to
|
53
|
-
it.
|
55
|
+
it. Subsequent executions of your script do not require allocating memory.
|
54
56
|
|
55
57
|
Here is an example of allocating memory on the sign:
|
56
58
|
|
57
|
-
bb = BetaBrite::
|
59
|
+
bb = BetaBrite::USB.new do |sign|
|
58
60
|
sign.allocate do |memory|
|
59
61
|
memory.text('A', 4096)
|
60
62
|
memory.string('0', 64)
|
@@ -65,7 +67,9 @@ Here is an example of allocating memory on the sign:
|
|
65
67
|
For more examples, see the EXAMPLES file.
|
66
68
|
|
67
69
|
== Different File Types
|
70
|
+
|
68
71
|
=== Text Files
|
72
|
+
|
69
73
|
The data stored in a text file is not supposed to change frequently. If the
|
70
74
|
data in a text file is changed, the sign will go blank before anything is
|
71
75
|
displayed. This is not good for applications like a stock ticker which
|
@@ -73,13 +77,14 @@ update data quite frequently. This problem can be avoided by having the
|
|
73
77
|
text file reference more volitile files like String Files.
|
74
78
|
|
75
79
|
=== String Files
|
80
|
+
|
76
81
|
String files contain more volitile memory. The contents of a String File
|
77
82
|
can be changed without the screen going blank. String Files, however, cannot
|
78
83
|
be displayed unless referenced from a Text File.
|
79
84
|
|
80
85
|
Here is an example of referencing a String File from a Text File:
|
81
86
|
|
82
|
-
bb = BetaBrite::
|
87
|
+
bb = BetaBrite::USB.new do |sign|
|
83
88
|
sign.stringfile('0') do
|
84
89
|
print string("cruel").red
|
85
90
|
end
|
data/Rakefile
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'hoe'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Hoe.spec 'betabrite' do |p|
|
4
|
+
developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
p.email = 'aaronp@rubyforge.org'
|
10
|
-
p.summary = "Provides a Ruby interface to BetaBrite LED signs"
|
6
|
+
self.extra_rdoc_files = Dir['*.rdoc']
|
7
|
+
self.history_file = 'CHANGELOG.rdoc'
|
8
|
+
self.readme_file = 'README.rdoc'
|
11
9
|
end
|
data/lib/betabrite.rb
CHANGED
data/lib/betabrite/files/dots.rb
CHANGED
@@ -14,9 +14,9 @@ module BetaBrite
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_s
|
17
|
-
string = "#{BetaBrite::
|
17
|
+
string = "#{BetaBrite::Device::STX}#{COMMAND_CODE}#{@label.to_s}" +
|
18
18
|
"#{sprintf('%02x', @rows)}#{sprintf('%02x', @columns)}" +
|
19
|
-
"#{picture.join(BetaBrite::
|
19
|
+
"#{picture.join(BetaBrite::Device::CR)}#{BetaBrite::Device::CR}"
|
20
20
|
end
|
21
21
|
alias :to_str :to_s
|
22
22
|
end
|
@@ -13,8 +13,8 @@ module BetaBrite
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_s
|
16
|
-
"#{BetaBrite::
|
17
|
-
"#{@message.to_s}#{BetaBrite::
|
16
|
+
"#{BetaBrite::Device::STX}#{COMMAND_CODE}#{@label.to_s}" +
|
17
|
+
"#{@message.to_s}#{BetaBrite::Device::ETX}"
|
18
18
|
end
|
19
19
|
alias :to_str :to_s
|
20
20
|
end
|
data/lib/betabrite/files/text.rb
CHANGED
@@ -76,11 +76,11 @@ module BetaBrite
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def stringfile(label)
|
79
|
-
"#{BetaBrite::
|
79
|
+
"#{BetaBrite::Device::DLE}#{label}"
|
80
80
|
end
|
81
81
|
|
82
82
|
def dotsfile(label)
|
83
|
-
"#{BetaBrite::
|
83
|
+
"#{BetaBrite::Device::STRING}#{label}"
|
84
84
|
end
|
85
85
|
|
86
86
|
def to_s
|
@@ -114,8 +114,8 @@ module BetaBrite
|
|
114
114
|
|
115
115
|
private
|
116
116
|
def combine
|
117
|
-
"#{BetaBrite::
|
118
|
-
"#{@position}#{@mode}#{@message}#{BetaBrite::
|
117
|
+
"#{BetaBrite::Device::STX}#{WRITE}#{@label}#{BetaBrite::Device::ESC}" +
|
118
|
+
"#{@position}#{@mode}#{@message}#{BetaBrite::Device::ETX}"
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
data/lib/betabrite/memory.rb
CHANGED
@@ -7,7 +7,7 @@ module BetaBrite
|
|
7
7
|
LOCKED = 'L'
|
8
8
|
UNLOCKED = 'U'
|
9
9
|
def self.clear
|
10
|
-
BetaBrite::
|
10
|
+
BetaBrite::Device::STX << COMMAND_CODE
|
11
11
|
end
|
12
12
|
|
13
13
|
attr_accessor :label, :type, :locked, :size, :time
|
@@ -91,7 +91,7 @@ module BetaBrite
|
|
91
91
|
|
92
92
|
class Clear < Memory
|
93
93
|
def to_s
|
94
|
-
"#{BetaBrite::
|
94
|
+
"#{BetaBrite::Device::STX}#{COMMAND_CODE}"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/lib/betabrite/serial.rb
CHANGED
data/lib/betabrite/usb.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module BetaBrite
|
2
|
-
class USB <
|
2
|
+
class USB < Device
|
3
3
|
# USB Device Codes
|
4
4
|
PRODUCT_ID = 0x1234
|
5
5
|
VENDOR_ID = 0x8765
|
6
6
|
INTERFACE = 0x00
|
7
7
|
RECV_LENGTH = 0x40 # Max Packet Size of 64
|
8
8
|
SEND_LENGTH = 0x40 # Max Packet Size of 64
|
9
|
-
WRITE_ENDPOINT = 0x02
|
9
|
+
WRITE_ENDPOINT = 0x02
|
10
10
|
READ_ENDPOINT = 0x82
|
11
11
|
WRITE_TIMEOUT = 5000
|
12
12
|
READ_TIMEOUT = 5000
|
@@ -44,15 +44,15 @@ module BetaBrite
|
|
44
44
|
|
45
45
|
retries = 0
|
46
46
|
begin
|
47
|
-
if
|
47
|
+
if RUBY_PLATFORM =~ /mswin/
|
48
48
|
# http://osdir.com/ml/lib.libusb.devel.windows/2004-06/msg00001.html
|
49
|
-
handle.set_configuration(0x01)
|
49
|
+
handle.set_configuration(0x01)
|
50
50
|
end
|
51
51
|
error_code = handle.usb_claim_interface(INTERFACE)
|
52
52
|
raise unless error_code.nil?
|
53
53
|
rescue
|
54
54
|
handle.usb_detach_kernel_driver_np(INTERFACE);
|
55
|
-
if retries.zero?
|
55
|
+
if retries.zero?
|
56
56
|
retries += 1
|
57
57
|
retry
|
58
58
|
else
|
data/test/helper.rb
CHANGED
data/test/test_many_mem.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'betabrite'
|
1
|
+
require 'helper'
|
6
2
|
|
7
3
|
class ManyMemoryAllocTest < Test::Unit::TestCase
|
8
4
|
def setup
|
9
|
-
@sign = BetaBrite::
|
5
|
+
@sign = BetaBrite::Device.new
|
10
6
|
@sign.sleep_time = 0
|
11
7
|
end
|
12
8
|
|
data/test/test_memory.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'betabrite'
|
6
|
-
|
7
1
|
class MemoryAllocTest < Test::Unit::TestCase
|
8
2
|
def setup
|
9
|
-
@sign = BetaBrite::
|
3
|
+
@sign = BetaBrite::Device.new
|
10
4
|
@sign.sleep_time = 0
|
11
5
|
end
|
12
6
|
|
data/test/test_set_string.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'betabrite'
|
6
|
-
|
7
1
|
class SetStringTest < Test::Unit::TestCase
|
8
2
|
def setup
|
9
|
-
@sign = BetaBrite::
|
3
|
+
@sign = BetaBrite::Device.new
|
10
4
|
@sign.sleep_time = 0
|
11
5
|
end
|
12
6
|
|
data/test/test_string.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'betabrite'
|
6
|
-
|
7
1
|
class StringTest < Test::Unit::TestCase
|
8
2
|
def test_const_dsl
|
9
3
|
s = BetaBrite::String.new("hello") { |a|
|
data/test/test_text_file.rb
CHANGED
data/test/test_usb_betabrite.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betabrite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Aaron Patterson
|
@@ -9,40 +15,45 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2011-08-20 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: hoe
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
|
-
- -
|
26
|
+
- - ~>
|
22
27
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 12
|
32
|
+
version: "2.12"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
25
35
|
description: Provides a Ruby interface to BetaBrite LED signs.
|
26
|
-
email:
|
36
|
+
email:
|
37
|
+
- aaron@tenderlovemaking.com
|
27
38
|
executables: []
|
28
39
|
|
29
40
|
extensions: []
|
30
41
|
|
31
42
|
extra_rdoc_files:
|
32
|
-
- History.txt
|
33
43
|
- Manifest.txt
|
34
|
-
-
|
44
|
+
- CHANGELOG.rdoc
|
45
|
+
- README.rdoc
|
35
46
|
files:
|
36
47
|
- .autotest
|
48
|
+
- CHANGELOG.rdoc
|
37
49
|
- EXAMPLES
|
38
|
-
- History.txt
|
39
50
|
- LICENSE
|
40
51
|
- Manifest.txt
|
41
|
-
- README.
|
52
|
+
- README.rdoc
|
42
53
|
- Rakefile
|
43
54
|
- lib/betabrite.rb
|
44
55
|
- lib/betabrite/autotest.rb
|
45
|
-
- lib/betabrite/
|
56
|
+
- lib/betabrite/device.rb
|
46
57
|
- lib/betabrite/files.rb
|
47
58
|
- lib/betabrite/files/dots.rb
|
48
59
|
- lib/betabrite/files/file_dsl.rb
|
@@ -68,33 +79,41 @@ files:
|
|
68
79
|
- test/test_string.rb
|
69
80
|
- test/test_text_file.rb
|
70
81
|
- test/test_usb_betabrite.rb
|
71
|
-
|
82
|
+
- .gemtest
|
72
83
|
homepage: http://rubyforge.org/projects/betabrite/
|
84
|
+
licenses: []
|
85
|
+
|
73
86
|
post_install_message:
|
74
87
|
rdoc_options:
|
75
88
|
- --main
|
76
|
-
- README.
|
89
|
+
- README.rdoc
|
77
90
|
require_paths:
|
78
91
|
- lib
|
79
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
80
94
|
requirements:
|
81
95
|
- - ">="
|
82
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
83
100
|
version: "0"
|
84
|
-
version:
|
85
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
86
103
|
requirements:
|
87
104
|
- - ">="
|
88
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
89
109
|
version: "0"
|
90
|
-
version:
|
91
110
|
requirements: []
|
92
111
|
|
93
112
|
rubyforge_project: betabrite
|
94
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.8.8
|
95
114
|
signing_key:
|
96
|
-
specification_version:
|
97
|
-
summary: Provides a Ruby interface to BetaBrite LED signs
|
115
|
+
specification_version: 3
|
116
|
+
summary: Provides a Ruby interface to BetaBrite LED signs.
|
98
117
|
test_files:
|
99
118
|
- test/test_many_mem.rb
|
100
119
|
- test/test_memory.rb
|