forked from STREIN-11/Intel_Unnati
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thread.py
74 lines (36 loc) · 1.1 KB
/
thread.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
import tkinter as tk
import time
import serial
import threading
import continuous_threading
ser = serial.Serial("COM7",9600)
val = 0
index=[]
def readSerial():
data = ser.readline()
Data = str(data)
Data = Data.replace("b'","")
Data = Data.replace("\\n","")
Data = Data.replace("\'","")
print(Data)
l = Data.split(",")
# print([float(x) for x in l])
A = [float(x) for x in l]
# global val
# ser_bytes = ser.readline()
# ser_bytes = ser_bytes.decode("utf-8")
# val = ser_bytes
# index.append(val)
# if len(index) == 1:
display1 = tk.Label(root,text=A[1]).place(x=50,y=10)
# elif len(index) == 2:
display2 = tk.Label(root,text=A[0]).place(x=50,y=40)
# if len(index) == 2:
# index.clear()
t1 = continuous_threading.PeriodicThread(0.5,readSerial)
root = tk.Tk()
root.geometry("300x250")
temp = tk.Label(root,text="Temp.").place(x=10,y=10)
hum = tk.Label(root,text="Hum.").place(x=10,y=40)
t1.start()
root.mainloop()