struct sample_ops_t ops;
int cal_level; /* 0 means not calibrated */
+
+ /* Depending on the sensor calibration may take too much at higher levels */
+ int max_cal_level;
void* cal_data;
/* Filtering data for noisy sensors */
struct compass_cal* cal_data = (struct compass_cal*) info->cal_data;
+ /*
+ * Some sensors take unrealistically long to calibrate at higher levels.
+ * We'll use a max_cal_level if we have such a property setup, or go with
+ * the default settings if not.
+ */
+ int cal_steps = (info->max_cal_level && info->max_cal_level <= CAL_STEPS) ?
+ info->max_cal_level : CAL_STEPS;
+
if (cal_data->sample_count < DS_SIZE)
return info->cal_level;
memcpy(cal_data->offset, new_cal_data.offset, sizeof(cal_data->offset));
memcpy(cal_data->w_invert, new_cal_data.w_invert, sizeof(cal_data->w_invert));
cal_data->bfield = new_cal_data.bfield;
- if (info->cal_level < (CAL_STEPS - 1))
+ if (info->cal_level < (cal_steps - 1))
info->cal_level++;
ALOGV("CompassCalibration: ready check success, caldata: %f %f %f %f %f %f %f %f %f %f %f %f %f, err %f",
cal_data->offset[0][0], cal_data->offset[1][0], cal_data->offset[2][0], cal_data->w_invert[0][0],
return 1000;
}
+int sensor_get_cal_steps (int s)
+{
+ int cal_steps;
+ if (!sensor_get_prop(s, "cal_steps", &cal_steps))
+ return cal_steps;
+
+ return 0;
+}
+
float sensor_get_resolution (int s)
{
if (sensor_info[s].resolution != 0.0 ||
int sensor_get_prop (int s, const char* sel, int* val);
int sensor_get_fl_prop (int s, const char* sel, float* val);
int sensor_get_order (int s,unsigned char map[MAX_CHANNELS]);
+int sensor_get_cal_steps (int s);
char* sensor_get_string_type (int s);
#endif
struct compass_cal* calibration_data = calloc(1, sizeof(struct compass_cal));
sensor_info[s].cal_data = calibration_data;
}
-
+ sensor_info[s].max_cal_level = sensor_get_cal_steps(s);
/* Select one of the available sensor sample processing styles */
select_transform(s);