1 #ifndef __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
2 #define __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_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>
27 #include <tilt-sensor.h>
39 * TiltSensor provides pitch & roll values when the device is tilted.
41 class TiltSensor : public Dali::BaseObject
45 typedef Dali::TiltSensor::TiltedSignalV2 TiltedSignalV2;
48 * Create a TiltSensor.
49 * This should only be called once by the Adaptor class.
50 * @return A newly allocated tilt-sensor.
52 static Dali::TiltSensor New();
55 * @copydoc Dali::TiltSensor::Get()
57 static Dali::TiltSensor Get();
60 * @copydoc Dali::TiltSensor::Enable()
65 * @copydoc Dali::TiltSensor::Disable()
70 * @copydoc Dali::TiltSensor::IsEnabled()
72 bool IsEnabled() const;
75 * @copydoc Dali::TiltSensor::GetRoll()
77 float GetRoll() const;
80 * @copydoc Dali::TiltSensor::GetPitch()
82 float GetPitch() const;
85 * @copydoc Dali::TiltSensor::GetRotation()
87 Quaternion GetRotation() const;
90 * @copydoc Dali::TiltSensor::TiltedSignal()
92 TiltedSignalV2& TiltedSignal();
95 * @copydoc Dali::TiltSensor::SetUpdateFrequency()
97 void SetUpdateFrequency( float frequencyHertz );
100 * @copydoc Dali::TiltSensor::GetUpdateFrequency()
102 float GetUpdateFrequency() const;
105 * @copydoc Dali::TiltSensor::SetRotationThreshold()
107 void SetRotationThreshold(Radian rotationThreshold);
110 * @copydoc Dali::TiltSensor::GetRotationThreshold()
112 Radian GetRotationThreshold() const;
115 * Connects a callback function with the object's signals.
116 * @param[in] object The object providing the signal.
117 * @param[in] tracker Used to disconnect the signal.
118 * @param[in] signalName The signal to connect to.
119 * @param[in] functor A newly allocated FunctorDelegate.
120 * @return True if the signal was connected.
121 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
123 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
128 * Private constructor; see also TiltSensor::New()
135 virtual ~TiltSensor();
138 * Timer callback to update the tilt values
143 TiltSensor(const TiltSensor&);
146 TiltSensor& operator=(TiltSensor&);
150 float mFrequencyHertz;
152 SlotDelegate< TiltSensor > mTimerSlot;
154 int mSensorFrameworkHandle;
158 Quaternion mRotation;
160 Radian mRotationThreshold;
162 std::deque<float> mRollValues;
163 std::deque<float> mPitchValues;
165 TiltedSignalV2 mTiltedSignalV2;
168 } // namespace Adaptor
170 } // namespace Internal
172 // Helpers for public-api forwarding methods
174 inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
176 DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
178 BaseObject& handle = sensor.GetBaseObject();
180 return static_cast<Internal::Adaptor::TiltSensor&>(handle);
183 inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
185 DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
187 const BaseObject& handle = sensor.GetBaseObject();
189 return static_cast<const Internal::Adaptor::TiltSensor&>(handle);
194 #endif // __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__