-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
761 additions
and
116 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Thermal\Profile; | ||
|
||
use Thermal\Printer; | ||
|
||
class Daruma extends Elgin | ||
{ | ||
/** | ||
* @param int $number drawer id | ||
* @param int $on_time time in milliseconds that activate the drawer | ||
* @param int $off_time time in milliseconds that deactivate the drawer | ||
*/ | ||
public function drawer($number, $on_time, $off_time) | ||
{ | ||
$index = [ | ||
Printer::DRAWER_1 => "p" | ||
]; | ||
if (!isset($index[$number])) { | ||
throw new \Exception( | ||
sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)), | ||
404 | ||
); | ||
} | ||
$this->getConnection()->write("\e" . $index[$number]); | ||
return $this; | ||
} | ||
|
||
protected function setAlignment($align) | ||
{ | ||
$cmd = [ | ||
Printer::ALIGN_LEFT => "\ej0", | ||
Printer::ALIGN_CENTER => "\ej1", | ||
Printer::ALIGN_RIGHT => "\ej2" | ||
]; | ||
$this->getConnection()->write($cmd[$align]); | ||
} | ||
|
||
protected function setMode($mode, $enable) | ||
{ | ||
if ($enable) { | ||
// enable styles | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\x0E"); | ||
} | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ew1"); | ||
} | ||
} else { | ||
// disable styles | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ew0"); | ||
} | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\x14"); | ||
} | ||
} | ||
return $this; | ||
} | ||
|
||
protected function fontChanged($new_font, $old_font) | ||
{ | ||
if ($new_font['name'] == 'Font A') { | ||
$this->getConnection()->write("\e!\x00"); | ||
} elseif ($new_font['name'] == 'Font B') { | ||
$this->getConnection()->write("\e!\x01"); | ||
} | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Thermal\Profile; | ||
|
||
use Thermal\Printer; | ||
|
||
class Diebold extends Elgin | ||
{ | ||
/** | ||
* @param int $number drawer id | ||
* @param int $on_time time in milliseconds that activate the drawer | ||
* @param int $off_time time in milliseconds that deactivate the drawer | ||
*/ | ||
public function drawer($number, $on_time, $off_time) | ||
{ | ||
$index = [ | ||
Printer::DRAWER_1 => '0' | ||
]; | ||
if (!isset($index[$number])) { | ||
throw new \Exception( | ||
sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)), | ||
404 | ||
); | ||
} | ||
$on_time = min((int)($on_time / 2), 65); | ||
$off_time = min((int)($off_time / 2), 65); | ||
$this->getConnection()->write("\e&" . $index[$number] . chr($on_time) . chr($off_time)); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Thermal\Profile; | ||
|
||
use Thermal\Printer; | ||
|
||
class Elgin extends EscPOS | ||
{ | ||
public function cutter($mode) | ||
{ | ||
if ($mode == Printer::CUT_FULL) { | ||
$this->getConnection()->write("\ew"); | ||
return $this; | ||
} | ||
return parent::cutter($mode); | ||
} | ||
|
||
public function buzzer() | ||
{ | ||
$this->getConnection()->write("\e(A\x04\x00\x01\xFF\x00\xFF"); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param int $number drawer id | ||
* @param int $on_time time in milliseconds that activate the drawer | ||
* @param int $off_time time in milliseconds that deactivate the drawer | ||
*/ | ||
public function drawer($number, $on_time, $off_time) | ||
{ | ||
$index = [ | ||
Printer::DRAWER_1 => "v" | ||
]; | ||
if (!isset($index[$number])) { | ||
throw new \Exception( | ||
sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)), | ||
404 | ||
); | ||
} | ||
$on_time = max(min($on_time, 200), 50); | ||
$this->getConnection()->write("\e" . $index[$number] . chr($on_time)); | ||
return $this; | ||
} | ||
|
||
protected function setStyle($style, $enable) | ||
{ | ||
if ($enable) { | ||
// enable styles | ||
if (Printer::STYLE_BOLD == $style) { | ||
$this->getConnection()->write("\eE"); | ||
return $this; | ||
} | ||
} else { | ||
// disable styles | ||
if (Printer::STYLE_BOLD == $style) { | ||
$this->getConnection()->write("\eF"); | ||
return $this; | ||
} | ||
} | ||
return parent::setStyle($style, $enable); | ||
} | ||
|
||
protected function setMode($mode, $enable) | ||
{ | ||
if ($enable) { | ||
// enable styles | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\eW\x01"); | ||
} | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ed\x01"); | ||
} | ||
} else { | ||
// disable styles | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ed\x00"); | ||
} | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\eW\x00"); | ||
} | ||
} | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Thermal\Profile; | ||
|
||
use Thermal\Printer; | ||
|
||
class Generic extends EscPOS | ||
{ | ||
protected function setMode($mode, $enable) | ||
{ | ||
if ($enable) { | ||
// enable styles | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\x0E"); | ||
} | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ed1"); | ||
} | ||
} else { | ||
// disable styles | ||
if (Printer::STYLE_DOUBLE_HEIGHT & $mode) { | ||
$this->getConnection()->write("\ed0"); | ||
} | ||
if (Printer::STYLE_DOUBLE_WIDTH & $mode) { | ||
$this->getConnection()->write("\x14"); | ||
} | ||
} | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.