1 #ifndef DALI_SENSOR_UBUNTU_TILT_SENSOR_IMPL_UBUNTU_H
2 #define DALI_SENSOR_UBUNTU_TILT_SENSOR_IMPL_UBUNTU_H
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/object/base-object.h>
26 #include <dali/internal/sensor/common/tilt-sensor-impl.h>
27 #include <dali/devel-api/adaptor-framework/tilt-sensor.h>
28 #include <dali/public-api/adaptor-framework/timer.h>
40 * TiltSensor provides pitch & roll values when the device is tilted.
42 class TiltSensorUbuntu : public Dali::Internal::Adaptor::TiltSensor
46 typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
50 * @return New instance of TiltSensorUbuntu
52 static TiltSensorUbuntu* New();
55 * @copydoc Dali::TiltSensor::Start()
57 bool Start() override;
60 * @copydoc Dali::TiltSensor::Stop()
65 * @copydoc Dali::TiltSensor::IsStarted()
67 bool IsStarted() const override;
70 * @copydoc Dali::TiltSensor::GetRoll()
72 float GetRoll() const override;
75 * @copydoc Dali::TiltSensor::GetPitch()
77 float GetPitch() const override;
80 * @copydoc Dali::TiltSensor::GetRotation()
82 Quaternion GetRotation() const override;
85 * @copydoc Dali::TiltSensor::TiltedSignal()
87 TiltedSignalType& TiltedSignal() override;
90 * @copydoc Dali::TiltSensor::SetUpdateFrequency()
92 void SetUpdateFrequency( float frequencyHertz ) override;
95 * @copydoc Dali::TiltSensor::GetUpdateFrequency()
97 float GetUpdateFrequency() const override;
100 * @copydoc Dali::TiltSensor::SetRotationThreshold()
102 void SetRotationThreshold(Radian rotationThreshold) override;
105 * @copydoc Dali::TiltSensor::GetRotationThreshold()
107 Radian GetRotationThreshold() const override;
110 * Connects a callback function with the object's signals.
111 * @param[in] object The object providing the signal.
112 * @param[in] tracker Used to disconnect the signal.
113 * @param[in] signalName The signal to connect to.
114 * @param[in] functor A newly allocated FunctorDelegate.
115 * @return True if the signal was connected.
116 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
118 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
123 * Private constructor; see also TiltSensor::New()
130 virtual ~TiltSensorUbuntu() override;
133 * Timer callback to update the tilt values
138 TiltSensorUbuntu(const TiltSensorUbuntu&) = delete;
141 TiltSensorUbuntu& operator=(TiltSensorUbuntu&) = delete;
145 float mFrequencyHertz;
147 SlotDelegate< TiltSensorUbuntu > mTimerSlot;
149 int mSensorFrameworkHandle;
153 Quaternion mRotation;
155 Radian mRotationThreshold;
157 std::deque<float> mRollValues;
158 std::deque<float> mPitchValues;
160 TiltedSignalType mTiltedSignal;
163 } // namespace Adaptor
165 } // namespace Internal
169 #endif // DALI_SENSOR_UBUNTU_TILT_SENSOR_IMPL_UBUNTU_H