alphasign 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/alphasign.gemspec +1 -1
  3. data/lib/alphasign.rb +48 -17
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{alphasign}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jon Proulx"]
@@ -17,22 +17,19 @@ class AlphaSign
17
17
  Preamble = [ ']', ']'].pack('x10ax10a')
18
18
  # everything starts with this, nulls are to auto set baud on unit
19
19
  StartHeader = Preamble + [ 0x01 ].pack('x20C')
20
- # this is still a bit dubious, docs say "A" for write text file, but
21
- # example and experience show "AA" is needed, other codes are as yet
22
- # untested YMMV..I simply doubled the char listed in docs. only 'wtxt'
23
- # actually works with anything else here
20
+ # only handlers for :wtxt implemented so far
24
21
  StartCMD = {
25
- :wtxt => [ 0x02, 'AA' ].pack('CA2'), # write text file
26
- :rtxt => [ 0x02, 'BB' ].pack('CA2'), # read text file
27
- :wfctn => [ 0x02, 'EE' ].pack('CA2'), # write special function
28
- :rfctn => [ 0x02, 'FF' ].pack('CA2'), # read special function
29
- :wstr => [ 0x02, 'GG' ].pack('CA2'), # write string file
30
- :rstr => [ 0x02, 'HH' ].pack('CA2'), # read string file
31
- :wdots => [ 0x02, 'II' ].pack('CA2'), # write DOTS picture file
32
- :rdots => [ 0x02, 'JJ' ].pack('CA2'), # read DOTS picture file
33
- :wadots => [ 0x02, 'MM' ].pack('CA2'), # write ALPHAVISON DOTS picture file
34
- :radots => [ 0x02, 'NN' ].pack('CA2'), # read ALPHAVISON DOTS picture file
35
- :bulletin => [ 0x02, 'OO' ].pack('CA2'), # write bulletin message
22
+ :wtxt => [ 0x02, 'A' ].pack('CA'), # write text file
23
+ :rtxt => [ 0x02, 'B' ].pack('CA'), # read text file
24
+ :wfctn => [ 0x02, 'E' ].pack('CA'), # write special function
25
+ :rfctn => [ 0x02, 'F' ].pack('CA'), # read special function
26
+ :wstr => [ 0x02, 'G' ].pack('CA'), # write string file
27
+ :rstr => [ 0x02, 'H' ].pack('CA'), # read string file
28
+ :wdots => [ 0x02, 'I' ].pack('CA'), # write DOTS picture file
29
+ :rdots => [ 0x02, 'J' ].pack('CA'), # read DOTS picture file
30
+ :wadots => [ 0x02, 'M' ].pack('CA'), # write ALPHAVISON DOTS picture file
31
+ :radots => [ 0x02, 'N' ].pack('CA'), # read ALPHAVISON DOTS picture file
32
+ :bulletin => [ 0x02, 'O' ].pack('CA'), # write bulletin message
36
33
  }
37
34
 
38
35
  # Marker for start of mode config
@@ -62,6 +59,36 @@ class AlphaSign
62
59
 
63
60
  Footer = [0x04].pack("C") # EOT end of transmission
64
61
 
62
+ # standard color codes, limited by hardware
63
+ Color = {
64
+ :red => [0x1c,0x31].pack("C2"),
65
+ :green => [0x1c,0x32].pack("C2"),
66
+ :amber => [0x1c,0x33].pack("C2"),
67
+ :dimred => [0x1c,0x34].pack("C2"),
68
+ :dimgreen => [0x1c,0x35].pack("C2"),
69
+ :brown => [0x1c,0x36].pack("C2"),
70
+ :orange => [0x1c,0x37].pack("C2"),
71
+ :yellow => [0x1c,0x38].pack("C2"),
72
+ :rainbow1 => [0x1c,0x39].pack("C2"),
73
+ :rainbow2 => [0x1c,0x41].pack("C2"),
74
+ :mix => [0x1c,0x42].pack("C2"),
75
+ :auto => [0x1c,0x43].pack("C2"),
76
+ }
77
+
78
+ # Character sets height & style
79
+ CharSet = {
80
+ :std5 => [0x1a,0x31].pack("C2"),
81
+ :std7 => [0x1a,0x33].pack("C2"),
82
+ :fancy7 => [0x1a,0x35].pack("C2"),
83
+ :std10 => [0x1a,0x36].pack("C2"),
84
+ :fullfancy => [0x1a,0x38].pack("C2"),
85
+ :fullstd => [0x1a,0x39].pack("C2"),
86
+ }
87
+
88
+ # speeds from slow to fast
89
+ Speed = [ [0x15].pack("C"), [0x16].pack("C"), [0x17].pack("C"),
90
+ [0x18].pack("C"), [0x19].pack("C") ]
91
+
65
92
  # @param [String] device the serial device the sign is connected to
66
93
  # for now we only speak rs232
67
94
  def initialize (device = "/dev/ttyS0")
@@ -77,9 +104,13 @@ class AlphaSign
77
104
 
78
105
  # we don't have an open yet so this still kludgey and enfoces using
79
106
  # only :wtxt command as thats the only one we know we can do
80
- def write (msg, position=:middle, mode=:rotate)
107
+ def write (msg, position=:middle, mode=:hold)
108
+ @fileLabel = [ 0x41 ].pack("C") # any value from 0x20 to 0x75
109
+ # except 0x30 which is reserved
110
+ # for "Priority Text" file
111
+ # according to docs
81
112
  @alphaFormat = StartMode + Position[position] + Mode[mode]
82
- @alphaHeader = StartHeader + @addr + StartCMD[:wtxt] + @alphaFormat
113
+ @alphaHeader = StartHeader + @addr + StartCMD[:wtxt] + @fileLabel + @alphaFormat
83
114
  sp=SerialPort.new(@device,
84
115
  Baud, DataBits, StopBits, Parity)
85
116
  sp.write @alphaHeader
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphasign
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Proulx