-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.kv
294 lines (276 loc) · 8.81 KB
/
main.kv
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<MainGraph, VoltGraph>:
md_bg_color: [0,.18,.16,1]
tick_color: [.75,.75,.75,1]
radius: dp(10)
padding: dp(10)
xmin: 0
xmax: 15
x_ticks_major: 1
x_ticks_minor: 1
y_grid_label: True
x_grid_label: False
y_grid: True
<MainGraph>:
size_hint: 1, 2/3
ymin: 60
ymax: 120
y_ticks_major: 5
ylabel: 'Degrees'
<VoltGraph>:
size_hint: .5, 1/3
ylabel: 'Voltage'
ymin: 10.5
ymax: 13
y_ticks_major: .5
y_grid: True
<Toggle>:
line_width: '2dp'
<SprungSlider>:
orientation:'vertical'
size_hint: None, None
size: '80dp', '500dp'
range: -128, 127
value: 0
on_active: self.sliderReleased()
<StepButton@Toggle>:
md_bg_color: self.theme_cls.primary_color
background_normal: self.theme_cls.primary_color
background_down: self.theme_cls.primary_dark
text_color: 'black'
font_color_normal: 'black'
line_color: app.theme_cls.primary_color
group: 'step'
size_hint: .25, 1
rounded_button: True
text: ""
<NumSpinner>
name: ""
min: 0
size_hint: None, None
adaptive_width: True
pos_hint: {'right': 1}
orientation: 'horizontal'
padding: '5dp'
height: '100dp'
spacing: '5dp'
MDLabel:
size_hint: None, 1
valign: 'center'
halign: 'right'
font_size: '20dp'
text: self.parent.name + ": "
TextInput:
size_hint: None, None
halign: 'center'
pos_hint: {'center_y': .5}
padding: dp(5), dp(7)
height: self.line_height+dp(14)
font_size: 20
multiline: False
write_tab: False
input_filter: 'float'
text: "{0:.2f}".format(root.value)
on_text: root.textUpdated(self.text)
MDBoxLayout:
adaptive_width: True
orientation: 'vertical'
size_hint: None, 1
spacing: '3dp'
width: '80dp'
MDFloatingActionButton:
icon: 'chevron-up'
size_hint: 1, .5
on_press: root.value += root.step
MDFloatingActionButton:
icon: 'chevron-down'
size_hint: 1, .5
on_press: root.value -= root.step
<ControllerMain>
pObj: pObj
iObj: iObj
dObj: dObj
trimObj: trimObj
speedObj: speedObj
enableObj: enableObj
connectBtn: connectBtn
btStatus: btStatus
graphStack: graphStack
step: 1
pidLocked: True # PID input until current values recieved from bot
connectLockout: True # all bot controls locked when not connected
consoleText: '\n'*15
MDAnchorLayout: #PID/Trim controls
size: root.size
anchor_x: 'right'
anchor_y: 'bottom'
padding: '20dp'
disabled: root.connectLockout
MDBoxLayout:
orientation: 'vertical'
size_hint: .3 , 1
width: '350dp'
# adaptive_height: True
MDBoxLayout: # Step Size selection
orientation: 'horizontal'
size_hint: 1, None
height: '60dp'
padding: '5dp'
spacing: '8dp'
StepButton:
text: "5"
on_press: root.step = 5
StepButton:
text: "1"
state: "down"
on_press: root.step = 1
StepButton:
text: ".1"
on_press: root.step = .1
StepButton:
text: ".01"
on_press: root.step = 0.01
NumSpinner:
id: trimObj
name: "Trim"
value: root.trim
min: -90
padding: '7dp','15dp'
height: "115dp"
step: root.step
on_value: root.trim_changed(self)
# MDWidget:
# size_hint: 1, None
# height: dp(2)
# md_bg_color: 'white'
NumSpinner:
id: pObj
name: "kP"
value: root.kP
step: root.step
on_value: root.kP = self.value
disabled: root.pidLocked
NumSpinner:
id: iObj
name: 'kI'
value: root.kI
step: root.step
on_value: root.kI = self.value
disabled: root.pidLocked
NumSpinner:
id: dObj
name: 'kD'
value: root.kD
step: root.step
on_value: root.kD = self.value
disabled: root.pidLocked
MDBoxLayout:
size_hint: .5, None
adaptive_width: True
height: '80dp'
orientation: 'horizontal'
pos_hint: {'right': 1}
spacing: '7dp'
padding: '7dp'
disabled: root.pidLocked
MDRaisedButton:
size_hint: None, 1
text: 'SEND PID'
on_press: root.sendPID_pressed(False)
MDRaisedButton:
size_hint: None, 1
text: 'SAVE PID'
on_press: root.sendPID_pressed(True)
# disabled: root.pidLocked
AnchorLayout: #Top Right controls
size: root.size
anchor_x: 'right'
anchor_y: 'top'
MDBoxLayout:
padding: '25dp'
spacing: '10dp'
orientation: 'vertical'
adaptive_size: True
Toggle: # Enable button
id: enableObj
text: 'ENABLE' if self.state == 'normal' else 'DISABLE'
font_size: 70
disabled: root.connectLockout
on_press: root.enable_pressed(self.state)
MDBoxLayout:
orientation: 'horizontal'
adaptive_height: True
spacing: dp(15)
MDLabel: # Voltage readout
valign: 'center'
halign: 'right'
font_size: '20dp'
text: root.voltageText
Toggle: # Connect button
id: connectBtn
pos_hint: {'right':1}
text: 'CONNECT'
font_size: 30
line_width: '2dp'
on_press: root.connect_pressed(self.state)
MDBoxLayout: #Bluetooth status message
id: btStatus
adaptive_height: True
orientation: 'horizontal'
pos_hint: {'right':1}
spacing: '10dp'
text: 'Disconnected'
working: False
MDLabel:
size_hint: 1,None
adaptive_height: True
halign: 'right'
text: btStatus.text
font_size: 15
color: 'lightslategray'
MDSpinner:
active: btStatus.working
pos_hint: {'right': 1}
size_hint: None, None
size: dp(20), dp(20)
color: 'lightslategray'
AnchorLayout: #slider and graphs
size: root.size
anchor_x: 'left'
anchor_y: 'top'
MDBoxLayout:
orientation: 'horizontal'
size_hint: .7, 1
padding: dp(50), dp(10)
disabled: root.connectLockout
SprungSlider:
id: speedObj
adaptive_width: True
pos_hint: {'center_y': .4}
on_value: root.set_slider(self.value)
MDStackLayout: #Graphs are added by the root.initGraphs function
id: graphStack
orientation: 'lr-tb'
padding: dp(10), dp(20)
spacing: dp(10)
MDRelativeLayout: #Text console
size_hint: .5, 1/3
pos_hint: {'center_y': 0}
TextInput:
foreground_color: "black"
background_color: 'white'
halign: 'left'
padding: dp(10), dp(32), dp(10), dp(10)
multiline: True
readonly: True
scroll_from_swipe: True
font_size: 24
text: root.consoleText
# text: "Hello\nHello\n"
MDLabel: #header label for console
padding: dp(5), dp(5)
md_bg_color: 'grey'
size_hint: 1, None
adaptive_height: True
pos: 0, self.parent.height - self.height
text: "Console: "
color: "black"