OSDN Git Service

Merge branch 'lineage-16.0' of https://github.com/me176c-dev/android_hardware_iio...
[android-x86/hardware-intel-libsensors.git] / compass-calibration.c
index 2fa41cf..602f4e2 100644 (file)
@@ -1,6 +1,18 @@
 /*
- * Copyright (C) 2014-2015 Intel Corporation.
- */
+// Copyright (c) 2015 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
 
 #include <math.h>
 #include <hardware/sensors.h>
@@ -482,14 +494,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 +510,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);