-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 830 Bytes
/
main.py
File metadata and controls
31 lines (23 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
from render import render
from printer import BluetoothDevice, LuckPrinter
async def main():
with open("receipt.xml", "r", encoding="utf-8") as f:
layout_xml = f.read()
# BLE示例 // run scan.py to get address
# device = BluetoothDevice("028EBD80-9CCC-AD10-E727-8715AF47A664")
device = BluetoothDevice("D3808B0D-2DDF-2E33-B434-8FC9576A2BBE")
# device = BluetoothDevice("60:6E:41:62:DC:F4")
# 串口示例
# from printer import SerialPortDevice
# device = SerialPortDevice("/dev/rfcomm1")
printer = LuckPrinter(device)
try:
await printer.initialize()
img = render(layout_xml)
await printer.print_image(img)
await printer.print_end()
finally:
await printer.close()
if __name__ == "__main__":
asyncio.run(main())