From: TaeminYeom Date: Mon, 11 Jul 2022 06:40:20 +0000 (+0900) Subject: Fix sensor_util_get_orientation X-Git-Tag: accepted/tizen/unified/20220713.144410~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2f95bae7f63981b329537520c8bdbf10c0458de;p=platform%2Fcore%2Fapi%2Fsensor.git Fix sensor_util_get_orientation Unify it with sensord algorithm Change-Id: I90b60796592aeef012d13a3385417664e3fdf646 Signed-off-by: TaeminYeom --- diff --git a/src/api/sensor.cpp b/src/api/sensor.cpp index 6c3dd58..e5e6a32 100644 --- a/src/api/sensor.cpp +++ b/src/api/sensor.cpp @@ -27,13 +27,12 @@ #include #include -#define SENSOR_SHIFT_TYPE 16 -#define SENSOR_UNDEFINED_ID -1 - -#define SENSOR_LISTENER_MAGIC 0xCAFECAFE - -#define CONVERT_AXIS_ENUM(X) ((X) < 3 ? (X) + 0x81 : (X) - 2) +#define SENSOR_SHIFT_TYPE 16 +#define SENSOR_UNDEFINED_ID -1 +#define SENSOR_LISTENER_MAGIC 0xCAFECAFE +#define RAD2DEGREE (180/M_PI) +#define CONVERT_AXIS_ENUM(X) ((X) < 3 ? (X) + 0x81 : (X) - 2) #define CONVERT_OPTION_PAUSE_POLICY(option) ((option) ^ 0b11) #define WARN_DEPRECATED_SENSOR(X) \ @@ -1032,9 +1031,11 @@ int sensor_util_get_orientation(float R[], float values[]) if (!R || !values) return SENSOR_ERROR_INVALID_PARAMETER; - values[0] = (float) atan2(R[1], R[4]); - values[1] = (float) asin(-R[7]); - values[2] = (float) atan2(-R[6], R[8]); + values[0] = atan2f(-R[3], R[0]) * RAD2DEGREE; + values[1] = atan2f(-R[7], R[8]) * RAD2DEGREE; + values[2] = asinf (R[6]) * RAD2DEGREE; + if (values[0] < 0) + values[0] += 360; return SENSOR_ERROR_NONE; }