OSDN Git Service

spring cleanup: Unify calibration parameters.
authorAdriana Reus <adriana.reus@intel.com>
Mon, 2 Mar 2015 16:13:44 +0000 (18:13 +0200)
committerAdriana Reus <adriana.reus@intel.com>
Mon, 9 Mar 2015 10:14:29 +0000 (12:14 +0200)
Change-Id: I96d4486407cb3575a2ca8f78b8846ad2bf9e2d71
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
calibration.h
compass-calibration.c
control.c
gyro-calibration.c
transform.c

index d353d43..00324da 100644 (file)
@@ -65,13 +65,13 @@ accel_cal_t;
 typedef double mat_input_t[MAGN_DS_SIZE][3];
 
 
-void calibrate_compass  (sensors_event_t* event, sensor_info_t* info);
-void compass_read_data  (sensor_info_t* info);
-void compass_store_data (sensor_info_t* info);
+void calibrate_compass  (int s, sensors_event_t* event);
+void compass_read_data  (int s);
+void compass_store_data (int s);
 
-void calibrate_gyro     (sensors_event_t* event, sensor_info_t* info);
-void gyro_cal_init      (sensor_info_t* info);
-void gyro_store_data    (sensor_info_t* info);
+void calibrate_gyro     (int s, sensors_event_t* event);
+void gyro_cal_init      (int s);
+void gyro_store_data    (int s);
 
 void calibrate_accel    (int s, sensors_event_t* event);
 void accel_cal_init     (int s);
index 2fa41cf..caf1597 100644 (file)
@@ -482,14 +482,14 @@ static int compass_ready (sensor_info_t* info)
 }
 
 
-void calibrate_compass (sensors_event_t* event, sensor_info_t* info)
+void calibrate_compass (int s, sensors_event_t* event)
 {
     int cal_level;
 
     /* Calibration is continuous */
-    compass_collect (event, info);
+    compass_collect (event, &sensor[s]);
 
-    cal_level = compass_ready(info);
+    cal_level = compass_ready(&sensor[s]);
 
     switch (cal_level) {
         case 0:
@@ -498,38 +498,38 @@ void calibrate_compass (sensors_event_t* event, sensor_info_t* info)
             break;
 
         case 1:
-            compass_compute_cal (event, info);
+            compass_compute_cal (event, &sensor[s]);
             event->magnetic.status = SENSOR_STATUS_ACCURACY_LOW;
             break;
 
         case 2:
-            compass_compute_cal (event, info);
+            compass_compute_cal (event, &sensor[s]);
             event->magnetic.status = SENSOR_STATUS_ACCURACY_MEDIUM;
             break;
 
         default:
-            compass_compute_cal (event, info);
+            compass_compute_cal (event, &sensor[s]);
             event->magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
             break;
     }
 }
 
-void compass_read_data (sensor_info_t* info)
+void compass_read_data (int s)
 {
     FILE* data_file = fopen (COMPASS_CALIBRATION_PATH, "r");
 
-    compass_cal_init(data_file, info);
+    compass_cal_init(data_file, &sensor[s]);
 
     if (data_file)
         fclose(data_file);
 }
 
 
-void compass_store_data (sensor_info_t* info)
+void compass_store_data (int s)
 {
     FILE* data_file = fopen (COMPASS_CALIBRATION_PATH, "w");
 
-    compass_store_result(data_file, info);
+    compass_store_result(data_file, &sensor[s]);
 
     if (data_file)
         fclose(data_file);
index 79856c6..62b2cc3 100644 (file)
--- a/control.c
+++ b/control.c
@@ -378,11 +378,11 @@ int adjust_counters (int s, int enabled, int from_virtual)
                                break;
 
                        case SENSOR_TYPE_MAGNETIC_FIELD:
-                               compass_read_data(&sensor[s]);
+                               compass_read_data(s);
                                break;
 
                        case SENSOR_TYPE_GYROSCOPE:
-                               gyro_cal_init(&sensor[s]);
+                               gyro_cal_init(s);
                                break;
                }
        } else {
@@ -398,11 +398,11 @@ int adjust_counters (int s, int enabled, int from_virtual)
                                break;
 
                        case SENSOR_TYPE_MAGNETIC_FIELD:
-                               compass_store_data(&sensor[s]);
+                               compass_store_data(s);
                                break;
 
                        case SENSOR_TYPE_GYROSCOPE:
-                               gyro_store_data(&sensor[s]);
+                               gyro_store_data(s);
                                break;
                }
        }
index d9f8183..dd9570c 100644 (file)
@@ -29,14 +29,14 @@ static void reset (gyro_cal_t* cal_data)
 }
 
 
-void gyro_cal_init (sensor_info_t* info)
+void gyro_cal_init (int s)
 {
        int ret;
-       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) sensor[s].cal_data;
        FILE* data_file;
        float version;
 
-       info->cal_level = 0;
+       sensor[s].cal_level = 0;
 
        if (cal_data == NULL)
                return;
@@ -59,10 +59,10 @@ void gyro_cal_init (sensor_info_t* info)
 }
 
 
-void gyro_store_data (sensor_info_t* info)
+void gyro_store_data (int s)
 {
        int ret;
-       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) sensor[s].cal_data;
        FILE* data_file;
 
        if (cal_data == NULL)
@@ -134,16 +134,16 @@ static int gyro_collect (float x, float y, float z, gyro_cal_t* cal_data)
 }
 
 
-void calibrate_gyro (sensors_event_t* event, sensor_info_t* info)
+void calibrate_gyro (int s, sensors_event_t* event)
 {
-       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) sensor[s].cal_data;
 
        if (cal_data == NULL)
                return;
 
        /* Attempt gyroscope calibration if we have not reached this state */
-       if (info->cal_level == 0)
-               info->cal_level = gyro_collect(event->data[0], event->data[1],
+       if (sensor[s].cal_level == 0)
+               sensor[s].cal_level = gyro_collect(event->data[0], event->data[1],
                                               event->data[2], cal_data);
 
 
@@ -151,6 +151,6 @@ void calibrate_gyro (sensors_event_t* event, sensor_info_t* info)
        event->data[1] = event->data[1] - cal_data->bias_y;
        event->data[2] = event->data[2] - cal_data->bias_z;
 
-       if (info->cal_level)
+       if (sensor[s].cal_level)
               event->gyro.status = SENSOR_STATUS_ACCURACY_HIGH;
 }
index 25094f6..47b4481 100644 (file)
@@ -305,7 +305,7 @@ static int finalize_sample_default (int s, sensors_event_t* data)
                        break;
 
                case SENSOR_TYPE_MAGNETIC_FIELD:
-                       calibrate_compass (data, &sensor[s]);
+                       calibrate_compass (s, data);
                        denoise(s, data);
                        break;
 
@@ -320,7 +320,7 @@ static int finalize_sample_default (int s, sensors_event_t* data)
                         */
                        if (sensor[s].selected_trigger !=
                                sensor[s].motion_trigger_name)
-                                       calibrate_gyro(data, &sensor[s]);
+                                       calibrate_gyro(s, data);
 
                        /*
                         * For noisy sensors drop a few samples to make sure we have at least GYRO_MIN_SAMPLES events in the