betabrite 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/EXAMPLES +86 -0
- data/LICENSE +340 -0
- data/NOTES +7 -0
- data/README +100 -0
- data/lib/bb_version.rb +3 -0
- data/lib/betabrite.rb +121 -0
- data/lib/files/dotsfile.rb +24 -0
- data/lib/files/stringfile.rb +22 -0
- data/lib/files/textfile.rb +93 -0
- data/lib/memory/memory.rb +76 -0
- data/lib/string.rb +72 -0
- data/test/bb_override.rb +5 -0
- data/test/tc_many_mem.rb +41 -0
- data/test/tc_memory.rb +71 -0
- data/test/tc_set_string.rb +58 -0
- data/test/ts_bb.rb +5 -0
- metadata +67 -0
data/CHANGELOG
ADDED
data/EXAMPLES
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= BetaBrite Examples
|
2
|
+
|
3
|
+
== Allocate Memory
|
4
|
+
|
5
|
+
require 'betabrite'
|
6
|
+
require 'serialport'
|
7
|
+
|
8
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
9
|
+
|
10
|
+
sign = BetaBrite.new
|
11
|
+
|
12
|
+
string = BetaBrite::Memory::String.new('0', 32)
|
13
|
+
dots = BetaBrite::Memory::Dots.new('1', 7, 7)
|
14
|
+
text = BetaBrite::Memory::Text.new('A', 256)
|
15
|
+
|
16
|
+
sign.add text
|
17
|
+
sign.add dots
|
18
|
+
sign.add string
|
19
|
+
|
20
|
+
sign.allocate { |text|
|
21
|
+
sp.write text
|
22
|
+
}
|
23
|
+
|
24
|
+
== Reset the sign
|
25
|
+
|
26
|
+
require 'betabrite'
|
27
|
+
require 'serialport'
|
28
|
+
|
29
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
30
|
+
|
31
|
+
sign = BetaBrite.new
|
32
|
+
sign.add BetaBrite::Memory::Clear.new
|
33
|
+
|
34
|
+
sign.allocate { |text|
|
35
|
+
sp.write text
|
36
|
+
}
|
37
|
+
|
38
|
+
== Write a text file
|
39
|
+
|
40
|
+
require 'serialport'
|
41
|
+
require 'betabrite'
|
42
|
+
|
43
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
44
|
+
|
45
|
+
sign = BetaBrite.new
|
46
|
+
tf = BetaBrite::TextFile.new
|
47
|
+
tf.message = ARGV[0]
|
48
|
+
|
49
|
+
sign.add tf
|
50
|
+
|
51
|
+
sign.write { |text|
|
52
|
+
sp.write text
|
53
|
+
}
|
54
|
+
|
55
|
+
== Write a text file that references a string file
|
56
|
+
|
57
|
+
require 'betabrite'
|
58
|
+
require 'serialport'
|
59
|
+
|
60
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
61
|
+
|
62
|
+
sign = BetaBrite.new
|
63
|
+
|
64
|
+
# Create a new TextFile with the COMPRESSED_ROTATE mode.
|
65
|
+
tf = BetaBrite::TextFile.new { |a|
|
66
|
+
a.mode = BetaBrite::TextFile::Mode::COMPRESSED_ROTATE
|
67
|
+
}
|
68
|
+
|
69
|
+
# Set up a BetaBrite::String
|
70
|
+
name = BetaBrite::String.new('James',
|
71
|
+
:color => BetaBrite::String::Color::AMBER
|
72
|
+
)
|
73
|
+
# Create a StringFile which can be modified without making the sign blink.
|
74
|
+
sf = BetaBrite::StringFile.new('0', name)
|
75
|
+
|
76
|
+
# Set the TextFile message and reference the StringFile
|
77
|
+
tf.message = BetaBrite::String.new("Aaron #{sf.id} Patterson")
|
78
|
+
|
79
|
+
|
80
|
+
sign.add tf
|
81
|
+
sign.add sf
|
82
|
+
|
83
|
+
sign.write { |text|
|
84
|
+
sp.write text
|
85
|
+
}
|
86
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,340 @@
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
|
+
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5
|
+
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
Preamble
|
10
|
+
|
11
|
+
The licenses for most software are designed to take away your
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
14
|
+
software--to make sure the software is free for all its users. This
|
15
|
+
General Public License applies to most of the Free Software
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
18
|
+
the GNU Library General Public License instead.) You can apply it to
|
19
|
+
your programs, too.
|
20
|
+
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
24
|
+
this service if you wish), that you receive source code or can get it
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
26
|
+
in new free programs; and that you know you can do these things.
|
27
|
+
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
31
|
+
distribute copies of the software, or if you modify it.
|
32
|
+
|
33
|
+
For example, if you distribute copies of such a program, whether
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
36
|
+
source code. And you must show them these terms so they know their
|
37
|
+
rights.
|
38
|
+
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
41
|
+
distribute and/or modify the software.
|
42
|
+
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
44
|
+
that everyone understands that there is no warranty for this free
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
46
|
+
want its recipients to know that what they have is not the original, so
|
47
|
+
that any problems introduced by others will not reflect on the original
|
48
|
+
authors' reputations.
|
49
|
+
|
50
|
+
Finally, any free program is threatened constantly by software
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
55
|
+
|
56
|
+
The precise terms and conditions for copying, distribution and
|
57
|
+
modification follow.
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
|
+
|
62
|
+
0. This License applies to any program or other work which contains
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
66
|
+
means either the Program or any derivative work under copyright law:
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
68
|
+
either verbatim or with modifications and/or translated into another
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
71
|
+
|
72
|
+
Activities other than copying, distribution and modification are not
|
73
|
+
covered by this License; they are outside its scope. The act of
|
74
|
+
running the Program is not restricted, and the output from the Program
|
75
|
+
is covered only if its contents constitute a work based on the
|
76
|
+
Program (independent of having been made by running the Program).
|
77
|
+
Whether that is true depends on what the Program does.
|
78
|
+
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
80
|
+
source code as you receive it, in any medium, provided that you
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
84
|
+
and give any other recipients of the Program a copy of this License
|
85
|
+
along with the Program.
|
86
|
+
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
89
|
+
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
93
|
+
above, provided that you also meet all of these conditions:
|
94
|
+
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
96
|
+
stating that you changed the files and the date of any change.
|
97
|
+
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
99
|
+
whole or in part contains or is derived from the Program or any
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
101
|
+
parties under the terms of this License.
|
102
|
+
|
103
|
+
c) If the modified program normally reads commands interactively
|
104
|
+
when run, you must cause it, when started running for such
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
106
|
+
announcement including an appropriate copyright notice and a
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
108
|
+
a warranty) and that users may redistribute the program under
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
111
|
+
does not normally print such an announcement, your work based on
|
112
|
+
the Program is not required to print an announcement.)
|
113
|
+
|
114
|
+
These requirements apply to the modified work as a whole. If
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
116
|
+
and can be reasonably considered independent and separate works in
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
118
|
+
sections when you distribute them as separate works. But when you
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
121
|
+
this License, whose permissions for other licensees extend to the
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123
|
+
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
126
|
+
exercise the right to control the distribution of derivative or
|
127
|
+
collective works based on the Program.
|
128
|
+
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
131
|
+
a storage or distribution medium does not bring the other work under
|
132
|
+
the scope of this License.
|
133
|
+
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
137
|
+
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
139
|
+
source code, which must be distributed under the terms of Sections
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141
|
+
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
143
|
+
years, to give any third party, for a charge no more than your
|
144
|
+
cost of physically performing source distribution, a complete
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147
|
+
customarily used for software interchange; or,
|
148
|
+
|
149
|
+
c) Accompany it with the information you received as to the offer
|
150
|
+
to distribute corresponding source code. (This alternative is
|
151
|
+
allowed only for noncommercial distribution and only if you
|
152
|
+
received the program in object code or executable form with such
|
153
|
+
an offer, in accord with Subsection b above.)
|
154
|
+
|
155
|
+
The source code for a work means the preferred form of the work for
|
156
|
+
making modifications to it. For an executable work, complete source
|
157
|
+
code means all the source code for all modules it contains, plus any
|
158
|
+
associated interface definition files, plus the scripts used to
|
159
|
+
control compilation and installation of the executable. However, as a
|
160
|
+
special exception, the source code distributed need not include
|
161
|
+
anything that is normally distributed (in either source or binary
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
163
|
+
operating system on which the executable runs, unless that component
|
164
|
+
itself accompanies the executable.
|
165
|
+
|
166
|
+
If distribution of executable or object code is made by offering
|
167
|
+
access to copy from a designated place, then offering equivalent
|
168
|
+
access to copy the source code from the same place counts as
|
169
|
+
distribution of the source code, even though third parties are not
|
170
|
+
compelled to copy the source along with the object code.
|
171
|
+
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173
|
+
except as expressly provided under this License. Any attempt
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175
|
+
void, and will automatically terminate your rights under this License.
|
176
|
+
However, parties who have received copies, or rights, from you under
|
177
|
+
this License will not have their licenses terminated so long as such
|
178
|
+
parties remain in full compliance.
|
179
|
+
|
180
|
+
5. You are not required to accept this License, since you have not
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
182
|
+
distribute the Program or its derivative works. These actions are
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
184
|
+
modifying or distributing the Program (or any work based on the
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
187
|
+
the Program or works based on it.
|
188
|
+
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
190
|
+
Program), the recipient automatically receives a license from the
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
192
|
+
these terms and conditions. You may not impose any further
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
195
|
+
this License.
|
196
|
+
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
207
|
+
the only way you could satisfy both it and this License would be to
|
208
|
+
refrain entirely from distribution of the Program.
|
209
|
+
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
212
|
+
apply and the section as a whole is intended to apply in other
|
213
|
+
circumstances.
|
214
|
+
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
216
|
+
patents or other property right claims or to contest validity of any
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
218
|
+
integrity of the free software distribution system, which is
|
219
|
+
implemented by public license practices. Many people have made
|
220
|
+
generous contributions to the wide range of software distributed
|
221
|
+
through that system in reliance on consistent application of that
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
223
|
+
to distribute software through any other system and a licensee cannot
|
224
|
+
impose that choice.
|
225
|
+
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
227
|
+
be a consequence of the rest of this License.
|
228
|
+
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
231
|
+
original copyright holder who places the Program under this License
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
233
|
+
those countries, so that distribution is permitted only in or among
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
235
|
+
the limitation as if written in the body of this License.
|
236
|
+
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
238
|
+
of the General Public License from time to time. Such new versions will
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
240
|
+
address new problems or concerns.
|
241
|
+
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
243
|
+
specifies a version number of this License which applies to it and "any
|
244
|
+
later version", you have the option of following the terms and conditions
|
245
|
+
either of that version or of any later version published by the Free
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
248
|
+
Foundation.
|
249
|
+
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
251
|
+
programs whose distribution conditions are different, write to the author
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
256
|
+
of promoting the sharing and reuse of software generally.
|
257
|
+
|
258
|
+
NO WARRANTY
|
259
|
+
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268
|
+
REPAIR OR CORRECTION.
|
269
|
+
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
279
|
+
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
|
+
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
287
|
+
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
289
|
+
to attach them to the start of each source file to most effectively
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
292
|
+
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
294
|
+
Copyright (C) <year> <name of author>
|
295
|
+
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
297
|
+
it under the terms of the GNU General Public License as published by
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
299
|
+
(at your option) any later version.
|
300
|
+
|
301
|
+
This program is distributed in the hope that it will be useful,
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
|
+
GNU General Public License for more details.
|
305
|
+
|
306
|
+
You should have received a copy of the GNU General Public License
|
307
|
+
along with this program; if not, write to the Free Software
|
308
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
309
|
+
|
310
|
+
|
311
|
+
Also add information on how to contact you by electronic and paper mail.
|
312
|
+
|
313
|
+
If the program is interactive, make it output a short notice like this
|
314
|
+
when it starts in an interactive mode:
|
315
|
+
|
316
|
+
Gnomovision version 69, Copyright (C) year name of author
|
317
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
318
|
+
This is free software, and you are welcome to redistribute it
|
319
|
+
under certain conditions; type `show c' for details.
|
320
|
+
|
321
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
322
|
+
parts of the General Public License. Of course, the commands you use may
|
323
|
+
be called something other than `show w' and `show c'; they could even be
|
324
|
+
mouse-clicks or menu items--whatever suits your program.
|
325
|
+
|
326
|
+
You should also get your employer (if you work as a programmer) or your
|
327
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
328
|
+
necessary. Here is a sample; alter the names:
|
329
|
+
|
330
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
331
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
332
|
+
|
333
|
+
<signature of Ty Coon>, 1 April 1989
|
334
|
+
Ty Coon, President of Vice
|
335
|
+
|
336
|
+
This General Public License does not permit incorporating your program into
|
337
|
+
proprietary programs. If your program is a subroutine library, you may
|
338
|
+
consider it more useful to permit linking proprietary applications with the
|
339
|
+
library. If this is what you want to do, use the GNU Library General
|
340
|
+
Public License instead of this License.
|
data/NOTES
ADDED
data/README
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
= BetaBrite Library
|
2
|
+
|
3
|
+
== Synopsis
|
4
|
+
|
5
|
+
This library is used for controlling BetaBrite LED signs via Ruby.
|
6
|
+
|
7
|
+
== More Information
|
8
|
+
|
9
|
+
The BetaBrite sign has memory that can be configured before any messages are
|
10
|
+
displayed. There are different types of "Files" that can be allocated.
|
11
|
+
"Text Files" are files that are displayed on the sign. To display any other
|
12
|
+
type of file on the sign, that file must be referenced from a Text File. Files
|
13
|
+
must be labeled, and are given a single character file name. The default text
|
14
|
+
file displayed on the sign is labeled 'A'.
|
15
|
+
|
16
|
+
Here is an example of modifying the default sign text:
|
17
|
+
|
18
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
19
|
+
|
20
|
+
sign = BetaBrite.new
|
21
|
+
tf = BetaBrite::TextFile.new
|
22
|
+
tf.message = ARGV[0]
|
23
|
+
|
24
|
+
sign.add tf
|
25
|
+
|
26
|
+
sign.write { |text|
|
27
|
+
sp.write text
|
28
|
+
}
|
29
|
+
|
30
|
+
== Allocating Memory
|
31
|
+
The memory in the BetaBrite sign should be configured before anything is
|
32
|
+
written to it. This means writing a seperate script to allocate the memory
|
33
|
+
from the one that actually writes data. This may change in the future, I
|
34
|
+
just haven't figured out if it is possible to allocate memory and write data
|
35
|
+
at the same time.
|
36
|
+
|
37
|
+
Here is an example of allocating memory on the sign:
|
38
|
+
|
39
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
40
|
+
|
41
|
+
sign = BetaBrite.new
|
42
|
+
|
43
|
+
string = BetaBrite::Memory::String.new('0', 32)
|
44
|
+
dots = BetaBrite::Memory::Dots.new('1', 7, 7)
|
45
|
+
text = BetaBrite::Memory::Text.new('A', 256)
|
46
|
+
|
47
|
+
sign.add text
|
48
|
+
sign.add dots
|
49
|
+
sign.add string
|
50
|
+
|
51
|
+
sign.allocate { |text|
|
52
|
+
sp.write text
|
53
|
+
}
|
54
|
+
|
55
|
+
For more examples, see the EXAMPLES file.
|
56
|
+
|
57
|
+
== Different File Types
|
58
|
+
=== Text Files
|
59
|
+
The data stored in a text file is not supposed to change frequently. If the
|
60
|
+
data in a text file is changed, the sign will go blank before anything is
|
61
|
+
displayed. This is not good for applications like a stock ticker which
|
62
|
+
update data quite frequently. This problem can be avoided by having the
|
63
|
+
text file reference more volitile files like String Files.
|
64
|
+
|
65
|
+
=== String Files
|
66
|
+
String files contain more volitile memory. The contents of a String File
|
67
|
+
can be changed without the screen going blank. String Files, however, cannot
|
68
|
+
be displayed unless referenced from a Text File.
|
69
|
+
|
70
|
+
Here is an example of referencing a String File from a Text File:
|
71
|
+
|
72
|
+
sp = SerialPort.new(0, 9600, 8, 1, SerialPort::NONE)
|
73
|
+
sign = BetaBrite.new
|
74
|
+
tf = BetaBrite::TextFile.new
|
75
|
+
|
76
|
+
# Set up a BetaBrite::String
|
77
|
+
middle_name = BetaBrite::String.new('James',
|
78
|
+
:color => BetaBrite::String::Color::AMBER
|
79
|
+
)
|
80
|
+
# Create a StringFile which can be modified without making the sign blink.
|
81
|
+
sf = BetaBrite::StringFile.new('0', middle_name)
|
82
|
+
|
83
|
+
# Set the TextFile message and reference the StringFile
|
84
|
+
tf.message = BetaBrite::String.new("Aaron #{sf.id} Patterson")
|
85
|
+
|
86
|
+
|
87
|
+
sign.add tf
|
88
|
+
sign.add sf
|
89
|
+
|
90
|
+
sign.write { |text|
|
91
|
+
sp.write text
|
92
|
+
}
|
93
|
+
|
94
|
+
Once the String file is allocated and displayed, it can be changed at any
|
95
|
+
time and the string will be updated without the screen going blank.
|
96
|
+
|
97
|
+
=== Dots Files
|
98
|
+
Dots files can contain pictures. Each pixel is set in an array of strings.
|
99
|
+
See dots_file.rb under the script directory for an example. Or see the
|
100
|
+
EXAMPLES file.
|
data/lib/bb_version.rb
ADDED
data/lib/betabrite.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'files/textfile'
|
2
|
+
require 'files/stringfile'
|
3
|
+
require 'files/dotsfile'
|
4
|
+
require 'memory/memory'
|
5
|
+
require 'string'
|
6
|
+
require 'bb_version'
|
7
|
+
|
8
|
+
# = Synopsis
|
9
|
+
# This class assembles all packets (different files) and yields the data
|
10
|
+
# that needs to be written back to the caller of the BetaBrite#write method.
|
11
|
+
class BetaBrite
|
12
|
+
HEADER = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ]
|
13
|
+
STX = 0x02.chr
|
14
|
+
ETX = 0x03.chr
|
15
|
+
EOT = 0x04.chr
|
16
|
+
ESC = 0x1b.chr
|
17
|
+
DLE = 0x10.chr
|
18
|
+
STRING = 0x14.chr
|
19
|
+
CR = 0x0d.chr
|
20
|
+
MEMORY_CODE = "E$"
|
21
|
+
|
22
|
+
# Beta Brite sign
|
23
|
+
SIGN_TYPE = 0x5a.chr
|
24
|
+
|
25
|
+
attr_reader :sleep_time
|
26
|
+
attr_reader :string_files, :text_files, :dots_files
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
# Default address is "00" which means broadcast to all signs
|
30
|
+
@sign_address = [ 0x30, 0x30 ]
|
31
|
+
@string_files = []
|
32
|
+
@text_files = []
|
33
|
+
@dots_files = []
|
34
|
+
@memory = []
|
35
|
+
|
36
|
+
# This shouldn't change except for unit testing
|
37
|
+
@sleep_time = 1
|
38
|
+
end
|
39
|
+
|
40
|
+
def header
|
41
|
+
header_str = HEADER.collect { |a| a.chr }.join
|
42
|
+
header_str << SIGN_TYPE << @sign_address.collect { |a| a.chr }.join
|
43
|
+
end
|
44
|
+
|
45
|
+
def inspect
|
46
|
+
header
|
47
|
+
end
|
48
|
+
|
49
|
+
def add(packet)
|
50
|
+
if packet.is_a? BetaBrite::Memory
|
51
|
+
add_memory packet
|
52
|
+
elsif packet.is_a? BetaBrite::StringFile
|
53
|
+
add_stringfile packet
|
54
|
+
elsif packet.is_a? BetaBrite::TextFile
|
55
|
+
add_textfile packet
|
56
|
+
elsif packet.is_a? BetaBrite::DotsFile
|
57
|
+
add_dotsfile packet
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_stringfile(packet)
|
62
|
+
@string_files << packet
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_textfile(packet)
|
66
|
+
@text_files << packet
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_dotsfile(packet)
|
70
|
+
@dots_files << packet
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_memory(packet)
|
74
|
+
@memory << packet
|
75
|
+
end
|
76
|
+
|
77
|
+
# This method is used to write on the sign
|
78
|
+
def write(&block)
|
79
|
+
if @text_files.length > 0 || @string_files.length > 0
|
80
|
+
write_header &block
|
81
|
+
@text_files.each { |packet| yield packet.to_s }
|
82
|
+
@string_files.each { |packet| block.call(packet.to_s) }
|
83
|
+
write_end &block
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def write_dots(&block)
|
88
|
+
if @dots_files.length > 0
|
89
|
+
write_header &block
|
90
|
+
@dots_files.each { |packet|
|
91
|
+
yield packet.to_s
|
92
|
+
sleep sleep_time
|
93
|
+
}
|
94
|
+
write_end &block
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# This method is used to allocate memory on the sign
|
99
|
+
def allocate(&block)
|
100
|
+
if @memory.length > 0
|
101
|
+
write_header &block
|
102
|
+
yield STX
|
103
|
+
yield MEMORY_CODE
|
104
|
+
@memory.each { |packet| yield packet.to_s }
|
105
|
+
write_end &block
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def write_header(&block)
|
112
|
+
header.split(//).each { |c|
|
113
|
+
yield c
|
114
|
+
sleep sleep_time
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
def write_end(&block)
|
119
|
+
yield EOT
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class BetaBrite
|
2
|
+
class DotsFile
|
3
|
+
COMMAND_CODE = 0x49.chr
|
4
|
+
|
5
|
+
attr_accessor :label, :rows, :columns, :picture
|
6
|
+
|
7
|
+
def initialize(label, rows, columns, picture)
|
8
|
+
@label = label
|
9
|
+
@rows = rows
|
10
|
+
@columns = columns
|
11
|
+
@picture = picture
|
12
|
+
end
|
13
|
+
|
14
|
+
def id
|
15
|
+
BetaBrite::STRING << @label
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
string = "#{BetaBrite::STX}#{COMMAND_CODE}#{@label.to_s}" +
|
20
|
+
"#{sprintf('%02x', @rows)}#{sprintf('%02x', @columns)}" +
|
21
|
+
"#{picture.join(BetaBrite::CR)}#{BetaBrite::CR}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class BetaBrite
|
2
|
+
class StringFile
|
3
|
+
COMMAND_CODE = 'G'
|
4
|
+
|
5
|
+
attr_accessor :label, :message
|
6
|
+
|
7
|
+
def initialize(label = nil, message = nil)
|
8
|
+
@label = label
|
9
|
+
@message = message
|
10
|
+
yield self if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def id
|
14
|
+
"#{BetaBrite::DLE}#{@label}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"#{BetaBrite::STX}#{COMMAND_CODE}#{@label.to_s}" +
|
19
|
+
"#{@message.to_s}#{BetaBrite::ETX}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class BetaBrite
|
2
|
+
class TextFile
|
3
|
+
WRITE = 0x41.chr
|
4
|
+
READ = 0x42.chr
|
5
|
+
|
6
|
+
class Position
|
7
|
+
MIDDLE = 0x20.chr
|
8
|
+
TOP = 0x22.chr
|
9
|
+
BOTTOM = 0x26.chr
|
10
|
+
FILL = 0x30.chr
|
11
|
+
LEFT = 0x31.chr
|
12
|
+
RIGHT = 0x32.chr
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mode
|
16
|
+
# Standard Modes
|
17
|
+
ROTATE = 0x61.chr # Message travels right to left
|
18
|
+
HOLD = 0x62.chr # Message remains stationary
|
19
|
+
FLASH = 0x63.chr # Message remains stationary and flashes
|
20
|
+
ROLL_UP = 0x65.chr # Message is pushed up by new message
|
21
|
+
ROLL_DOWN = 0x66.chr # Message is pushed down by new message
|
22
|
+
ROLL_LEFT = 0x67.chr # Message is pushed left by a new message
|
23
|
+
ROLL_RIGHT = 0x68.chr # Message is pushed right by a new message
|
24
|
+
WIPE_UP = 0x69.chr # Message is wiped over bottom to top
|
25
|
+
WIPE_DOWN = 0x6A.chr # Message is wiped over top to bottom
|
26
|
+
WIPE_LEFT = 0x6B.chr # Message is wiped over right to left
|
27
|
+
WIPE_RIGHT = 0x6C.chr # Message is wiped over left to right
|
28
|
+
SCROLL = 0x6D.chr # New message pushes up if 2 line sign
|
29
|
+
AUTOMODE = 0x6F.chr # Various modes are called automatically
|
30
|
+
ROLL_IN = 0x70.chr # Message pushed toward center of display
|
31
|
+
ROLL_OUT = 0x71.chr # Message pushed away from center of display
|
32
|
+
WIPE_IN = 0x72.chr # Message wiped over in inward motion
|
33
|
+
WIPE_OUT = 0x73.chr # Message wiped over in outward motion
|
34
|
+
COMPRESSED_ROTATE = 0x74.chr # Left to right, chars half normal width
|
35
|
+
EXPLODE = 0x75.chr # Message flies apart (Alpha 3.0)
|
36
|
+
CLOCK = 0x76.chr # Wipe in clockwise direction (Alpha 3.0)
|
37
|
+
|
38
|
+
# Special Modes
|
39
|
+
TWINKLE = 0x6E.chr << 0x30.chr # Message will twinkle
|
40
|
+
SPARKLE = 0x6E.chr << 0x31.chr # Message will sparkle
|
41
|
+
SNOW = 0x6E.chr << 0x32.chr # Message will snow
|
42
|
+
INTERLOCK = 0x6E.chr << 0x33.chr # Message will interlock
|
43
|
+
SWITCH = 0x6E.chr << 0x34.chr # Message will switch
|
44
|
+
SLIDE = 0x6E.chr << 0x35.chr # Message will slide
|
45
|
+
SPRAY = 0x6E.chr << 0x36.chr # Message will spray across
|
46
|
+
STARBURST = 0x6E.chr << 0x37.chr # Explodes message to screen
|
47
|
+
WELCOME = 0x6E.chr << 0x38.chr # The world "Welcome" is written
|
48
|
+
SLOT_MACHINE= 0x6E.chr << 0x39.chr # Slot Machine shows up
|
49
|
+
NEWS_FLASH = 0x6E.chr << 0x3A.chr # News flash animation
|
50
|
+
TRUMPET = 0x6E.chr << 0x3B.chr # Trumpet animation
|
51
|
+
CYCLE_COLORS= 0x6E.chr << 0x43.chr # Color changes from one to another
|
52
|
+
|
53
|
+
# Special Graphics
|
54
|
+
THANK_YOU = 0x6E.chr << 0x53.chr # "Thank You" in script
|
55
|
+
NO_SMOKING = 0x6E.chr << 0x55.chr # No smoking
|
56
|
+
DRINK_DRIVE = 0x6E.chr << 0x56.chr # Don't drink and drive
|
57
|
+
ANIMAL_ANIM = 0x6E.chr << 0x57.chr # Animal animation
|
58
|
+
FIREWORKS = 0x6E.chr << 0x58.chr # Fireworks animation
|
59
|
+
BALLOONS = 0x6E.chr << 0x59.chr # Balloon animation
|
60
|
+
CHERRY_BOMB = 0x6E.chr << 0x5A.chr # A bomb animation
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_accessor :label, :display_position, :mode, :message
|
64
|
+
|
65
|
+
def initialize
|
66
|
+
@display_position = Position::MIDDLE
|
67
|
+
@label = "A"
|
68
|
+
@mode = Mode::ROTATE
|
69
|
+
yield self if block_given?
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_s
|
73
|
+
"#{combine}#{checksum(combine)}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def checksum(string)
|
77
|
+
total = 0
|
78
|
+
0.upto(string.length - 1) do |i|
|
79
|
+
total += string[i]
|
80
|
+
end
|
81
|
+
|
82
|
+
sprintf("%04x", total).upcase
|
83
|
+
end
|
84
|
+
|
85
|
+
alias :inspect :to_s
|
86
|
+
|
87
|
+
private
|
88
|
+
def combine
|
89
|
+
"#{BetaBrite::STX}#{WRITE}#{@label}#{BetaBrite::ESC}" <<
|
90
|
+
"#{@display_position}#{@mode}#{@message}#{BetaBrite::ETX}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class BetaBrite
|
2
|
+
class Memory
|
3
|
+
COMMAND_CODE = "E$"
|
4
|
+
TEXT = 'A'
|
5
|
+
STRING = 'B'
|
6
|
+
DOTS = 'D'
|
7
|
+
LOCKED = 'L'
|
8
|
+
UNLOCKED = 'U'
|
9
|
+
def self.clear
|
10
|
+
BetaBrite::STX << COMMAND_CODE
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :label, :type, :locked, :size, :time
|
14
|
+
def initialize(opts = {})
|
15
|
+
args = { :label => 'A',
|
16
|
+
:type => STRING,
|
17
|
+
:locked => LOCKED,
|
18
|
+
:size => sprintf("%04x", 0),
|
19
|
+
:time => '0000'
|
20
|
+
}.merge opts
|
21
|
+
@label = args[:label]
|
22
|
+
@type = args[:type]
|
23
|
+
@locked = args[:locked]
|
24
|
+
@size = args[:size]
|
25
|
+
@time = args[:time]
|
26
|
+
yield self if block_given?
|
27
|
+
end
|
28
|
+
|
29
|
+
def format
|
30
|
+
#BetaBrite::STX << COMMAND_CODE << @label << @type << @locked <<
|
31
|
+
@label << @type << @locked << @size.upcase << @time
|
32
|
+
end
|
33
|
+
|
34
|
+
alias :to_s :format
|
35
|
+
|
36
|
+
class String < Memory
|
37
|
+
def initialize(label, size)
|
38
|
+
super( :label => label,
|
39
|
+
:type => STRING,
|
40
|
+
:locked => LOCKED,
|
41
|
+
:size => sprintf("%04x", size),
|
42
|
+
:time => '0000'
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Text < Memory
|
48
|
+
def initialize(label, size)
|
49
|
+
super( :label => label,
|
50
|
+
:type => TEXT,
|
51
|
+
:locked => UNLOCKED,
|
52
|
+
:size => sprintf("%04x", size),
|
53
|
+
:time => 'FF00'
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Dots < Memory
|
59
|
+
def initialize(label, rows, columns)
|
60
|
+
size = sprintf("%02x", rows) << sprintf("%02x", columns)
|
61
|
+
super( :label => label,
|
62
|
+
:type => DOTS,
|
63
|
+
:locked => UNLOCKED,
|
64
|
+
:size => size,
|
65
|
+
:time => '4000'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class Clear < Memory
|
71
|
+
def to_s
|
72
|
+
"#{BetaBrite::STX}#{COMMAND_CODE}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/string.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
class BetaBrite
|
2
|
+
# This class encapsulates a string and attributes about the string such as
|
3
|
+
# color, character set, and also contains special characters.
|
4
|
+
class String
|
5
|
+
LEFT_ARROW = 0xc6.chr
|
6
|
+
RIGHT_ARROW = 0xc6.chr
|
7
|
+
PACKMAN = 0xc8.chr
|
8
|
+
SAIL_BOAT = 0xc9.chr
|
9
|
+
BALL = 0xca.chr
|
10
|
+
TELEPHONE = 0xcb.chr
|
11
|
+
HEART = 0xcc.chr
|
12
|
+
CAR = 0xcd.chr
|
13
|
+
HANDICAP = 0xce.chr
|
14
|
+
RHINO = 0xcf.chr
|
15
|
+
MUG = 0xd0.chr
|
16
|
+
SATELLITE_DISH = 0xd1.chr
|
17
|
+
COPYRIGHT = 0xd2.chr
|
18
|
+
MALE_SYM = 0xd3.chr
|
19
|
+
FEMALE_SYM = 0xd4.chr
|
20
|
+
BOTTLE = 0xd5.chr
|
21
|
+
DISKETTE = 0xd6.chr
|
22
|
+
PRINTER = 0xd7.chr
|
23
|
+
NOTE = 0xd8.chr
|
24
|
+
INFINITY = 0xd9.chr
|
25
|
+
class Color
|
26
|
+
RED = '1'
|
27
|
+
GREEN = '2'
|
28
|
+
AMBER = '3'
|
29
|
+
DIM_RED = '4'
|
30
|
+
DIM_GREEN = '5'
|
31
|
+
BROWN = '6'
|
32
|
+
ORANGE = '7'
|
33
|
+
YELLOW = '8'
|
34
|
+
RAINBOW_1 = '9'
|
35
|
+
RAINBOW_2 = 'A'
|
36
|
+
COLOR_MIX = 'B'
|
37
|
+
AUTOCOLOR = 'C'
|
38
|
+
end
|
39
|
+
class CharSet
|
40
|
+
FIVE_HIGH = '1'
|
41
|
+
FIVE_STROKE = '2'
|
42
|
+
SEVEN_HIGH = '3'
|
43
|
+
SEVEN_STROKE = '4'
|
44
|
+
SEVEN_FANCY = '5'
|
45
|
+
TEN_HIGH = '6'
|
46
|
+
SEVEN_SHADOW = '7'
|
47
|
+
FULL_FANCY = '8'
|
48
|
+
FULL_HEIGHT = '9'
|
49
|
+
SEVEN_SHDW_F = ':'
|
50
|
+
FIVE_WIDE = ';'
|
51
|
+
SEVEN_WIDE = '<'
|
52
|
+
SEVEN_WIDE_F = '='
|
53
|
+
WIDE_SRK_FIVE = '>'
|
54
|
+
end
|
55
|
+
attr_accessor :color, :charset, :string
|
56
|
+
|
57
|
+
def initialize(string, opts = {})
|
58
|
+
args = { :color => Color::GREEN,
|
59
|
+
:charset => CharSet::SEVEN_HIGH
|
60
|
+
}.merge opts
|
61
|
+
@string = string
|
62
|
+
@color = args[:color]
|
63
|
+
@charset = args[:charset]
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
"#{0x1a.chr}#{@charset}#{0x1c.chr}#{@color}#{@string}"
|
68
|
+
end
|
69
|
+
|
70
|
+
#alias :to_s :format
|
71
|
+
end
|
72
|
+
end
|
data/test/bb_override.rb
ADDED
data/test/tc_many_mem.rb
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
+
require 'bb_override'
|
7
|
+
|
8
|
+
class MemoryAllocTest < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@sign = BetaBrite.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_text_and_string
|
14
|
+
final =
|
15
|
+
[
|
16
|
+
0x00,0x00,0x00,0x00,0x00,0x01,0x5a,0x30,0x30,0x02,0x45,0x24,0x41,0x41,0x55,0x31,
|
17
|
+
0x30,0x30,0x30,0x46,0x46,0x30,0x30,0x30,0x42,0x4c,0x30,0x30,0x34,0x30,0x30,0x30,
|
18
|
+
0x30,0x30,0x31,0x42,0x4c,0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x32,0x42,0x4c,
|
19
|
+
0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x33,0x42,0x4c,0x30,0x30,0x34,0x30,0x30,
|
20
|
+
0x30,0x30,0x30,0x34,0x42,0x4c,0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x35,0x42,
|
21
|
+
0x4c,0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x36,0x42,0x4c,0x30,0x30,0x34,0x30,
|
22
|
+
0x30,0x30,0x30,0x30,0x37,0x42,0x4c,0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x38,
|
23
|
+
0x42,0x4c,0x30,0x30,0x34,0x30,0x30,0x30,0x30,0x30,0x39,0x42,0x4c,0x30,0x30,0x34,
|
24
|
+
0x30,0x30,0x30,0x30,0x30,0x04
|
25
|
+
]
|
26
|
+
final_s = final.collect { |x| x.chr }.join
|
27
|
+
@sign.add BetaBrite::Memory::Text.new('A', 4096)
|
28
|
+
|
29
|
+
0.upto(9) { |i|
|
30
|
+
string = BetaBrite::Memory::String.new(i.to_s, 64)
|
31
|
+
@sign.add string
|
32
|
+
}
|
33
|
+
|
34
|
+
test_string = ''
|
35
|
+
@sign.allocate { |text|
|
36
|
+
#obj.tty.write text
|
37
|
+
test_string << text
|
38
|
+
}
|
39
|
+
assert_equal(final_s, test_string)
|
40
|
+
end
|
41
|
+
end
|
data/test/tc_memory.rb
ADDED
@@ -0,0 +1,71 @@
|
|
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
|
+
require 'bb_override'
|
7
|
+
|
8
|
+
class MemoryAllocTest < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@sign = BetaBrite.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_text_file
|
14
|
+
alloc_string = [ 0, 0, 0, 0, 0, 1, 90, 48, 48, 2, 69, 36, 65, 65, 85, 48, 49, 48, 48, 70, 70, 48, 48, 4 ]
|
15
|
+
string = alloc_string.collect { |x| x.chr }.join
|
16
|
+
mem = BetaBrite::Memory::Text.new('A', 256)
|
17
|
+
|
18
|
+
@sign.add mem
|
19
|
+
test_string = ''
|
20
|
+
@sign.allocate { |text|
|
21
|
+
test_string << text
|
22
|
+
}
|
23
|
+
|
24
|
+
assert_equal(string, test_string)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_string_file
|
28
|
+
alloc_string = [ 0, 0, 0, 0, 0, 1, 90, 48, 48, 2, 69, 36, 48, 66, 76, 48, 48, 50, 48, 48, 48, 48, 48, 4 ]
|
29
|
+
string = alloc_string.collect { |x| x.chr }.join
|
30
|
+
mem = BetaBrite::Memory::String.new('0', 32)
|
31
|
+
|
32
|
+
@sign.add mem
|
33
|
+
test_string = ''
|
34
|
+
@sign.allocate { |text|
|
35
|
+
test_string << text
|
36
|
+
}
|
37
|
+
|
38
|
+
assert_equal(string, test_string)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_dots_file
|
42
|
+
alloc_string = [ 0, 0, 0, 0, 0, 1, 90, 48, 48, 2, 69, 36, 49, 68, 85, 48, 55, 48, 55, 52, 48, 48, 48, 4 ]
|
43
|
+
string = alloc_string.collect { |x| x.chr }.join
|
44
|
+
mem = BetaBrite::Memory::Dots.new('1', 7, 7)
|
45
|
+
|
46
|
+
@sign.add mem
|
47
|
+
test_string = ''
|
48
|
+
@sign.allocate { |text|
|
49
|
+
test_string << text
|
50
|
+
}
|
51
|
+
|
52
|
+
assert_equal(string, test_string)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_string_text_file
|
56
|
+
alloc_string = [ 0, 0, 0, 0, 0, 1, 90, 48, 48, 2, 69, 36, 48, 66, 76, 48, 48, 50, 48, 48, 48, 48, 48, 65, 65, 85, 48, 49, 48, 48, 70, 70, 48, 48, 4 ]
|
57
|
+
string = alloc_string.collect { |x| x.chr }.join
|
58
|
+
mem = BetaBrite::Memory::String.new('0', 32)
|
59
|
+
text = BetaBrite::Memory::Text.new('A', 256)
|
60
|
+
|
61
|
+
@sign.add mem
|
62
|
+
@sign.add text
|
63
|
+
|
64
|
+
test_string = ''
|
65
|
+
@sign.allocate { |text|
|
66
|
+
test_string << text
|
67
|
+
}
|
68
|
+
|
69
|
+
assert_equal(string, test_string)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
+
require 'bb_override'
|
7
|
+
|
8
|
+
class MemoryAllocTest < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@sign = BetaBrite.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_many_mem
|
14
|
+
final =
|
15
|
+
[
|
16
|
+
0x00,0x00,0x00,0x00,0x00,0x01,0x5a,0x30,0x30,0x02,0x47,0x30,0x31,0x31,0x30,0x34,
|
17
|
+
0x35,0x2e,0x32,0x38,0x20,0x03,0x02,0x47,0x31,0x32,0x2e,0x34,0x31,0x20,0x03,0x02,
|
18
|
+
0x47,0x32,0x31,0x39,0x2e,0x39,0x32,0x20,0x03,0x02,0x47,0x33,0x31,0x36,0x2e,0x35,
|
19
|
+
0x36,0x20,0x03,0x02,0x47,0x34,0x33,0x2e,0x33,0x37,0x20,0x03,0x02,0x47,0x35,0x31,
|
20
|
+
0x36,0x2e,0x34,0x37,0x20,0x03,0x04
|
21
|
+
]
|
22
|
+
final_s = final.collect { |x| x.chr }.join
|
23
|
+
[
|
24
|
+
'11045.28 ',
|
25
|
+
'2.41 ',
|
26
|
+
'19.92 ',
|
27
|
+
'16.56 ',
|
28
|
+
'3.37 ',
|
29
|
+
'16.47 '
|
30
|
+
].each_with_index do |price,idx|
|
31
|
+
@sign.add_stringfile BetaBrite::StringFile.new(idx, price)
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal('11045.28 ', @sign.string_files[0].message)
|
35
|
+
assert_equal(0, @sign.string_files[0].label)
|
36
|
+
assert_equal('2.41 ', @sign.string_files[1].message)
|
37
|
+
assert_equal(1, @sign.string_files[1].label)
|
38
|
+
assert_equal('19.92 ', @sign.string_files[2].message)
|
39
|
+
assert_equal(2, @sign.string_files[2].label)
|
40
|
+
assert_equal('16.56 ', @sign.string_files[3].message)
|
41
|
+
assert_equal(3, @sign.string_files[3].label)
|
42
|
+
assert_equal('3.37 ', @sign.string_files[4].message)
|
43
|
+
assert_equal(4, @sign.string_files[4].label)
|
44
|
+
assert_equal('16.47 ', @sign.string_files[5].message)
|
45
|
+
assert_equal(5, @sign.string_files[5].label)
|
46
|
+
|
47
|
+
assert_equal(6, @sign.string_files.length)
|
48
|
+
assert_equal(0, @sign.text_files.length)
|
49
|
+
assert_equal(0, @sign.dots_files.length)
|
50
|
+
|
51
|
+
printed = ''
|
52
|
+
count = 0
|
53
|
+
@sign.write { |text|
|
54
|
+
printed << text
|
55
|
+
}
|
56
|
+
assert_equal(final_s, printed)
|
57
|
+
end
|
58
|
+
end
|
data/test/ts_bb.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: betabrite
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-07-09 00:00:00 -07:00
|
8
|
+
summary: Provides a Ruby interface to BetaBrite LED signs
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: aaronp@rubyforge.org
|
12
|
+
homepage: betabrite.rubyforge.org
|
13
|
+
rubyforge_project: betabrite
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: ruby
|
27
|
+
signing_key:
|
28
|
+
cert_chain:
|
29
|
+
post_install_message:
|
30
|
+
authors:
|
31
|
+
- Aaron Patterson
|
32
|
+
files:
|
33
|
+
- test/bb_override.rb
|
34
|
+
- test/tc_many_mem.rb
|
35
|
+
- test/tc_memory.rb
|
36
|
+
- test/tc_set_string.rb
|
37
|
+
- test/ts_bb.rb
|
38
|
+
- lib/bb_version.rb
|
39
|
+
- lib/betabrite.rb
|
40
|
+
- lib/files
|
41
|
+
- lib/memory
|
42
|
+
- lib/string.rb
|
43
|
+
- lib/files/dotsfile.rb
|
44
|
+
- lib/files/stringfile.rb
|
45
|
+
- lib/files/textfile.rb
|
46
|
+
- lib/memory/memory.rb
|
47
|
+
- README
|
48
|
+
- EXAMPLES
|
49
|
+
- CHANGELOG
|
50
|
+
- LICENSE
|
51
|
+
- NOTES
|
52
|
+
test_files: []
|
53
|
+
rdoc_options:
|
54
|
+
- "--main"
|
55
|
+
- README
|
56
|
+
- "--title"
|
57
|
+
- "'BetaBrite RDoc'"
|
58
|
+
extra_rdoc_files:
|
59
|
+
- README
|
60
|
+
- EXAMPLES
|
61
|
+
- CHANGELOG
|
62
|
+
- LICENSE
|
63
|
+
- NOTES
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
requirements: []
|
67
|
+
dependencies: []
|