#define PROP_BASE "ro.iio.%s.%s" /* Note: PROPERTY_KEY_MAX is small */
+#define MAX_EVENTS 400 /* 400 Hz */
#define MAX_TYPE_SPEC_LEN 32 /* Channel type spec len; ex: "le:u10/16>>0" */
#define MAX_SENSOR_REPORT_SIZE 32 /* Sensor report buffer size */
#define MAX_NAME_SIZE 32
#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
+#define REPORTING_MODE(x) ((x) & 0x06)
#ifdef __LP64__
typedef uint64_t flag_t;
struct sensor_info_t
{
- char friendly_name[MAX_NAME_SIZE]; /* ex: Accelerometer */
- char internal_name[MAX_NAME_SIZE]; /* ex: accel_3d */
- char vendor_name[MAX_NAME_SIZE]; /* ex: Intel */
- char trigger_name[MAX_NAME_SIZE]; /* ex: accel-name-dev1 */
+ char friendly_name[MAX_NAME_SIZE]; /* ex: Accelerometer */
+ char internal_name[MAX_NAME_SIZE]; /* ex: accel_3d */
+ char vendor_name[MAX_NAME_SIZE]; /* ex: Intel */
+ char init_trigger_name[MAX_NAME_SIZE]; /* ex: accel-name-dev1 */
+ char motion_trigger_name[MAX_NAME_SIZE];/* ex: accel-any-motion-dev1 */
float max_range;
float resolution;
float power;
+ /*
+ * Currently active trigger - either a pointer to the initial (default)
+ * trigger name buffer, or a pointer to the motion trigger name buffer,
+ * or something else (typically NULL or a pointer to some static "\n".
+ * This is used to determine if the conditions are met to switch from
+ * the default trigger to the motion trigger for a sensor, or rather for
+ * the interrupt-driven sensors associated to a given iio device.
+ */
+ const char* selected_trigger;
+
float offset; /* (cooked = raw + offset) * scale */
float scale; /*default: 1. when set to 0, use channel specific value*/
float illumincalib; /* to set the calibration for the ALS */
int report_pending;
/*
+ * This flag is set if we have a meta data event pending
+ */
+ volatile int meta_data_pending;
+
+ /*
* Timestamp closely matching the date of sampling, preferably retrieved
* from a iio channel alongside sample data. Value zero indicates that
* we couldn't get such a closely correlated timestamp, and that one
struct sample_ops_t ops;
- int calibrated;
+ int cal_level; /* 0 means not calibrated */
void* cal_data;
+ /* Filtering data for noisy sensors */
+ void* filter;
+
float prev_val; /* Previously reported value, for on-change sensors */
/*
* a sample containing 4 fields.
*/
unsigned char order[MAX_CHANNELS];
+
+ /* A few variables used for data filtering */
+ float *history; /* Working buffer containing recorded samples */
+ float *history_sum; /* The current sum of the history elements */
+ int history_size; /* Number of recorded samples */
+ int history_entries; /* How many of these are initialized */
+ int history_index; /* Index of sample to evict next time */
};
/* Reference a few commonly used variables... */
extern struct sensor_info_t sensor_info[MAX_SENSORS];
extern struct sensor_catalog_entry_t sensor_catalog[];
+/* We are required to be in sync with SystemClock.getNanos */
+extern int64_t ts_delta;
+
#endif