-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.py
executable file
·86 lines (79 loc) · 2.27 KB
/
display.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*
import serial
'''客显'''
class Display():
def __init__(self):
self.ser=serial.Serial()
self.ser.baudrate =2400
self.ser.port = 'COM2' # '/dev/tty.Bluetooth-Incoming-Port'
#初始化
def init(self):
self.ser.open()
data = b'\x1B\40' # 初始化
n = self.ser.write(data)
self.ser.close()
return n
#清屏
def clear(self):
self.ser.open()
data = b'\x0C'#清屏
n = self.ser.write(data)
self.ser.close()
return n
# 全暗
def darkScreen(self):
self.ser.open()
data = b'\x1B\x73\x30'#全暗
n = self.ser.write(data)
self.ser.close()
return n
#单价
def unitPrice(self,price):
self.ser.open()
data =b'\x1B\x73\x31'#单价
num=b'\x1B\x51\x41' + (str(price)).encode('utf-8') + b'\x0D' # 发送数据
self.ser.write(data)
n=self.ser.write(num)
self.ser.close()
return n
# 应收
def ablePrice(self, price):
self.ser.open()
data = b'\x1B\x73\x32'#应收
num = b'\x1B\x51\x41' + (str(price)).encode('utf-8') + b'\x0D' # 发送数据
self.ser.write(data)
n = self.ser.write(num)
self.ser.close()
return n
# 实收
def receivedPrice(self, price):
self.ser.open()
data = b'\x1B\x73\x33'#实收
num = b'\x1B\x51\x41' + (str(price)).encode('utf-8') + b'\x0D' # 发送数据
self.ser.write(data)
n = self.ser.write(num)
self.ser.close()
return n
# 找回
def backPrice(self, price):
self.ser.open()
data = b'\x1B\x73\x34'#找回
num = b'\x1B\x51\x41' + (str(price)).encode('utf-8') + b'\x0D' # 发送数据
self.ser.write(data)
n = self.ser.write(num)
self.ser.close()
return n
#清除光标
def clearPointer(self):
self.ser.open()
data = b'\x24'#清除光标
n=self.ser.write(data)
self.ser.close()
return n
# 移动光标
def movePointer(self,num):
self.ser.open()
data = b'\x1B\x6C'+(str(num)).encode('utf-8')#移动光标
n = self.ser.write(data)
self.ser.close()
return n