{
}
-bool TiltSensor::Enable()
+bool TiltSensor::Start()
{
- return GetImplementation(*this).Enable();
+ return GetImplementation(*this).Start();
}
-void TiltSensor::Disable()
+void TiltSensor::Stop()
{
- GetImplementation(*this).Disable();
+ GetImplementation(*this).Stop();
}
-bool TiltSensor::IsEnabled() const
+bool TiltSensor::IsStarted() const
{
- return GetImplementation(*this).IsEnabled();
+ return GetImplementation(*this).IsStarted();
}
float TiltSensor::GetRoll() const
* {
* TiltSensor sensor = TiltSensor::Get();
*
- * // Try to enable the sensor
- * if ( sensor.Enable() )
+ * // Try to start the tilt sensor
+ * if ( sensor.Start() )
* {
* // Query the current values
* std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
*
* // Get notifications when the device is tilted
- * sensor.SignalTilted().Connect( &OnTilted );
+ * sensor.TiltedSignal().Connect( &OnTilted );
* }
* }
*
- * void OnTilted()
+ * void OnTilted( const TiltSensor& sensor )
* {
* // Query the new values
* std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
*
* @endcode
*
- * While the tilt sensor is enabled, it will periodically poll for the latest pitch & roll values.
+ * While the tilt sensor is started, it will periodically poll for the latest pitch & roll values.
* For performance & power-saving, applications should disable this polling when no longer needed:
*
* @code
*
* void EndExample()
* {
- * // Disable the sensor when no longer needed
- * TiltSensor::Get().Disable();
+ * // Stop the sensor when no longer needed
+ * TiltSensor::Get().Stop();
* }
*
* @endcode
~TiltSensor();
/**
- * Attempt to enable the tilt-sensor. This will fail if the underlying sensor hardware is powered-down,
+ * Attempt to start the tilt-sensor. This will fail if the underlying sensor hardware is powered-down,
* typically this occurs when the device is set to "sleep" mode.
- * @return True if the tilt-sensor is enabled.
+ * @return True if the tilt-sensor is started.
*/
- bool Enable();
+ bool Start();
/**
- * Disable the tilt-sensor.
+ * Stop the tilt-sensor.
*/
- void Disable();
+ void Stop();
/**
- * Query whether the tilt-sensor is disabled.
+ * Query whether the tilt-sensor is started.
* The sensor may be disabled automatically; typically this occurs when the device is set to "sleep" mode.
- * @return True if the tilt-sensor is enabled.
+ * @return True if the tilt-sensor is started.
*/
- bool IsEnabled() const;
+ bool IsStarted() const;
/**
* Query the roll value. This is in the range -1 to 1.
* When the device is lying face-up on a flat surface, this method will return a value close to zero.
* A value close to 1 indicates that the right-side of the device is pointing upwards.
* A value close to -1 indicates that the right-side of the device is pointing downwards.
- * @pre The tilt-sensor is enabled.
+ * @pre The tilt-sensor is started.
* @return The roll value.
*/
float GetRoll() const;
* When the device is lying face-up on a flat surface, this method will return a value close to zero.
* A value close to 1 indicates that the top of the device is pointing upwards.
* A value close to -1 indicates that the top of the device is pointing downwards.
- * @pre The tilt-sensor is enabled.
+ * @pre The tilt-sensor is started.
* @return The pitch value.
*/
float GetPitch() const;
* Retrieve the rotation of the device.
* When the device is lying face-up on a flat surface, the rotation angle will be approximately zero.
* The roll & pitch of the device is considered to be a rotation around the Y and X axes respectively.
- * @pre The tilt-sensor is enabled.
+ * @pre The tilt-sensor is started.
* @return The rotation in quaternion format.
*/
Quaternion GetRotation() const;
/**
- * This signal will be emitted when the device is tilted, if the tilt-sensor is enabled.
+ * This signal will be emitted when the device is tilted, if the tilt-sensor is started.
* The frequency of the signals can be controlled using SetUpdateFrequency().
* @return The signal to connect to.
*
bool TiltSensor::Start()
{
- if(mSensorListener && mState == CONNECTED)
+ if( mSensorListener && ( mState == CONNECTED || mState == STOPPED ) )
{
#ifdef SENSOR_ENABLED
int ret = 0;
}
else
{
- if(mState != CONNECTED)
+ if( mState == STARTED )
{
- DALI_LOG_ERROR("Wrong state [%d]\n", mState);
+ DALI_LOG_ERROR("TiltSensor is already started. Current state [%d]\n", mState);
+ }
+ else
+ {
+ // mState is DISCONNECTED
+ DALI_LOG_ERROR("TiltSensor is disconnected. Current state [%d]\n", mState);
}
return false;
}
#endif
}
-bool TiltSensor::Enable()
-{
- // start sensor callback
- return Start();
-}
-
-void TiltSensor::Disable()
-{
- // stop sensor callback
- Stop();
-}
-
-bool TiltSensor::IsEnabled() const
+bool TiltSensor::IsStarted() const
{
return ( mSensorListener && mState == STARTED );
}
static Dali::TiltSensor Get();
/**
- * @copydoc Dali::TiltSensor::Enable()
+ * @copydoc Dali::TiltSensor::Start()
*/
- bool Enable();
+ bool Start();
/**
- * @copydoc Dali::TiltSensor::Disable()
+ * @copydoc Dali::TiltSensor::Stop()
*/
- void Disable();
+ void Stop();
/**
- * @copydoc Dali::TiltSensor::IsEnabled()
+ * @copydoc Dali::TiltSensor::IsStarted()
*/
- bool IsEnabled() const;
+ bool IsStarted() const;
/**
* @copydoc Dali::TiltSensor::GetRoll()
*/
void Disconnect();
- /**
- * Start sensor operation
- */
- bool Start();
- /**
- * Stop sensor operation
- */
- void Stop();
-
// Undefined
TiltSensor(const TiltSensor&);
TiltSensor::~TiltSensor()
{
- Disable();
+ Stop();
}
-bool TiltSensor::Enable()
+bool TiltSensor::Start()
{
// Make sure sensor API is responding
bool success = Update();
return success;
}
-void TiltSensor::Disable()
+void TiltSensor::Stop()
{
if ( mTimer )
{
}
}
-bool TiltSensor::IsEnabled() const
+bool TiltSensor::IsStarted() const
{
return ( mTimer && mTimer.IsRunning() );
}
static Dali::TiltSensor Get();
/**
- * @copydoc Dali::TiltSensor::Enable()
+ * @copydoc Dali::TiltSensor::Start()
*/
- bool Enable();
+ bool Start();
/**
- * @copydoc Dali::TiltSensor::Disable()
+ * @copydoc Dali::TiltSensor::Stop()
*/
- void Disable();
+ void Stop();
/**
- * @copydoc Dali::TiltSensor::IsEnabled()
+ * @copydoc Dali::TiltSensor::IsStarted()
*/
- bool IsEnabled() const;
+ bool IsStarted() const;
/**
* @copydoc Dali::TiltSensor::GetRoll()
}
-int UtcDaliTiltSensorEnable(void)
+int UtcDaliTiltSensorStart(void)
{
TestApplication application;
- tet_infoline("UtcDaliTiltSensorEnable");
+ tet_infoline("UtcDaliTiltSensorStart");
TiltSensor sensor = GetTiltSensor();
DALI_TEST_CHECK( sensor );
- sensor.Enable();
- DALI_TEST_CHECK( sensor.IsEnabled() );
+ sensor.Start();
+ DALI_TEST_CHECK( sensor.IsStarted() );
END_TEST;
}
-int UtcDaliTiltSensorDisable(void)
+int UtcDaliTiltSensorStop(void)
{
TestApplication application;
- tet_infoline("UtcDaliTiltSensorDisable");
+ tet_infoline("UtcDaliTiltSensorStop");
TiltSensor sensor = GetTiltSensor();
DALI_TEST_CHECK( sensor );
- sensor.Enable();
- DALI_TEST_CHECK( sensor.IsEnabled() );
+ sensor.Start();
+ DALI_TEST_CHECK( sensor.IsStarted() );
- sensor.Disable();
- DALI_TEST_CHECK( !sensor.IsEnabled() );
+ sensor.Stop();
+ DALI_TEST_CHECK( !sensor.IsStarted() );
END_TEST;
}
-int UtcDaliTiltSensorIsEnabled(void)
+int UtcDaliTiltSensorIsStarted(void)
{
TestApplication application;
- tet_infoline("UtcDaliTiltSensorIsEnabled");
+ tet_infoline("UtcDaliTiltSensorIsStarted");
TiltSensor sensor = GetTiltSensor();
DALI_TEST_CHECK( sensor );
// Should be disabled by default
- DALI_TEST_CHECK( !sensor.IsEnabled() );
+ DALI_TEST_CHECK( !sensor.IsStarted() );
END_TEST;
}
TiltSensor sensor = GetTiltSensor();
DALI_TEST_CHECK( sensor );
- sensor.Enable();
+ sensor.Start();
Radian angle(Degree(-45));
//Setting a negative threshold for testing purpose
TiltSensor sensor = GetTiltSensor();
DALI_TEST_CHECK( sensor );
- sensor.Enable();
+ sensor.Start();
Radian angle(Degree(-45));
sensor.SetRotationThreshold( angle );