-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbpid.py
196 lines (164 loc) · 6.08 KB
/
bpid.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/python3
# Import 3rd party libraries ----------------------------------------
import tkinter as tk
import tkinter.font as font
# Import standard libraries -----------------------------------------
# Import application libraries --------------------------------------
import colors
import paths
from xchg import XchgData
# -------------------------------------------------------------------
# Associate attached sensors to beer, chamber, or ambient temps
# -------------------------------------------------------------------
class gBPID(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.create_widgets()
self.xd = XchgData() # read only for now
self.visible = False
self.populate_widgets()
def populate_widgets(self):
self.beer_P['text'] = 'P ' + str(round(self.master.beer_kp, 1))
self.beer_I['text'] = 'I ' + str(round(self.master.beer_ki, 4))
def create_widgets(self):
font1 = font.Font(family='TkTextFont', size=-60, weight='bold')
font2 = font.Font(family='TkTextFont', size=-40, weight='bold')
self.plus_P = tk.Button(
self.master.values_box,
text="+",
command=self.increase_P,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font1,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.minus_P = tk.Button(
self.master.values_box,
text="-",
command=self.decrease_P,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font1,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.default_P = tk.Button(
self.master.values_box,
text="@",
command=self.default_P,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font2,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.beer_P = tk.Label(
self.master.values_box,
text="P ?.?",
background=colors.background,
fg=colors.normal50,
font=font2
)
# Integrator Values
self.plus_I = tk.Button(
self.master.values_box,
text="+",
command=self.increase_I,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font1,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.minus_I = tk.Button(
self.master.values_box,
text="-",
command=self.decrease_I,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font1,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.default_I = tk.Button(
self.master.values_box,
text="@",
command=self.default_I,
foreground=colors.background,
background=colors.normal50,
borderwidth=0,
highlightthickness=0,
font=font2,
activebackground=colors.normal_button,
highlightbackground=colors.normal_button,
highlightcolor=colors.normal_button,
relief=tk.FLAT
)
self.beer_I = tk.Label(
self.master.values_box,
text="I ?.?",
background=colors.background,
fg=colors.normal50,
font=font2
)
def increase_P(self):
self.master.beer_kp += 0.1
self.populate_widgets()
def decrease_P(self):
self.master.beer_kp -= 0.1
self.populate_widgets()
def default_P(self):
self.master.beer_kp = paths.default_beerP
self.populate_widgets()
def increase_I(self):
self.master.beer_ki += 0.0005
self.populate_widgets()
def decrease_I(self):
self.master.beer_ki -= 0.0005
self.populate_widgets()
def default_I(self):
self.master.beer_ki = paths.default_beerI
self.populate_widgets()
def hide(self):
self.visible = False
self.plus_P.place(x=0, y=0, height=0, width=0)
self.minus_P.place(x=0, y=0, height=0, width=0)
self.beer_P.place(x=0, y=0, height=0, width=0)
self.default_P.place(x=0, y=0, height=0, width=0)
self.plus_I.place(x=0, y=0, height=0, width=0)
self.minus_I.place(x=0, y=0, height=0, width=0)
self.beer_I.place(x=0, y=0, height=0, width=0)
self.default_I.place(x=0, y=0, height=0, width=0)
def show(self):
self.visible = True
self.populate_widgets()
self.plus_P.place(x=160, y=60, height=60, width=60)
self.minus_P.place(x=260, y=60, height=60, width=60)
self.beer_P.place(x=360, y=60, height=60, width=240)
self.default_P.place(x=720, y=60, height=60, width=80)
self.plus_I.place(x=160, y=140, height=60, width=60)
self.minus_I.place(x=260, y=140, height=60, width=60)
self.beer_I.place(x=360, y=140, height=60, width=240)
self.default_I.place(x=720, y=140, height=60, width=80)