RotationVectorSensor.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef ANDROID_ROTATION_VECTOR_SENSOR_H
  17. #define ANDROID_ROTATION_VECTOR_SENSOR_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <gui/Sensor.h>
  21. #include "SensorDevice.h"
  22. #include "SensorInterface.h"
  23. #include "Fusion.h"
  24. #include "SensorFusion.h"
  25. // ---------------------------------------------------------------------------
  26. namespace android {
  27. // ---------------------------------------------------------------------------
  28. class RotationVectorSensor : public SensorInterface {
  29. SensorDevice& mSensorDevice;
  30. SensorFusion& mSensorFusion;
  31. public:
  32. RotationVectorSensor();
  33. virtual bool process(sensors_event_t* outEvent,
  34. const sensors_event_t& event);
  35. virtual status_t activate(void* ident, bool enabled);
  36. virtual status_t setDelay(void* ident, int handle, int64_t ns);
  37. virtual Sensor getSensor() const;
  38. virtual bool isVirtual() const { return true; }
  39. };
  40. class GyroDriftSensor : public SensorInterface {
  41. SensorDevice& mSensorDevice;
  42. SensorFusion& mSensorFusion;
  43. public:
  44. GyroDriftSensor();
  45. virtual bool process(sensors_event_t* outEvent,
  46. const sensors_event_t& event);
  47. virtual status_t activate(void* ident, bool enabled);
  48. virtual status_t setDelay(void* ident, int handle, int64_t ns);
  49. virtual Sensor getSensor() const;
  50. virtual bool isVirtual() const { return true; }
  51. };
  52. // ---------------------------------------------------------------------------
  53. }; // namespace android
  54. #endif // ANDROID_ROTATION_VECTOR_SENSOR_H