-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMicroprinter_debug.rb
More file actions
133 lines (100 loc) · 2.6 KB
/
Microprinter_debug.rb
File metadata and controls
133 lines (100 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# TODO: turn this debug library into an rspec mock/stub; when testing, send serial data to a stub, so that we can test for expected responses, etc.
class Microprinter_debug
BARCODE_MODE_UPCA = 0x00
BARCODE_MODE_UPCE = 0x01
BARCODE_MODE_JAN13AEN = 0x02
BARCODE_MODE_JAN8EAN = 0x03
BARCODE_MODE_CODE39 = 0x04
BARCODE_MODE_ITF = 0x05
BARCODE_MODE_CODEABAR = 0x06
BARCODE_MODE_CODE128 = 0x07
BARCODE_WIDTH_NARROW = 0x02
BARCODE_WIDTH_MEDIUM = 0x03
BARCODE_WIDTH_WIDE = 0x04
def initialize(port_str = "")
puts "[Microprinter init]"
end
def close
puts "[Microprinter closing]"
end
# Feed this method either a string or an array of strings; each will be printed on its own line.
#def print_text(text)
# text.each do |line|
# print("[print]#{line}\n")
# end
#end
def print(text)
puts text
end
def print_line(text)
puts("#{text}\n")
end
def feed
puts "[feed]\n\n\n"
end
def cut
puts "[-----FULL CUT-----]"
end
def partial_cut
puts "[-----PARTIAL CUT-----]"
end
def feed_and_cut
self.feed
self.cut
end
def print_and_cut(text) # utility method. print line (or array of lines) then feed & cut
self.print_line(text)
self.feed_and_cut
end
def set_character_width_normal
puts "[set print mode a (normal width text)]"
end
def set_character_width_narrow
puts "[set print mode b (narrow width text)]"
end
def set_print_mode_a
set_character_width_normal
end
def set_print_mode_b
set_character_width_narrow
end
def set_font_weight_bold
puts "[set double print on (bold text)]"
end
def set_double_print_on
set_font_weight_bold
end
def set_font_weight_normal
puts "[set double print off (normal weight text)]"
end
def set_double_print_off
set_font_weight_normal
end
def set_underline_on
puts "[set underline on]"
end
def set_underline_off
puts "[set underline off]"
end
def print_barcode(barcode_mode, barcode)
puts "[barcode] ||||| #{barcode} (mode #{barcode_mode})"
end
def set_barcode_height(height) # in dots. default = 162
puts "[set barcode height = #{height}]"
end
def set_barcode_width(width) # 2, 3 or 4. default = 3
puts "[set barcode width = #{width}]"
end
def set_barcode_text_position(position) # 0-3
puts "[set barcode text position = #{position}]"
end
def set_linefeed_rate(rate) #def = 22
puts "[set linefeed rate = #{rate}]"
end
def print_image_row(data)
puts "[print image row]"
end
def print_image_bytes(mode, data)
puts "[print image bytes]"
end
end