Add get_pattern option to print_test_color_pattern

This commit is contained in:
Ircama
2025-07-22 08:34:06 +02:00
parent cfaeaf8b0a
commit a224d81780

View File

@@ -2541,13 +2541,22 @@ class EpsonPrinter:
lpr.disconnect() lpr.disconnect()
return status return status
def print_test_color_pattern(self): def print_test_color_pattern(
self,
get_pattern=False,
get_fullpattern=False
):
""" """
Print a one-page test color pattern with different qualities. Print a one-page color test pattern at various quality levels via LPR.
For XP-200, XP-205 Optimized for XP-200 and XP-205 models.
Returns True if the pattern was successfully printed (sending the
print-out to the host by creating a LPR job), False otherwise.
If get_pattern is True, returns the ESC/P2 command sequence for the
patterns as bytes.
If get_pattern is False and get_fullpattern is True, returns the
complete pattern as bytes (including ESC/P2 job headers and
footers).
""" """
if not self.hostname:
return None
status = True status = True
lpr = LprClient(self.hostname, port="LPR", label="Check nozzles") lpr = LprClient(self.hostname, port="LPR", label="Check nozzles")
@@ -2718,6 +2727,8 @@ class EpsonPrinter:
# Join all command parts into final hex string # Join all command parts into final hex string
return "".join(command_parts) return "".join(command_parts)
if get_pattern:
return bytes.fromhex(generate_patterns())
pattern = ( pattern = (
lpr.INITIALIZE_PRINTER lpr.INITIALIZE_PRINTER
+ lpr.REMOTE_MODE + lpr.REMOTE_MODE
@@ -2738,7 +2749,11 @@ class EpsonPrinter:
+ lpr.JOB_END + lpr.JOB_END
+ lpr.EXIT_REMOTE_MODE + lpr.EXIT_REMOTE_MODE
) )
if get_fullpattern:
return pattern
if not self.hostname:
return None
try: try:
lpr.connect() lpr.connect()
resp = lpr.send(pattern) resp = lpr.send(pattern)