betabrite 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.autotest +7 -0
  2. data/EXAMPLES +28 -73
  3. data/History.txt +16 -0
  4. data/Manifest.txt +35 -0
  5. data/{README → README.txt} +58 -52
  6. data/Rakefile +11 -0
  7. data/lib/betabrite.rb +6 -120
  8. data/lib/betabrite/autotest.rb +43 -0
  9. data/lib/betabrite/base.rb +86 -0
  10. data/lib/betabrite/files.rb +4 -0
  11. data/lib/betabrite/files/dots.rb +24 -0
  12. data/lib/betabrite/files/file_dsl.rb +18 -0
  13. data/lib/betabrite/files/string.rb +22 -0
  14. data/lib/betabrite/files/text.rb +122 -0
  15. data/lib/{memory → betabrite}/memory.rb +27 -5
  16. data/lib/betabrite/serial.rb +28 -0
  17. data/lib/{string.rb → betabrite/string.rb} +41 -15
  18. data/lib/betabrite/usb.rb +64 -0
  19. data/script/alloc.rb +21 -0
  20. data/script/clear_memory.rb +16 -0
  21. data/script/client.rb +39 -0
  22. data/script/dots_file.rb +35 -0
  23. data/script/server.rb +12 -0
  24. data/script/sign_test.rb +17 -0
  25. data/script/stock_alloc.rb +81 -0
  26. data/script/stock_client.rb +40 -0
  27. data/script/stockdata.rb +65 -0
  28. data/test/helper.rb +6 -0
  29. data/test/{tc_many_mem.rb → test_many_mem.rb} +6 -10
  30. data/test/{tc_memory.rb → test_memory.rb} +11 -24
  31. data/test/{tc_set_string.rb → test_set_string.rb} +5 -9
  32. data/test/test_string.rb +34 -0
  33. data/test/test_text_file.rb +19 -0
  34. data/test/test_usb_betabrite.rb +94 -0
  35. metadata +94 -60
  36. data/CHANGELOG +0 -10
  37. data/NOTES +0 -29
  38. data/lib/bb_version.rb +0 -3
  39. data/lib/files/dotsfile.rb +0 -24
  40. data/lib/files/stringfile.rb +0 -22
  41. data/lib/files/textfile.rb +0 -114
  42. data/test/bb_override.rb +0 -5
  43. data/test/tc_string.rb +0 -20
  44. data/test/tc_text_file.rb +0 -18
  45. data/test/ts_bb.rb +0 -7
@@ -1,3 +0,0 @@
1
- class BetaBrite
2
- Version = '0.0.2'
3
- end
@@ -1,24 +0,0 @@
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
@@ -1,22 +0,0 @@
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
@@ -1,114 +0,0 @@
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
- alias_method :position, :display_position
66
- alias_method :position=, :display_position=
67
-
68
- def initialize
69
- @display_position = Position::MIDDLE
70
- @label = "A"
71
- @mode = Mode::ROTATE
72
- yield self if block_given?
73
- end
74
-
75
- def to_s
76
- "#{combine}#{checksum(combine)}"
77
- end
78
-
79
- def checksum(string)
80
- total = 0
81
- 0.upto(string.length - 1) do |i|
82
- total += string[i]
83
- end
84
-
85
- sprintf("%04x", total).upcase
86
- end
87
-
88
- def method_missing(sym, *args)
89
- if args.length > 0 && sym.to_s =~ /^set_(mode|position)$/
90
- class_name = $1
91
-
92
- const_sym = class_name.capitalize.to_sym
93
-
94
- klass = self.class.const_get const_sym
95
- if klass.const_defined? args.first.upcase.to_sym
96
- return send("#{class_name}=".to_sym,
97
- klass.const_get(args.first.upcase.to_sym))
98
- else
99
- raise ArgumentError, "no constant #{args.first.upcase}", caller
100
- end
101
- end
102
-
103
- super
104
- end
105
-
106
- alias :inspect :to_s
107
-
108
- private
109
- def combine
110
- "#{BetaBrite::STX}#{WRITE}#{@label}#{BetaBrite::ESC}" <<
111
- "#{@display_position}#{@mode}#{@message}#{BetaBrite::ETX}"
112
- end
113
- end
114
- end
@@ -1,5 +0,0 @@
1
- class BetaBrite
2
- def sleep_time
3
- 0
4
- end
5
- end
@@ -1,20 +0,0 @@
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 StringTest < Test::Unit::TestCase
9
- def test_const_dsl
10
- s = BetaBrite::String.new("hello") { |a|
11
- a.set_color "green"
12
- a.set_charset "five_high"
13
- }
14
-
15
- assert_equal(BetaBrite::String::Color::GREEN, s.color)
16
- assert_equal(BetaBrite::String::CharSet::FIVE_HIGH, s.charset)
17
- assert_equal("hello", s.string)
18
- end
19
- end
20
-
@@ -1,18 +0,0 @@
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 TextFileTest < Test::Unit::TestCase
9
- def test_const_dsl
10
- tf = BetaBrite::TextFile.new { |a|
11
- a.set_mode "roll_down"
12
- a.set_position "middle"
13
- }
14
-
15
- assert_equal(BetaBrite::TextFile::Position::MIDDLE, tf.position)
16
- assert_equal(BetaBrite::TextFile::Mode::ROLL_DOWN, tf.mode)
17
- end
18
- end
@@ -1,7 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'tc_many_mem'
4
- require 'tc_memory'
5
- require 'tc_set_string'
6
- require 'tc_text_file'
7
- require 'tc_string'