-
Notifications
You must be signed in to change notification settings - Fork 9
/
SensorsStatus.qml
312 lines (272 loc) · 11.1 KB
/
SensorsStatus.qml
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
import QtQuick 2.2
import Ubuntu.Components 1.1
import QtPositioning 5.2
import QtSensors 5.2
/*!
\brief MainView with a Label and Button elements.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "me.yohanboniface.sensorsstatus"
automaticOrientation: true
useDeprecatedToolbar: false
width: units.gu(100)
height: units.gu(75)
function printablePositionMethod(method) {
var out = "Unknown position method";
if (method === PositionSource.SatellitePositioningMethod) out = "Satellite";
else if (method === PositionSource.NoPositioningMethod) out = "Not available";
else if (method === PositionSource.NonSatellitePositioningMethod) out = "Non-satellite";
else if (method === PositionSource.AllPositioningMethods) out = "All/multiple";
return out;
}
function printableSourceError(method) {
var out = "Unknown source error";
if (method === PositionSource.AccessError) out = "Access error";
else if (method === PositionSource.ClosedError) out = "Closed error";
else if (method === PositionSource.NoError) out = "No error";
else if (method === PositionSource.UnknownSourceError) out = "Unidentified source error";
else if (method === PositionSource.SocketError) out = "Socket error";
return out;
}
PageStack {
id: pageStack
Component.onCompleted: push(tabs)
Tabs {
id: tabs
Tab {
title: i18n.tr('Accelerometer')
page: Page {
id: accelerometerPage
NoData {
visible: !accelerometer.connectedToBackend
}
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
visible: !!accelerometer.connectedToBackend
Accelerometer {
id: accelerometer
active: true
}
RowField {
title: i18n.tr('x (m/s/s)')
text: accelerometer.reading != null ? accelerometer.reading.x : '-'
}
RowField {
title: i18n.tr('y (m/s/s)')
text: accelerometer.reading != null ? accelerometer.reading.y : '-'
}
RowField {
title: i18n.tr('z (m/s/s)')
text: accelerometer.reading != null ? accelerometer.reading.z : '-'
}
}
}
}
Tab {
title: i18n.tr('Altimeter')
page: Page {
id: altimeterPage
NoData {
visible: !altimeter.connectedToBackend
}
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
visible: !!altimeter.connectedToBackend
Altimeter {
id: altimeter
active: true
}
RowField {
title: i18n.tr('altitude (m)')
text: altimeter.reading != null ? altimeter.reading.altitude : '—'
}
}
}
}
Tab {
title: i18n.tr('Compass')
page: Page {
id: compassPage
NoData {
visible: !compass.connectedToBackend
}
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
visible: !!compass.connectedToBackend
Compass {
id: compass
active: true
}
RowField {
title: i18n.tr('azimuth (º)')
text: compass.reading != null ? compass.reading.azimuth : '—'
}
RowField {
title: i18n.tr('calibration level')
text: compass.reading != null ? compass.reading.calibrationLevel : '—'
}
}
}
}
Tab {
title: i18n.tr("GPS")
page: Page {
id: gpsPage
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
Row {
width: parent.width
spacing: units.gu(1)
anchors.margins: units.gu(0.5)
Label {
text: i18n.tr('Found supported backend')
anchors.verticalCenter: backendFound.verticalCenter
}
CheckBox {
id: backendFound
checked: geoposition.valid
enabled: false
}
}
Row {
width: parent.width
spacing: units.gu(1)
anchors.margins: units.gu(0.5)
Label {
text: i18n.tr('Active')
anchors.verticalCenter: backendActive.verticalCenter
}
CheckBox {
id: backendActive
checked: geoposition.active
enabled: false
}
}
RowField {
title: i18n.tr('Source status')
text: printableSourceError(geoposition.sourceError)
}
RowField {
title: i18n.tr('Name')
text: geoposition.name
}
RowField {
title: i18n.tr('Method')
text: printablePositionMethod(geoposition.positioningMethod)
}
RowField {
title: i18n.tr('Latitude (º)')
text: geoposition.position.coordinate.latitude || '—'
}
RowField {
title: i18n.tr('Longitude (º)')
text: geoposition.position.coordinate.longitude || '—'
}
RowField {
title: i18n.tr('Horizontal accuracy (m)')
text: geoposition.position.horizontalAccuracy || '—'
}
RowField {
title: i18n.tr('Altitude (m)')
text: geoposition.position.coordinate.altitude || '—'
}
RowField {
title: i18n.tr('Vertical accuracy (m)')
text: geoposition.position.verticalAccuracy || '—'
}
RowField {
title: i18n.tr('Speed (m/s)')
text: geoposition.position.speed === -1 ? '—' : geoposition.position.speed
}
RowField {
title: i18n.tr('Last updated')
text: geoposition.position.timestamp ? geoposition.position.timestamp : '—'
}
PositionSource {
id: geoposition
active: true
updateInterval: 1000
}
}
}
}
Tab {
title: i18n.tr('Gyroscope')
page: Page {
id: gyroscopePage
NoData {
visible: !gyroscope.connectedToBackend
}
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
visible: !!gyroscope.connectedToBackend
Gyroscope {
id: gyroscope
active: true
}
RowField {
title: i18n.tr('x (º/s)')
text: gyroscope.reading != null ? gyroscope.reading.x : '-'
}
RowField {
title: i18n.tr('y (º/s)')
text: gyroscope.reading != null ? gyroscope.reading.y : '-'
}
RowField {
title: i18n.tr('z (º/s)')
text: gyroscope.reading != null ? gyroscope.reading.z : '-'
}
}
}
}
Tab {
title: i18n.tr('Pressure')
page: Page {
id: pressurePage
NoData {
visible: !pressure.connectedToBackend
}
Column {
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
visible: !!pressure.connectedToBackend
PressureSensor {
id: pressure
active: true
}
RowField {
title: i18n.tr('pressure (Pa)')
text: pressure.reading != null ? pressure.reading.pressure : '-'
}
}
}
}
}
}
}