summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSooyoung Ha <yoosah.ha@samsung.com>2013-03-08 13:38:16 +0900
committerSooyoung Ha <yoosah.ha@samsung.com>2013-03-08 13:38:16 +0900
commitd3a4c16607f3fbd68987f2bb75e6e12e2fa7677f (patch)
tree2356c9837a2b86b3bdf74f197e549b1d614fb414
parentf991a8a2615a793c3c441816f0dc99aff6656f83 (diff)
downloademulator-plugin-accel-proc-d3a4c16607f3fbd68987f2bb75e6e12e2fa7677f.tar.gz
emulator-plugin-accel-proc-d3a4c16607f3fbd68987f2bb75e6e12e2fa7677f.tar.bz2
emulator-plugin-accel-proc-d3a4c16607f3fbd68987f2bb75e6e12e2fa7677f.zip
[Title] add new processor.
[Desc.] for Linear_Acceleration and Gravity data.
-rw-r--r--include/accel_sim_processor.h16
-rw-r--r--packaging/sf-plugin-proc-accel-emul.spec2
-rw-r--r--src/accel_sim_processor.cpp27
3 files changed, 38 insertions, 7 deletions
diff --git a/include/accel_sim_processor.h b/include/accel_sim_processor.h
index de6eeb0..2484d06 100644
--- a/include/accel_sim_processor.h
+++ b/include/accel_sim_processor.h
@@ -31,14 +31,16 @@ public:
static const char *LCD_TYPE_KEY;
enum data_id {
- ACCELEROMETER_BASE_DATA_SET = (0x0001<<16) | 0x0001,
- ACCELEROMETER_ORIENTATION_DATA_SET = (0x0001 << 16) | 0x0002,
+ ACCELEROMETER_BASE_DATA_SET = (0x0001 << 16) | 0x0001,
+ ACCELEROMETER_ORIENTATION_DATA_SET = (0x0001 << 16) | 0x0002,
+ ACCELEROMETER_LINEAR_ACCELERATION_DATA_SET = (0x0001 << 16) | 0x0004,
+ ACCELEROMETER_GRAVITY_DATA_SET = (0x0001 << 16) | 0x0008,
};
enum evet_type_t {
- ACCELEROMETER_EVENT_ROTATION_CHECK = (0x0001<<16) |0x0001,
- ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME = (0x0001<<16) |0x0002,
- ACCELEROMETER_EVENT_CALIBRATION_NEEDED = (0x0001<<16) |0x0004,
+ ACCELEROMETER_EVENT_ROTATION_CHECK = (0x0001 << 16) | 0x0001,
+ ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME = (0x0001 << 16) | 0x0002,
+ ACCELEROMETER_EVENT_CALIBRATION_NEEDED = (0x0001 << 16) | 0x0004,
ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME = (0x0001 << 16) | 0x0020,
};
enum value_t {
@@ -156,6 +158,10 @@ private:
long m_x;
long m_y;
long m_z;
+
+ float m_gravity_x;
+ float m_gravity_y;
+ float m_gravity_z;
long m_event;
long m_new_event;
diff --git a/packaging/sf-plugin-proc-accel-emul.spec b/packaging/sf-plugin-proc-accel-emul.spec
index f752380..f142de1 100644
--- a/packaging/sf-plugin-proc-accel-emul.spec
+++ b/packaging/sf-plugin-proc-accel-emul.spec
@@ -1,6 +1,6 @@
#git:/slp/pkgs/e/emulator-plugin-accel-proc
Name: sf-plugin-proc-accel-emul
-Version: 0.2.16
+Version: 0.2.17
Release: 1
Summary: Accel simulator Processor plugin for sensor framework (using setting)
Group: System Environment/Libraries
diff --git a/src/accel_sim_processor.cpp b/src/accel_sim_processor.cpp
index fab6c09..2fafb70 100644
--- a/src/accel_sim_processor.cpp
+++ b/src/accel_sim_processor.cpp
@@ -69,6 +69,10 @@
#define DEBUG
#define SRV_IP "10.0.2.2"
#define RADIAN_VALUE 57.29747
+#define GRAVITY_VALUE 0.0098
+#define BINARY_TO_GRAVITY 0.001
+#define LOW_FILTER_ALPHA 0.8
+#define LOW_FILTER_ALPHA_R 0.2
const char *accel_sim_processor::LCD_TYPE_NODE = "/sys/class/graphics/fb0/virtual_size";
@@ -80,6 +84,9 @@ accel_sim_processor::accel_sim_processor()
, m_x(-1)
, m_y(-1)
, m_z(-1)
+, m_gravity_x(-1)
+, m_gravity_y(-1)
+, m_gravity_z(-1)
, m_event(0)
, m_new_event(0)
, m_version(1)
@@ -902,7 +909,25 @@ int accel_sim_processor::get_struct_value(unsigned int struct_type , void *struc
return_struct_data->values[2] = 180 - return_struct_data->values[2];
else if (return_struct_data->values[2] < -90)
return_struct_data->values[2] = -180 - return_struct_data->values[2];
-
+ } else if (struct_type == ACCELEROMETER_LINEAR_ACCELERATION_DATA_SET) {
+ return_struct_data = (base_data_struct *)struct_values;
+ return_struct_data->data_accuracy = sensor_struct_data.data_accuracy;
+ return_struct_data->data_unit_idx = IDX_UNIT_METRE_PER_SECOND_SQUARED;
+ return_struct_data->values_num = 3;
+ m_gravity_x = (LOW_FILTER_ALPHA * m_gravity_x) + (LOW_FILTER_ALPHA_R * sensor_struct_data.values[0]);
+ m_gravity_y = (LOW_FILTER_ALPHA * m_gravity_y) + (LOW_FILTER_ALPHA_R * sensor_struct_data.values[1]);
+ m_gravity_z = (LOW_FILTER_ALPHA * m_gravity_z) + (LOW_FILTER_ALPHA_R * sensor_struct_data.values[2]);
+ return_struct_data->values[0] = (sensor_struct_data.values[0] - m_gravity_x);
+ return_struct_data->values[1] = (sensor_struct_data.values[1] - m_gravity_y);
+ return_struct_data->values[2] = (sensor_struct_data.values[2] - m_gravity_z);
+ } else if (struct_type == ACCELEROMETER_GRAVITY_DATA_SET) {
+ return_struct_data = (base_data_struct *)struct_values;
+ return_struct_data->data_accuracy = sensor_struct_data.data_accuracy;
+ return_struct_data->data_unit_idx = IDX_UNIT_METRE_PER_SECOND_SQUARED;
+ return_struct_data->values_num = 3;
+ return_struct_data->values[0] = sensor_struct_data.values[0] / GRAVITY_VALUE * BINARY_TO_GRAVITY;
+ return_struct_data->values[1] = sensor_struct_data.values[1] / GRAVITY_VALUE * BINARY_TO_GRAVITY;
+ return_struct_data->values[2] = sensor_struct_data.values[2] / GRAVITY_VALUE * BINARY_TO_GRAVITY;
} else {
ERR("does not support stuct_type\n");
return -1;