Home | History | Annotate | Download | only in mag_sphere_fit_cal
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef LOCATION_LBS_CONTEXTHUB_NANOAPPS_CALIBRATION_MAGNETOMETER_MAG_SPHERE_FIT_CAL_MAG_SPHERE_FIT_H_
     18 #define LOCATION_LBS_CONTEXTHUB_NANOAPPS_CALIBRATION_MAGNETOMETER_MAG_SPHERE_FIT_CAL_MAG_SPHERE_FIT_H_
     19 
     20 #include "calibration/magnetometer/mag_cal/mag_cal.h"
     21 #include "calibration/sphere_fit/sphere_fit_calibration.h"
     22 
     23 #define NUM_SPHERE_FIT_DATA 50
     24 
     25 #ifdef __cplusplus
     26 extern "C" {
     27 #endif
     28 
     29 struct SphereFit {
     30   struct LmParams params;
     31   struct LmData lm_data;
     32   struct SphereFitCal sphere_cal;
     33   struct ThreeAxisCalData sphere_param;
     34 };
     35 
     36 struct MagCalSphere {
     37   // KASA Fit Struct.
     38   struct MagCal moc;
     39 
     40   // Sphere fit Struct.
     41   struct SphereFit sphere_fit;
     42 
     43   // down sampler control.
     44   uint32_t number_of_data_samples;
     45   uint32_t sample_counter;
     46   uint32_t sample_drop;
     47   float inv_data_size;
     48   float batch_time_in_sec;
     49 
     50   // Sphere fit data set.
     51   float sphere_data[THREE_AXIS_DATA_DIM * NUM_SPHERE_FIT_DATA];
     52 };
     53 
     54 void initMagCalSphere(
     55     struct MagCalSphere *mocs,
     56     const struct MagCalParameters *mag_cal_parameters,
     57     const struct DiversityCheckerParameters *diverse_parameters,
     58     float default_odr_in_hz);
     59 
     60 void magCalSphereDestroy(struct MagCalSphere *mocs);
     61 
     62 enum MagUpdate magCalSphereUpdate(struct MagCalSphere *mocs,
     63                                   uint64_t sample_time_us, float x, float y,
     64                                   float z);
     65 
     66 void magCalSphereOdrUpdate(struct MagCalSphere *mocs, float odr_in_hz);
     67 
     68 #ifdef __cplusplus
     69 }
     70 #endif
     71 
     72 #endif  // LOCATION_LBS_CONTEXTHUB_NANOAPPS_CALIBRATION_MAGNETOMETER_MAG_SPHERE_FIT_CAL_MAG_SPHERE_FIT_H_
     73