This commit is contained in:
9
main.py
9
main.py
@@ -141,7 +141,11 @@ def process_message(msg, display, image_state, image_data_list, printer_uart=Non
|
||||
|
||||
elif image_state == PRINTER_STATE_RECEIVING:
|
||||
if printer_uart:
|
||||
printer_uart.write(msg)
|
||||
chunk_size = 128
|
||||
for i in range(0, len(msg), chunk_size):
|
||||
chunk = msg[i:i+chunk_size]
|
||||
printer_uart.write(chunk)
|
||||
time.sleep_ms(5)
|
||||
return image_state, None
|
||||
|
||||
return image_state, None
|
||||
@@ -165,6 +169,9 @@ def process_message(msg, display, image_state, image_data_list, printer_uart=Non
|
||||
|
||||
elif msg == "PRINTER_DATA_END":
|
||||
print("Printer data received completely")
|
||||
# 发送打印完成的回车
|
||||
if printer_uart:
|
||||
printer_uart.write(b'\r\n')
|
||||
return IMAGE_STATE_IDLE, ("printer_done",)
|
||||
|
||||
elif msg.startswith("STATUS:"):
|
||||
|
||||
@@ -77,12 +77,14 @@ def image_to_tspl_commands(image_path):
|
||||
cmds = bytearray()
|
||||
|
||||
# 1. 初始化
|
||||
# CLS
|
||||
cmds.extend(b"CLS\r\n")
|
||||
# SIZE 48 mm, 30 mm
|
||||
cmds.extend(b"SIZE 48 mm, 30 mm\r\n")
|
||||
# GAP 2 mm, 0 mm
|
||||
cmds.extend(b"GAP 2 mm, 0 mm\r\n")
|
||||
# CLS
|
||||
cmds.extend(b"CLS\r\n")
|
||||
# HOME
|
||||
cmds.extend(b"HOME\r\n")
|
||||
|
||||
# 2. BITMAP
|
||||
# BITMAP x, y, width_bytes, height, mode, data
|
||||
@@ -15,7 +15,8 @@ from dashscope import ImageSynthesis
|
||||
from dashscope import Generation
|
||||
|
||||
import sys
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
# import os
|
||||
# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import convert_img
|
||||
|
||||
# 加载环境变量
|
||||
|
||||
Reference in New Issue
Block a user