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.
22 #ifdef CAPI_SYSTEM_SENSOR_SUPPORT
23 #include <sensor/sensor.h>
25 #define SENSOR_ENABLED
29 #include <dali/public-api/object/base-object.h>
32 #include <public-api/adaptor-framework/timer.h>
33 #include <devel-api/adaptor-framework/tilt-sensor.h>
45 * TiltSensor provides pitch & roll values when the device is tilted.
47 class TiltSensor : public Dali::BaseObject
51 typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
54 * Create a TiltSensor.
55 * This should only be called once by the Adaptor class.
56 * @return A newly allocated tilt-sensor.
58 static Dali::TiltSensor New();
61 * @copydoc Dali::TiltSensor::Get()
63 static Dali::TiltSensor Get();
66 * @copydoc Dali::TiltSensor::Enable()
71 * @copydoc Dali::TiltSensor::Disable()
76 * @copydoc Dali::TiltSensor::IsEnabled()
78 bool IsEnabled() const;
81 * @copydoc Dali::TiltSensor::GetRoll()
83 float GetRoll() const;
86 * @copydoc Dali::TiltSensor::GetPitch()
88 float GetPitch() const;
91 * @copydoc Dali::TiltSensor::GetRotation()
93 Quaternion GetRotation() const;
96 * @copydoc Dali::TiltSensor::TiltedSignal()
98 TiltedSignalType& TiltedSignal();
101 * @copydoc Dali::TiltSensor::SetUpdateFrequency()
103 void SetUpdateFrequency( float frequencyHertz );
106 * @copydoc Dali::TiltSensor::GetUpdateFrequency()
108 float GetUpdateFrequency() const;
111 * @copydoc Dali::TiltSensor::SetRotationThreshold()
113 void SetRotationThreshold(Radian rotationThreshold);
116 * @copydoc Dali::TiltSensor::GetRotationThreshold()
118 Radian GetRotationThreshold() const;
121 * Connects a callback function with the object's signals.
122 * @param[in] object The object providing the signal.
123 * @param[in] tracker Used to disconnect the signal.
124 * @param[in] signalName The signal to connect to.
125 * @param[in] functor A newly allocated FunctorDelegate.
126 * @return True if the signal was connected.
127 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
129 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
133 * @note This is called by static sensor callback function
134 * @param[in] event sensor event data
136 #ifdef SENSOR_ENABLED
137 void Update(sensor_event_s *event);
151 * Private constructor; see also TiltSensor::New()
158 virtual ~TiltSensor();
161 * Connect sensor device
165 * Disconnect sensor device
170 * Start sensor operation
174 * Stop sensor operation
179 TiltSensor(const TiltSensor&);
182 TiltSensor& operator=(TiltSensor&);
186 float mFrequencyHertz;
188 #ifdef SENSOR_ENABLED
189 sensor_type_e mSensorType;
191 sensor_listener_h mSensorListener;
195 int* mSensorListener;
200 Quaternion mRotation;
202 Radian mRotationThreshold;
204 TiltedSignalType mTiltedSignal;
207 } // namespace Adaptor
209 } // namespace Internal
211 // Helpers for public-api forwarding methods
213 inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
215 DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
217 BaseObject& handle = sensor.GetBaseObject();
219 return static_cast<Internal::Adaptor::TiltSensor&>(handle);
222 inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
224 DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
226 const BaseObject& handle = sensor.GetBaseObject();
228 return static_cast<const Internal::Adaptor::TiltSensor&>(handle);
233 #endif // __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__