1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thermal\Profile; |
4
|
|
|
|
5
|
|
|
use Thermal\Printer; |
6
|
|
|
|
7
|
|
|
class Bematech extends Epson |
8
|
|
|
{ |
9
|
2 |
|
protected function setStyle($style, $enable) |
10
|
|
|
{ |
11
|
2 |
|
if ($this->getFont()['name'] != 'Font C') { |
12
|
1 |
|
return parent::setStyle($style, $enable); |
13
|
|
|
} |
14
|
2 |
|
if ($enable) { |
15
|
|
|
// enable styles |
16
|
2 |
|
if (Printer::STYLE_BOLD == $style) { |
17
|
1 |
|
$this->getConnection()->write("\eE"); |
18
|
2 |
|
return $this; |
19
|
|
|
} |
20
|
|
|
} else { |
21
|
|
|
// disable styles |
22
|
2 |
|
if (Printer::STYLE_BOLD == $style) { |
23
|
1 |
|
$this->getConnection()->write("\eF"); |
24
|
1 |
|
return $this; |
25
|
|
|
} |
26
|
|
|
} |
27
|
2 |
|
return parent::setStyle($style, $enable); |
28
|
|
|
} |
29
|
|
|
|
30
|
1 |
|
public function buzzer() |
31
|
|
|
{ |
32
|
1 |
|
if ($this->getFont()['name'] != 'Font C') { |
33
|
|
|
// Bematech changed ESC/POS buzzer command |
34
|
1 |
|
$this->getConnection()->write("\e(A\x05\x00ad\x02\x02\x01"); |
35
|
1 |
|
return $this; |
36
|
|
|
} |
37
|
|
|
// ESC/Bema does not have buzzer command working, remove call bellow? |
38
|
1 |
|
return parent::buzzer(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param int $number drawer id |
43
|
|
|
* @param int $on_time time in milliseconds that activate the drawer |
44
|
|
|
* @param int $off_time time in milliseconds that deactivate the drawer |
45
|
|
|
*/ |
46
|
2 |
|
public function drawer($number, $on_time, $off_time) |
47
|
|
|
{ |
48
|
2 |
|
if ($this->getFont()['name'] != 'Font C') { |
49
|
1 |
|
return parent::drawer($number, $on_time, $off_time); |
50
|
|
|
} |
51
|
|
|
$index = [ |
52
|
1 |
|
Printer::DRAWER_1 => "v", |
53
|
1 |
|
Printer::DRAWER_2 => "\x80" |
54
|
|
|
]; |
55
|
1 |
|
if (!isset($index[$number])) { |
56
|
1 |
|
throw new \Exception( |
57
|
1 |
|
sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)), |
58
|
1 |
|
404 |
59
|
|
|
); |
60
|
|
|
} |
61
|
1 |
|
$on_time = max(min($on_time, 255), 50); |
62
|
1 |
|
$this->getConnection()->write("\e" . $index[$number] . chr($on_time)); |
63
|
1 |
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
2 |
|
public function qrcode($data, $size) |
67
|
|
|
{ |
68
|
2 |
|
$len = strlen($data) + 3; |
69
|
2 |
|
$pL = $len & 0xFF; |
|
|
|
|
70
|
2 |
|
$pH = ($len >> 8) & 0xFF; |
|
|
|
|
71
|
|
|
|
72
|
2 |
|
$error = 2; // N1 Error correction level 0 - L, 1 - M, 2 - Q, 3 - H |
73
|
2 |
|
$size = min(11, max(1, $size ?: 4)) * 2; // N2 - MSB; 0 = default = 4 |
74
|
2 |
|
$version = 0; // N3 - Version QRCode |
75
|
2 |
|
$encoding = 1; // N4, Encoding modes: 0 – Numeric only, 1 – Alphanumeric, 2 – Binary (8 bits), 3 – Kanji,; |
76
|
2 |
|
$this->getConnection()->write("\x1dkQ"); |
77
|
2 |
|
$this->getConnection()->write(chr($error) . chr($size) . chr($version) . chr($encoding)); |
78
|
2 |
|
$this->getConnection()->write(chr($pL) . chr($pH)); // N5 e N6 - Length |
|
|
|
|
79
|
2 |
|
$this->getConnection()->write($data); // Data |
80
|
2 |
|
$this->getConnection()->write("\x00"); |
81
|
2 |
|
$this->feed(1); |
82
|
2 |
|
} |
83
|
|
|
|
84
|
4 |
|
protected function fontChanged($new_font, $old_font) |
85
|
|
|
{ |
86
|
|
|
// columns define the command set: ESC/Bema or ESC/POS |
87
|
4 |
|
if ($new_font['name'] == 'Font C') { |
88
|
4 |
|
$this->getConnection()->write("\x1d\xf950"); |
89
|
4 |
|
return $this; |
90
|
|
|
} |
91
|
4 |
|
$this->getConnection()->write("\x1d\xf951"); |
92
|
4 |
|
return parent::fontChanged($new_font, $old_font); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.