This commit is contained in:
@@ -3,7 +3,7 @@ from machine import UART
|
||||
from config import ttl_tx, ttl_rx
|
||||
from printer_driver import TsplPrinter
|
||||
|
||||
def print_bitmap(printer, data, width, height, x_offset=0, y_offset=0):
|
||||
def print_bitmap(printer, data, width, height, x_offset=0, y_offset=0, invert=False):
|
||||
"""
|
||||
发送位图数据到打印机
|
||||
:param printer: TsplPrinter 对象
|
||||
@@ -12,7 +12,12 @@ def print_bitmap(printer, data, width, height, x_offset=0, y_offset=0):
|
||||
:param height: 图像高度 (dots)
|
||||
:param x_offset: X轴偏移
|
||||
:param y_offset: Y轴偏移
|
||||
:param invert: 是否反色打印 (默认False)
|
||||
"""
|
||||
if invert:
|
||||
# 反转每一个字节
|
||||
data = bytearray([~b & 0xFF for b in data])
|
||||
|
||||
width_bytes = (width + 7) // 8
|
||||
|
||||
# TSPL BITMAP 指令
|
||||
|
||||
Reference in New Issue
Block a user