From 8922bed52492ef6f1251d8fc38e694e5ef35334a Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Thu, 25 Oct 2018 21:04:43 +1100 Subject: [PATCH] implement upside-down print command, closes #615 --- src/Mike42/Escpos/Printer.php | 13 ++++++++++++- test/unit/EscposTest.php | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Mike42/Escpos/Printer.php b/src/Mike42/Escpos/Printer.php index 5e732b1a..c1441a91 100644 --- a/src/Mike42/Escpos/Printer.php +++ b/src/Mike42/Escpos/Printer.php @@ -972,7 +972,18 @@ public function setUnderline($underline = Printer::UNDERLINE_SINGLE) self::validateInteger($underline, 0, 2, __FUNCTION__); $this -> connector -> write(self::ESC . "-" . chr($underline)); } - + + /** + * Print each line upside-down (180 degrees rotated). + * + * @param boolean $on True to enable, false to disable. + */ + public function setUpsideDown($on = true) + { + self::validateBoolean($on, __FUNCTION__); + $this -> connector -> write(self::ESC . "{" . ($on ? chr(1) : chr(0))); + } + /** * Add text to the buffer. * diff --git a/test/unit/EscposTest.php b/test/unit/EscposTest.php index 5ac5f263..0b70e96b 100644 --- a/test/unit/EscposTest.php +++ b/test/unit/EscposTest.php @@ -1100,6 +1100,13 @@ public function testPrintLeftMarginInvalid() $this -> printer -> setPrintLeftMargin(70000); $this -> checkOutput(); } + + /* Upside-down print */ + public function testSetUpsideDown() + { + $this -> printer -> setUpsideDown(true); + $this -> checkOutput("\x1b@\x1b{\x01"); + } } /*