1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thermal\Profile; |
4
|
|
|
|
5
|
|
|
use Thermal\Printer; |
6
|
|
|
|
7
|
|
|
class Elgin extends EscPOS |
8
|
|
|
{ |
9
|
1 |
|
public function cutter($mode) |
10
|
|
|
{ |
11
|
1 |
|
if ($mode == Printer::CUT_FULL) { |
12
|
1 |
|
$this->getConnection()->write("\ew"); |
13
|
1 |
|
return $this; |
14
|
|
|
} |
15
|
1 |
|
return parent::cutter($mode); |
16
|
|
|
} |
17
|
|
|
|
18
|
1 |
|
public function buzzer() |
19
|
|
|
{ |
20
|
1 |
|
$this->getConnection()->write("\e(A\x04\x00\x01\xFF\x00\xFF"); |
21
|
1 |
|
return $this; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param int $number drawer id |
26
|
|
|
* @param int $on_time time in milliseconds that activate the drawer |
27
|
|
|
* @param int $off_time time in milliseconds that deactivate the drawer |
28
|
|
|
*/ |
29
|
1 |
|
public function drawer($number, $on_time, $off_time) |
30
|
|
|
{ |
31
|
|
|
$index = [ |
32
|
1 |
|
Printer::DRAWER_1 => "v" |
33
|
|
|
]; |
34
|
1 |
|
if (!isset($index[$number])) { |
35
|
1 |
|
throw new \Exception( |
36
|
1 |
|
sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)), |
37
|
1 |
|
404 |
38
|
|
|
); |
39
|
|
|
} |
40
|
1 |
|
$on_time = max(min($on_time, 200), 50); |
41
|
1 |
|
$this->getConnection()->write("\e" . $index[$number] . chr($on_time)); |
42
|
1 |
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
3 |
|
protected function setStyle($style, $enable) |
46
|
|
|
{ |
47
|
3 |
|
if ($enable) { |
48
|
|
|
// enable styles |
49
|
3 |
|
if (Printer::STYLE_BOLD == $style) { |
50
|
1 |
|
$this->getConnection()->write("\eE"); |
51
|
3 |
|
return $this; |
52
|
|
|
} |
53
|
|
|
} else { |
54
|
|
|
// disable styles |
55
|
3 |
|
if (Printer::STYLE_BOLD == $style) { |
56
|
1 |
|
$this->getConnection()->write("\eF"); |
57
|
1 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
} |
60
|
3 |
|
return parent::setStyle($style, $enable); |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
protected function setMode($mode, $enable) |
64
|
|
|
{ |
65
|
1 |
|
if ($enable) { |
66
|
|
|
// enable styles |
67
|
1 |
|
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { |
68
|
1 |
|
$this->getConnection()->write("\eW\x01"); |
69
|
|
|
} |
70
|
1 |
|
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { |
71
|
1 |
|
$this->getConnection()->write("\ed\x01"); |
72
|
|
|
} |
73
|
|
|
} else { |
74
|
|
|
// disable styles |
75
|
1 |
|
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { |
76
|
1 |
|
$this->getConnection()->write("\ed\x00"); |
77
|
|
|
} |
78
|
1 |
|
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { |
79
|
1 |
|
$this->getConnection()->write("\eW\x00"); |
80
|
|
|
} |
81
|
|
|
} |
82
|
1 |
|
return $this; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|