From 3bc6b6bbde2431d7932c3fa9a346a801d845b955 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Thu, 3 Sep 2020 14:23:44 +0200 Subject: [PATCH 01/14] Added 2.168 version --- adafruit_thermal_printer/__init__.py | 16 ++++++-- adafruit_thermal_printer/thermal_printer.py | 37 +++++++++++++++++-- .../thermal_printer_264.py | 3 +- .../thermal_printer_legacy.py | 3 +- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/adafruit_thermal_printer/__init__.py b/adafruit_thermal_printer/__init__.py index b0a8fed..b89830b 100644 --- a/adafruit_thermal_printer/__init__.py +++ b/adafruit_thermal_printer/__init__.py @@ -29,11 +29,19 @@ def get_printer_class(version): assert version is not None assert version >= 0.0 # pylint: disable=import-outside-toplevel - if version < 2.64: - import adafruit_thermal_printer.thermal_printer_legacy as thermal_printer - elif version < 2.68: + + # I reversed order of checking the version + + #TODO the legacy printer should be a base class for all newer printer. It'll make it easier + #to upgrade the library with newer firmware + if version >= 2.168: + import adafruit_thermal_printer.thermal_printer_2168 as thermal_printer + elif version >= 2.68: + import adafruit_thermal_printer.thermal_printer as thermal_printer + elif version >= 2.64: import adafruit_thermal_printer.thermal_printer_264 as thermal_printer else: - import adafruit_thermal_printer.thermal_printer as thermal_printer + import adafruit_thermal_printer.thermal_printer_legacy as thermal_printer + # pylint: enable=import-outside-toplevel return thermal_printer.ThermalPrinter diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index fdeebd2..e847635 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -57,6 +57,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer.git" +# pylint: disable=bad-whitespace # Internally used constants. _UPDOWN_MASK = const(1 << 2) _BOLD_MASK = const(1 << 3) @@ -73,6 +74,7 @@ SIZE_LARGE = const(2) UNDERLINE_THIN = const(0) UNDERLINE_THICK = const(1) +# pylint: enable=bad-whitespace # Disable too many instance members warning. This is not something pylint can @@ -102,8 +104,9 @@ # else it will be very easy to break or introduce subtle incompatibilities with # older firmware printers. class ThermalPrinter: - """Thermal printer for printers with firmware version 2.68 or higher.""" + """Thermal printer for printers with firmware version from 2.68 and below 2.168""" + # pylint: disable=bad-whitespace # Barcode types. These vary based on the firmware version so are made # as class-level variables that users can reference (i.e. # ThermalPrinter.UPC_A, etc) and write code that is independent of the @@ -117,6 +120,7 @@ class ThermalPrinter: CODABAR = 71 CODE93 = 72 CODE128 = 73 + # pylint: enable=bad-whitespace class _PrintModeBit: # Internal descriptor class to simplify printer mode change properties. @@ -149,6 +153,9 @@ def __set__(self, obj, val): # pylint: enable=protected-access # pylint: enable=too-few-public-methods + + + def __init__( self, uart, @@ -180,6 +187,7 @@ def __init__( self._char_height = 24 self._line_spacing = 6 self._barcode_height = 50 + self.up_down_mode = True # pylint: disable=line-too-long # Byte delay calculated based on assumption of 19200 baud. # From Arduino library code, see formula here: @@ -312,6 +320,16 @@ def print(self, text, end="\n"): self._write_char(char) if end is not None: self._write_char(end) + # def upDownMode(self, val): + # """ Turns on/off upside-down printing mode (ESC + { + n) + # where n is 0 or 1 + # + # """ + # if val is True: + # self.send_command("\x1B{\x01") + # else: + # self.send_command("\x1B{\x00") + def print_barcode(self, text, barcode_type): """Print a barcode with the specified text/number (the meaning @@ -386,7 +404,8 @@ def set_defaults(self): self.size = SIZE_SMALL self.underline = None self.inverse = False - self.upside_down = False + self.upside_down = False # wg. dokumentacji powinno działać ale nie działa + self.up_down_mode = True # zamiast powyższego zaiplementowałem to << self.double_height = False self.double_width = False self.strike = False @@ -487,7 +506,19 @@ def _set_inverse(self, inverse): ) # pylint: enable=line-too-long - upside_down = _PrintModeBit(_UPDOWN_MASK) + def _set_up_down_mode(self, up_down_mode): + if up_down_mode: + self.send_command("\x1B{\x01") + + else: + self.send_command("\x1B{\x00") + + + + + up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") + + upside_down = _PrintModeBit(_UPDOWN_MASK) #wg. dokumentacji to powinno działać ale nie działa double_height = _PrintModeBit(_DOUBLE_HEIGHT_MASK) diff --git a/adafruit_thermal_printer/thermal_printer_264.py b/adafruit_thermal_printer/thermal_printer_264.py index 26bbb2a..b1fc74e 100644 --- a/adafruit_thermal_printer/thermal_printer_264.py +++ b/adafruit_thermal_printer/thermal_printer_264.py @@ -28,7 +28,8 @@ versions and care must be taken to select the appropriate module inside this package for your firmware printer: -* thermal_printer = The latest printers with firmware version 2.68+ +* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer = The latest printers with firmware version 2.68 up to 2.168 * thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. * thermal_printer_legacy = Printers with firmware version before 2.64. diff --git a/adafruit_thermal_printer/thermal_printer_legacy.py b/adafruit_thermal_printer/thermal_printer_legacy.py index ae64c52..b0d7db5 100644 --- a/adafruit_thermal_printer/thermal_printer_legacy.py +++ b/adafruit_thermal_printer/thermal_printer_legacy.py @@ -28,7 +28,8 @@ versions and care must be taken to select the appropriate module inside this package for your firmware printer: -* thermal_printer = The latest printers with firmware version 2.68+ +* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer = The latest printers with firmware version 2.68 up to 2.168 * thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. * thermal_printer_legacy = Printers with firmware version before 2.64. From be3078cf23741f41a23a3093a1d4fe0881f3960b Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Thu, 3 Sep 2020 15:20:10 +0200 Subject: [PATCH 02/14] added missing file --- .../thermal_printer_2168.py | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 adafruit_thermal_printer/thermal_printer_2168.py diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py new file mode 100644 index 0000000..db6a8d5 --- /dev/null +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -0,0 +1,90 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Grzegorz Nowicki +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +`adafruit_thermal_printer.thermal_printer_2168.ThermalPrinter` +============================================================== + +Thermal printer control module built to work with small serial thermal +receipt printers. Note that these printers have many different firmware +versions and care must be taken to select the appropriate module inside this +package for your firmware printer: + +* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer = The latest printers with firmware version 2.68 up to 2.168 +* thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. +* thermal_printer_legacy = Printers with firmware version before 2.64. + +* Author(s): Tony DiCola, Grzegorz Nowicki +""" + +from micropython import const + +import adafruit_thermal_printer.thermal_printer as thermal_printer + +class ThermalPrinter(thermal_printer.ThermalPrinter): + """Thermal printer for printers with firmware version from 2.168 + """ + + # Barcode types. These vary based on the firmware version so are made + # as class-level variables that users can reference (i.e. + # ThermalPrinter.UPC_A, etc) and write code that is independent of the + # printer firmware version. + UPC_A = 65 + UPC_E = 66 + EAN13 = 67 + EAN8 = 68 + CODE39 = 69 + ITF = 70 + CODABAR = 71 + CODE93 = 72 + CODE128 = 73 + + def __init__( + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03, auto_warm_up=True + ): + """Thermal printer class. Requires a serial UART connection with at + least the TX pin connected. Take care connecting RX as the printer + will output a 5V signal which can damage boards! If RX is unconnected + the only loss in functionality is the has_paper function, all other + printer functions will continue to work. The byte_delay_s, dot_feed_s, + and dot_print_s values are delays which are used to prevent overloading + the printer with data. Use the default delays unless you fully + understand the workings of the printer and how delays, baud rate, + number of dots, heat time, etc. relate to each other. + """ + super().__init__( + uart, + byte_delay_s=byte_delay_s, + dot_feed_s=dot_feed_s, + dot_print_s=dot_print_s, + auto_warm_up=auto_warm_up + ) + + def warm_up(self, heat_time=120): + """Apparently there are no parameters for setting darkness in 2.168 (at least commands from 2.68 dont work), + So it is little compatibility method to reuse older code. + """ + self._set_timeout(0.5) # Half second delay for printer to initialize. + self.reset() + + \ No newline at end of file From 9fc51c065946626bb3241bfa196a156b2475c729 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Thu, 3 Sep 2020 15:23:37 +0200 Subject: [PATCH 03/14] corrected copyright notice --- adafruit_thermal_printer/thermal_printer.py | 14 +++----------- adafruit_thermal_printer/thermal_printer_2168.py | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index e847635..0049744 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -320,15 +320,7 @@ def print(self, text, end="\n"): self._write_char(char) if end is not None: self._write_char(end) - # def upDownMode(self, val): - # """ Turns on/off upside-down printing mode (ESC + { + n) - # where n is 0 or 1 - # - # """ - # if val is True: - # self.send_command("\x1B{\x01") - # else: - # self.send_command("\x1B{\x00") + def print_barcode(self, text, barcode_type): @@ -516,9 +508,9 @@ def _set_up_down_mode(self, up_down_mode): - up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") + up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") #Should work in 2.68 so its here and not in 2.168 module - upside_down = _PrintModeBit(_UPDOWN_MASK) #wg. dokumentacji to powinno działać ale nie działa + upside_down = _PrintModeBit(_UPDOWN_MASK) #Don't work in 2.168 hence the above double_height = _PrintModeBit(_DOUBLE_HEIGHT_MASK) diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index db6a8d5..36a2dde 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -1,6 +1,6 @@ # The MIT License (MIT) # -# Copyright (c) 2020 Grzegorz Nowicki +# Copyright (c) 2020 Tony DiCola, Grzegorz Nowicki # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal From 87d5823f6ad095b7052d8bf2a8d7f5ed040eee48 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 09:26:06 +0200 Subject: [PATCH 04/14] included commit 03a1e0ba8925074d912140c14e7121429fedb902 changes 2 --- adafruit_thermal_printer/thermal_printer.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index 0049744..456905d 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -57,7 +57,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer.git" -# pylint: disable=bad-whitespace + # Internally used constants. _UPDOWN_MASK = const(1 << 2) _BOLD_MASK = const(1 << 3) @@ -74,7 +74,7 @@ SIZE_LARGE = const(2) UNDERLINE_THIN = const(0) UNDERLINE_THICK = const(1) -# pylint: enable=bad-whitespace + # Disable too many instance members warning. This is not something pylint can @@ -106,7 +106,6 @@ class ThermalPrinter: """Thermal printer for printers with firmware version from 2.68 and below 2.168""" - # pylint: disable=bad-whitespace # Barcode types. These vary based on the firmware version so are made # as class-level variables that users can reference (i.e. # ThermalPrinter.UPC_A, etc) and write code that is independent of the @@ -120,8 +119,7 @@ class ThermalPrinter: CODABAR = 71 CODE93 = 72 CODE128 = 73 - # pylint: enable=bad-whitespace - + class _PrintModeBit: # Internal descriptor class to simplify printer mode change properties. # This is tightly coupled to the ThermalPrinter implementation--do not From e62d0d9877296d79318905fed183d7448c07bf50 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 09:46:57 +0200 Subject: [PATCH 05/14] changes to conform with pylint --- adafruit_thermal_printer/thermal_printer.py | 23 ++++++++----------- .../thermal_printer_2168.py | 13 +++++------ .../thermal_printer_264.py | 2 +- .../thermal_printer_legacy.py | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index 456905d..912b2cf 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -57,7 +57,6 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer.git" - # Internally used constants. _UPDOWN_MASK = const(1 << 2) _BOLD_MASK = const(1 << 3) @@ -74,7 +73,6 @@ SIZE_LARGE = const(2) UNDERLINE_THIN = const(0) UNDERLINE_THICK = const(1) - # Disable too many instance members warning. This is not something pylint can @@ -119,7 +117,7 @@ class ThermalPrinter: CODABAR = 71 CODE93 = 72 CODE128 = 73 - + class _PrintModeBit: # Internal descriptor class to simplify printer mode change properties. # This is tightly coupled to the ThermalPrinter implementation--do not @@ -152,16 +150,14 @@ def __set__(self, obj, val): # pylint: enable=too-few-public-methods - - def __init__( - self, - uart, - *, - byte_delay_s=0.00057346, - dot_feed_s=0.0021, - dot_print_s=0.03, - auto_warm_up=True + self, + uart, + *, + byte_delay_s=0.00057346, + dot_feed_s=0.0021, + dot_print_s=0.03, + auto_warm_up=True ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer @@ -506,7 +502,8 @@ def _set_up_down_mode(self, up_down_mode): - up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") #Should work in 2.68 so its here and not in 2.168 module + up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") + #The above Should work in 2.68 so its here and not in 2.168 module upside_down = _PrintModeBit(_UPDOWN_MASK) #Don't work in 2.168 hence the above diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index 36a2dde..9c4035f 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -60,7 +60,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE128 = 73 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03, auto_warm_up=True + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03, auto_warm_up=True ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer @@ -81,10 +81,9 @@ def __init__( ) def warm_up(self, heat_time=120): - """Apparently there are no parameters for setting darkness in 2.168 (at least commands from 2.68 dont work), - So it is little compatibility method to reuse older code. - """ + """Apparently there are no parameters for setting darkness in 2.168 + (at least commands from 2.68 dont work), So it is little + compatibility method to reuse older code. + """ self._set_timeout(0.5) # Half second delay for printer to initialize. - self.reset() - - \ No newline at end of file + self.reset() \ No newline at end of file diff --git a/adafruit_thermal_printer/thermal_printer_264.py b/adafruit_thermal_printer/thermal_printer_264.py index b1fc74e..0b89536 100644 --- a/adafruit_thermal_printer/thermal_printer_264.py +++ b/adafruit_thermal_printer/thermal_printer_264.py @@ -71,7 +71,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE128 = 73 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer diff --git a/adafruit_thermal_printer/thermal_printer_legacy.py b/adafruit_thermal_printer/thermal_printer_legacy.py index b0d7db5..d3a2a5a 100644 --- a/adafruit_thermal_printer/thermal_printer_legacy.py +++ b/adafruit_thermal_printer/thermal_printer_legacy.py @@ -71,7 +71,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): MSI = 10 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer From 5655109b881b9d63e19765b8c982166ab8f5cd5d Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 09:55:18 +0200 Subject: [PATCH 06/14] black formatting --- adafruit_thermal_printer/__init__.py | 6 ++-- adafruit_thermal_printer/thermal_printer.py | 35 ++++++++----------- .../thermal_printer_2168.py | 19 ++++++---- .../thermal_printer_264.py | 2 +- .../thermal_printer_legacy.py | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/adafruit_thermal_printer/__init__.py b/adafruit_thermal_printer/__init__.py index b89830b..5a2722e 100644 --- a/adafruit_thermal_printer/__init__.py +++ b/adafruit_thermal_printer/__init__.py @@ -32,8 +32,8 @@ def get_printer_class(version): # I reversed order of checking the version - #TODO the legacy printer should be a base class for all newer printer. It'll make it easier - #to upgrade the library with newer firmware + # TODO the legacy printer should be a base class for all newer printer. It'll make it easier + # to upgrade the library with newer firmware if version >= 2.168: import adafruit_thermal_printer.thermal_printer_2168 as thermal_printer elif version >= 2.68: @@ -42,6 +42,6 @@ def get_printer_class(version): import adafruit_thermal_printer.thermal_printer_264 as thermal_printer else: import adafruit_thermal_printer.thermal_printer_legacy as thermal_printer - + # pylint: enable=import-outside-toplevel return thermal_printer.ThermalPrinter diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index 912b2cf..c8596ed 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -149,15 +149,14 @@ def __set__(self, obj, val): # pylint: enable=protected-access # pylint: enable=too-few-public-methods - def __init__( - self, - uart, - *, - byte_delay_s=0.00057346, - dot_feed_s=0.0021, - dot_print_s=0.03, - auto_warm_up=True + self, + uart, + *, + byte_delay_s=0.00057346, + dot_feed_s=0.0021, + dot_print_s=0.03, + auto_warm_up=True ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer @@ -315,8 +314,6 @@ def print(self, text, end="\n"): if end is not None: self._write_char(end) - - def print_barcode(self, text, barcode_type): """Print a barcode with the specified text/number (the meaning varies based on the type of barcode) and type. Type is a value from @@ -390,8 +387,8 @@ def set_defaults(self): self.size = SIZE_SMALL self.underline = None self.inverse = False - self.upside_down = False # wg. dokumentacji powinno działać ale nie działa - self.up_down_mode = True # zamiast powyższego zaiplementowałem to << + self.upside_down = False # wg. dokumentacji powinno działać ale nie działa + self.up_down_mode = True # zamiast powyższego zaiplementowałem to << self.double_height = False self.double_width = False self.strike = False @@ -499,13 +496,12 @@ def _set_up_down_mode(self, up_down_mode): else: self.send_command("\x1B{\x00") + up_down_mode = property( + None, _set_up_down_mode, None, "Turns on/off upside-down printing mode" + ) + # The above Should work in 2.68 so its here and not in 2.168 module - - - up_down_mode = property(None, _set_up_down_mode, None, "Turns on/off upside-down printing mode") - #The above Should work in 2.68 so its here and not in 2.168 module - - upside_down = _PrintModeBit(_UPDOWN_MASK) #Don't work in 2.168 hence the above + upside_down = _PrintModeBit(_UPDOWN_MASK) # Don't work in 2.168 hence the above double_height = _PrintModeBit(_DOUBLE_HEIGHT_MASK) @@ -540,8 +536,7 @@ def offline(self): self.send_command("\x1B=\x00") # ESC + '=' + 0 def online(self): - """Put the printer into an online state after previously put offline. - """ + """Put the printer into an online state after previously put offline.""" self.send_command("\x1B=\x01") # ESC + '=' + 1 def has_paper(self): diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index 9c4035f..3909772 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -41,9 +41,9 @@ import adafruit_thermal_printer.thermal_printer as thermal_printer + class ThermalPrinter(thermal_printer.ThermalPrinter): - """Thermal printer for printers with firmware version from 2.168 - """ + """Thermal printer for printers with firmware version from 2.168""" # Barcode types. These vary based on the firmware version so are made # as class-level variables that users can reference (i.e. @@ -60,7 +60,12 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE128 = 73 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03, auto_warm_up=True + self, + uart, + byte_delay_s=0.00057346, + dot_feed_s=0.0021, + dot_print_s=0.03, + auto_warm_up=True, ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer @@ -77,13 +82,13 @@ def __init__( byte_delay_s=byte_delay_s, dot_feed_s=dot_feed_s, dot_print_s=dot_print_s, - auto_warm_up=auto_warm_up + auto_warm_up=auto_warm_up, ) def warm_up(self, heat_time=120): - """Apparently there are no parameters for setting darkness in 2.168 + """Apparently there are no parameters for setting darkness in 2.168 (at least commands from 2.68 dont work), So it is little - compatibility method to reuse older code. + compatibility method to reuse older code. """ self._set_timeout(0.5) # Half second delay for printer to initialize. - self.reset() \ No newline at end of file + self.reset() diff --git a/adafruit_thermal_printer/thermal_printer_264.py b/adafruit_thermal_printer/thermal_printer_264.py index 0b89536..b1fc74e 100644 --- a/adafruit_thermal_printer/thermal_printer_264.py +++ b/adafruit_thermal_printer/thermal_printer_264.py @@ -71,7 +71,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE128 = 73 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer diff --git a/adafruit_thermal_printer/thermal_printer_legacy.py b/adafruit_thermal_printer/thermal_printer_legacy.py index d3a2a5a..b0d7db5 100644 --- a/adafruit_thermal_printer/thermal_printer_legacy.py +++ b/adafruit_thermal_printer/thermal_printer_legacy.py @@ -71,7 +71,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): MSI = 10 def __init__( - self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 + self, uart, byte_delay_s=0.00057346, dot_feed_s=0.0021, dot_print_s=0.03 ): """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer From 50dae099fb8230ea7edf1451b3dfe3a12abb9b62 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 10:03:28 +0200 Subject: [PATCH 07/14] pylint again --- adafruit_thermal_printer/thermal_printer_2168.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index 3909772..9e536b5 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -37,7 +37,6 @@ * Author(s): Tony DiCola, Grzegorz Nowicki """ -from micropython import const import adafruit_thermal_printer.thermal_printer as thermal_printer @@ -59,6 +58,7 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE93 = 72 CODE128 = 73 + # pylint: disable=too-many-arguments def __init__( self, uart, @@ -67,6 +67,7 @@ def __init__( dot_print_s=0.03, auto_warm_up=True, ): + # pylint: enable=too-many-arguments """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer will output a 5V signal which can damage boards! If RX is unconnected @@ -85,6 +86,7 @@ def __init__( auto_warm_up=auto_warm_up, ) + def warm_up(self, heat_time=120): """Apparently there are no parameters for setting darkness in 2.168 (at least commands from 2.68 dont work), So it is little From 395ac041308880adab5acda5b755ccb1d59f9b3b Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 10:06:02 +0200 Subject: [PATCH 08/14] black again --- adafruit_thermal_printer/thermal_printer_2168.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index 9e536b5..e11b35d 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -67,7 +67,7 @@ def __init__( dot_print_s=0.03, auto_warm_up=True, ): - # pylint: enable=too-many-arguments + # pylint: enable=too-many-arguments """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer will output a 5V signal which can damage boards! If RX is unconnected @@ -86,7 +86,6 @@ def __init__( auto_warm_up=auto_warm_up, ) - def warm_up(self, heat_time=120): """Apparently there are no parameters for setting darkness in 2.168 (at least commands from 2.68 dont work), So it is little From 7a5c6a9b2acdf535bc1e2f81099f145cc9ed6a93 Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 4 Sep 2020 10:11:29 +0200 Subject: [PATCH 09/14] formating hell --- adafruit_thermal_printer/thermal_printer_2168.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index e11b35d..2535498 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -41,6 +41,7 @@ import adafruit_thermal_printer.thermal_printer as thermal_printer +# pylint: disable=too-many-arguments class ThermalPrinter(thermal_printer.ThermalPrinter): """Thermal printer for printers with firmware version from 2.168""" @@ -58,7 +59,6 @@ class ThermalPrinter(thermal_printer.ThermalPrinter): CODE93 = 72 CODE128 = 73 - # pylint: disable=too-many-arguments def __init__( self, uart, @@ -67,7 +67,6 @@ def __init__( dot_print_s=0.03, auto_warm_up=True, ): - # pylint: enable=too-many-arguments """Thermal printer class. Requires a serial UART connection with at least the TX pin connected. Take care connecting RX as the printer will output a 5V signal which can damage boards! If RX is unconnected From ad7d5ea76d9a72499053b8ee0e74fb9477f3ada7 Mon Sep 17 00:00:00 2001 From: greg-elmi <69034892+greg-elmi@users.noreply.github.com> Date: Fri, 11 Sep 2020 13:54:33 +0200 Subject: [PATCH 10/14] Update adafruit_thermal_printer/thermal_printer_264.py Co-authored-by: Scott Shawcroft --- adafruit_thermal_printer/thermal_printer_264.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_thermal_printer/thermal_printer_264.py b/adafruit_thermal_printer/thermal_printer_264.py index b1fc74e..7fe4859 100644 --- a/adafruit_thermal_printer/thermal_printer_264.py +++ b/adafruit_thermal_printer/thermal_printer_264.py @@ -28,7 +28,7 @@ versions and care must be taken to select the appropriate module inside this package for your firmware printer: -* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer_2168 = Printers with firmware version 2.168+. * thermal_printer = The latest printers with firmware version 2.68 up to 2.168 * thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. * thermal_printer_legacy = Printers with firmware version before 2.64. From 721999be8c9494875e201c7fb2a37b6eac6b448c Mon Sep 17 00:00:00 2001 From: greg-elmi <69034892+greg-elmi@users.noreply.github.com> Date: Fri, 11 Sep 2020 13:58:32 +0200 Subject: [PATCH 11/14] Update adafruit_thermal_printer/thermal_printer_legacy.py Co-authored-by: Scott Shawcroft --- adafruit_thermal_printer/thermal_printer_legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_thermal_printer/thermal_printer_legacy.py b/adafruit_thermal_printer/thermal_printer_legacy.py index b0d7db5..5f4b995 100644 --- a/adafruit_thermal_printer/thermal_printer_legacy.py +++ b/adafruit_thermal_printer/thermal_printer_legacy.py @@ -28,7 +28,7 @@ versions and care must be taken to select the appropriate module inside this package for your firmware printer: -* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer_2168 = Printers with firmware version 2.168+. * thermal_printer = The latest printers with firmware version 2.68 up to 2.168 * thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. * thermal_printer_legacy = Printers with firmware version before 2.64. From c0e84ca291d927f05677369b74263634e5975d5b Mon Sep 17 00:00:00 2001 From: greg-elmi <69034892+greg-elmi@users.noreply.github.com> Date: Fri, 11 Sep 2020 14:00:28 +0200 Subject: [PATCH 12/14] Update adafruit_thermal_printer/thermal_printer_2168.py Co-authored-by: Scott Shawcroft --- adafruit_thermal_printer/thermal_printer_2168.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_thermal_printer/thermal_printer_2168.py b/adafruit_thermal_printer/thermal_printer_2168.py index 2535498..0cf6aa6 100644 --- a/adafruit_thermal_printer/thermal_printer_2168.py +++ b/adafruit_thermal_printer/thermal_printer_2168.py @@ -29,7 +29,7 @@ versions and care must be taken to select the appropriate module inside this package for your firmware printer: -* thermal_printer_2164 = Printers with firmware version 2.168+. +* thermal_printer_2168 = Printers with firmware version 2.168+. * thermal_printer = The latest printers with firmware version 2.68 up to 2.168 * thermal_printer_264 = Printers with firmware version 2.64 up to 2.68. * thermal_printer_legacy = Printers with firmware version before 2.64. From 0c927c45a2333973e90e5135c0bcc7eb2aca15b4 Mon Sep 17 00:00:00 2001 From: greg-elmi <69034892+greg-elmi@users.noreply.github.com> Date: Fri, 11 Sep 2020 14:05:09 +0200 Subject: [PATCH 13/14] Update thermal_printer.py --- adafruit_thermal_printer/thermal_printer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index c8596ed..ee30bd3 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -387,8 +387,9 @@ def set_defaults(self): self.size = SIZE_SMALL self.underline = None self.inverse = False - self.upside_down = False # wg. dokumentacji powinno działać ale nie działa - self.up_down_mode = True # zamiast powyższego zaiplementowałem to << + self.upside_down = False # this should work in 2.68 according to user manual v 4.0 + # but it does't work with 2.168 hence i implemented the below + self.up_down_mode = True self.double_height = False self.double_width = False self.strike = False From e3db283f7c58f1e447d4a3a2e7dc3f987e63bbeb Mon Sep 17 00:00:00 2001 From: greg-elmi Date: Fri, 11 Sep 2020 14:15:03 +0200 Subject: [PATCH 14/14] black formating --- adafruit_thermal_printer/thermal_printer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adafruit_thermal_printer/thermal_printer.py b/adafruit_thermal_printer/thermal_printer.py index ee30bd3..0c85ca4 100644 --- a/adafruit_thermal_printer/thermal_printer.py +++ b/adafruit_thermal_printer/thermal_printer.py @@ -387,9 +387,10 @@ def set_defaults(self): self.size = SIZE_SMALL self.underline = None self.inverse = False - self.upside_down = False # this should work in 2.68 according to user manual v 4.0 - # but it does't work with 2.168 hence i implemented the below - self.up_down_mode = True + self.upside_down = False + # this should work in 2.68 according to user manual v 4.0 + # but it does't work with 2.168 hence i implemented the below + self.up_down_mode = True self.double_height = False self.double_width = False self.strike = False