Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_SensorImpl_Common.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_SensorImpl_Common.h
4 Content : Source common to SensorImpl and Sensor2Impl.
5 Created : January 21, 2014
6 Authors : Lee Cooper
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 *************************************************************************************/
26 
27 #ifndef OVR_SensorImpl_Common_h
28 #define OVR_SensorImpl_Common_h
29 
30 #include "Kernel/OVR_System.h"
31 #include "OVR_Device.h"
32 
33 namespace OVR
34 {
35 
36 void UnpackSensor(const UByte* buffer, SInt32* x, SInt32* y, SInt32* z);
37 void PackSensor(UByte* buffer, SInt32 x, SInt32 y, SInt32 z);
38 
39 // Sensor HW only accepts specific maximum range values, used to maximize
40 // the 16-bit sensor outputs. Use these ramps to specify and report appropriate values.
41 const UInt16 AccelRangeRamp[] = { 2, 4, 8, 16 };
42 const UInt16 GyroRangeRamp[] = { 250, 500, 1000, 2000 };
43 const UInt16 MagRangeRamp[] = { 880, 1300, 1900, 2500 };
44 
45 UInt16 SelectSensorRampValue(const UInt16* ramp, unsigned count,
46  float val, float factor, const char* label);
47 
48 // SensorScaleImpl provides buffer packing logic for the Sensor Range
49 // record that can be applied to DK1 sensor through Get/SetFeature. We expose this
50 // through SensorRange class, which has different units.
52 {
53  enum { PacketSize = 8 };
55 
60 
61  SensorRangeImpl(const SensorRange& r, UInt16 commandId = 0);
62 
63  void SetSensorRange(const SensorRange& r, UInt16 commandId = 0);
65 
67 
68  void Pack();
69  void Unpack();
70 };
71 
73 {
74  enum { PacketSize = 7 };
76 
77  // Flag values for Flags.
78  enum {
79  Flag_RawMode = 0x01,
80  Flag_CalibrationTest = 0x02, // Internal test mode
86  };
87 
90  UInt16 PacketInterval; // LDC - This should be a UByte. Fix when you have time to test it.
92 
94 
95  void SetSensorCoordinates(bool sensorCoordinates);
96  bool IsUsingSensorCoordinates() const;
97 
98  void Pack();
99  void Unpack();
100 };
101 
103 {
104  enum { PacketSize = 69 };
106 
111  float Temperature;
112 
114 
115  void Pack(); // Not yet implemented.
116  void Unpack();
117 };
118 
119 
120 // SensorKeepAlive - feature report that needs to be sent at regular intervals for sensor
121 // to receive commands.
123 {
124  enum { PacketSize = 5 };
126 
129 
130  SensorKeepAliveImpl(UInt16 interval = 0, UInt16 commandId = 0);
131 
132  void Pack();
133  void Unpack();
134 };
135 
137 {
140 };
141 
143 {
146 };
147 
148 } // namespace OVR
149 
150 #endif // OVR_SensorImpl_Common_h
void SetSensorRange(const SensorRange &r, UInt16 commandId=0)
uint16_t UInt16
Definition: OVR_Types.h:251
const UInt16 GyroRangeRamp[]
SensorRangeImpl(const SensorRange &r, UInt16 commandId=0)
uint8_t UByte
Definition: OVR_Types.h:249
void GetSensorRange(SensorRange *r)
static SensorRange GetMaxSensorRange()
void PackSensor(UByte *buffer, SInt32 x, SInt32 y, SInt32 z)
UByte Buffer[PacketSize]
const UInt16 AccelRangeRamp[]
void SetSensorCoordinates(bool sensorCoordinates)
int32_t SInt32
Definition: OVR_Types.h:252
void UnpackSensor(const UByte *buffer, SInt32 *x, SInt32 *y, SInt32 *z)
SensorKeepAliveImpl(UInt16 interval=0, UInt16 commandId=0)
UInt16 SelectSensorRampValue(const UInt16 *ramp, unsigned count, float val, float factor, const char *label)
const UInt16 MagRangeRamp[]