-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
84 lines (60 loc) · 2.48 KB
/
main.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
import customtkinter
import mysql.connector as sql
import serial
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")
root=customtkinter.CTk()
root.geometry("500x350")
ser = serial.Serial('COM3', 9600)
def reset(counter):
return 300
def update(values,counter):
flag=True
if counter==0:
flag=False
values= values[0:len(values)-3]
print(values)
values=round((((9/5)*float(values))+36),1)
print(values)
cur.execute("SELECT Overall_Health FROM HealthCare WHERE Temp = %s AND BP=120 ;",(values,))
result=cur.fetchone()
label2.configure(text="{}".format(result[0]))
if(result==None):
label2.configure(text="{}".format("Take reading again"))
else:
label2.configure(text="{}".format(result[0]))
# on buzzer
ser.write(b'1')
# OFF BUZZER
ser.write(b'0')
button.configure(text="Start")
button['state']=customtkinter.NORMAL
if ser.in_waiting > 0:
values = ser.readline().decode('utf-8').rstrip()
label1.configure(text="{}".format(values))
if flag:
#renders customTk() window every 100ms
root.after(100,update,values,counter-1)
def fetch():
button["state"]=customtkinter.DISABLED
button.configure(text="Waiting")
values=0
counter=300
update(values,counter)
#main
conn = sql.connect(host="localhost", user="root", passwd="", database="health")
if conn.is_connected:
print("Database Connection is Successful")
cur=conn.cursor()
font=customtkinter.CTkFont(family='Roboto',size=24)
label=customtkinter.CTkLabel(master=root,text="Temperature Readings taken below".capitalize(),font=font)
label.pack(pady=12,padx=10)
label1=customtkinter.CTkLabel(master=root,text="0.00°C".capitalize(),font=font)
label1.pack(pady=12,padx=10)
label2=customtkinter.CTkLabel(master=root,text="FeedBack is displayed here",font=font)
label2.pack(pady=12,padx=10)
button=customtkinter.CTkButton(master=root,text="Start",command=fetch)
button.pack(pady=12,padx=10)
root.mainloop()
else:
print("Database not connected")