ld220 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/doc/VFD LD220 User Manual_V2.3.pdf +0 -0
- data/examples/shell +8 -0
- data/ld220.gemspec +24 -0
- data/lib/ld220.rb +28 -0
- data/lib/ld220/mode/utc.rb +64 -0
- data/lib/ld220/version.rb +3 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c2a5f8d7a58515ecc219dcd411f4047d771c86e3
|
4
|
+
data.tar.gz: 105772d419bea226b86ab8d687d75d460663772e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbcd3f9c840165910aaf1fcccb6319e3544d40a21a5db1c481813206b544d1d95855476aecad00ef6c6d5e7744536e4eca2a5837e282afd507910290bbf231ca
|
7
|
+
data.tar.gz: 323b3530efdf7975230d526357d78373a313279531e2745fe4c0e5830196e5ffb7952094eb1c19660afef782aba0177a0df20f2f68aa50d82e3254fd77ef2c04
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.*.sw*
|
Binary file
|
data/examples/shell
ADDED
data/ld220.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ld220/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ld220"
|
7
|
+
s.version = LD220::VERSION
|
8
|
+
s.authors = ["Ben Klang"]
|
9
|
+
s.email = ["bklang@mojolingo.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Interface to LD220 Point-of-Sale Display}
|
12
|
+
s.description = %q{This gem provides an interface and helper functions for displaying messages on LD220 Point-of-Sale displays (eg. HP POS Pole Displays)}
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.rubyforge_project = "ld220"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency %q<rubyserial>
|
22
|
+
|
23
|
+
s.add_development_dependency %q<pry>
|
24
|
+
end
|
data/lib/ld220.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubyserial'
|
3
|
+
|
4
|
+
class LD220
|
5
|
+
attr_accessor :debug
|
6
|
+
|
7
|
+
def initialize(device, mode, options = {})
|
8
|
+
extend mode
|
9
|
+
options[:speed] ||= 9600
|
10
|
+
@debug = options[:debug]
|
11
|
+
@display = Serial.new device, options[:speed]
|
12
|
+
end
|
13
|
+
|
14
|
+
def type(string, delay = 0.1)
|
15
|
+
clear
|
16
|
+
sleep delay
|
17
|
+
string.split('').each do |char|
|
18
|
+
write char
|
19
|
+
sleep delay
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def write(data)
|
24
|
+
data = data.encode Encoding::US_ASCII
|
25
|
+
puts "Sending: #{data.inspect}" if @debug
|
26
|
+
@display.write data
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class LD220
|
4
|
+
class Mode
|
5
|
+
module UTC
|
6
|
+
ENHANCED_PREAMBLE = "\x1b\x75"
|
7
|
+
|
8
|
+
def clear
|
9
|
+
write "\x1f"
|
10
|
+
end
|
11
|
+
|
12
|
+
def reset
|
13
|
+
standard_mode
|
14
|
+
move_cursor_to 0
|
15
|
+
clear
|
16
|
+
end
|
17
|
+
|
18
|
+
def cursor(enabled)
|
19
|
+
write enabled ? "\x13" : "\x14"
|
20
|
+
end
|
21
|
+
|
22
|
+
def move_cursor_to(pos)
|
23
|
+
raise ArgumentError, "Position must be between 0 and 39" unless (0..39).include? pos
|
24
|
+
write "\x10#{pos.chr}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def scroll_msg(msg)
|
28
|
+
msg = msg.to_s
|
29
|
+
# Messages longer than 45 chars are accepted, but truncated
|
30
|
+
raise ArgumentError, "Message must be 45 or fewer characters" if msg.length > 45
|
31
|
+
enhanced_cmd { write "#{ENHANCED_PREAMBLE}\x44#{msg}\x0d" }
|
32
|
+
end
|
33
|
+
|
34
|
+
def scroll_once(msg)
|
35
|
+
enhanced_cmd { write "#{ENHANCED_PREAMBLE}\x46#{msg}\x0d" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def stop_scroll
|
39
|
+
# There is no documented way to stop an infinite scroll.
|
40
|
+
# However, using "scroll once" with an empty value gets us close
|
41
|
+
scroll_once ''
|
42
|
+
reset
|
43
|
+
end
|
44
|
+
|
45
|
+
def show_time(time = Time.now)
|
46
|
+
enhanced_cmd { write "#{ENHANCED_PREAMBLE}\x45#{time.strftime "%H:%M"}\x0d" }
|
47
|
+
end
|
48
|
+
|
49
|
+
def enhanced_cmd
|
50
|
+
enhanced_mode
|
51
|
+
yield
|
52
|
+
standard_mode
|
53
|
+
end
|
54
|
+
|
55
|
+
def enhanced_mode
|
56
|
+
write "\x1b\x64"
|
57
|
+
end
|
58
|
+
|
59
|
+
def standard_mode
|
60
|
+
write "\x1b\x0f\x0d"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ld220
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Klang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyserial
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This gem provides an interface and helper functions for displaying messages
|
42
|
+
on LD220 Point-of-Sale displays (eg. HP POS Pole Displays)
|
43
|
+
email:
|
44
|
+
- bklang@mojolingo.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- doc/VFD LD220 User Manual_V2.3.pdf
|
51
|
+
- examples/shell
|
52
|
+
- ld220.gemspec
|
53
|
+
- lib/ld220.rb
|
54
|
+
- lib/ld220/mode/utc.rb
|
55
|
+
- lib/ld220/version.rb
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project: ld220
|
76
|
+
rubygems_version: 2.4.6
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Interface to LD220 Point-of-Sale Display
|
80
|
+
test_files: []
|