-
Notifications
You must be signed in to change notification settings - Fork 0
/
xyzsensor.go
69 lines (57 loc) · 1.57 KB
/
xyzsensor.go
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
package phyphox
// Represents a sensor with three variables:
// X, Y, and Z
type XYZSensor struct {
prefix string
phyphox *Phyphox
}
// Returns the value of the sensor from phyphox SensorsData
func (s *XYZSensor) Get(axis string) (float64, bool) {
value, ok := s.phyphox.SensorsData[s.prefix+axis]
if !ok {
return 0, false
}
return value, true
}
// Returns the X value of the sensor from phyphox SensorsData
func (s *XYZSensor) X() (float64, bool) {
return s.Get("X")
}
// Returns the Y value of the sensor from phyphox SensorsData
func (s *XYZSensor) Y() (float64, bool) {
return s.Get("Y")
}
// Returns the Z value of the sensor from phyphox SensorsData
func (s *XYZSensor) Z() (float64, bool) {
return s.Get("Z")
}
// Returns the Time value of the sensor from phyphox SensorsData
func (s *XYZSensor) Time() (float64, bool) {
return s.Get("_time")
}
// Next Update() calls will fetch
// the X value form the sensor
func (s *XYZSensor) IncludeX() {
s.phyphox.query += s.prefix + "X&"
}
// Next Update() calls will fetch
// the Y value form the sensor
func (s *XYZSensor) IncludeY() {
s.phyphox.query += s.prefix + "Y&"
}
// Next Update() calls will fetch
// the Z value form the sensor
func (s *XYZSensor) IncludeZ() {
s.phyphox.query += s.prefix + "Z&"
}
// Next Update() calls will fetch all the data
// from the sensor, except for time
func (s *XYZSensor) IncludeAll() {
s.phyphox.query += s.prefix + "X&" +
s.prefix + "Y&" +
s.prefix + "Z&"
}
// Next Update() calls will fetch the sensor time
func (s *XYZSensor) IncludeTime() {
s.phyphox.query += s.prefix + "_time&"
}