├── AccelSensor.cpp ├── AccelSensor.h ├── Android.mk ├── CONTRIBUTING.md ├── Documentation └── LinuxHal │ ├── Makefile │ ├── README.md │ └── test_linux.c ├── GyroSensor.cpp ├── GyroSensor.h ├── HumiditySensor.cpp ├── HumiditySensor.h ├── InputEventReader.cpp ├── InputEventReader.h ├── MagnSensor.cpp ├── MagnSensor.h ├── Makefile ├── PressSensor.cpp ├── PressSensor.h ├── README.md ├── STCal ├── Android.mk └── st_cal_daemon.c ├── SensorBase.cpp ├── SensorBase.h ├── SignMotionSensor.cpp ├── SignMotionSensor.h ├── StepCounterSensor.cpp ├── StepCounterSensor.h ├── StepDetectorSensor.cpp ├── StepDetectorSensor.h ├── StoreCalibration.cpp ├── StoreCalibration.h ├── TapSensor.cpp ├── TapSensor.h ├── TempSensor.cpp ├── TempSensor.h ├── TiltSensor.cpp ├── TiltSensor.h ├── VirtualGyroSensor.cpp ├── VirtualGyroSensor.h ├── conf ├── conf_A3G4250D.h ├── conf_ACCELCALIB.h ├── conf_ACT_RECO.h ├── conf_AIS328DQ.h ├── conf_ASM330LHH.h ├── conf_ASM330LXH.h ├── conf_FILE_CALIB.h ├── conf_FUSION.h ├── conf_GBIAS.h ├── conf_GEOMAG.h ├── conf_HTS221.h ├── conf_IIS2DH.h ├── conf_IIS2MDC.h ├── conf_IIS3DHHC.h ├── conf_ISM303DAC.h ├── conf_ISM330DLC.h ├── conf_L3GD20.h ├── conf_L3GD20H.h ├── conf_LIS2DE12.h ├── conf_LIS2DH12.h ├── conf_LIS2DS12.h ├── conf_LIS2DW12.h ├── conf_LIS2HH12.h ├── conf_LIS2MDL.h ├── conf_LIS3DH.h ├── conf_LIS3DHH.h ├── conf_LIS3MDL.h ├── conf_LPS22HB.h ├── conf_LPS22HD.h ├── conf_LPS22HH.h ├── conf_LPS25H.h ├── conf_LPS33HW.h ├── conf_LSM303AGR.h ├── conf_LSM303AH.h ├── conf_LSM303C.h ├── conf_LSM303D.h ├── conf_LSM303DLHC.h ├── conf_LSM330.h ├── conf_LSM330D.h ├── conf_LSM330DLC.h ├── conf_LSM6DS0.h ├── conf_LSM6DS3.h ├── conf_LSM6DSL.h ├── conf_LSM6DSM.h ├── conf_LSM6DSOX.h ├── conf_LSM9DS0.h ├── conf_LSM9DS1.h ├── conf_MAGCALIB.h └── conf_VGYRO.h ├── configuration.h ├── iNemoEngineSensor.cpp ├── iNemoEngineSensor.h ├── lib └── Android.mk ├── linux └── hardware │ ├── activity_recognition.h │ ├── hardware.h │ ├── sensors-base.h │ └── sensors.h ├── sensors.cpp └── sensors.h /AccelSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | 21 | #if (SENSORS_ACCELEROMETER_ENABLE == 1) 22 | #ifndef ANDROID_ACC_SENSOR_H 23 | #define ANDROID_ACC_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | 34 | #if (SENSORS_ACTIVITY_RECOGNIZER_ENABLE == 1) 35 | extern "C" 36 | { 37 | #include "ActivityRecoLib.h" 38 | }; 39 | #endif 40 | #if (ACCEL_CALIBRATION_ENABLE == 1) 41 | extern "C" 42 | { 43 | #include "STAccCalibration_API.h" 44 | }; 45 | #endif 46 | 47 | /*****************************************************************************/ 48 | 49 | struct input_event; 50 | 51 | class AccelSensor : public SensorBase { 52 | enum { 53 | Acceleration = 0, 54 | AccelUncalib, 55 | SignificantMotion, 56 | iNemoAcceleration, 57 | MagCalAcceleration, 58 | GeoMagRotVectAcceleration, 59 | Orientation, 60 | Gravity_Accel, 61 | Linear_Accel, 62 | VirtualGyro, 63 | Gbias, 64 | ActivityReco, 65 | numSensors 66 | }; 67 | static int mEnabled; 68 | static int64_t delayms; 69 | static int current_fullscale; 70 | InputEventCircularReader mInputReader; 71 | uint32_t mPendingMask; 72 | sensors_event_t mPendingEvents[numSensors]; 73 | bool mHasPendingEvent; 74 | int setInitialState(); 75 | #if ACCEL_CALIBRATION_ENABLE == 1 76 | STAccCalibration_Input accCalibIn; 77 | STAccCalibration_Output accCalibOut; 78 | #endif 79 | 80 | private: 81 | static sensors_vec_t dataBuffer; 82 | static int64_t setDelayBuffer[numSensors]; 83 | static int64_t writeDelayBuffer[numSensors]; 84 | static int DecimationBuffer[numSensors]; 85 | static int DecimationCount; 86 | virtual bool setBufferData(sensors_vec_t *value); 87 | float data_raw[3]; 88 | float data_rot[3]; 89 | sensors_vec_t data_calibrated; 90 | static pthread_mutex_t dataMutex; 91 | int64_t timestamp; 92 | 93 | public: 94 | AccelSensor(); 95 | virtual ~AccelSensor(); 96 | virtual int readEvents(sensors_event_t *data, int count); 97 | virtual bool hasPendingEvents() const; 98 | virtual int setDelay(int32_t handle, int64_t ns); 99 | virtual int writeMinDelay(void); 100 | static void getAccDelay(int64_t *Acc_Delay_ms); 101 | virtual int setFullScale(int32_t handle, int value); 102 | virtual int enable(int32_t handle, int enabled, int type); 103 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 104 | virtual int getWhatFromHandle(int32_t handle); 105 | }; 106 | 107 | #endif /* ANDROID_ACCEL_SENSOR_H */ 108 | 109 | #endif /* SENSORS_ACCELEROMETER_ENABLE */ 110 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing guide 2 | This document serves as a checklist before contributing to this repository. It includes links to additional information if topics are unclear to you. 3 | 4 | This guide mainly focuses on the proper use of Git. 5 | 6 | ### 1. Before opening an issue 7 | To report a bug/request please enter the issue in the right repository. 8 | 9 | Please check the following boxes before posting an issue: 10 | - [ ] `Make sure you are using the latest commit (major releases are Tagged, but corrections are available as new commits).` 11 | - [ ] `Make sure your issue is a question/feedback/suggestion RELATED TO the software provided in this repository.` Otherwise, it should be discussed on the [ST Community forum](https://community.st.com/s/). 12 | - [ ] `Make sure your issue is not already reported/fixed on GitHub or discussed in a previous issue.` Please refer to the tab issue for the list of issues and pull-requests. Do not forget to browse to the **closed** issues. 13 | 14 | ### 2. Posting the issue 15 | When you have checked the previous boxes, you will find two templates (Bug Report or Other Issue) available in the **Issues** tab of the repository. 16 | 17 | ### 3. Pull Requests 18 | STMicroelectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure. 19 | 20 | * If you are an individual writing original source code and you are sure **you own the intellectual property**, then you need to sign an Individual CLA (https://cla.st.com). 21 | * If you work for a company that wants also to allow you to contribute with your work, your company needs to provide a Corporate CLA (https://cla.st.com) mentioning your GitHub account name. 22 | * If you are not sure that a CLA (Individual or Corporate) has been signed for your GitHub account, you can check here (https://cla.st.com). 23 | 24 | Please note that: 25 | * The Corporate CLA will always take precedence over the Individual CLA. 26 | * One CLA submission is sufficient for any project proposed by STMicroelectronics. 27 | 28 | #### How to proceed 29 | 30 | * We recommend to engage first a communication through an issue, in order to present your proposal and just to confirm that it corresponds to a STMicroelectronics domain or scope. 31 | * Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version. 32 | * Please submit one Pull Request for one new feature or proposal. This will facilitate the analysis and the final merge if accepted. 33 | 34 | -------------------------------------------------------------------------------- /Documentation/LinuxHal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2021 STMicroelectronics 3 | # Motion MEMS Product Div. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | #/ 17 | 18 | .PHONY: test_linux 19 | IDIR = -I. -I../../linux/ 20 | 21 | CC=$(CROSS_COMPILE)gcc 22 | LD=$(CROSS_COMPILE)gcc 23 | CFLAGS=$(IDIR) -DLOG_TAG=\"test_linux\" -DPLTF_LINUX_ENABLED 24 | LIB=-ldl -lpthread -lm 25 | 26 | .PHONY: test_linux 27 | 28 | all: test_linux 29 | 30 | OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) 31 | 32 | %.o: %.c 33 | $(CC) -c -o $@ $< $(CFLAGS) 34 | 35 | test_linux: test_linux.o 36 | $(CC) -o $@ $^ $(CFLAGS) $(LIB) 37 | 38 | clean: 39 | rm -f *.o test_linux 40 | -------------------------------------------------------------------------------- /Documentation/LinuxHal/README.md: -------------------------------------------------------------------------------- 1 | Index 2 | ===== 3 | * Introduction 4 | * Configure and Build test_linux 5 | * Copyright 6 | 7 | 8 | Introduction 9 | ========= 10 | 11 | SensorHal Linux Documentation 12 | 13 | The **test_linux** application is an example that demonstrates how to reuse the **SensorHAL** library code even in a Linux environment 14 | 15 | This test_linux code examples searches the SensorHAL shared library(*) in the following paths of the target board: 16 | 17 | > "/tmp/mnt/SensorHAL.so" 18 | > "/system/vendor/lib64/hw/SensorHAL.so" 19 | > "/system/vendor/lib/hw/SensorHAL.so" 20 | 21 | Once found the SensorHAL shared library the test_linux example application executes the dlopen (open_hal routine) and looks for the symbol library HAL_MODULE_INFO_SYM_AS_STR (defined as "HMI"); if library is found on the target, test_linux launches the hmi-> common.methods-> open method of the SensorHAL 22 | 23 | The SensorHAL open method will search for all configured and supported MEMS sensor devices and add them to the list of managed sensors 24 | 25 | At the end of the scanning procedure it will be possible to use the **poll_dev** and **hmi** structure methods to perform all common sensor operations, for examples: 26 | 27 | ##### list of scanned ST MEMS sensors: 28 | sensor_num = hmi->get_sensors_list(hmi, &list); 29 | 30 | ##### getting reference to a sensor: 31 | handle = get_sensor(list, , &sensor); 32 | 33 | ##### acrivate a sensor: 34 | sensor_activate(handle, SENSOR_ENABLE); 35 | 36 | ##### deactivate a sensor: 37 | sensor_activate(handle, SENSOR_DISABLE); 38 | 39 | ##### setting ODR frequency (in Hz): 40 | static int sensor_setdelay(int type, int odr) 41 | { 42 | int handle; 43 | int64_t delay; 44 | struct sensor_t *sensor = NULL; 45 | 46 | delay = 1000000000 / odr; 47 | handle = get_sensor(list, type, &sensor); 48 | if (handle != INVALID_HANDLE && sensor) { 49 | return poll_dev->setDelay(&poll_dev->v0, handle, delay); 50 | } 51 | 52 | return -1; 53 | } 54 | 55 | All the native SensorHAL methods have been implemented in the test_linux application 56 | 57 | The test_linux example application has the following menu options: 58 | 59 | usage: ./test_linux [OPTIONS] 60 | 61 | OPTIONS: 62 | --accodr: Set Accelerometer ODR (default 104) 63 | --gyroodr: Set Gyroscope ODR (default 104) 64 | --list: Show sensor list 65 | --nsample: Number of samples (default 10) 66 | --delay: Set Delay time in ns 67 | --timeout: Set timeout (s) for receive samples (default 1 s) 68 | --sensor: Select sensor (default all) 69 | --logname: Output log file (default log.txt) 70 | --version: Print Version 71 | --help: This help 72 | 73 | NOTE: (*) SensorHAL library must becompiled for linux by using the Makefile provided 74 | 75 | Configure and Build test_linux 76 | ======== 77 | 78 | To build the test_linux sample application set CROSS_COMPILE environment accordingly to you target board, follow an examples for raspberry pi zero target: 79 | 80 | > PATH=$PATH:/local/home/raspy/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin 81 | > make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 82 | 83 | 84 | Copyright 85 | ======== 86 | 87 | Copyright (C) 2022 STMicroelectronics 88 | 89 | 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 90 | 91 | http://www.apache.org/licenses/LICENSE-2.0 92 | 93 | 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. 94 | -------------------------------------------------------------------------------- /GyroSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_GYROSCOPE_ENABLE == 1) 21 | 22 | #ifndef ANDROID_GYRO_SENSOR_H 23 | #define ANDROID_GYRO_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | #include "AccelSensor.h" 34 | 35 | #if defined(STORE_CALIB_GYRO_ENABLED) 36 | #include "StoreCalibration.h" 37 | #endif 38 | 39 | #if (GYROSCOPE_GBIAS_ESTIMATION_STANDALONE == 1) 40 | extern "C" 41 | { 42 | #include 43 | }; 44 | #endif 45 | 46 | /*****************************************************************************/ 47 | 48 | struct input_event; 49 | 50 | class GyroSensor : public SensorBase 51 | { 52 | enum { 53 | Gyro = 0, 54 | GyroUncalib, 55 | iNemoGyro, 56 | numSensors 57 | }; 58 | static int mEnabled; 59 | static int64_t delayms; 60 | static int current_fullscale; 61 | InputEventCircularReader mInputReader; 62 | sensors_event_t mPendingEvent[numSensors]; 63 | bool mHasPendingEvent; 64 | int setInitialState(); 65 | 66 | private: 67 | static int startup_samples; 68 | static int samples_to_discard; 69 | static sensors_vec_t dataBuffer; 70 | static int64_t setDelayBuffer[numSensors]; 71 | static int64_t writeDelayBuffer[numSensors]; 72 | static int DecimationBuffer[numSensors]; 73 | static int DecimationCount[numSensors]; 74 | virtual bool setBufferData(sensors_vec_t *value); 75 | static float gbias_out[3]; 76 | float data_raw[3]; 77 | float data_rot[3]; 78 | static pthread_mutex_t dataMutex; 79 | int64_t timestamp; 80 | #if defined(STORE_CALIB_GYRO_ENABLED) 81 | StoreCalibration *pStoreCalibration; 82 | #endif 83 | #if ((SENSORS_ACCELEROMETER_ENABLE == 1) && (GYROSCOPE_GBIAS_ESTIMATION_STANDALONE == 1)) 84 | static AccelSensor *acc; 85 | float data_acc[3]; 86 | #endif 87 | 88 | public: 89 | GyroSensor(); 90 | virtual ~GyroSensor(); 91 | virtual int readEvents(sensors_event_t *data, int count); 92 | virtual bool hasPendingEvents() const; 93 | virtual int setDelay(int32_t handle, int64_t ns); 94 | virtual int writeMinDelay(void); 95 | virtual int setFullScale(int32_t handle, int value); 96 | virtual int enable(int32_t handle, int enabled, int type); 97 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 98 | static void getGyroDelay(int64_t *Gyro_Delay_ms); 99 | virtual int getWhatFromHandle(int32_t handle); 100 | }; 101 | 102 | #endif /* ANDROID_GYRO_SENSOR_H */ 103 | 104 | #endif /* SENSORS_GYROSCOPE_ENABLE */ 105 | -------------------------------------------------------------------------------- /HumiditySensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if ((SENSORS_HUMIDITY_ENABLE == 1) || (SENSORS_TEMP_RH_ENABLE == 1)) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #if defined(PLTF_LINUX_ENABLED) 31 | #else /* PLTF_LINUX_ENABLED */ 32 | #if (ANDROID_VERSION >= ANDROID_P) 33 | #include 34 | #else 35 | #include 36 | #endif 37 | #endif /* PLTF_LINUX_ENABLED */ 38 | 39 | #include "HumiditySensor.h" 40 | 41 | HumiditySensor::HumiditySensor() : 42 | SensorBase(NULL, SENSOR_DATANAME_HUMIDITY), 43 | mEnabled(false), 44 | current_fullscale(0), 45 | mInputReader(4) 46 | { 47 | memset(mPendingEvents, 0, sizeof(mPendingEvents)); 48 | /* humidity sensor */ 49 | mPendingEvents[0].version = sizeof(sensors_event_t); 50 | mPendingEvents[0].sensor = ID_HUMIDITY; 51 | mPendingEvents[0].type = SENSOR_TYPE_RELATIVE_HUMIDITY; 52 | /* temperature sensor */ 53 | mPendingEvents[1].version = sizeof(sensors_event_t); 54 | mPendingEvents[1].sensor = ID_TEMPERATURE; 55 | mPendingEvents[1].type = SENSOR_TYPE_TEMPERATURE; 56 | } 57 | 58 | HumiditySensor::~HumiditySensor() 59 | { 60 | if (mEnabled) 61 | enable(SENSORS_HUMIDITY_HANDLE, 0, 0); 62 | } 63 | 64 | int HumiditySensor::writeSensorDelay(int handle) 65 | { 66 | int err = writeDelay(handle, delayms); 67 | 68 | return err >= 0 ? 0 : err; 69 | } 70 | 71 | int HumiditySensor::enable(int32_t handle, int en, int type) 72 | { 73 | int err = 0; 74 | 75 | if (en) { 76 | err = writeSensorDelay(SENSORS_HUMIDITY_HANDLE); 77 | if (err < 0) 78 | return err; 79 | 80 | if (!mEnabled) 81 | err = writeEnable(SENSORS_HUMIDITY_HANDLE, 1); 82 | 83 | if (err >= 0) { 84 | err = 0; 85 | mEnabled = true; 86 | } 87 | } else { 88 | err = writeEnable(SENSORS_HUMIDITY_HANDLE, 0); 89 | if (err < 0) 90 | return err; 91 | 92 | mEnabled = false; 93 | err = 0; 94 | } 95 | 96 | return err; 97 | } 98 | 99 | int HumiditySensor::setDelay(int32_t handle, int64_t delay_ns) 100 | { 101 | int64_t delay_ms = NSEC_TO_MSEC(delay_ns); 102 | int err = 0; 103 | 104 | if (delay_ms == 0) 105 | return -EINVAL; 106 | 107 | delayms = delay_ms; 108 | if (mEnabled) 109 | err = writeSensorDelay(SENSORS_HUMIDITY_HANDLE); 110 | 111 | return err; 112 | } 113 | 114 | int HumiditySensor::setFullScale(int32_t __attribute__((unused))handle, int value) 115 | { 116 | int err = 0; 117 | 118 | if (value <= 0) 119 | return -EINVAL; 120 | 121 | if (value != current_fullscale) { 122 | err = writeFullScale(SENSORS_HUMIDITY_HANDLE, value); 123 | if (err >= 0) { 124 | err = 0; 125 | current_fullscale = value; 126 | } 127 | } 128 | return err; 129 | } 130 | 131 | int HumiditySensor::readEvents(sensors_event_t* data, int count) 132 | { 133 | #if DEBUG_HUMIDITY_SENSOR == 1 134 | STLOGD("HumiditySensor::readEvents (count=%d)",count); 135 | #endif 136 | 137 | if (count < 1) 138 | return -EINVAL; 139 | 140 | ssize_t n = mInputReader.fill(data_fd); 141 | if (n < 0) 142 | return n; 143 | 144 | int numEventReceived = 0; 145 | input_event const* event; 146 | 147 | while (count && mInputReader.readEvent(&event)) { 148 | #if DEBUG_HUMIDITY_SENSOR == 1 149 | STLOGD("HumiditySensor::readEvents (count=%d),type(%d)",count,event->type); 150 | #endif 151 | 152 | if (event->type == EV_MSC) { 153 | float value = (float) event->value; 154 | #if SENSORS_HUMIDITY_ENABLE == 1 155 | if (event->code == EVENT_TYPE_HUMIDITY) { 156 | mPendingEvents[0].relative_humidity = value * CONVERT_RH; 157 | mPendingEvents[0].timestamp = timevalToNano(event->time); 158 | *data++ = mPendingEvents[0]; 159 | count--; 160 | numEventReceived++; 161 | } 162 | #endif 163 | #if SENSORS_TEMP_RH_ENABLE == 1 164 | if (event->code == EVENT_TYPE_TEMPERATURE) { 165 | mPendingEvents[1].temperature = value * CONVERT_TEMP; 166 | mPendingEvents[1].timestamp = timevalToNano(event->time); 167 | *data++ = mPendingEvents[1]; 168 | count--; 169 | numEventReceived++; 170 | } 171 | #endif 172 | } else if (event->type != EV_SYN) { 173 | STLOGE("HumiditySensor: unknown event type (type=%d, code=%d)", 174 | event->type, event->code); 175 | } 176 | mInputReader.next(); 177 | } 178 | 179 | return numEventReceived; 180 | } 181 | #endif /* SENSORS_HUMIDITY_ENABLE */ 182 | 183 | -------------------------------------------------------------------------------- /HumiditySensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if ((SENSORS_HUMIDITY_ENABLE == 1) || (SENSORS_TEMP_RH_ENABLE == 1)) 21 | 22 | #ifndef ANDROID_HUMIDITY_SENSOR_H 23 | #define ANDROID_HUMIDITY_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | 34 | class HumiditySensor : public SensorBase { 35 | private: 36 | bool mEnabled; 37 | int current_fullscale; 38 | InputEventCircularReader mInputReader; 39 | sensors_event_t mPendingEvents[2]; 40 | 41 | int64_t delayms; 42 | char device_sysfs_path_prs[PATH_MAX]; 43 | int device_sysfs_path_prs_len; 44 | int writeSensorDelay(int handle); 45 | public: 46 | HumiditySensor(); 47 | ~HumiditySensor(); 48 | int readEvents(sensors_event_t* data, int count); 49 | bool hasPendingEvents() const { return false; } 50 | int setDelay(int32_t handle, int64_t ns); 51 | int setFullScale(int32_t handle, int value); 52 | int enable(int32_t handle, int enabled, int type); 53 | int getWhatFromHandle(int32_t handle) { return 0; } 54 | }; 55 | #endif /* ANDROID_HUMIDITY_SENSOR_H */ 56 | #endif /* SENSORS_HUMIDITYURE_ENABLE || SENSORS_TEMP_RH_ENABLE */ 57 | -------------------------------------------------------------------------------- /InputEventReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | 38 | #include "InputEventReader.h" 39 | 40 | /*****************************************************************************/ 41 | 42 | struct input_event; 43 | 44 | InputEventCircularReader::InputEventCircularReader(size_t numEvents) 45 | : mBuffer(new input_event[numEvents * 2]), 46 | mBufferEnd(mBuffer + numEvents), 47 | mHead(mBuffer), 48 | mCurr(mBuffer), 49 | mFreeSpace(numEvents) 50 | { 51 | } 52 | 53 | InputEventCircularReader::~InputEventCircularReader() 54 | { 55 | delete [] mBuffer; 56 | } 57 | 58 | ssize_t InputEventCircularReader::fill(int fd) 59 | { 60 | size_t numEventsRead = 0; 61 | if (mFreeSpace) { 62 | const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event)); 63 | if (nread<0 || nread % sizeof(input_event)) { 64 | return nread < 0 ? -errno : -EINVAL; 65 | } 66 | 67 | numEventsRead = nread / sizeof(input_event); 68 | if (numEventsRead) { 69 | mHead += numEventsRead; 70 | mFreeSpace -= numEventsRead; 71 | if (mHead > mBufferEnd) { 72 | size_t s = mHead - mBufferEnd; 73 | memcpy(mBuffer, mBufferEnd, s * sizeof(input_event)); 74 | mHead = mBuffer + s; 75 | } 76 | } 77 | } 78 | return numEventsRead; 79 | } 80 | 81 | ssize_t InputEventCircularReader::readEvent(input_event const** events) 82 | { 83 | *events = mCurr; 84 | ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace; 85 | return available ? 1 : 0; 86 | } 87 | 88 | void InputEventCircularReader::next() 89 | { 90 | mCurr++; 91 | mFreeSpace++; 92 | if(mCurr >= mBufferEnd) { 93 | mCurr = mBuffer; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /InputEventReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef ANDROID_INPUT_EVENT_READER_H 20 | #define ANDROID_INPUT_EVENT_READER_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /*****************************************************************************/ 28 | 29 | struct input_event; 30 | 31 | class InputEventCircularReader 32 | { 33 | struct input_event* const mBuffer; 34 | struct input_event* const mBufferEnd; 35 | struct input_event* mHead; 36 | struct input_event* mCurr; 37 | ssize_t mFreeSpace; 38 | 39 | public: 40 | InputEventCircularReader(size_t numEvents); 41 | ~InputEventCircularReader(); 42 | ssize_t fill(int fd); 43 | ssize_t readEvent(input_event const** events); 44 | void next(); 45 | }; 46 | 47 | /*****************************************************************************/ 48 | 49 | #endif // ANDROID_INPUT_EVENT_READER_H 50 | -------------------------------------------------------------------------------- /MagnSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_MAGNETIC_FIELD_ENABLE == 1) 21 | 22 | #ifndef ANDROID_MAGN_SENSOR_H 23 | #define ANDROID_MAGN_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "configuration.h" 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | #include "AccelSensor.h" 35 | 36 | #if MAG_CALIBRATION_ENABLE == 1 37 | extern "C" 38 | { 39 | #include "STMagCalibration_API.h" 40 | }; 41 | #endif 42 | #if (SENSORS_GEOMAG_ROTATION_VECTOR_ENABLE == 1) 43 | extern "C" 44 | { 45 | #include "iNemoEngineGeoMagAPI.h" 46 | }; 47 | #endif 48 | /*****************************************************************************/ 49 | 50 | struct input_event; 51 | 52 | 53 | class MagnSensor : public SensorBase 54 | { 55 | enum { 56 | MagneticField = 0, 57 | UncalibMagneticField, 58 | iNemoMagnetic, 59 | GeoMagRotVect_Magnetic, 60 | Orientation, 61 | Gravity_Accel, 62 | Linear_Accel, 63 | VirtualGyro, 64 | numSensors 65 | }; 66 | static int mEnabled; 67 | static int64_t delayms; 68 | static int current_fullscale; 69 | InputEventCircularReader mInputReader; 70 | sensors_event_t mPendingEvent[numSensors]; 71 | bool mHasPendingEvent; 72 | int data_read; 73 | int setInitialState(); 74 | #if SENSOR_GEOMAG_ENABLE == 1 75 | int refFreq; 76 | #endif 77 | #if MAG_CALIBRATION_ENABLE == 1 78 | STMagCalibration_Input magCalibIn; 79 | STMagCalibration_Output magCalibOut; 80 | #endif 81 | 82 | private: 83 | static sensors_vec_t dataBuffer; 84 | static int64_t setDelayBuffer[numSensors]; 85 | static int64_t writeDelayBuffer[numSensors]; 86 | static int DecimationBuffer[numSensors]; 87 | static int DecimationCount[numSensors]; 88 | sensors_vec_t mSensorsBufferedVectors[3]; 89 | virtual bool setBufferData(sensors_vec_t *value); 90 | #if (SENSORS_ACCELEROMETER_ENABLE == 1) 91 | static AccelSensor *acc; 92 | #endif 93 | #if (SENSOR_GEOMAG_ENABLE == 1) 94 | iNemoGeoMagSensorsData sData; 95 | #endif 96 | float data_raw[3]; 97 | float data_rot[3]; 98 | sensors_vec_t data_calibrated; 99 | static pthread_mutex_t dataMutex; 100 | int64_t timestamp; 101 | 102 | public: 103 | MagnSensor(); 104 | virtual ~MagnSensor(); 105 | virtual int readEvents(sensors_event_t* data, int count); 106 | virtual bool hasPendingEvents() const; 107 | virtual int setDelay(int32_t handle, int64_t ns); 108 | virtual int writeMinDelay(void); 109 | static void getMagDelay(int64_t *Mag_Delay_ms); 110 | virtual int setFullScale(int32_t handle, int value); 111 | virtual int enable(int32_t handle, int enabled, int type); 112 | virtual int getWhatFromHandle(int32_t handle); 113 | int64_t getDelayms() { 114 | return delayms; 115 | }; 116 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 117 | static int count_call_ecompass; 118 | static int freq; 119 | }; 120 | 121 | #endif /* ANDROID_MAGN_SENSOR_H */ 122 | 123 | #endif /* SENSORS_MAGNETIC_FIELD_ENABLE */ 124 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2018 STMicroelectronics 3 | # Denis Ciocca - Motion MEMS Product Div. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | #/ 17 | 18 | LOCAL_PATH := ${CURDIR} 19 | 20 | CC := $(CROSS_COMPILE)gcc 21 | CXX := $(CROSS_COMPILE)g++ 22 | RM = rm -f 23 | INCLUDES := -I$(LOCAL_PATH)/ -I$(LOCAL_PATH)/conf -I$(LOCAL_PATH)/linux 24 | CFLAGS += $(INCLUDES) -DLOG_TAG=\"SensorHAL\" -DPLTF_LINUX_ENABLED -Wall \ 25 | -Wunused-parameter -Wunused-value -Wunused-function -Wunused-label \ 26 | -fPIC -DLSM6DSOX 27 | 28 | CPPFLAGS = $(INCLUDES) -g -DPLTF_LINUX_ENABLED -Wunused-label -Wall -fPIC \ 29 | -D_DEFAULT_SOURCE -std=c++11 -DLSM6DSOX -DANDROID_VERSION=29 30 | LDFLAGS = -g -L$(OUT) 31 | LDLIBS = -lpthread 32 | 33 | ifeq ($(DEBUG),y) 34 | CFLAGS += -g -O0 35 | endif # DEBUG 36 | 37 | # Where to produce shared object 38 | OUT = $(LOCAL_PATH) 39 | 40 | LOCAL_SRC_FILES := \ 41 | SensorBase.cpp \ 42 | sensors.cpp \ 43 | AccelSensor.cpp \ 44 | GyroSensor.cpp \ 45 | InputEventReader.cpp \ 46 | MagnSensor.cpp \ 47 | HumiditySensor.cpp \ 48 | PressSensor.cpp \ 49 | TempSensor.cpp \ 50 | SignMotionSensor.cpp \ 51 | StepCounterSensor.cpp \ 52 | StepDetectorSensor.cpp \ 53 | StoreCalibration.cpp \ 54 | TapSensor.cpp \ 55 | TiltSensor.cpp \ 56 | VirtualGyroSensor.cpp \ 57 | iNemoEngineSensor.cpp 58 | 59 | OBJS=$(subst .cpp,.o,$(LOCAL_SRC_FILES)) 60 | 61 | all: SensorHAL 62 | 63 | SensorHAL: $(OBJS) 64 | $(CXX) $(LDFLAGS) -shared $(OBJS) $(LDLIBS) -o $(OUT)/SensorHAL.so 65 | 66 | clean: 67 | $(RM) $(OBJS) $(OUT)/SensorHAL.so 68 | 69 | -------------------------------------------------------------------------------- /PressSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if ((SENSORS_PRESSURE_ENABLE == 1) || (SENSORS_TEMP_PRESS_ENABLE == 1)) 21 | 22 | #ifndef ANDROID_PRESS_SENSOR_H 23 | #define ANDROID_PRESS_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | 34 | class PressSensor : public SensorBase { 35 | private: 36 | enum { 37 | Pressure = 0, 38 | Temperature, 39 | numSensors 40 | }; 41 | static unsigned int mEnabled; 42 | static int current_fullscale; 43 | uint32_t mPendingMask; 44 | InputEventCircularReader mInputReader; 45 | sensors_event_t mPendingEvents[numSensors]; 46 | bool mHasPendingEvent; 47 | 48 | int setInitialState(); 49 | 50 | enum channelid{ 51 | pressChan = 0, 52 | tempChan 53 | }; 54 | int64_t delayms; 55 | 56 | //char device_sysfs_path_prs[PATH_MAX]; 57 | //int device_sysfs_path_prs_len; 58 | int writeSensorDelay(int handle); 59 | public: 60 | PressSensor(); 61 | virtual ~PressSensor(); 62 | virtual int readEvents(sensors_event_t* data, int count); 63 | virtual bool hasPendingEvents() const { return mHasPendingEvent; } 64 | virtual int setDelay(int32_t handle, int64_t ns); 65 | virtual int setFullScale(int32_t handle, int value); 66 | virtual int enable(int32_t handle, int enabled, int type); 67 | virtual int getWhatFromHandle(int32_t handle); 68 | }; 69 | 70 | #endif // ANDROID_PRESS_SENSOR_H 71 | #endif /* SENSORS_TEMP_PRESS_ENABLE | SENSORS_PRESSURE_ENABLE */ 72 | -------------------------------------------------------------------------------- /STCal/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES:= \ 6 | st_cal_daemon.c 7 | 8 | LOCAL_CPPFLAGS := \ 9 | -std=gnu++11 \ 10 | -W -Wall -Wextra \ 11 | -Wunused \ 12 | -Werror \ 13 | 14 | LOCAL_SHARED_LIBRARIES := libc liblog 15 | 16 | LOCAL_CFLAGS += -DLOG_TAG=\"STCalibrationD\" 17 | 18 | LOCAL_MODULE := stcald 19 | 20 | include $(BUILD_EXECUTABLE) 21 | 22 | -------------------------------------------------------------------------------- /STCal/st_cal_daemon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * STMicroelectronics calibration daemon 3 | * 4 | * Copyright 2015 STMicroelectronics Inc. 5 | * 6 | * Giuseppe Barba 7 | * 8 | * Licensed under the GPL-2. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #if (ANDROID_VERSION >= ANDROID_P) 17 | #include 18 | #else 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | 25 | #define concat(first, second) first second 26 | 27 | #define PACKAGENAME "com.st.mems.st_calibrationtool" 28 | #define CAL_FILE "calibration.txt" 29 | 30 | #define APP_DATA_DIR "/data/data/" 31 | #define APP_FILE_PRIVATE_DIR "/files/" 32 | #define APP_PRIVATE_DATA_DIR concat(concat(APP_DATA_DIR,PACKAGENAME),APP_FILE_PRIVATE_DIR) 33 | #define CAL_FILE_PATH concat(APP_PRIVATE_DATA_DIR,CAL_FILE) 34 | #define CAL_DIR "/data/" 35 | #define CAL_OUT_FILE_PATH concat(CAL_DIR,CAL_FILE) 36 | #define OBS_MASK (IN_MODIFY | IN_DELETE | IN_CREATE) 37 | #define NUM_OF_SENSORS 4 38 | #define NUM_OF_AXIS 3 39 | #define THD_SLEEP_USEC 3000000 40 | #define EVENT_SIZE (sizeof(struct inotify_event)) 41 | #define MAX_CHARS_PER_LINE 512 42 | #define DELIMITER " " 43 | #define MAX_TOKENS_PER_LINE 4 44 | #define EVENT_BUF_SIZE (1024 * (EVENT_SIZE + 16)) 45 | 46 | int eventCheck(int fd) 47 | { 48 | fd_set rfds; 49 | 50 | FD_ZERO (&rfds); 51 | FD_SET (fd, &rfds); 52 | /* Wait until an event happens */ 53 | 54 | return select(FD_SETSIZE, &rfds, NULL, NULL, NULL); 55 | } 56 | 57 | int copy_file(const char *infile, const char *outfile) 58 | { 59 | FILE *fin, *fout; 60 | char *buffer; 61 | struct stat st; 62 | int ret; 63 | 64 | stat(infile, &st); 65 | buffer = (char *)malloc(sizeof(char) * st.st_size); 66 | if (!buffer) { 67 | ALOGE("Error to allocate temp buffer"); 68 | 69 | return -1; 70 | } 71 | 72 | fin = fopen(infile, "r"); 73 | if (!fin) { 74 | ALOGE("Error to open input file: %s error: %d", infile, errno); 75 | 76 | return -1; 77 | } 78 | 79 | fout = fopen(outfile, "w"); 80 | if (!fout) { 81 | ALOGE("Error to open output file: %s error: %d", outfile, errno); 82 | 83 | return -3; 84 | } 85 | 86 | fread(buffer, sizeof(char), st.st_size, fin); 87 | fclose(fin); 88 | 89 | fwrite(buffer, sizeof(char), st.st_size, fout); 90 | fclose(fout); 91 | 92 | ret = chmod(outfile, 93 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); 94 | 95 | return ret; 96 | } 97 | 98 | int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) 99 | { 100 | char event_buf[EVENT_BUF_SIZE]; 101 | struct inotify_event* event; 102 | int num_bytes = 0; 103 | int event_pos; 104 | int event_size; 105 | struct stat s; 106 | int watch_fd; 107 | int observer_fd = 0; 108 | int ret; 109 | 110 | ALOGI("Start ST Calibration Daemon"); 111 | while (stat(APP_PRIVATE_DATA_DIR, &s) < 0) { 112 | /* sleep until the calibration directory is present */ 113 | usleep(THD_SLEEP_USEC); 114 | ALOGI("wait for cal dir %s", APP_PRIVATE_DATA_DIR); 115 | } 116 | 117 | //Copy stored calibration data to apk 118 | ret = copy_file(CAL_OUT_FILE_PATH, CAL_FILE_PATH); 119 | if (ret) 120 | ALOGE("Error while coping file (%d)", ret); 121 | 122 | observer_fd = inotify_init(); 123 | if (observer_fd < 0) { 124 | ALOGE("Error to start inotify!!!"); 125 | return -1; 126 | } 127 | 128 | watch_fd = inotify_add_watch(observer_fd, APP_PRIVATE_DATA_DIR, OBS_MASK); 129 | if (!watch_fd) { 130 | ALOGE("Error while adding inotify watcher!!!\n"); 131 | 132 | return -1; 133 | } 134 | 135 | while (1) { 136 | ret = eventCheck(observer_fd); 137 | if (ret) { 138 | num_bytes = read(observer_fd, event_buf, EVENT_BUF_SIZE); 139 | event_pos = 0; 140 | 141 | while (num_bytes >= (int)sizeof(*event)) { 142 | event = (struct inotify_event *)(event_buf + event_pos); 143 | if (event->len) { 144 | if (event->mask & (IN_MODIFY | IN_CREATE)) { 145 | if (!strcmp(event->name, CAL_FILE)) { 146 | ALOGI("Changes on Calibration file detected"); 147 | ret = copy_file(CAL_FILE_PATH, CAL_OUT_FILE_PATH); 148 | if (ret) 149 | ALOGE("Error while coping file (%d)", ret); 150 | } 151 | } else if (event->mask & (IN_DELETE)) { 152 | ALOGI("Calibration file deleted"); 153 | 154 | } else { 155 | ALOGE("Event not used %d", event->mask); 156 | } 157 | } 158 | event_size = sizeof(*event) + event->len; 159 | num_bytes -= event_size; 160 | event_pos += event_size; 161 | } 162 | } 163 | usleep(THD_SLEEP_USEC); 164 | } 165 | ALOGI("Exit from ST Calibration Daemon"); 166 | } 167 | -------------------------------------------------------------------------------- /SensorBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef ANDROID_SENSOR_BASE_H 20 | #define ANDROID_SENSOR_BASE_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define DELAY_OFF (-1000000) 28 | #define MSEC_TO_SEC(x) ((x) / 1000) 29 | #define NSEC_TO_MSEC(x) ((x) / 1000000) 30 | #define MSEC_TO_NSEC(x) ((x) * 1000000) 31 | #define SEC_TO_MSEC(x) ((x) * 1000) 32 | #define SEC_TO_NSEC(x) (MSEC_TO_NSEC(SEC_TO_MSEC(x))) 33 | /*****************************************************************************/ 34 | 35 | struct sensors_event_t; 36 | 37 | class SensorBase { 38 | 39 | protected: 40 | const char* dev_name; 41 | const char* data_name; 42 | char sysfs_device_path[PATH_MAX]; 43 | int sysfs_device_path_len; 44 | int dev_fd; 45 | int data_fd; 46 | 47 | int openInput(const char* inputDeviceName); 48 | 49 | 50 | static int64_t timevalToNano(timeval const& t) { 51 | return t.tv_sec*1000000000LL + t.tv_usec*1000; 52 | } 53 | 54 | int open_device(); 55 | int close_device(); 56 | int getSysfsDevicePath(char* sysfs_path, const char* inputDeviceName); 57 | 58 | public: 59 | SensorBase(const char* dev_name, const char* data_name); 60 | virtual ~SensorBase(); 61 | 62 | virtual int readEvents(sensors_event_t* data, int count) = 0; 63 | virtual bool hasPendingEvents() const; 64 | virtual int getFd() const; 65 | virtual int setDelay(int32_t handle, int64_t ns); 66 | virtual int enable(int32_t handle, int enabled, int type) = 0; 67 | virtual int writeFullScale(int32_t handle, int value); 68 | virtual int writeEnable(int32_t handle, int enable); 69 | virtual int writeDelay(int32_t handle, int64_t delay_ms); 70 | virtual int writeSysfsCommand(int32_t handle, const char *sysfsFilename, const char *dataFormat, int64_t param); 71 | virtual int getWhatFromHandle(int32_t handle) = 0; 72 | }; 73 | 74 | /*****************************************************************************/ 75 | 76 | #endif // ANDROID_SENSOR_BASE_H 77 | -------------------------------------------------------------------------------- /SignMotionSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_SIGN_MOTION_ENABLE == 1) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | #include 38 | #include "SignMotionSensor.h" 39 | 40 | 41 | /*****************************************************************************/ 42 | int SignMotionSensor::mEnabled = 0; 43 | 44 | SignMotionSensor::SignMotionSensor() 45 | : SensorBase(NULL, SENSOR_DATANAME_SIGN_M), 46 | mInputReader(4) 47 | { 48 | mPendingEvent.version = sizeof(sensors_event_t); 49 | mPendingEvent.sensor = ID_SIGN_MOTION; 50 | mPendingEvent.type = SENSOR_TYPE_SIGNIFICANT_MOTION; 51 | mPendingEvent.data[0] = 1.0f; 52 | 53 | if (data_fd) { 54 | STLOGI("SignMotionSensor::SignMotionSensor device_sysfs_path:(%s)", sysfs_device_path); 55 | } else { 56 | STLOGE("SignMotionSensor::SignMotionSensor device_sysfs_path:(%s) not found", sysfs_device_path); 57 | } 58 | } 59 | 60 | SignMotionSensor::~SignMotionSensor() 61 | { 62 | if (mEnabled) { 63 | enable(SENSORS_SIGN_MOTION_HANDLE, 0, 0); 64 | } 65 | } 66 | 67 | int SignMotionSensor::enable(int32_t handle, int en, int __attribute__((unused))type) 68 | { 69 | int err = 0; 70 | int flags = en ? 1 : 0; 71 | 72 | if (flags) { 73 | if (!mEnabled) { 74 | err = writeEnable(SENSORS_SIGN_MOTION_HANDLE, flags); 75 | if(err >= 0) 76 | err = 0; 77 | } 78 | mEnabled = 1; 79 | } else { 80 | if (mEnabled){ 81 | err = writeEnable(SENSORS_SIGN_MOTION_HANDLE, flags); 82 | if(err >= 0) { 83 | err = 0; 84 | mEnabled = 0; 85 | } 86 | } 87 | } 88 | 89 | if(err >= 0 ) { 90 | STLOGD("SignMotionSensor::enable(%d), handle: %d, mEnabled: %d", 91 | flags, handle, mEnabled); 92 | } else { 93 | STLOGE("SignMotionSensor::enable(%d), handle: %d, mEnabled: %d", 94 | flags, handle, mEnabled); 95 | } 96 | 97 | return err; 98 | } 99 | 100 | int SignMotionSensor::getWhatFromHandle(int32_t __attribute__((unused))handle) 101 | { 102 | return 0; 103 | } 104 | 105 | bool SignMotionSensor::hasPendingEvents() const 106 | { 107 | return false; 108 | } 109 | 110 | int SignMotionSensor::setDelay(int32_t __attribute__((unused))handle, 111 | int64_t __attribute__((unused))delay_ns) 112 | { 113 | return 0; 114 | } 115 | 116 | int SignMotionSensor::readEvents(sensors_event_t* data, int count) 117 | { 118 | if (count < 1) 119 | return -EINVAL; 120 | 121 | ssize_t n = mInputReader.fill(data_fd); 122 | if (n < 0) 123 | return n; 124 | 125 | int numEventReceived = 0; 126 | input_event const* event; 127 | 128 | while (count && mInputReader.readEvent(&event)) { 129 | 130 | if (event->type == EVENT_TYPE_SIGN_M) { 131 | 132 | #if (DEBUG_SIGN_M == 1) 133 | STLOGD("SignMotionSensor::readEvents (event_code=%d)", event->code); 134 | #endif 135 | switch(event->code) { 136 | case EVENT_TYPE_SIGN_M_DATA: 137 | 138 | break; 139 | #if defined(INPUT_EVENT_HAS_TIMESTAMP) 140 | case EVENT_TYPE_TIME_MSB: 141 | timestamp = ((int64_t)(event->value)) << 32; 142 | 143 | break; 144 | case EVENT_TYPE_TIME_LSB: 145 | timestamp |= (uint32_t)(event->value); 146 | 147 | break; 148 | #endif 149 | default: 150 | STLOGE("SignMotionSensor: unknown event code \ 151 | (type = %d, code = %d)", event->type, 152 | event->code); 153 | } 154 | } else if (event->type == EV_SYN) { 155 | 156 | enable(SENSORS_SIGN_MOTION_HANDLE, 0, 0); 157 | #if !defined(INPUT_EVENT_HAS_TIMESTAMP) 158 | timestamp = timevalToNano(event->time); 159 | #endif 160 | mPendingEvent.timestamp = timestamp; 161 | memcpy(data, &mPendingEvent, sizeof(mPendingEvent)); 162 | data++; 163 | count--; 164 | numEventReceived++; 165 | #if (DEBUG_SIGN_M == 1) 166 | STLOGD("SignMotionSensor::readEvents (time = %lld), count(%d), received(%d)", 167 | mPendingEvent.timestamp, 168 | count, numEventReceived); 169 | #endif 170 | 171 | } else { 172 | STLOGE("SignMotionSensor: unknown event (type=%d, code=%d)", 173 | event->type, event->code); 174 | } 175 | mInputReader.next(); 176 | } 177 | 178 | return numEventReceived; 179 | } 180 | 181 | #endif /* SENSORS_SIGN_MOTION_ENABLE */ 182 | -------------------------------------------------------------------------------- /SignMotionSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_SIGN_MOTION_ENABLE == 1) 21 | 22 | #ifndef ANDROID_SIGN_MOTION_SENSOR_H 23 | #define ANDROID_SIGN_MOTION_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | 35 | struct input_event; 36 | 37 | class SignMotionSensor : public SensorBase 38 | { 39 | static int mEnabled; 40 | InputEventCircularReader mInputReader; 41 | sensors_event_t mPendingEvent; 42 | 43 | private: 44 | static pthread_mutex_t dataMutex; 45 | int64_t timestamp; 46 | int32_t steps; 47 | 48 | public: 49 | SignMotionSensor(); 50 | virtual ~SignMotionSensor(); 51 | virtual int readEvents(sensors_event_t *data, int count); 52 | virtual bool hasPendingEvents() const; 53 | virtual int getWhatFromHandle(int32_t handle); 54 | virtual int setDelay(int32_t handle, int64_t ns); 55 | virtual int enable(int32_t handle, int enabled, int type); 56 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 57 | }; 58 | 59 | #endif // ANDROID_SIGN_MOTION_SENSOR_H 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /StepCounterSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_STEP_COUNTER_ENABLE == 1) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | #include 38 | #include "StepCounterSensor.h" 39 | 40 | 41 | /*****************************************************************************/ 42 | int StepCounterSensor::mEnabled = 0; 43 | 44 | StepCounterSensor::StepCounterSensor() 45 | : SensorBase(NULL, SENSOR_DATANAME_STEP_C), 46 | mInputReader(4) 47 | { 48 | mPendingEvent.version = sizeof(sensors_event_t); 49 | mPendingEvent.sensor = ID_STEP_COUNTER; 50 | mPendingEvent.type = SENSOR_TYPE_STEP_COUNTER; 51 | memset(&mPendingEvent.u64, 0, sizeof(mPendingEvent.u64)); 52 | delivery_rate = 0; 53 | 54 | if (data_fd) { 55 | STLOGI("StepCounterSensor::StepCounterSensor device_sysfs_path:(%s)", sysfs_device_path); 56 | } else { 57 | STLOGE("StepCounterSensor::StepCounterSensor device_sysfs_path:(%s) not found", sysfs_device_path); 58 | } 59 | } 60 | 61 | StepCounterSensor::~StepCounterSensor() 62 | { 63 | if (mEnabled) { 64 | enable(SENSORS_STEP_COUNTER_HANDLE, 0, 0); 65 | } 66 | } 67 | 68 | int StepCounterSensor::enable(int32_t handle, int en, int __attribute__((unused))type) 69 | { 70 | int err = 0; 71 | int flags = en ? 1 : 0; 72 | 73 | if (flags) { 74 | if (!mEnabled) { 75 | err = writeEnable(SENSORS_STEP_COUNTER_HANDLE, flags); 76 | if(err >= 0) 77 | err = 0; 78 | } 79 | mEnabled = 1; 80 | } else { 81 | if (mEnabled){ 82 | err = writeEnable(SENSORS_STEP_COUNTER_HANDLE, flags); 83 | if(err >= 0) { 84 | err = 0; 85 | mEnabled = 0; 86 | } 87 | } 88 | } 89 | 90 | if(err >= 0 ) { 91 | STLOGD("StepCounterSensor::enable(%d), handle: %d, mEnabled: %d", 92 | flags, handle, mEnabled); 93 | } else { 94 | STLOGE("StepCounterSensor::enable(%d), handle: %d, mEnabled: %d", 95 | flags, handle, mEnabled); 96 | } 97 | 98 | return err; 99 | } 100 | 101 | int StepCounterSensor::getWhatFromHandle(int32_t __attribute__((unused))handle) 102 | { 103 | return 0; 104 | } 105 | 106 | bool StepCounterSensor::hasPendingEvents() const 107 | { 108 | return false; 109 | } 110 | 111 | int StepCounterSensor::setDelay(int32_t __attribute__((unused))handle, 112 | int64_t delay_ns) 113 | { 114 | int err = 0; 115 | 116 | if (delay_ns != delivery_rate) { 117 | err = writeDelay(SENSORS_STEP_COUNTER_HANDLE, 118 | NSEC_TO_MSEC(delay_ns)); 119 | if(err >= 0) 120 | delivery_rate = delay_ns; 121 | } 122 | return err; 123 | } 124 | 125 | int StepCounterSensor::readEvents(sensors_event_t* data, int count) 126 | { 127 | if (count < 1) 128 | return -EINVAL; 129 | 130 | ssize_t n = mInputReader.fill(data_fd); 131 | if (n < 0) 132 | return n; 133 | 134 | int numEventReceived = 0; 135 | input_event const* event; 136 | 137 | while (count && mInputReader.readEvent(&event)) { 138 | 139 | if (event->type == EVENT_TYPE_STEP_C) { 140 | 141 | #if (DEBUG_STEP_C == 1) 142 | STLOGD("StepCounterSensor::readEvents (event_code=%d)", event->code); 143 | #endif 144 | switch(event->code) { 145 | case EVENT_TYPE_STEP_C_DATA: 146 | steps = (uint32_t)event->value; 147 | 148 | break; 149 | #if defined(INPUT_EVENT_HAS_TIMESTAMP) 150 | case EVENT_TYPE_TIME_MSB: 151 | timestamp = ((int64_t)(event->value)) << 32; 152 | 153 | break; 154 | case EVENT_TYPE_TIME_LSB: 155 | timestamp |= (uint32_t)(event->value); 156 | 157 | break; 158 | #endif 159 | default: 160 | STLOGE("StepCounterSensor: unknown event code \ 161 | (type = %d, code = %d)", event->type, 162 | event->code); 163 | } 164 | } else if (event->type == EV_SYN) { 165 | 166 | #if !defined(INPUT_EVENT_HAS_TIMESTAMP) 167 | timestamp = timevalToNano(event->time); 168 | #endif 169 | mPendingEvent.u64.step_counter = (uint64_t)steps; 170 | mPendingEvent.timestamp = timestamp; 171 | memcpy(data, &mPendingEvent, sizeof(mPendingEvent)); 172 | data++; 173 | count--; 174 | numEventReceived++; 175 | #if (DEBUG_STEP_C == 1) 176 | STLOGD("StepCounterSensor::readEvents (time = %lld), count(%d), received(%d), steps(%d)", 177 | mPendingEvent.timestamp, 178 | count, numEventReceived, steps); 179 | #endif 180 | 181 | } else { 182 | STLOGE("StepCounterSensor: unknown event (type=%d, code=%d)", 183 | event->type, event->code); 184 | } 185 | mInputReader.next(); 186 | } 187 | 188 | return numEventReceived; 189 | } 190 | 191 | #endif /* SENSORS_STEP_COUNTER_ENABLE */ 192 | -------------------------------------------------------------------------------- /StepCounterSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_STEP_COUNTER_ENABLE == 1) 21 | 22 | #ifndef ANDROID_STEP_COUNTER_SENSOR_H 23 | #define ANDROID_STEP_COUNTER_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | 35 | struct input_event; 36 | 37 | class StepCounterSensor : public SensorBase 38 | { 39 | static int mEnabled; 40 | InputEventCircularReader mInputReader; 41 | sensors_event_t mPendingEvent; 42 | 43 | private: 44 | static pthread_mutex_t dataMutex; 45 | int64_t timestamp; 46 | uint32_t steps; 47 | int64_t delivery_rate; 48 | 49 | public: 50 | StepCounterSensor(); 51 | virtual ~StepCounterSensor(); 52 | virtual int readEvents(sensors_event_t *data, int count); 53 | virtual bool hasPendingEvents() const; 54 | virtual int getWhatFromHandle(int32_t handle); 55 | virtual int setDelay(int32_t handle, int64_t ns); 56 | virtual int enable(int32_t handle, int enabled, int type); 57 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 58 | }; 59 | 60 | #endif // ANDROID_STEP_COUNTER_SENSOR_H 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /StepDetectorSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_STEP_DETECTOR_ENABLE == 1) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | #include 38 | #include "StepDetectorSensor.h" 39 | 40 | 41 | /*****************************************************************************/ 42 | int StepDetectorSensor::mEnabled = 0; 43 | 44 | StepDetectorSensor::StepDetectorSensor() 45 | : SensorBase(NULL, SENSOR_DATANAME_STEP_D), 46 | mInputReader(4) 47 | { 48 | mPendingEvent.version = sizeof(sensors_event_t); 49 | mPendingEvent.sensor = ID_STEP_DETECTOR; 50 | mPendingEvent.type = SENSOR_TYPE_STEP_DETECTOR; 51 | mPendingEvent.data[0] = 1.0f; 52 | 53 | if (data_fd) { 54 | STLOGI("StepDetectorSensor::StepDetectorSensor device_sysfs_path:(%s)", sysfs_device_path); 55 | } else { 56 | STLOGE("StepDetectorSensor::StepDetectorSensor device_sysfs_path:(%s) not found", sysfs_device_path); 57 | } 58 | } 59 | 60 | StepDetectorSensor::~StepDetectorSensor() 61 | { 62 | if (mEnabled) { 63 | enable(SENSORS_STEP_DETECTOR_HANDLE, 0, 0); 64 | } 65 | } 66 | 67 | int StepDetectorSensor::enable(int32_t handle, int en, int __attribute__((unused))type) 68 | { 69 | int err = 0; 70 | int flags = en ? 1 : 0; 71 | 72 | if (flags) { 73 | if (!mEnabled) { 74 | err = writeEnable(SENSORS_STEP_DETECTOR_HANDLE, flags); 75 | if(err >= 0) 76 | err = 0; 77 | } 78 | mEnabled = 1; 79 | } else { 80 | if (mEnabled){ 81 | err = writeEnable(SENSORS_STEP_DETECTOR_HANDLE, flags); 82 | if(err >= 0) { 83 | err = 0; 84 | mEnabled = 0; 85 | } 86 | } 87 | } 88 | 89 | if(err >= 0 ) { 90 | STLOGD("StepDetectorSensor::enable(%d), handle: %d, mEnabled: %d", 91 | flags, handle, mEnabled); 92 | } else { 93 | STLOGE("StepDetectorSensor::enable(%d), handle: %d, mEnabled: %d", 94 | flags, handle, mEnabled); 95 | } 96 | 97 | return err; 98 | } 99 | 100 | int StepDetectorSensor::getWhatFromHandle(int32_t __attribute__((unused))handle) 101 | { 102 | return 0; 103 | } 104 | 105 | bool StepDetectorSensor::hasPendingEvents() const 106 | { 107 | return false; 108 | } 109 | 110 | int StepDetectorSensor::setDelay(int32_t __attribute__((unused))handle, 111 | int64_t __attribute__((unused))delay_ns) 112 | { 113 | return 0; 114 | } 115 | 116 | int StepDetectorSensor::readEvents(sensors_event_t* data, int count) 117 | { 118 | if (count < 1) 119 | return -EINVAL; 120 | 121 | ssize_t n = mInputReader.fill(data_fd); 122 | if (n < 0) 123 | return n; 124 | 125 | int numEventReceived = 0; 126 | input_event const* event; 127 | 128 | while (count && mInputReader.readEvent(&event)) { 129 | 130 | if (event->type == EVENT_TYPE_STEP_D) { 131 | 132 | #if (DEBUG_STEP_D == 1) 133 | STLOGD("StepDetectorSensor::readEvents (event_code=%d)", event->code); 134 | #endif 135 | switch(event->code) { 136 | case EVENT_TYPE_STEP_D_DATA: 137 | 138 | break; 139 | #if defined(INPUT_EVENT_HAS_TIMESTAMP) 140 | case EVENT_TYPE_TIME_MSB: 141 | timestamp = ((int64_t)(event->value)) << 32; 142 | 143 | break; 144 | case EVENT_TYPE_TIME_LSB: 145 | timestamp |= (uint32_t)(event->value); 146 | 147 | break; 148 | #endif 149 | default: 150 | STLOGE("StepDetectorSensor: unknown event code \ 151 | (type = %d, code = %d)", event->type, 152 | event->code); 153 | } 154 | } else if (event->type == EV_SYN) { 155 | 156 | #if !defined(INPUT_EVENT_HAS_TIMESTAMP) 157 | timestamp = timevalToNano(event->time); 158 | #endif 159 | mPendingEvent.timestamp = timestamp; 160 | memcpy(data, &mPendingEvent, sizeof(mPendingEvent)); 161 | data++; 162 | count--; 163 | numEventReceived++; 164 | #if (DEBUG_STEP_D == 1) 165 | STLOGD("StepDetectorSensor::readEvents (time = %lld), count(%d), received(%d)", 166 | mPendingEvent.timestamp, 167 | count, numEventReceived); 168 | #endif 169 | 170 | } else { 171 | STLOGE("StepDetectorSensor: unknown event (type=%d, code=%d)", 172 | event->type, event->code); 173 | } 174 | mInputReader.next(); 175 | } 176 | 177 | return numEventReceived; 178 | } 179 | 180 | #endif /* SENSORS_STEP_DETECTOR_ENABLE */ 181 | -------------------------------------------------------------------------------- /StepDetectorSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_STEP_DETECTOR_ENABLE == 1) 21 | 22 | #ifndef ANDROID_STEP_DETECTOR_SENSOR_H 23 | #define ANDROID_STEP_DETECTOR_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | 35 | struct input_event; 36 | 37 | class StepDetectorSensor : public SensorBase 38 | { 39 | static int mEnabled; 40 | InputEventCircularReader mInputReader; 41 | sensors_event_t mPendingEvent; 42 | 43 | private: 44 | static pthread_mutex_t dataMutex; 45 | int64_t timestamp; 46 | int32_t steps; 47 | 48 | public: 49 | StepDetectorSensor(); 50 | virtual ~StepDetectorSensor(); 51 | virtual int readEvents(sensors_event_t *data, int count); 52 | virtual bool hasPendingEvents() const; 53 | virtual int getWhatFromHandle(int32_t handle); 54 | virtual int setDelay(int32_t handle, int64_t ns); 55 | virtual int enable(int32_t handle, int enabled, int type); 56 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 57 | }; 58 | 59 | #endif // ANDROID_STEP_DETECTOR_SENSOR_H 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /StoreCalibration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba 4 | * Motion MEMS Product Div. 5 | * Copyright (C) 2008 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef _STORE_CALIBRATION_H 21 | #define _STORE_CALIBRATION_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "configuration.h" 31 | 32 | #if defined(STORE_CALIB_ENABLED) 33 | #define concat(first, second) first second 34 | #define PACKAGENAME "com.st.mems.st_gyrocal" 35 | #define CAL_FILE "calibration.txt" 36 | #define CAL_DIR "/data/" 37 | #define OBS_MASK (IN_MODIFY | IN_DELETE | IN_CREATE) 38 | #define NUM_OF_SENSORS 6 39 | #define NUM_OF_AXIS 3 40 | #define THD_SLEEP_USEC 3000000 41 | #define EVENT_SIZE (sizeof(struct inotify_event)) 42 | #define MAX_CHARS_PER_LINE 512 43 | #define DELIMITER " " 44 | #define MAX_TOKENS_PER_LINE 4 45 | #define EVENT_BUF_SIZE 512 46 | 47 | typedef float calib_out_t[NUM_OF_SENSORS][NUM_OF_AXIS]; 48 | 49 | typedef struct { 50 | uid_t uid; 51 | char isDebuggable; 52 | char dataDir[PATH_MAX]; 53 | char seinfo[PATH_MAX]; 54 | } PackageInfo; 55 | 56 | class StoreCalibration { 57 | private: 58 | StoreCalibration(); 59 | static void* checkChangesThread(void *arg); 60 | static void readCalibrationFile(); 61 | static int eventCheck(int fd); 62 | 63 | static int instanceCount; 64 | static StoreCalibration *single; 65 | static calib_out_t calibration; 66 | static time_t oldMTime; 67 | static int observer_fd; 68 | static int watch_fd; 69 | static int cal_file; 70 | pthread_t thread; 71 | static bool is_changed; 72 | 73 | public: 74 | enum { 75 | GYROSCOPE_BIAS = 0, 76 | GYROSCOPE_SENS, 77 | ACCELEROMETER_BIAS, 78 | ACCELEROMETER_SENS, 79 | MAGNETOMETER_BIAS, 80 | MAGNETOMETER_SENS, 81 | SPEC_NUM, 82 | }; 83 | 84 | enum { 85 | XAxis = 0, 86 | YAxis, 87 | ZAxis, 88 | NumAxis, 89 | }; 90 | 91 | static StoreCalibration* getInstance(); 92 | ~StoreCalibration() { 93 | instanceCount--; 94 | if (instanceCount == 0) { 95 | inotify_rm_watch(observer_fd, watch_fd); 96 | } 97 | } 98 | float getCalibration(int sensorId, int axis); 99 | bool isChanged(); 100 | }; 101 | #endif /* STORE_CALIB_ENABLED */ 102 | #endif /* _STORE_CALIBRATION_H */ -------------------------------------------------------------------------------- /TapSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_TAP_ENABLE == 1) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | #include 38 | 39 | #include "TapSensor.h" 40 | 41 | 42 | /*****************************************************************************/ 43 | int TapSensor::mEnabled = 0; 44 | 45 | TapSensor::TapSensor() 46 | : SensorBase(NULL, SENSOR_DATANAME_TAP), 47 | mInputReader(4) 48 | { 49 | mPendingEvent.version = sizeof(sensors_event_t); 50 | mPendingEvent.sensor = ID_TAP; 51 | mPendingEvent.type = SENSOR_TYPE_TAP; 52 | mPendingEvent.data[0] = 1.0f; 53 | 54 | if (data_fd) { 55 | STLOGI("TapSensor::TapSensor device_sysfs_path:(%s)", sysfs_device_path); 56 | } else { 57 | STLOGE("TapSensor::TapSensor device_sysfs_path:(%s) not found", sysfs_device_path); 58 | } 59 | } 60 | 61 | TapSensor::~TapSensor() 62 | { 63 | if (mEnabled) { 64 | enable(SENSORS_TAP_HANDLE, 0, 0); 65 | } 66 | } 67 | 68 | int TapSensor::enable(int32_t handle, int en, int __attribute__((unused))type) 69 | { 70 | int err = 0; 71 | int flags = en ? 1 : 0; 72 | int mEnabledPrev; 73 | 74 | if (flags) { 75 | if (!mEnabled) { 76 | err = writeEnable(SENSORS_TAP_HANDLE, flags); 77 | if(err >= 0) 78 | err = 0; 79 | } 80 | mEnabled = 1; 81 | } else { 82 | if (mEnabled){ 83 | err = writeEnable(SENSORS_TAP_HANDLE, flags); 84 | if(err >= 0) { 85 | err = 0; 86 | mEnabled = 0; 87 | } 88 | } 89 | } 90 | 91 | if(err >= 0 ) { 92 | STLOGD("TapSensor::enable(%d), handle: %d, mEnabled: %d", 93 | flags, handle, mEnabled); 94 | } else { 95 | STLOGE("TapSensor::enable(%d), handle: %d, mEnabled: %d", 96 | flags, handle, mEnabled); 97 | } 98 | 99 | return err; 100 | } 101 | 102 | int TapSensor::getWhatFromHandle(int32_t __attribute__((unused))handle) 103 | { 104 | return 0; 105 | } 106 | 107 | bool TapSensor::hasPendingEvents() const 108 | { 109 | return false; 110 | } 111 | 112 | int TapSensor::setDelay(int32_t __attribute__((unused))handle, 113 | int64_t __attribute__((unused))delay_ns) 114 | { 115 | return 0; 116 | } 117 | 118 | int TapSensor::readEvents(sensors_event_t* data, int count) 119 | { 120 | if (count < 1) 121 | return -EINVAL; 122 | 123 | ssize_t n = mInputReader.fill(data_fd); 124 | if (n < 0) 125 | return n; 126 | 127 | int numEventReceived = 0; 128 | input_event const* event; 129 | 130 | while (count && mInputReader.readEvent(&event)) { 131 | 132 | if (event->type == EVENT_TYPE_TAP) { 133 | 134 | #if (DEBUG_TAP == 1) 135 | STLOGD("TapSensor::readEvents (event_code=%d)", event->code); 136 | #endif 137 | switch(event->code) { 138 | case EVENT_TYPE_TAP_DATA: 139 | 140 | break; 141 | #if defined(INPUT_EVENT_HAS_TIMESTAMP) 142 | case EVENT_TYPE_TIME_MSB: 143 | timestamp = ((int64_t)(event->value)) << 32; 144 | 145 | break; 146 | case EVENT_TYPE_TIME_LSB: 147 | timestamp |= (uint32_t)(event->value); 148 | 149 | break; 150 | #endif 151 | default: 152 | STLOGE("TapSensor: unknown event code \ 153 | (type = %d, code = %d)", event->type, 154 | event->code); 155 | } 156 | } else if (event->type == EV_SYN) { 157 | 158 | #if !defined(INPUT_EVENT_HAS_TIMESTAMP) 159 | timestamp = timevalToNano(event->time); 160 | #endif 161 | mPendingEvent.timestamp = timestamp; 162 | memcpy(data, &mPendingEvent, sizeof(mPendingEvent)); 163 | data++; 164 | count--; 165 | numEventReceived++; 166 | #if (DEBUG_TAP == 1) 167 | STLOGD("TapSensor::readEvents (time = %lld), count(%d), received(%d)", 168 | mPendingEvent.timestamp, 169 | count, numEventReceived); 170 | #endif 171 | 172 | } else { 173 | STLOGE("TapSensor: unknown event (type=%d, code=%d)", 174 | event->type, event->code); 175 | } 176 | no_data: 177 | mInputReader.next(); 178 | } 179 | 180 | return numEventReceived; 181 | } 182 | 183 | #endif /* SENSORS_TAP_ENABLE */ 184 | -------------------------------------------------------------------------------- /TapSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_TAP_ENABLE == 1) 21 | 22 | #ifndef ANDROID_TAP_SENSOR_H 23 | #define ANDROID_TAP_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | 35 | struct input_event; 36 | 37 | class TapSensor : public SensorBase 38 | { 39 | static int mEnabled; 40 | InputEventCircularReader mInputReader; 41 | sensors_event_t mPendingEvent; 42 | 43 | private: 44 | static pthread_mutex_t dataMutex; 45 | int64_t timestamp; 46 | int32_t steps; 47 | 48 | public: 49 | TapSensor(); 50 | virtual ~TapSensor(); 51 | virtual int readEvents(sensors_event_t *data, int count); 52 | virtual bool hasPendingEvents() const; 53 | virtual int getWhatFromHandle(int32_t handle); 54 | virtual int setDelay(int32_t handle, int64_t ns); 55 | virtual int enable(int32_t handle, int enabled, int type); 56 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 57 | }; 58 | 59 | #endif // ANDROID_TAP_SENSOR_H 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /TempSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | 21 | /* Standalone Temperature sensor */ 22 | #if (SENSORS_TEMP_ENABLE == 1) 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #if defined(PLTF_LINUX_ENABLED) 33 | #else /* PLTF_LINUX_ENABLED */ 34 | #if (ANDROID_VERSION >= ANDROID_P) 35 | #include 36 | #else 37 | #include 38 | #endif 39 | #endif /* PLTF_LINUX_ENABLED */ 40 | 41 | #include "TempSensor.h" 42 | 43 | int TempSensor::current_fullscale = 0; 44 | int unsigned TempSensor::mEnabled = 0; 45 | 46 | TempSensor::TempSensor() : 47 | SensorBase(NULL, SENSOR_DATANAME_TERMOMETER), 48 | mPendingMask(0), 49 | mInputReader(4), 50 | mHasPendingEvent(false) 51 | { 52 | memset(mPendingEvents, 0, sizeof(mPendingEvents)); 53 | 54 | mPendingEvents[Temperature].version = sizeof(sensors_event_t); 55 | mPendingEvents[Temperature].sensor = ID_TEMPERATURE; 56 | mPendingEvents[Temperature].type = SENSOR_TYPE_TEMPERATURE; 57 | 58 | if (data_fd) { 59 | STLOGI("TempSensor::TempSensor temp_device_sysfs_path:(%s)", sysfs_device_path); 60 | } else { 61 | STLOGE("TempSensor::TempSensor temp_device_sysfs_path:(%s) not found", sysfs_device_path); 62 | } 63 | } 64 | 65 | TempSensor::~TempSensor() 66 | { 67 | if (mEnabled) { 68 | enable(SENSORS_TEMPERATURE_HANDLE, 0, 0); 69 | } 70 | } 71 | 72 | int TempSensor::setInitialState() 73 | { 74 | struct input_absinfo absinfo_temperature; 75 | float value; 76 | 77 | if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_TEMPERATURE), &absinfo_temperature)) 78 | { 79 | value = absinfo_temperature.value; 80 | mPendingEvents[Temperature].temperature = TEMPERATURE_OFFSET + value * CONVERT_TEMP; 81 | mHasPendingEvent = true; 82 | } 83 | 84 | return 0; 85 | } 86 | 87 | int TempSensor::getWhatFromHandle(int32_t handle) 88 | { 89 | int what = -1; 90 | 91 | switch(handle) { 92 | case SENSORS_TEMPERATURE_HANDLE: 93 | what = Temperature; 94 | break; 95 | default: 96 | what = -1; 97 | } 98 | 99 | return what; 100 | } 101 | 102 | int TempSensor::writeSensorDelay(int handle) 103 | { 104 | int err = writeDelay(handle, delayms); 105 | 106 | return err >= 0 ? 0 : err; 107 | } 108 | 109 | int TempSensor::enable(int32_t handle, int en, int type __attribute__((unused))) 110 | { 111 | int err = 0; 112 | int what = -1; 113 | static int enabled = 0; 114 | 115 | what = getWhatFromHandle(handle); 116 | if (what < 0) 117 | return what; 118 | 119 | if(en) { 120 | err = writeSensorDelay(handle); 121 | if (err < 0) 122 | return err; 123 | 124 | if(mEnabled == 0) { 125 | enabled = 1; 126 | err = writeEnable(SENSORS_TEMPERATURE_HANDLE, 1); 127 | } 128 | if(err >= 0) { 129 | mEnabled |= (1<= 0) { 184 | err = 0; 185 | current_fullscale = value; 186 | } 187 | } 188 | return err; 189 | } 190 | 191 | int TempSensor::readEvents(sensors_event_t* data, int count) 192 | { 193 | static float lastTempValue = 0.0f; 194 | #if defined(TEMP_EVENT_HAS_TIMESTAMP) 195 | int64_t timestamp; 196 | #endif 197 | 198 | #if DEBUG_TEMPERATURE_SENSOR == 1 199 | STLOGD("TempSensor::readEvents (count=%d)",count); 200 | #endif 201 | 202 | if (count < 1) 203 | return -EINVAL; 204 | 205 | if (mHasPendingEvent) { 206 | mHasPendingEvent = false; 207 | } 208 | 209 | ssize_t n = mInputReader.fill(data_fd); 210 | if (n < 0) 211 | return n; 212 | 213 | int numEventReceived = 0; 214 | input_event const* event; 215 | 216 | while (count && mInputReader.readEvent(&event)) { 217 | #if DEBUG_TEMPERATURE_SENSOR == 1 218 | STLOGD("TempSensor::readEvents (count=%d),type(%d)", count, event->type); 219 | #endif 220 | 221 | if (event->type == EV_MSC) { 222 | int value = event->value; 223 | 224 | if (event->code == EVENT_TYPE_TEMPERATURE) { 225 | lastTempValue = value; 226 | mPendingEvents[Temperature].temperature = TEMPERATURE_OFFSET + value * CONVERT_TEMP; 227 | } 228 | #if defined(TEMP_EVENT_HAS_TIMESTAMP) 229 | else if (event->code == EVENT_TYPE_TIME_MSB) { 230 | timestamp = ((int64_t)(event->value)) << 32; 231 | } 232 | else if (event->code == EVENT_TYPE_TIME_LSB) { 233 | timestamp |= (uint32_t)(event->value); 234 | } 235 | #endif 236 | } else if (event->type == EV_SYN) { 237 | if(mEnabled & (1 << Temperature)) 238 | mPendingMask |= 1 << Temperature; 239 | 240 | #if !defined(TEMP_EVENT_HAS_TIMESTAMP) 241 | timestamp = timevalToNano(event->time); 242 | #endif 243 | for (int j = 0; count && mPendingMask && (j < numSensors); j++) { 244 | if (mPendingMask & (1 << j)) { 245 | mPendingMask &= ~(1 << j); 246 | mPendingEvents[j].timestamp = timestamp; 247 | if (mEnabled & (1 << j)) { 248 | *data++ = mPendingEvents[j]; 249 | count--; 250 | numEventReceived++; 251 | } 252 | } 253 | } 254 | } 255 | mInputReader.next(); 256 | } 257 | 258 | return numEventReceived; 259 | } 260 | 261 | #endif /* SENSORS_TEMP_ENABLE */ 262 | -------------------------------------------------------------------------------- /TempSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSORS_TEMP_ENABLE == 1) 21 | 22 | #ifndef ANDROID_TEMP_SENSOR_H 23 | #define ANDROID_TEMP_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | 34 | class TempSensor : public SensorBase { 35 | private: 36 | enum { 37 | Temperature, 38 | numSensors 39 | }; 40 | static unsigned int mEnabled; 41 | static int current_fullscale; 42 | uint32_t mPendingMask; 43 | InputEventCircularReader mInputReader; 44 | sensors_event_t mPendingEvents[numSensors]; 45 | bool mHasPendingEvent; 46 | 47 | int setInitialState(); 48 | 49 | enum channelid{ 50 | tempChan = 0 51 | }; 52 | int64_t delayms; 53 | 54 | //char device_sysfs_path_prs[PATH_MAX]; 55 | //int device_sysfs_path_prs_len; 56 | int writeSensorDelay(int handle); 57 | public: 58 | TempSensor(); 59 | virtual ~TempSensor(); 60 | virtual int readEvents(sensors_event_t* data, int count); 61 | virtual bool hasPendingEvents() const { return mHasPendingEvent; } 62 | virtual int setDelay(int32_t handle, int64_t ns); 63 | virtual int setFullScale(int32_t handle, int value); 64 | virtual int enable(int32_t handle, int enabled, int type); 65 | virtual int getWhatFromHandle(int32_t handle); 66 | }; 67 | 68 | #endif // ANDROID_TEMP_SENSOR_H 69 | #endif /* SENSORS_TEMP_ENABLE */ 70 | -------------------------------------------------------------------------------- /TiltSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if ((SENSORS_TILT_ENABLE == 1) && (ANDROID_VERSION >= ANDROID_L)) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(PLTF_LINUX_ENABLED) 30 | #else /* PLTF_LINUX_ENABLED */ 31 | #if (ANDROID_VERSION >= ANDROID_P) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #endif /* PLTF_LINUX_ENABLED */ 37 | #include 38 | #include "TiltSensor.h" 39 | 40 | 41 | /*****************************************************************************/ 42 | int TiltSensor::mEnabled = 0; 43 | 44 | TiltSensor::TiltSensor() 45 | : SensorBase(NULL, SENSOR_DATANAME_TILT), 46 | mInputReader(4) 47 | { 48 | mPendingEvent.version = sizeof(sensors_event_t); 49 | mPendingEvent.sensor = ID_TILT_DETECTOR; 50 | mPendingEvent.type = SENSOR_TYPE_TILT_DETECTOR; 51 | mPendingEvent.data[0] = 1.0f; 52 | 53 | if (data_fd) { 54 | STLOGI("TiltSensor::TiltSensor device_sysfs_path:(%s)", sysfs_device_path); 55 | } else { 56 | STLOGE("TiltSensor::TiltSensor device_sysfs_path:(%s) not found", sysfs_device_path); 57 | } 58 | } 59 | 60 | TiltSensor::~TiltSensor() 61 | { 62 | if (mEnabled) 63 | enable(SENSORS_TILT_DETECTOR_HANDLE, 0, 0); 64 | } 65 | 66 | int TiltSensor::enable(int32_t handle, int en, int __attribute__((unused))type) 67 | { 68 | int err = 0; 69 | int flags = en ? 1 : 0; 70 | 71 | if (flags) { 72 | if (!mEnabled) { 73 | err = writeEnable(SENSORS_TILT_DETECTOR_HANDLE, flags); 74 | if(err >= 0) 75 | err = 0; 76 | } 77 | mEnabled = 1; 78 | } else { 79 | if (mEnabled){ 80 | err = writeEnable(SENSORS_TILT_DETECTOR_HANDLE, flags); 81 | if(err >= 0) { 82 | err = 0; 83 | mEnabled = 0; 84 | } 85 | } 86 | } 87 | 88 | if(err >= 0 ) { 89 | STLOGD("TiltSensor::enable(%d), handle: %d, mEnabled: %d", 90 | flags, handle, mEnabled); 91 | } else { 92 | STLOGE("TiltSensor::enable(%d), handle: %d, mEnabled: %d", 93 | flags, handle, mEnabled); 94 | } 95 | 96 | return err; 97 | } 98 | 99 | int TiltSensor::getWhatFromHandle(int32_t __attribute__((unused))handle) 100 | { 101 | return 0; 102 | } 103 | 104 | bool TiltSensor::hasPendingEvents() const 105 | { 106 | return false; 107 | } 108 | 109 | int TiltSensor::setDelay(int32_t __attribute__((unused))handle, 110 | int64_t __attribute__((unused))delay_ns) 111 | { 112 | ALOGD("SetDelay not allowed for Tilt sensor"); 113 | 114 | return 0; 115 | } 116 | 117 | int TiltSensor::readEvents(sensors_event_t* data, int count) 118 | { 119 | int numEventReceived = 0; 120 | input_event const* event; 121 | 122 | if (count < 1) 123 | return -EINVAL; 124 | 125 | ssize_t n = mInputReader.fill(data_fd); 126 | if (n < 0) 127 | return n; 128 | 129 | while (count && mInputReader.readEvent(&event)) { 130 | if (event->type == EVENT_TYPE_TILT) { 131 | #if (DEBUG_TILT == 1) 132 | STLOGD("TiltSensor::readEvents (event_code=%d)", event->code); 133 | #endif 134 | switch(event->code) { 135 | case EVENT_TYPE_TILT_DATA: 136 | tilt_data = event->value; 137 | 138 | break; 139 | #if defined(INPUT_EVENT_HAS_TIMESTAMP) 140 | case EVENT_TYPE_TIME_MSB: 141 | timestamp = ((int64_t)(event->value)) << 32; 142 | 143 | break; 144 | case EVENT_TYPE_TIME_LSB: 145 | timestamp |= (uint32_t)(event->value); 146 | 147 | break; 148 | #endif 149 | default: 150 | STLOGE("TiltSensor: unknown event code (type = %d, code = %d)", 151 | event->type, event->code); 152 | } 153 | } else if (event->type == EV_SYN) { 154 | #if !defined(INPUT_EVENT_HAS_TIMESTAMP) 155 | timestamp = timevalToNano(event->time); 156 | #endif 157 | mPendingEvent.timestamp = timestamp; 158 | memcpy(data, &mPendingEvent, sizeof(mPendingEvent)); 159 | data++; 160 | count--; 161 | numEventReceived++; 162 | #if (DEBUG_TILT == 1) 163 | STLOGD("TiltSensor::readEvents (time = %lld), count(%d), received(%d)", 164 | mPendingEvent.timestamp, 165 | count, numEventReceived); 166 | #endif 167 | } else { 168 | STLOGE("TiltSensor: unknown event (type=%d, code=%d)", 169 | event->type, event->code); 170 | } 171 | mInputReader.next(); 172 | } 173 | 174 | return numEventReceived; 175 | } 176 | 177 | #endif /* SENSORS_TILT_ENABLE */ 178 | -------------------------------------------------------------------------------- /TiltSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2015 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if ((SENSORS_TILT_ENABLE == 1) && (ANDROID_VERSION >= ANDROID_L)) 21 | 22 | #ifndef ANDROID_TILT_SENSOR_H 23 | #define ANDROID_TILT_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include "sensors.h" 32 | #include "SensorBase.h" 33 | #include "InputEventReader.h" 34 | 35 | struct input_event; 36 | 37 | class TiltSensor : public SensorBase 38 | { 39 | static int mEnabled; 40 | InputEventCircularReader mInputReader; 41 | sensors_event_t mPendingEvent; 42 | 43 | private: 44 | static pthread_mutex_t dataMutex; 45 | int64_t timestamp; 46 | int32_t tilt_data; 47 | 48 | public: 49 | TiltSensor(); 50 | virtual ~TiltSensor(); 51 | virtual int readEvents(sensors_event_t *data, int count); 52 | virtual bool hasPendingEvents() const; 53 | virtual int getWhatFromHandle(int32_t handle); 54 | virtual int setDelay(int32_t handle, int64_t ns); 55 | virtual int enable(int32_t handle, int enabled, int type); 56 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 57 | }; 58 | 59 | #endif // ANDROID_TILT_SENSOR_H 60 | #endif /* ANDROID_VERSION */ 61 | -------------------------------------------------------------------------------- /VirtualGyroSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Alberto Marinoni, Giuseppe Barba 4 | * Motion MEMS Product Div. 5 | * Copyright (C) 2008 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "configuration.h" 21 | #if (SENSORS_VIRTUAL_GYROSCOPE_ENABLE == 1) 22 | 23 | #ifndef ANDROID_VIRTUAL_GYRO_SENSOR_H 24 | #define ANDROID_VIRTUAL_GYRO_SENSOR_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | #include "sensors.h" 33 | #include "SensorBase.h" 34 | #include "InputEventReader.h" 35 | #include "MagnSensor.h" 36 | #include "AccelSensor.h" 37 | 38 | extern "C" 39 | { 40 | #include "iNemoEngineGeoMagAPI.h" 41 | }; 42 | 43 | /*****************************************************************************/ 44 | 45 | struct input_event; 46 | 47 | class VirtualGyroSensor : public SensorBase 48 | { 49 | enum { 50 | Acceleration = 0, 51 | MagneticField, 52 | VirtualGyro, 53 | iNemoGyro, 54 | numSensors 55 | }; 56 | static int mEnabled; 57 | static int64_t delayms; 58 | static int current_fullscale; 59 | sensors_event_t mPendingEvent[numSensors]; 60 | int setInitialState(); 61 | InputEventCircularReader mInputReader; 62 | bool mHasPendingEvent; 63 | sensors_vec_t mSensorsBufferedVectors[2]; 64 | 65 | private: 66 | static int startup_samples; 67 | static int samples_to_discard; 68 | static sensors_vec_t dataBuffer; 69 | static int64_t MagDelay_ms; 70 | static int64_t setDelayBuffer[numSensors]; 71 | static int DecimationBuffer[numSensors]; 72 | static int DecimationCount; 73 | virtual bool setBufferData(sensors_vec_t *value); 74 | 75 | float gyro[3]; 76 | MagnSensor *mag; 77 | AccelSensor *acc; 78 | static pthread_mutex_t dataMutex; 79 | 80 | public: 81 | VirtualGyroSensor(); 82 | virtual ~VirtualGyroSensor(); 83 | virtual int readEvents(sensors_event_t *data, int count); 84 | virtual bool hasPendingEvents() const; 85 | virtual int setDelay(int32_t handle, int64_t ns); 86 | virtual void updateDecimations(int64_t Delay_ms); 87 | virtual int setFullScale(int32_t handle, int value); 88 | virtual int enable(int32_t handle, int enabled, int type); 89 | static bool getBufferData(sensors_vec_t *lastBufferedValues); 90 | static void getGyroDelay(int64_t *Gyro_Delay_ms); 91 | virtual int getWhatFromHandle(int32_t handle); 92 | }; 93 | 94 | #endif // ANDROID_VIRTUAL_GYRO_SENSOR_H 95 | 96 | #endif /* SENSORS_GYROSCOPE_ENABLE */ 97 | -------------------------------------------------------------------------------- /conf/conf_A3G4250D.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_A3G4250D_H 21 | #define CONFIGURATION_A3G4250D_H 22 | 23 | #define SENSORS_GYROSCOPE_ENABLE (1) 24 | #define SENSORS_UNCALIB_GYROSCOPE_ENABLE (1 & SENSORS_GYROSCOPE_ENABLE & OS_VERSION_ENABLE) 25 | 26 | /* GYROSCOPE SENSOR */ 27 | #define SENSOR_GYRO_LABEL "A3G4250D 3-axis Gyroscope sensor" // Label views in Android Applications 28 | #define SENSOR_UNCALIB_GYRO_LABEL "A3G4250D 3-axis Uncalibrated Gyroscope sensor" 29 | #define SENSOR_DATANAME_GYROSCOPE "a3g4250d_gyr" // Name of input device: struct input_dev->name 30 | #define GYRO_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 31 | #define GYRO_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 32 | #define GYRO_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 33 | #define GYRO_MAX_RANGE (245.0f*(float)M_PI/180.0f) // Set Max Full-scale [rad/sec] 34 | #define GYRO_MAX_ODR 200 // Set Max value of ODR [Hz] 35 | #define GYRO_POWER_CONSUMPTION 6.1f // Set sensor's power consumption [mA] 36 | #define GYRO_DEFAULT_FULLSCALE 245 // Set default full-scale (value depends on the driver sysfs file) 37 | 38 | 39 | /* INEMO_ENGINE SENSOR */ 40 | #define GYRO_DEFAULT_RANGE 245 // full scale set to 2000 DPS (value depends on the driver sysfs file) 41 | #define GYR_DEFAULT_DELAY 10 // 1/frequency (default: 9.523809f -> 105 Hz) [ms] 42 | 43 | /* SENSOR FUSION */ 44 | #define GYROSCOPE_ACTIVE 1 // Enable Gyroscope sensor in Sensor Fusion -> [0]:off, [1]:on 45 | #define GYR_GBIAS_THRESHOLD 475e-6 // Set gyroscope gbias threshold [uT] - Default value for L3G4200D: 400e-6 46 | 47 | /* GYROSCOPE STARTUP */ 48 | #define DEFAULT_SAMPLES_TO_DISCARD (20) 49 | #define GYRO_STARTUP_TIME_MS (200) 50 | 51 | /*****************************************************************************/ 52 | /* EVENT TYPE */ 53 | /*****************************************************************************/ 54 | /* Event Type in gyroscope sensor: see input_set_abs_params() function in your input driver */ 55 | #define EVENT_TYPE_GYRO EV_MSC 56 | 57 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 58 | #define EVENT_TYPE_TIME_LSB MSC_MAX 59 | #define EVENT_TYPE_GYRO_X MSC_SERIAL 60 | #define EVENT_TYPE_GYRO_Y MSC_PULSELED 61 | #define EVENT_TYPE_GYRO_Z MSC_GESTURE 62 | 63 | /*****************************************************************************/ 64 | /* AXIS MAPPING */ 65 | /*****************************************************************************/ 66 | 67 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 68 | * 69 | * Example: 70 | * y' /| z' 71 | * ^ / 72 | * | / You must define this coordinate system (reference system of board) 73 | * | / in accordance to definition of the axis 74 | * |/ definition in sensors.h file 75 | * +----------------------------------------------+---------> x' 76 | * | ^ x | 77 | * | | ^ z | 78 | * | | | | 79 | * | +-----+---> y | | 80 | * | | ACC | <---+-----+ | 81 | * | | | x | GYR | | 82 | * | +-----+ | | | 83 | * | / +-----+ | 84 | * | |/ y ^ /| z / | 85 | * | z | / |/ | 86 | * | |/ y | 87 | * | +-----+---> x | 88 | * | | MAG | | 89 | * | | | | 90 | * | +-----+ | 91 | * | BOARD | 92 | * +----------------------------------------------+ 93 | * 94 | * 95 | * GYROSCOPE: 96 | * 97 | * board gyr | -1 0 0 | 98 | * [x' y' z'] = [x y z] * | 1 0 0 | 99 | * | 0 -1 0 | 100 | * 101 | */ 102 | 103 | static short matrix_gyr[3][3] = { 104 | { 1, 0, 0 }, 105 | { 0, 1, 0 }, 106 | { 0, 0, 1 } 107 | }; 108 | 109 | /*****************************************************************************/ 110 | /* DATA CONVERSION */ 111 | /*****************************************************************************/ 112 | // conversion of gyro data to SI units (radian/sec) 113 | #define CONVERT_GYRO ((8.75f*((float)M_PI)) / 180000.0f) 114 | #define CONVERT_GYRO_X (CONVERT_GYRO) 115 | #define CONVERT_GYRO_Y (CONVERT_GYRO) 116 | #define CONVERT_GYRO_Z (CONVERT_GYRO) 117 | 118 | #define GYRO_EVENT_HAS_TIMESTAMP 1 119 | 120 | #endif /* CONFIGURATION_A3G4250D_H */ 121 | -------------------------------------------------------------------------------- /conf/conf_ACCELCALIB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Armando Visconti - Motion MEMS Product Div. 4 | * Copyright (C) 2017 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_ACCELCAL_H 21 | #define CONFIGURATION_ACCELCAL_H 22 | 23 | #define ACCEL_CALIBRATION_ENABLE (1 & ST_ACCEL_CALIB_MODULE_PRESENT & SENSORS_ACCELEROMETER_ENABLE) 24 | #define ACCEL_CALIB_FREQUENCY (25) 25 | #define ACCEL_CALIB_PERIOD_MS (1000.0f / ACCEL_CALIB_FREQUENCY) 26 | 27 | #endif /* CONFIGURATION_ACCELCAL_H */ 28 | 29 | -------------------------------------------------------------------------------- /conf/conf_ACT_RECO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_ACTIVITY_RECO_H 20 | #define CONFIGURATION_ACTIVITY_RECO_H 21 | 22 | #define SENSORS_ACTIVITY_RECOGNIZER_ENABLE (1 && ACTIVITY_RECOGNIZER_MODULE_PRESENT && SENSORS_ACCELEROMETER_ENABLE) 23 | #define SENSORS_ACTIVITY_RECOGNIZER_POWER ACCEL_POWER_CONSUMPTION 24 | #define SENSOR_ACTIVITY_RECOGNIZERO_LABEL "Activity Recognition" 25 | #define SENSOR_STRING_TYPE_ACTIVITY "com.st.activity" 26 | #define ACTIVITY_RECOGNIZER_ODR 16 27 | 28 | #endif -------------------------------------------------------------------------------- /conf/conf_AIS328DQ.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_AIS328DQ_H 20 | #define CONFIGURATION_AIS328DQ_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | 24 | /* ACCELEROMETER SENSOR */ 25 | #define SENSOR_ACC_LABEL "AIS328DQ 3-axis Accelerometer" // Label views in Android Applications 26 | #define SENSOR_DATANAME_ACCELEROMETER "ais328dq_acc" // Name of input device: struct input_dev->name 27 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 28 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 29 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 30 | #define ACCEL_MAX_RANGE 8*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 31 | #define ACCEL_MAX_ODR 200 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 32 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 33 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 34 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 35 | /*****************************************************************************/ 36 | /* EVENT TYPE */ 37 | /*****************************************************************************/ 38 | #define EVENT_TYPE_ACCEL EV_MSC 39 | 40 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 41 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 42 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 43 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 44 | 45 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 46 | #define EVENT_TYPE_TIME_LSB MSC_MAX 47 | 48 | /*****************************************************************************/ 49 | /* AXIS MAPPING */ 50 | /*****************************************************************************/ 51 | 52 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 53 | * 54 | * Example: 55 | * y' /| z' 56 | * ^ / 57 | * | / You must define this coordinate system (reference system of board) 58 | * | / in accordance to definition of the axis 59 | * |/ definition in sensors.h file 60 | * +----------------------------------------------+---------> x' 61 | * | ^ x | 62 | * | | ^ z | 63 | * | | | | 64 | * | +-----+---> y | | 65 | * | | ACC | <---+-----+ | 66 | * | | | x | GYR | | 67 | * | +-----+ | | | 68 | * | / +-----+ | 69 | * | |/ y ^ /| z / | 70 | * | z | / |/ | 71 | * | |/ y | 72 | * | +-----+---> x | 73 | * | | MAG | | 74 | * | | | | 75 | * | +-----+ | 76 | * | BOARD | 77 | * +----------------------------------------------+ 78 | * 79 | * ACCELEROMETER: 80 | * 81 | * board acc | 0 1 0 | 82 | * [x' y' z'] = [x y z] * | 1 0 0 | 83 | * | 0 0 -1 | 84 | * 85 | */ 86 | 87 | static short matrix_acc[3][3] = { 88 | { 1, 0, 0 }, 89 | { 0, 1, 0 }, 90 | { 0, 0, 1 } 91 | }; 92 | 93 | /*****************************************************************************/ 94 | /* DATA CONVERSION */ 95 | /*****************************************************************************/ 96 | // conversion of acceleration data to SI units (m/s^2) 97 | #define CONVERT_A (GRAVITY_EARTH/1000) // 1000mg = 9.86 m/s^2 98 | #define CONVERT_A_X (CONVERT_A) 99 | #define CONVERT_A_Y (CONVERT_A) 100 | #define CONVERT_A_Z (CONVERT_A) 101 | 102 | #define ACC_EVENT_HAS_TIMESTAMP 1 103 | 104 | #endif /* CONFIGURATION_AIS328DQ_H */ 105 | -------------------------------------------------------------------------------- /conf/conf_FILE_CALIB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_FILE_CALIB_H 20 | #define CONFIGURATION_FILE_CALIB_H 21 | 22 | #define STORE_CALIB_ACCEL_ENABLED 1 23 | #define STORE_CALIB_GYRO_ENABLED 1 24 | #define STORE_CALIB_ENABLED STORE_CALIB_GYRO_ENABLED 25 | #endif 26 | -------------------------------------------------------------------------------- /conf/conf_FUSION.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_FUSION_H 21 | #define CONFIGURATION_FUSION_H 22 | 23 | #define REAL_9AXIS_AVAILABLE (SENSORS_ACCELEROMETER_ENABLE && SENSORS_MAGNETIC_FIELD_ENABLE && SENSORS_GYROSCOPE_ENABLE) 24 | #define REAL_6AXIS_AVAILABLE (SENSORS_ACCELEROMETER_ENABLE && SENSORS_GYROSCOPE_ENABLE && !SENSORS_MAGNETIC_FIELD_ENABLE) 25 | #define VIRTUAL_9AXIS_AVAILABLE (SENSORS_ACCELEROMETER_ENABLE && SENSORS_MAGNETIC_FIELD_ENABLE && SENSORS_VIRTUAL_GYROSCOPE_ENABLE) 26 | #define SENSORS_ORIENTATION_ENABLE (1 && (REAL_9AXIS_AVAILABLE || VIRTUAL_9AXIS_AVAILABLE) && SENSOR_FUSION_MODULE_PRESENT) 27 | #define SENSORS_GRAVITY_ENABLE (1 && (REAL_9AXIS_AVAILABLE || VIRTUAL_9AXIS_AVAILABLE || REAL_6AXIS_AVAILABLE) && SENSOR_FUSION_MODULE_PRESENT) 28 | #define SENSORS_LINEAR_ACCELERATION_ENABLE (1 && (REAL_9AXIS_AVAILABLE || VIRTUAL_9AXIS_AVAILABLE || REAL_6AXIS_AVAILABLE) && SENSOR_FUSION_MODULE_PRESENT) 29 | #define SENSORS_ROTATION_VECTOR_ENABLE (1 && (REAL_9AXIS_AVAILABLE || VIRTUAL_9AXIS_AVAILABLE) && SENSOR_FUSION_MODULE_PRESENT) 30 | #define SENSORS_GAME_ROTATION_ENABLE (1 && SENSORS_ACCELEROMETER_ENABLE && (SENSORS_GYROSCOPE_ENABLE || SENSORS_VIRTUAL_GYROSCOPE_ENABLE) && OS_VERSION_ENABLE && SENSOR_FUSION_MODULE_PRESENT) 31 | #define SENSOR_FUSION_ENABLE (SENSOR_FUSION_MODULE_PRESENT && (SENSORS_ORIENTATION_ENABLE || SENSORS_GRAVITY_ENABLE || SENSORS_LINEAR_ACCELERATION_ENABLE || SENSORS_ROTATION_VECTOR_ENABLE || SENSORS_GAME_ROTATION_ENABLE)) 32 | #define FUSION_6AXIS (SENSORS_GYROSCOPE_ENABLE && SENSORS_ACCELEROMETER_ENABLE) 33 | #define FUSION_9AXIS (FUSION_6AXIS && SENSORS_MAGNETIC_FIELD_ENABLE) 34 | 35 | #if (FUSION_6AXIS && !FUSION_9AXIS) 36 | #define FUSION_CONSUMPTION (GYRO_POWER_CONSUMPTION + ACCEL_POWER_CONSUMPTION) 37 | #else 38 | #if (FUSION_9AXIS) 39 | #define FUSION_CONSUMPTION (GYRO_POWER_CONSUMPTION + MAGN_POWER_CONSUMPTION + ACCEL_POWER_CONSUMPTION) 40 | #else 41 | #define FUSION_CONSUMPTION (MAGN_POWER_CONSUMPTION + ACCEL_POWER_CONSUMPTION) 42 | #endif 43 | #endif 44 | 45 | #if (SENSORS_ORIENTATION_ENABLE == 1) 46 | #define ORIENTATION_POWER_CONSUMPTION (FUSION_CONSUMPTION) 47 | #define ORIENTATION_MAX_ODR (100) 48 | #define ORIENTATION_MIN_ODR (1) 49 | #endif 50 | 51 | #define GRAVITY_POWER_CONSUMPTION (FUSION_CONSUMPTION) 52 | #define LINEAR_ACCEL_POWER_CONSUMPTION (FUSION_CONSUMPTION) 53 | #define ROT_VEC_POWER_CONSUMPTION (FUSION_CONSUMPTION) 54 | #define FUSION_MAX_ODR (100) 55 | #define FUSION_MIN_ODR (1) 56 | 57 | #endif /* CONFIGURATION_FUSION_H */ 58 | -------------------------------------------------------------------------------- /conf/conf_GBIAS.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_GBIAS_H 21 | #define CONFIGURATION_GBIAS_H 22 | 23 | #define GYROSCOPE_GBIAS_CALIBRATION (1 & GYROSCOPE_GBIAS_MODULE_PRESENT & SENSORS_GYROSCOPE_ENABLE) 24 | 25 | /* GYROSCOPE BIAS ESTIMATION */ 26 | #define GYROSCOPE_GBIAS_ESTIMATION_FUSION (0 & GYROSCOPE_GBIAS_CALIBRATION & SENSOR_FUSION_ENABLE) 27 | #define GYROSCOPE_GBIAS_ESTIMATION_STANDALONE (1 & GYROSCOPE_GBIAS_CALIBRATION & !GYROSCOPE_GBIAS_ESTIMATION_FUSION) 28 | 29 | #endif /* CONFIGURATION_GBIAS_H */ 30 | -------------------------------------------------------------------------------- /conf/conf_GEOMAG.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_GEOMAG_H 21 | #define CONFIGURATION_GEOMAG_H 22 | 23 | #define SENSORS_GEOMAG_ROTATION_VECTOR_ENABLE (1 & GEOMAG_FUSION_MODULE_PRESENT & SENSORS_MAGNETIC_FIELD_ENABLE && SENSORS_ACCELEROMETER_ENABLE && OS_VERSION_ENABLE) 24 | #define GEOMAG_COMPASS_ORIENTATION_ENABLE (0 & GEOMAG_FUSION_MODULE_PRESENT & SENSORS_MAGNETIC_FIELD_ENABLE & SENSORS_ACCELEROMETER_ENABLE) 25 | #define GEOMAG_LINEAR_ACCELERATION_ENABLE (0 & GEOMAG_FUSION_MODULE_PRESENT & SENSORS_MAGNETIC_FIELD_ENABLE & SENSORS_ACCELEROMETER_ENABLE) 26 | #define GEOMAG_GRAVITY_ENABLE (0 & GEOMAG_FUSION_MODULE_PRESENT & SENSORS_MAGNETIC_FIELD_ENABLE & SENSORS_ACCELEROMETER_ENABLE) 27 | #define SENSOR_GEOMAG_ENABLE (SENSORS_GEOMAG_ROTATION_VECTOR_ENABLE || GEOMAG_COMPASS_ORIENTATION_ENABLE || GEOMAG_LINEAR_ACCELERATION_ENABLE || GEOMAG_GRAVITY_ENABLE) 28 | 29 | #define GEOMAG_FREQUENCY (100) 30 | 31 | #endif /* CONFIGURATION_GEOMAG_H */ 32 | -------------------------------------------------------------------------------- /conf/conf_HTS221.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_HTS221_H 20 | #define CONFIGURATION_HTS221_H 21 | 22 | #define SENSORS_HUMIDITY_ENABLE (0) 23 | #define SENSORS_TEMP_RH_ENABLE (1) 24 | 25 | #define SENSOR_HUMIDITY_LABEL "HTS221 Humidity sensor" // Label views in Android Applications 26 | #define SENSOR_TEMP_LABEL "HTS221 Temperature sensor" // Label views in Android Applications 27 | #define SENSOR_DATANAME_HUMIDITY "hts221" // Name of input device: struct input_dev->name 28 | #define HUMIDITY_DELAY_FILE_NAME "device/poll_ms" // name of sysfs file for setting the pollrate 29 | #define HUMIDITY_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 30 | #define HUMIDITY_DELAY_FILE_NAME "device/poll_ms" // name of sysfs file for setting the pollrate 31 | #define HUMIDITY_MAX_RANGE 80 // Set Max Full-scale [Celsius] 32 | #define TEMP_MAX_RANGE 80 // Set Max Full-scale [Celsius] 33 | #define HUMIDITY_MAX_ODR 13 // Set Max value of ODR [Hz] 34 | #define HUMIDITY_MIN_ODR 1 // Set Min value of ODR [Hz] 35 | #define HUMIDITY_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 36 | #define TEMP_MAX_ODR HUMIDITY_MAX_ODR // Set Max value of ODR [Hz] 37 | #define TEMP_MIN_ODR HUMIDITY_MIN_ODR // Set Min value of ODR [Hz] 38 | #define TEMP_POWER_CONSUMPTION HUMIDITY_POWER_CONSUMPTION // Set sensor's power consumption [mA] 39 | 40 | /*****************************************************************************/ 41 | /* EVENT TYPE */ 42 | /*****************************************************************************/ 43 | #define EVENT_TYPE_HUMIDITY MSC_PULSELED 44 | #define EVENT_TYPE_TEMPERATURE MSC_SERIAL 45 | 46 | /*****************************************************************************/ 47 | /* DATA CONVERSION */ 48 | /*****************************************************************************/ 49 | #define CONVERT_RH (1.0f/1000.0f) 50 | #define CONVERT_TEMP (1.0f/1000.0f) 51 | 52 | #endif /* CONFIGURATION_HTS221_H */ 53 | -------------------------------------------------------------------------------- /conf/conf_IIS2DH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 STMicroelectronics AMG/MSD Product Div. 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CONFIGURATION_IIS2DH_H 19 | #define CONFIGURATION_IIS2DH_H 20 | 21 | #define SENSORS_ACCELEROMETER_ENABLE (1) 22 | 23 | /* ACCELEROMETER SENSOR */ 24 | #define SENSOR_ACC_LABEL "LIS2DH 3-axis Accelerometer" // Label views in Android Applications 25 | #define SENSOR_DATANAME_ACCELEROMETER "lis2dh_acc" // Name of input device: struct input_dev->name 26 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 27 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 28 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 29 | #define ACCEL_MAX_RANGE 16*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 30 | #define ACCEL_MAX_ODR 200 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 31 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 32 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 33 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 34 | /*****************************************************************************/ 35 | /* EVENT TYPE */ 36 | /*****************************************************************************/ 37 | #define EVENT_TYPE_ACCEL EV_MSC 38 | 39 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 40 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 41 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 42 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 43 | 44 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 45 | #define EVENT_TYPE_TIME_LSB MSC_MAX 46 | 47 | /*****************************************************************************/ 48 | /* AXIS MAPPING */ 49 | /*****************************************************************************/ 50 | 51 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 52 | * 53 | * Example: 54 | * y' /| z' 55 | * ^ / 56 | * | / You must define this coordinate system (reference system of board) 57 | * | / in accordance to definition of the axis 58 | * |/ definition in sensors.h file 59 | * +----------------------------------------------+---------> x' 60 | * | ^ x | 61 | * | | ^ z | 62 | * | | | | 63 | * | +-----+---> y | | 64 | * | | ACC | <---+-----+ | 65 | * | | | x | GYR | | 66 | * | +-----+ | | | 67 | * | / +-----+ | 68 | * | |/ y ^ /| z / | 69 | * | z | / |/ | 70 | * | |/ y | 71 | * | +-----+---> x | 72 | * | | MAG | | 73 | * | | | | 74 | * | +-----+ | 75 | * | BOARD | 76 | * +----------------------------------------------+ 77 | * 78 | * ACCELEROMETER: 79 | * 80 | * board acc | 0 1 0 | 81 | * [x' y' z'] = [x y z] * | 1 0 0 | 82 | * | 0 0 -1 | 83 | * 84 | */ 85 | 86 | static short matrix_acc[3][3] = { 87 | { 1, 0, 0 }, 88 | { 0, 1, 0 }, 89 | { 0, 0, 1 } 90 | }; 91 | 92 | /*****************************************************************************/ 93 | /* DATA CONVERSION */ 94 | /*****************************************************************************/ 95 | // conversion of acceleration data to SI units (m/s^2) 96 | #define CONVERT_A (GRAVITY_EARTH/1000) // 1000mg = 9.86 m/s^2 97 | #define CONVERT_A_X (CONVERT_A) 98 | #define CONVERT_A_Y (CONVERT_A) 99 | #define CONVERT_A_Z (CONVERT_A) 100 | 101 | #define ACC_EVENT_HAS_TIMESTAMP 1 102 | 103 | #endif /* CONFIGURATION_IIS2DH_H */ 104 | -------------------------------------------------------------------------------- /conf/conf_IIS2MDC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 STMicroelectronics AMG/MSD Product Div. 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CONFIGURATION_IIS2MDC_H 19 | #define CONFIGURATION_IIS2MDC_H 20 | 21 | #define SENSORS_MAGNETIC_FIELD_ENABLE (1) 22 | #define SENSORS_UNCALIB_MAGNETIC_FIELD_ENABLE (1 & SENSORS_MAGNETIC_FIELD_ENABLE & OS_VERSION_ENABLE) 23 | 24 | /* MAGNETOMETER SENSOR */ 25 | #define SENSOR_MAGN_LABEL "IIS2MDC 3-axis Magnetometer Sensor" 26 | #define SENSOR_UNCALIB_MAGN_LABEL "IIS2MDC 3-axis Uncalibrated Magnetometer sensor" 27 | #define SENSOR_DATANAME_MAGNETIC_FIELD "ST IIS2MDC Magnetometer Sensor" 28 | #define MAGN_DELAY_FILE_NAME "magn/polling_rate" 29 | #define MAGN_ENABLE_FILE_NAME "magn/enable" 30 | #define MAGN_RANGE_FILE_NAME "magn/range" 31 | #define CALIBRATION_ENABLE 1 32 | #define MAGN_MAX_RANGE 1000.0f 33 | #define MAGN_MAX_ODR 100 34 | #define MAGN_MIN_ODR 25 35 | #define MAGN_POWER_CONSUMPTION 0.077f 36 | #define MAGN_DEFAULT_FULLSCALE 50 37 | 38 | /* INEMO_ENGINE SENSOR */ 39 | #define MAG_DEFAULT_RANGE 8 // full scale set to +-2.5Gauss (value depends on the driver sysfs file) 40 | #define MAG_DEFAULT_DELAY 12 // 1/frequency (default: 10 -> 100 Hz) [ms] 41 | 42 | /*****************************************************************************/ 43 | /* EVENT TYPE */ 44 | /*****************************************************************************/ 45 | #define EVENT_TYPE_MAG EV_MSC 46 | 47 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 48 | #define EVENT_TYPE_TIME_LSB MSC_MAX 49 | 50 | #define EVENT_TYPE_MAG_X MSC_SERIAL 51 | #define EVENT_TYPE_MAG_Y MSC_PULSELED 52 | #define EVENT_TYPE_MAG_Z MSC_GESTURE 53 | 54 | /*****************************************************************************/ 55 | /* AXIS MAPPING */ 56 | /*****************************************************************************/ 57 | 58 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 59 | * 60 | * Example: 61 | * y' /| z' 62 | * ^ / 63 | * | / You must define this coordinate system (reference system of board) 64 | * | / in accordance to definition of the axis 65 | * |/ definition in sensors.h file 66 | * +----------------------------------------------+---------> x' 67 | * | ^ x | 68 | * | | ^ z | 69 | * | | | | 70 | * | +-----+---> y | | 71 | * | | ACC | <---+-----+ | 72 | * | | | x | GYR | | 73 | * | +-----+ | | | 74 | * | / +-----+ | 75 | * | |/ y ^ /| z / | 76 | * | z | / |/ | 77 | * | |/ y | 78 | * | +-----+---> x | 79 | * | | MAG | | 80 | * | | | | 81 | * | +-----+ | 82 | * | BOARD | 83 | * +----------------------------------------------+ 84 | * 85 | * 86 | * ACCELEROMETER: 87 | * 88 | * board acc | 0 1 0 | 89 | * [x' y' z'] = [x y z] * | 1 0 0 | 90 | * | 0 0 -1 | 91 | * 92 | */ 93 | static short matrix_mag[3][3] = { 94 | { 1, 0, 0 }, 95 | { 0, 1, 0 }, 96 | { 0, 0, 1 } 97 | }; 98 | 99 | /*****************************************************************************/ 100 | /* DATA CONVERSION */ 101 | /*****************************************************************************/ 102 | #define CONVERT_M (1.0f/10000.0f) 103 | #define CONVERT_M_X (CONVERT_M) 104 | #define CONVERT_M_Y (CONVERT_M) 105 | #define CONVERT_M_Z (CONVERT_M) 106 | 107 | #define INPUT_EVENT_HAS_TIMESTAMP 1 108 | #define NOT_SET_MAG_INITIAL_STATE 1 109 | #define MAG_EVENT_HAS_TIMESTAMP 1 110 | 111 | #endif /* CONFIGURATION_IIS2MDC_H */ 112 | -------------------------------------------------------------------------------- /conf/conf_IIS3DHHC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 STMicroelectronics AMG/MSD Product Div. 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CONFIGURATION_IIS3DHHC_H 19 | #define CONFIGURATION_IIS3DHHC_H 20 | 21 | #define SENSORS_ACCELEROMETER_ENABLE (1) 22 | 23 | /* ACCELEROMETER SENSOR */ 24 | #define SENSOR_ACC_LABEL "IIS3DHHC 3-axis Accelerometer" // Label views in Android Applications 25 | #define SENSOR_DATANAME_ACCELEROMETER "iis3dhhc" // Name of input device: struct input_dev->name 26 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 27 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 28 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 29 | #define ACCEL_MAX_RANGE 2.5*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 30 | #define ACCEL_MAX_ODR 1100 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 31 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 32 | #define ACCEL_DEFAULT_FULLSCALE 2.5 // Set default full-scale (value depends on the driver sysfs file) 33 | #define ACC_DEFAULT_DELAY 0.9 // 1/frequency (default: 10 -> 100 Hz) [ms] 34 | /*****************************************************************************/ 35 | /* EVENT TYPE */ 36 | /*****************************************************************************/ 37 | #define EVENT_TYPE_ACCEL EV_MSC 38 | 39 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 40 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 41 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 42 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 43 | 44 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 45 | #define EVENT_TYPE_TIME_LSB MSC_MAX 46 | 47 | /*****************************************************************************/ 48 | /* AXIS MAPPING */ 49 | /*****************************************************************************/ 50 | 51 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 52 | * 53 | * Example: 54 | * y' /| z' 55 | * ^ / 56 | * | / You must define this coordinate system (reference system of board) 57 | * | / in accordance to definition of the axis 58 | * |/ definition in sensors.h file 59 | * +----------------------------------------------+---------> x' 60 | * | ^ x | 61 | * | | ^ z | 62 | * | | | | 63 | * | +-----+---> y | | 64 | * | | ACC | <---+-----+ | 65 | * | | | x | GYR | | 66 | * | +-----+ | | | 67 | * | / +-----+ | 68 | * | |/ y ^ /| z / | 69 | * | z | / |/ | 70 | * | |/ y | 71 | * | +-----+---> x | 72 | * | | MAG | | 73 | * | | | | 74 | * | +-----+ | 75 | * | BOARD | 76 | * +----------------------------------------------+ 77 | * 78 | * ACCELEROMETER: 79 | * 80 | * board acc | 0 1 0 | 81 | * [x' y' z'] = [x y z] * | 1 0 0 | 82 | * | 0 0 -1 | 83 | * 84 | */ 85 | 86 | static short matrix_acc[3][3] = { 87 | { 1, 0, 0 }, 88 | { 0, 1, 0 }, 89 | { 0, 0, 1 } 90 | }; 91 | 92 | /*****************************************************************************/ 93 | /* DATA CONVERSION */ 94 | /*****************************************************************************/ 95 | // conversion of acceleration data to SI units (m/s^2) 96 | #define CONVERT_A (GRAVITY_EARTH/1000000.0f) // 1000000ug = 9.86 m/s^2 97 | #define CONVERT_A_X (CONVERT_A) 98 | #define CONVERT_A_Y (CONVERT_A) 99 | #define CONVERT_A_Z (CONVERT_A) 100 | 101 | #define ACC_EVENT_HAS_TIMESTAMP 1 102 | 103 | #endif /* CONFIGURATION_IIS3DHHC_H */ 104 | -------------------------------------------------------------------------------- /conf/conf_L3GD20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_L3GD20_H 21 | #define CONFIGURATION_L3GD20_H 22 | 23 | #define SENSORS_GYROSCOPE_ENABLE (1) 24 | #define SENSORS_UNCALIB_GYROSCOPE_ENABLE (1 & SENSORS_GYROSCOPE_ENABLE & OS_VERSION_ENABLE) 25 | 26 | /* GYROSCOPE SENSOR */ 27 | #define SENSOR_GYRO_LABEL "L3GD20 3-axis Gyroscope sensor" // Label views in Android Applications 28 | #define SENSOR_UNCALIB_GYRO_LABEL "L3GD20 3-axis Uncalibrated Gyroscope sensor" 29 | #define SENSOR_DATANAME_GYROSCOPE "l3gd20_gyr" // Name of input device: struct input_dev->name 30 | #define GYRO_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 31 | #define GYRO_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 32 | #define GYRO_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 33 | #define GYRO_MAX_RANGE (2000.0f*(float)M_PI/180.0f) // Set Max Full-scale [rad/sec] 34 | #define GYRO_MAX_ODR 200 // Set Max value of ODR [Hz] 35 | #define GYRO_POWER_CONSUMPTION 6.1f // Set sensor's power consumption [mA] 36 | #define GYRO_DEFAULT_FULLSCALE 2000 // Set default full-scale (value depends on the driver sysfs file) 37 | 38 | 39 | /* INEMO_ENGINE SENSOR */ 40 | #define GYRO_DEFAULT_RANGE 2000 // full scale set to 2000 DPS (value depends on the driver sysfs file) 41 | #define GYR_DEFAULT_DELAY 10 // 1/frequency (default: 9.523809f -> 105 Hz) [ms] 42 | 43 | /* SENSOR FUSION */ 44 | #define GYROSCOPE_ACTIVE 1 // Enable Gyroscope sensor in Sensor Fusion -> [0]:off, [1]:on 45 | #define GYR_GBIAS_THRESHOLD 475e-6 // Set gyroscope gbias threshold [uT] - Default value for L3G4200D: 400e-6 46 | 47 | /* GYROSCOPE STARTUP */ 48 | #define DEFAULT_SAMPLES_TO_DISCARD (20) 49 | #define GYRO_STARTUP_TIME_MS (200) 50 | 51 | /*****************************************************************************/ 52 | /* EVENT TYPE */ 53 | /*****************************************************************************/ 54 | /* Event Type in gyroscope sensor: see input_set_abs_params() function in your input driver */ 55 | #define EVENT_TYPE_GYRO EV_MSC 56 | 57 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 58 | #define EVENT_TYPE_TIME_LSB MSC_MAX 59 | #define EVENT_TYPE_GYRO_X MSC_SERIAL 60 | #define EVENT_TYPE_GYRO_Y MSC_PULSELED 61 | #define EVENT_TYPE_GYRO_Z MSC_GESTURE 62 | 63 | /*****************************************************************************/ 64 | /* AXIS MAPPING */ 65 | /*****************************************************************************/ 66 | 67 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 68 | * 69 | * Example: 70 | * y' /| z' 71 | * ^ / 72 | * | / You must define this coordinate system (reference system of board) 73 | * | / in accordance to definition of the axis 74 | * |/ definition in sensors.h file 75 | * +----------------------------------------------+---------> x' 76 | * | ^ x | 77 | * | | ^ z | 78 | * | | | | 79 | * | +-----+---> y | | 80 | * | | ACC | <---+-----+ | 81 | * | | | x | GYR | | 82 | * | +-----+ | | | 83 | * | / +-----+ | 84 | * | |/ y ^ /| z / | 85 | * | z | / |/ | 86 | * | |/ y | 87 | * | +-----+---> x | 88 | * | | MAG | | 89 | * | | | | 90 | * | +-----+ | 91 | * | BOARD | 92 | * +----------------------------------------------+ 93 | * 94 | * 95 | * GYROSCOPE: 96 | * 97 | * board gyr | -1 0 0 | 98 | * [x' y' z'] = [x y z] * | 1 0 0 | 99 | * | 0 -1 0 | 100 | * 101 | */ 102 | 103 | static short matrix_gyr[3][3] = { 104 | { 1, 0, 0 }, 105 | { 0, 1, 0 }, 106 | { 0, 0, 1 } 107 | }; 108 | 109 | /*****************************************************************************/ 110 | /* DATA CONVERSION */ 111 | /*****************************************************************************/ 112 | // conversion of gyro data to SI units (radian/sec) 113 | #define CONVERT_GYRO ((7.0f*((float)M_PI)) / 18000.0f) 114 | #define CONVERT_GYRO_X (CONVERT_GYRO) 115 | #define CONVERT_GYRO_Y (CONVERT_GYRO) 116 | #define CONVERT_GYRO_Z (CONVERT_GYRO) 117 | 118 | #define GYRO_EVENT_HAS_TIMESTAMP 1 119 | #define INPUT_EVENT_HAS_TIMESTAMP 1 120 | 121 | #endif /* CONFIGURATION_L3GD20_H */ 122 | -------------------------------------------------------------------------------- /conf/conf_L3GD20H.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_SENSOR_L3GD20H_H 21 | #define CONFIGURATION_SENSOR_L3GD20H_H 22 | 23 | #define SENSORS_GYROSCOPE_ENABLE (1) 24 | #define SENSORS_UNCALIB_GYROSCOPE_ENABLE (1 & SENSORS_GYROSCOPE_ENABLE & OS_VERSION_ENABLE) 25 | 26 | #define SENSOR_GYRO_LABEL "L3GD20H 3-axis Gyroscope sensor" // Label views in Android Applications 27 | #define SENSOR_DATANAME_GYROSCOPE "l3gd20h_gyr" // Name of input device: struct input_dev->name 28 | #define GYRO_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 29 | #define GYRO_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 30 | #define GYRO_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 31 | #define GYRO_MAX_RANGE (2000.0f*(float)M_PI/180.0f) // Set Max Full-scale [rad/sec] 32 | #define GYRO_MAX_ODR 800 // Set Max value of ODR [Hz] 33 | #define GYRO_POWER_CONSUMPTION 6.1f // Set sensor's power consumption [mA] 34 | #define GYRO_DEFAULT_FULLSCALE 2000 // Set default full-scale (value depends on the driver sysfs file) 35 | #define GYR_DEFAULT_DELAY 10 // 1/frequency (default: 9.523809f -> 105 Hz) [ms] 36 | #define GYR_GBIAS_THRESHOLD 1491e-6 // Set gyroscope gbias threshold [uT] - Default value for L3G4200D: 400e-6 37 | 38 | /* INEMO_ENGINE SENSOR */ 39 | #define GYRO_DEFAULT_RANGE 2000 // full scale set to 2000 DPS (value depends on the driver sysfs file) 40 | #define GYR_DEFAULT_DELAY 10 // 1/frequency (default: 9.523809f -> 105 Hz) [ms] 41 | 42 | /* GYROSCOPE STARTUP */ 43 | #define DEFAULT_SAMPLES_TO_DISCARD (20) 44 | #define GYRO_STARTUP_TIME_MS (200) 45 | 46 | /*****************************************************************************/ 47 | /* EVENT TYPE */ 48 | /*****************************************************************************/ 49 | /* Event Type in gyroscope sensor: see input_set_abs_params() function in your input driver */ 50 | #define EVENT_TYPE_GYRO EV_MSC 51 | 52 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 53 | #define EVENT_TYPE_TIME_LSB MSC_MAX 54 | #define EVENT_TYPE_GYRO_X MSC_SERIAL 55 | #define EVENT_TYPE_GYRO_Y MSC_PULSELED 56 | #define EVENT_TYPE_GYRO_Z MSC_GESTURE 57 | 58 | /*****************************************************************************/ 59 | /* AXIS MAPPING */ 60 | /*****************************************************************************/ 61 | 62 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 63 | * 64 | * Example: 65 | * y' /| z' 66 | * ^ / 67 | * | / You must define this coordinate system (reference system of board) 68 | * | / in accordance to definition of the axis 69 | * |/ definition in sensors.h file 70 | * +----------------------------------------------+---------> x' 71 | * | ^ x | 72 | * | | ^ z | 73 | * | | | | 74 | * | +-----+---> y | | 75 | * | | ACC | <---+-----+ | 76 | * | | | x | GYR | | 77 | * | +-----+ | | | 78 | * | / +-----+ | 79 | * | |/ y ^ /| z / | 80 | * | z | / |/ | 81 | * | |/ y | 82 | * | +-----+---> x | 83 | * | | MAG | | 84 | * | | | | 85 | * | +-----+ | 86 | * | BOARD | 87 | * +----------------------------------------------+ 88 | * 89 | * 90 | * GYROSCOPE: 91 | * 92 | * board gyr | -1 0 0 | 93 | * [x' y' z'] = [x y z] * | 1 0 0 | 94 | * | 0 -1 0 | 95 | * 96 | */ 97 | 98 | static short matrix_gyr[3][3] = { 99 | { 1, 0, 0 }, 100 | { 0, 1, 0 }, 101 | { 0, 0, 1 } 102 | }; 103 | 104 | /*****************************************************************************/ 105 | /* DATA CONVERSION */ 106 | /*****************************************************************************/ 107 | // conversion of gyro data to SI units (radian/sec) 108 | #define CONVERT_GYRO ((7.0f*((float)M_PI)) / 18000.0f) 109 | #define CONVERT_GYRO_X (CONVERT_GYRO) 110 | #define CONVERT_GYRO_Y (CONVERT_GYRO) 111 | #define CONVERT_GYRO_Z (CONVERT_GYRO) 112 | 113 | #define GYRO_EVENT_HAS_TIMESTAMP 1 114 | #define INPUT_EVENT_HAS_TIMESTAMP 1 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /conf/conf_LIS2DE12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS2DE12_H 20 | #define CONFIGURATION_LIS2DE12_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | 24 | /* ACCELEROMETER SENSOR */ 25 | #define SENSOR_ACC_LABEL "LIS2DE 3-axis Accelerometer" // Label views in Android Applications 26 | #define SENSOR_DATANAME_ACCELEROMETER "lis2de_acc" // Name of input device: struct input_dev->name 27 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 28 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 29 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 30 | #define ACCEL_MAX_RANGE 16*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 31 | #define ACCEL_MAX_ODR 100 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 32 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 33 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 34 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 35 | /*****************************************************************************/ 36 | /* EVENT TYPE */ 37 | /*****************************************************************************/ 38 | #define EVENT_TYPE_ACCEL EV_MSC 39 | 40 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 41 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 42 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 43 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 44 | 45 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 46 | #define EVENT_TYPE_TIME_LSB MSC_MAX 47 | 48 | /*****************************************************************************/ 49 | /* AXIS MAPPING */ 50 | /*****************************************************************************/ 51 | 52 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 53 | * 54 | * Example: 55 | * y' /| z' 56 | * ^ / 57 | * | / You must define this coordinate system (reference system of board) 58 | * | / in accordance to definition of the axis 59 | * |/ definition in sensors.h file 60 | * +----------------------------------------------+---------> x' 61 | * | ^ x | 62 | * | | ^ z | 63 | * | | | | 64 | * | +-----+---> y | | 65 | * | | ACC | <---+-----+ | 66 | * | | | x | GYR | | 67 | * | +-----+ | | | 68 | * | / +-----+ | 69 | * | |/ y ^ /| z / | 70 | * | z | / |/ | 71 | * | |/ y | 72 | * | +-----+---> x | 73 | * | | MAG | | 74 | * | | | | 75 | * | +-----+ | 76 | * | BOARD | 77 | * +----------------------------------------------+ 78 | * 79 | * ACCELEROMETER: 80 | * 81 | * board acc | 0 1 0 | 82 | * [x' y' z'] = [x y z] * | 1 0 0 | 83 | * | 0 0 -1 | 84 | * 85 | */ 86 | 87 | static short matrix_acc[3][3] = { 88 | { 1, 0, 0 }, 89 | { 0, 1, 0 }, 90 | { 0, 0, 1 } 91 | }; 92 | 93 | /*****************************************************************************/ 94 | /* DATA CONVERSION */ 95 | /*****************************************************************************/ 96 | // conversion of acceleration data to SI units (m/s^2) 97 | #define CONVERT_A (GRAVITY_EARTH/1000) // 1000mg = 9.86 m/s^2 98 | #define CONVERT_A_X (CONVERT_A) 99 | #define CONVERT_A_Y (CONVERT_A) 100 | #define CONVERT_A_Z (CONVERT_A) 101 | 102 | #define ACC_EVENT_HAS_TIMESTAMP 1 103 | 104 | #endif /* CONFIGURATION_LIS2DE12_H */ 105 | -------------------------------------------------------------------------------- /conf/conf_LIS2DH12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS2DH12_H 20 | #define CONFIGURATION_LIS2DH12_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | 24 | /* ACCELEROMETER SENSOR */ 25 | #define SENSOR_ACC_LABEL "LIS2DH 3-axis Accelerometer" // Label views in Android Applications 26 | #define SENSOR_DATANAME_ACCELEROMETER "lis2dh_acc" // Name of input device: struct input_dev->name 27 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 28 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 29 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 30 | #define ACCEL_MAX_RANGE 16*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 31 | #define ACCEL_MAX_ODR 200 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 32 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 33 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 34 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 35 | /*****************************************************************************/ 36 | /* EVENT TYPE */ 37 | /*****************************************************************************/ 38 | #define EVENT_TYPE_ACCEL EV_MSC 39 | 40 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 41 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 42 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 43 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 44 | 45 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 46 | #define EVENT_TYPE_TIME_LSB MSC_MAX 47 | 48 | /*****************************************************************************/ 49 | /* AXIS MAPPING */ 50 | /*****************************************************************************/ 51 | 52 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 53 | * 54 | * Example: 55 | * y' /| z' 56 | * ^ / 57 | * | / You must define this coordinate system (reference system of board) 58 | * | / in accordance to definition of the axis 59 | * |/ definition in sensors.h file 60 | * +----------------------------------------------+---------> x' 61 | * | ^ x | 62 | * | | ^ z | 63 | * | | | | 64 | * | +-----+---> y | | 65 | * | | ACC | <---+-----+ | 66 | * | | | x | GYR | | 67 | * | +-----+ | | | 68 | * | / +-----+ | 69 | * | |/ y ^ /| z / | 70 | * | z | / |/ | 71 | * | |/ y | 72 | * | +-----+---> x | 73 | * | | MAG | | 74 | * | | | | 75 | * | +-----+ | 76 | * | BOARD | 77 | * +----------------------------------------------+ 78 | * 79 | * ACCELEROMETER: 80 | * 81 | * board acc | 0 1 0 | 82 | * [x' y' z'] = [x y z] * | 1 0 0 | 83 | * | 0 0 -1 | 84 | * 85 | */ 86 | 87 | static short matrix_acc[3][3] = { 88 | { 1, 0, 0 }, 89 | { 0, 1, 0 }, 90 | { 0, 0, 1 } 91 | }; 92 | 93 | /*****************************************************************************/ 94 | /* DATA CONVERSION */ 95 | /*****************************************************************************/ 96 | // conversion of acceleration data to SI units (m/s^2) 97 | #define CONVERT_A (GRAVITY_EARTH/1000) // 1000mg = 9.86 m/s^2 98 | #define CONVERT_A_X (CONVERT_A) 99 | #define CONVERT_A_Y (CONVERT_A) 100 | #define CONVERT_A_Z (CONVERT_A) 101 | 102 | #define ACC_EVENT_HAS_TIMESTAMP 1 103 | 104 | #endif /* CONFIGURATION_LIS2DH12_H */ 105 | -------------------------------------------------------------------------------- /conf/conf_LIS2DW12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * This configuration file is valid for LIS2DW12 sensors because 19 | * share the same driver 20 | */ 21 | 22 | #ifndef CONFIGURATION_LIS2DW12_H 23 | #define CONFIGURATION_LIS2DW12_H 24 | 25 | #define SENSORS_ACCELEROMETER_ENABLE (1) 26 | #define SENSORS_TAP_ENABLE (1) 27 | 28 | /* ACCELEROMETER SENSOR */ 29 | #define SENSOR_ACC_LABEL "LIS2DW12 3-axis Accelerometer Sensor" // Label views in Android Applications 30 | #define SENSOR_DATANAME_ACCELEROMETER "ST LIS2DW12 Accelerometer Sensor" // Name of input device: struct input_dev->name 31 | #define ACCEL_DELAY_FILE_NAME "accel/polling_rate" // name of sysfs file for setting the pollrate 32 | #define ACCEL_ENABLE_FILE_NAME "accel/enable" // name of sysfs file for enable/disable the sensor state 33 | #define ACCEL_RANGE_FILE_NAME "accel/scale" // name of sysfs file for setting the full scale 34 | #define ACCEL_MAX_RANGE 16 * GRAVITY_EARTH // Set Max Full-scale [m/s^2] 35 | #define ACCEL_MAX_ODR 100 // Set Max value of ODR [Hz] 36 | #define ACCEL_MIN_ODR 1 // Set Max value of ODR [Hz] 37 | #define ACCEL_POWER_CONSUMPTION 0.6f // Set sensor's power consumption [mA] 38 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 39 | 40 | /* STEP TAP SENSOR */ 41 | #define SENSOR_TAP_LABEL "LIS2DW12 Tap Sensor" // Label views in Android Applications 42 | #define SENSOR_DATANAME_TAP "ST LIS2DW12 Tap Sensor" // Name of input device: struct input_dev->name 43 | #define TAP_ENABLE_FILE_NAME "tap/enable" // name of sysfs file for enable/disable the sensor state 44 | #define TAP_POWER_CONSUMPTION ACCEL_POWER_CONSUMPTION 45 | 46 | /* INEMO_ENGINE SENSOR */ 47 | #define ACC_DEFAULT_RANGE 8 // full scale set to 8g (value depends on the driver sysfs file) 48 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 49 | 50 | /* SENSOR FUSION */ 51 | #define ACC_GBIAS_THRESHOLD 550e-6 // Set acceleration gbias threshold 52 | 53 | /*****************************************************************************/ 54 | /* EVENT TYPE */ 55 | /*****************************************************************************/ 56 | #define EVENT_TYPE_ACCEL EV_MSC 57 | #define EVENT_TYPE_TILT EV_MSC 58 | #define EVENT_TYPE_SIGN_M EV_MSC 59 | #define EVENT_TYPE_TAP EV_MSC 60 | 61 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 62 | #define EVENT_TYPE_TIME_LSB MSC_MAX 63 | 64 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 65 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 66 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 67 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 68 | 69 | #define EVENT_TYPE_TILT_DATA MSC_SERIAL 70 | #define EVENT_TYPE_SIGN_M_DATA MSC_SERIAL 71 | #define EVENT_TYPE_TAP_DATA MSC_SERIAL 72 | 73 | /*****************************************************************************/ 74 | /* AXIS MAPPING */ 75 | /*****************************************************************************/ 76 | 77 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 78 | * 79 | * Example: 80 | * y' /| z' 81 | * ^ / 82 | * | / You must define this coordinate system (reference system of board) 83 | * | / in accordance to definition of the axis 84 | * |/ definition in sensors.h file 85 | * +----------------------------------------------+---------> x' 86 | * | ^ x | 87 | * | | ^ z | 88 | * | | | | 89 | * | +-----+---> y | | 90 | * | | ACC | <---+-----+ | 91 | * | | | x | GYR | | 92 | * | +-----+ | | | 93 | * | / +-----+ | 94 | * | |/ y ^ /| z / | 95 | * | z | / |/ | 96 | * | |/ y | 97 | * | +-----+---> x | 98 | * | | MAG | | 99 | * | | | | 100 | * | +-----+ | 101 | * | BOARD | 102 | * +----------------------------------------------+ 103 | * 104 | * 105 | * ACCELEROMETER: 106 | * 107 | * board acc | 0 1 0 | 108 | * [x' y' z'] = [x y z] * | 1 0 0 | 109 | * | 0 0 -1 | 110 | * 111 | */ 112 | static short matrix_acc[3][3] = { 113 | { 0, -1, 0 }, 114 | { -1, 0, 0 }, 115 | { 0, 0, 1 } 116 | }; 117 | 118 | /*****************************************************************************/ 119 | /* DATA CONVERSION */ 120 | /*****************************************************************************/ 121 | // conversion of acceleration data to SI units (m/s^2) 122 | #define CONVERT_A (GRAVITY_EARTH / 1000000.0f) 123 | #define CONVERT_A_X (CONVERT_A) 124 | #define CONVERT_A_Y (CONVERT_A) 125 | #define CONVERT_A_Z (CONVERT_A) 126 | 127 | #define ACC_EVENT_HAS_TIMESTAMP 1 128 | #define INPUT_EVENT_HAS_TIMESTAMP 1 129 | #define NOT_SET_ACC_INITIAL_STATE 1 130 | #endif /* CONFIGURATION_LIS2DW12_H */ 131 | -------------------------------------------------------------------------------- /conf/conf_LIS2HH12.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * This configuration file is valid for LIS2HH and LIS2HH sensors because 19 | * share the same driver 20 | */ 21 | 22 | #ifndef CONFIGURATION_LIS2HH_H 23 | #define CONFIGURATION_LIS2HH_H 24 | 25 | #define SENSORS_ACCELEROMETER_ENABLE (1) 26 | 27 | /* ACCELEROMETER SENSOR */ 28 | #define SENSOR_ACC_LABEL "LIS2HH12 3-axis Accelerometer Sensor" // Label views in Android Applications 29 | #define SENSOR_DATANAME_ACCELEROMETER "lis2hh12_acc" // Name of input device: struct input_dev->name 30 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 31 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 32 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 33 | #define ACCEL_MAX_RANGE 8 * GRAVITY_EARTH // Set Max Full-scale [m/s^2] 34 | #define ACCEL_MAX_ODR 200 // Set Max value of ODR [Hz] 35 | #define ACCEL_MIN_ODR 1 // Set Max value of ODR [Hz] 36 | #define ACCEL_POWER_CONSUMPTION 0.6f // Set sensor's power consumption [mA] 37 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 38 | 39 | /* INEMO_ENGINE SENSOR */ 40 | #define ACC_DEFAULT_RANGE 8 // full scale set to 8g (value depends on the driver sysfs file) 41 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 42 | 43 | /* SENSOR FUSION */ 44 | #define ACC_GBIAS_THRESHOLD 550e-6 // Set acceleration gbias threshold 45 | 46 | /*****************************************************************************/ 47 | /* EVENT TYPE */ 48 | /*****************************************************************************/ 49 | #define EVENT_TYPE_ACCEL EV_MSC 50 | #define EVENT_TYPE_TILT EV_MSC 51 | #define EVENT_TYPE_SIGN_M EV_MSC 52 | #define EVENT_TYPE_TAP EV_MSC 53 | 54 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 55 | #define EVENT_TYPE_TIME_LSB MSC_MAX 56 | 57 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 58 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 59 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 60 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 61 | 62 | #define EVENT_TYPE_TILT_DATA MSC_SERIAL 63 | #define EVENT_TYPE_SIGN_M_DATA MSC_SERIAL 64 | #define EVENT_TYPE_TAP_DATA MSC_SERIAL 65 | 66 | /*****************************************************************************/ 67 | /* AXIS MAPPING */ 68 | /*****************************************************************************/ 69 | 70 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 71 | * 72 | * Example: 73 | * y' /| z' 74 | * ^ / 75 | * | / You must define this coordinate system (reference system of board) 76 | * | / in accordance to definition of the axis 77 | * |/ definition in sensors.h file 78 | * +----------------------------------------------+---------> x' 79 | * | ^ x | 80 | * | | ^ z | 81 | * | | | | 82 | * | +-----+---> y | | 83 | * | | ACC | <---+-----+ | 84 | * | | | x | GYR | | 85 | * | +-----+ | | | 86 | * | / +-----+ | 87 | * | |/ y ^ /| z / | 88 | * | z | / |/ | 89 | * | |/ y | 90 | * | +-----+---> x | 91 | * | | MAG | | 92 | * | | | | 93 | * | +-----+ | 94 | * | BOARD | 95 | * +----------------------------------------------+ 96 | * 97 | * 98 | * ACCELEROMETER: 99 | * 100 | * board acc | 0 1 0 | 101 | * [x' y' z'] = [x y z] * | 1 0 0 | 102 | * | 0 0 -1 | 103 | * 104 | */ 105 | static short matrix_acc[3][3] = { 106 | { 0, -1, 0 }, 107 | { -1, 0, 0 }, 108 | { 0, 0, 1 } 109 | }; 110 | 111 | /*****************************************************************************/ 112 | /* DATA CONVERSION */ 113 | /*****************************************************************************/ 114 | // conversion of acceleration data to SI units (m/s^2) 115 | #define CONVERT_A (GRAVITY_EARTH / 1000000.0f) 116 | #define CONVERT_A_X (CONVERT_A) 117 | #define CONVERT_A_Y (CONVERT_A) 118 | #define CONVERT_A_Z (CONVERT_A) 119 | 120 | #define ACC_EVENT_HAS_TIMESTAMP 1 121 | #define INPUT_EVENT_HAS_TIMESTAMP 1 122 | #define NOT_SET_ACC_INITIAL_STATE 1 123 | #endif /* CONFIGURATION_LIS2HH_H */ 124 | -------------------------------------------------------------------------------- /conf/conf_LIS2MDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS2MDL_H 20 | #define CONFIGURATION_LIS2MDL_H 21 | 22 | #define SENSORS_MAGNETIC_FIELD_ENABLE (1) 23 | #define SENSORS_UNCALIB_MAGNETIC_FIELD_ENABLE (1 & SENSORS_MAGNETIC_FIELD_ENABLE & OS_VERSION_ENABLE) 24 | 25 | /* MAGNETOMETER SENSOR */ 26 | #define SENSOR_MAGN_LABEL "LIS2MDL 3-axis Magnetometer Sensor" 27 | #define SENSOR_UNCALIB_MAGN_LABEL "LIS2MDL 3-axis Uncalibrated Magnetometer sensor" 28 | #define SENSOR_DATANAME_MAGNETIC_FIELD "ST LIS2MDL Magnetometer Sensor" 29 | #define MAGN_DELAY_FILE_NAME "magn/polling_rate" 30 | #define MAGN_ENABLE_FILE_NAME "magn/enable" 31 | #define MAGN_RANGE_FILE_NAME "magn/range" 32 | #define CALIBRATION_ENABLE 1 33 | #define MAGN_MAX_RANGE 1000.0f 34 | #define MAGN_MAX_ODR 100 35 | #define MAGN_MIN_ODR 25 36 | #define MAGN_POWER_CONSUMPTION 0.077f 37 | #define MAGN_DEFAULT_FULLSCALE 50 38 | 39 | /* INEMO_ENGINE SENSOR */ 40 | #define MAG_DEFAULT_RANGE 8 // full scale set to +-2.5Gauss (value depends on the driver sysfs file) 41 | #define MAG_DEFAULT_DELAY 12 // 1/frequency (default: 10 -> 100 Hz) [ms] 42 | 43 | /* SENSOR FUSION */ 44 | #define MAGNETOMETER_ACTIVE 1 // Enable Magnetometer sensor in Sensor Fusion -> [0]:off, [1]:on 45 | #define MAG_GBIAS_THRESHOLD 1200e-6 // Set magnetometer gbias threshold [uT] 46 | 47 | /*****************************************************************************/ 48 | /* EVENT TYPE */ 49 | /*****************************************************************************/ 50 | #define EVENT_TYPE_MAG EV_MSC 51 | 52 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 53 | #define EVENT_TYPE_TIME_LSB MSC_MAX 54 | 55 | #define EVENT_TYPE_MAG_X MSC_SERIAL 56 | #define EVENT_TYPE_MAG_Y MSC_PULSELED 57 | #define EVENT_TYPE_MAG_Z MSC_GESTURE 58 | 59 | /*****************************************************************************/ 60 | /* AXIS MAPPING */ 61 | /*****************************************************************************/ 62 | 63 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 64 | * 65 | * Example: 66 | * y' /| z' 67 | * ^ / 68 | * | / You must define this coordinate system (reference system of board) 69 | * | / in accordance to definition of the axis 70 | * |/ definition in sensors.h file 71 | * +----------------------------------------------+---------> x' 72 | * | ^ x | 73 | * | | ^ z | 74 | * | | | | 75 | * | +-----+---> y | | 76 | * | | ACC | <---+-----+ | 77 | * | | | x | GYR | | 78 | * | +-----+ | | | 79 | * | / +-----+ | 80 | * | |/ y ^ /| z / | 81 | * | z | / |/ | 82 | * | |/ y | 83 | * | +-----+---> x | 84 | * | | MAG | | 85 | * | | | | 86 | * | +-----+ | 87 | * | BOARD | 88 | * +----------------------------------------------+ 89 | * 90 | * 91 | * ACCELEROMETER: 92 | * 93 | * board acc | 0 1 0 | 94 | * [x' y' z'] = [x y z] * | 1 0 0 | 95 | * | 0 0 -1 | 96 | * 97 | */ 98 | static short matrix_mag[3][3] = { 99 | { 1, 0, 0 }, 100 | { 0, 1, 0 }, 101 | { 0, 0, 1 } 102 | }; 103 | 104 | /*****************************************************************************/ 105 | /* DATA CONVERSION */ 106 | /*****************************************************************************/ 107 | #define CONVERT_M (1.0f/10000.0f) 108 | #define CONVERT_M_X (CONVERT_M) 109 | #define CONVERT_M_Y (CONVERT_M) 110 | #define CONVERT_M_Z (CONVERT_M) 111 | 112 | #define INPUT_EVENT_HAS_TIMESTAMP 1 113 | #define NOT_SET_MAG_INITIAL_STATE 1 114 | #define MAG_EVENT_HAS_TIMESTAMP 1 115 | 116 | #endif /* CONFIGURATION_LIS2MDL_H */ 117 | -------------------------------------------------------------------------------- /conf/conf_LIS3DH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS3DH_H 20 | #define CONFIGURATION_LIS3DH_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | 24 | /* ACCELEROMETER SENSOR */ 25 | #define SENSOR_ACC_LABEL "LIS3DH 3-axis Accelerometer" // Label views in Android Applications 26 | #define SENSOR_DATANAME_ACCELEROMETER "lis3dh_acc" // Name of input device: struct input_dev->name 27 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 28 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 29 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 30 | #define ACCEL_MAX_RANGE 16*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 31 | #define ACCEL_MAX_ODR 200 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 32 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 33 | #define ACCEL_DEFAULT_FULLSCALE 4 // Set default full-scale (value depends on the driver sysfs file) 34 | #define ACC_DEFAULT_DELAY 10 // 1/frequency (default: 10 -> 100 Hz) [ms] 35 | /*****************************************************************************/ 36 | /* EVENT TYPE */ 37 | /*****************************************************************************/ 38 | #define EVENT_TYPE_ACCEL EV_MSC 39 | 40 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 41 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 42 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 43 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 44 | 45 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 46 | #define EVENT_TYPE_TIME_LSB MSC_MAX 47 | 48 | /*****************************************************************************/ 49 | /* AXIS MAPPING */ 50 | /*****************************************************************************/ 51 | 52 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 53 | * 54 | * Example: 55 | * y' /| z' 56 | * ^ / 57 | * | / You must define this coordinate system (reference system of board) 58 | * | / in accordance to definition of the axis 59 | * |/ definition in sensors.h file 60 | * +----------------------------------------------+---------> x' 61 | * | ^ x | 62 | * | | ^ z | 63 | * | | | | 64 | * | +-----+---> y | | 65 | * | | ACC | <---+-----+ | 66 | * | | | x | GYR | | 67 | * | +-----+ | | | 68 | * | / +-----+ | 69 | * | |/ y ^ /| z / | 70 | * | z | / |/ | 71 | * | |/ y | 72 | * | +-----+---> x | 73 | * | | MAG | | 74 | * | | | | 75 | * | +-----+ | 76 | * | BOARD | 77 | * +----------------------------------------------+ 78 | * 79 | * ACCELEROMETER: 80 | * 81 | * board acc | 0 1 0 | 82 | * [x' y' z'] = [x y z] * | 1 0 0 | 83 | * | 0 0 -1 | 84 | * 85 | */ 86 | 87 | static short matrix_acc[3][3] = { 88 | { 1, 0, 0 }, 89 | { 0, 1, 0 }, 90 | { 0, 0, 1 } 91 | }; 92 | 93 | /*****************************************************************************/ 94 | /* DATA CONVERSION */ 95 | /*****************************************************************************/ 96 | // conversion of acceleration data to SI units (m/s^2) 97 | #define CONVERT_A (GRAVITY_EARTH/1000) // 1000mg = 9.86 m/s^2 98 | #define CONVERT_A_X (CONVERT_A) 99 | #define CONVERT_A_Y (CONVERT_A) 100 | #define CONVERT_A_Z (CONVERT_A) 101 | 102 | #define ACC_EVENT_HAS_TIMESTAMP 1 103 | 104 | #endif /* CONFIGURATION_LIS3DH_H */ 105 | -------------------------------------------------------------------------------- /conf/conf_LIS3DHH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 STMicroelectronics 3 | * Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS3DHH_H 20 | #define CONFIGURATION_LIS3DHH_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | 24 | /* ACCELEROMETER SENSOR */ 25 | #define SENSOR_ACC_LABEL "LIS3DHH 3-axis Accelerometer" // Label views in Android Applications 26 | #define SENSOR_DATANAME_ACCELEROMETER "lis3dhh" // Name of input device: struct input_dev->name 27 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 28 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 29 | #define ACCEL_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 30 | #define ACCEL_MAX_RANGE 2.5*GRAVITY_EARTH // Set Max Full-scale [m/s^2] 31 | #define ACCEL_MAX_ODR 1100 // Set Max value of ODR [Hz] - driver uses delayed works (min tick 1 jiffies) 32 | #define ACCEL_POWER_CONSUMPTION 0.033f // Set sensor's power consumption [mA] 33 | #define ACCEL_DEFAULT_FULLSCALE 2.5 // Set default full-scale (value depends on the driver sysfs file) 34 | #define ACC_DEFAULT_DELAY 0.9 // 1/frequency (default: 10 -> 100 Hz) [ms] 35 | /*****************************************************************************/ 36 | /* EVENT TYPE */ 37 | /*****************************************************************************/ 38 | #define EVENT_TYPE_ACCEL EV_MSC 39 | 40 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 41 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 42 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 43 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 44 | 45 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 46 | #define EVENT_TYPE_TIME_LSB MSC_MAX 47 | 48 | /*****************************************************************************/ 49 | /* AXIS MAPPING */ 50 | /*****************************************************************************/ 51 | 52 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 53 | * 54 | * Example: 55 | * y' /| z' 56 | * ^ / 57 | * | / You must define this coordinate system (reference system of board) 58 | * | / in accordance to definition of the axis 59 | * |/ definition in sensors.h file 60 | * +----------------------------------------------+---------> x' 61 | * | ^ x | 62 | * | | ^ z | 63 | * | | | | 64 | * | +-----+---> y | | 65 | * | | ACC | <---+-----+ | 66 | * | | | x | GYR | | 67 | * | +-----+ | | | 68 | * | / +-----+ | 69 | * | |/ y ^ /| z / | 70 | * | z | / |/ | 71 | * | |/ y | 72 | * | +-----+---> x | 73 | * | | MAG | | 74 | * | | | | 75 | * | +-----+ | 76 | * | BOARD | 77 | * +----------------------------------------------+ 78 | * 79 | * ACCELEROMETER: 80 | * 81 | * board acc | 0 1 0 | 82 | * [x' y' z'] = [x y z] * | 1 0 0 | 83 | * | 0 0 -1 | 84 | * 85 | */ 86 | 87 | static short matrix_acc[3][3] = { 88 | { 1, 0, 0 }, 89 | { 0, 1, 0 }, 90 | { 0, 0, 1 } 91 | }; 92 | 93 | /*****************************************************************************/ 94 | /* DATA CONVERSION */ 95 | /*****************************************************************************/ 96 | // conversion of acceleration data to SI units (m/s^2) 97 | #define CONVERT_A (GRAVITY_EARTH/1000000.0f) // 1000000ug = 9.86 m/s^2 98 | #define CONVERT_A_X (CONVERT_A) 99 | #define CONVERT_A_Y (CONVERT_A) 100 | #define CONVERT_A_Z (CONVERT_A) 101 | 102 | #define ACC_EVENT_HAS_TIMESTAMP 1 103 | 104 | #endif /* CONFIGURATION_LIS3DHH_H */ 105 | -------------------------------------------------------------------------------- /conf/conf_LIS3MDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LIS3MDL_H 20 | #define CONFIGURATION_LIS3MDL_H 21 | 22 | #define SENSORS_MAGNETIC_FIELD_ENABLE (1) 23 | #define SENSORS_UNCALIB_MAGNETIC_FIELD_ENABLE (1 & SENSORS_MAGNETIC_FIELD_ENABLE & OS_VERSION_ENABLE) 24 | 25 | /* MAGNETOMETER SENSOR */ 26 | #define SENSOR_MAGN_LABEL "LIS3MDL 3-axis Magnetometer Sensor" // Label views in Android Applications 27 | #define SENSOR_UNCALIB_MAGN_LABEL "LIS3MDL 3-axis Uncalibrated Magnetometer sensor" 28 | #define SENSOR_DATANAME_MAGNETIC_FIELD "lis3mdl_mag" // Name of input device: struct input_dev->name 29 | #define MAGN_DELAY_FILE_NAME "device/pollrate_ms" // name of sysfs file for setting the pollrate 30 | #define MAGN_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 31 | #define MAGN_RANGE_FILE_NAME "device/full_scale" // name of sysfs file for setting the full scale 32 | #define CALIBRATION_ENABLE 1 // Enable Calibration -> [0]:off, [1]:on 33 | #define MAGN_MAX_RANGE 1000.0f // Set Max Full-scale [uT] 34 | #define MAGN_MAX_ODR 80 // Set Max value of ODR [Hz] 35 | #define MAGN_POWER_CONSUMPTION 0.077f // Set sensor's power consumption [mA] 36 | #define MAGN_DEFAULT_FULLSCALE 8 // Set default full-scale (value depends on the driver sysfs file) 37 | 38 | /* INEMO_ENGINE SENSOR */ 39 | #define MAG_DEFAULT_RANGE 8 // full scale set to +-2.5Gauss (value depends on the driver sysfs file) 40 | #define MAG_DEFAULT_DELAY 12 // 1/frequency (default: 10 -> 100 Hz) [ms] 41 | 42 | /* SENSOR FUSION */ 43 | #define LOCAL_EARTH_MAGNETIC_FIELD 50.0f // Value of local earth magnetic field [uT] 44 | #define MAGNETOMETER_ACTIVE 1 // Enable Magnetometer sensor in Sensor Fusion -> [0]:off, [1]:on 45 | #define MAG_GBIAS_THRESHOLD 1471e-6 // Set magnetometer gbias threshold [uT] - Default value for LSM303DLHC: 1200e-6 46 | 47 | /*****************************************************************************/ 48 | /* EVENT TYPE */ 49 | /*****************************************************************************/ 50 | /* Event Type in magnetometer sensor: see input_set_abs_params() function in your input driver */ 51 | #define EVENT_TYPE_MAG EV_MSC 52 | 53 | #define EVENT_TYPE_MAG_X MSC_SERIAL 54 | #define EVENT_TYPE_MAG_Y MSC_PULSELED 55 | #define EVENT_TYPE_MAG_Z MSC_GESTURE 56 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 57 | #define EVENT_TYPE_TIME_LSB MSC_MAX 58 | #define MAG_EVENT_HAS_TIMESTAMP 1 59 | /*****************************************************************************/ 60 | /* AXIS MAPPING */ 61 | /*****************************************************************************/ 62 | 63 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 64 | * 65 | * Example: 66 | * y' /| z' 67 | * ^ / 68 | * | / You must define this coordinate system (reference system of board) 69 | * | / in accordance to definition of the axis 70 | * |/ definition in sensors.h file 71 | * +----------------------------------------------+---------> x' 72 | * | ^ x | 73 | * | | ^ z | 74 | * | | | | 75 | * | +-----+---> y | | 76 | * | | ACC | <---+-----+ | 77 | * | | | x | GYR | | 78 | * | +-----+ | | | 79 | * | / +-----+ | 80 | * | |/ y ^ /| z / | 81 | * | z | / |/ | 82 | * | |/ y | 83 | * | +-----+---> x | 84 | * | | MAG | | 85 | * | | | | 86 | * | +-----+ | 87 | * | BOARD | 88 | * +----------------------------------------------+ 89 | * 90 | * 91 | * MAGNETOMETER: 92 | * 93 | * board mag | 1 0 0 | 94 | * [x' y' z'] = [x y z] * | 0 0 1 | 95 | * | 0 0 1 | 96 | * 97 | */ 98 | 99 | static short matrix_mag[3][3] = { 100 | { 1, 0, 0 }, 101 | { 0, 1, 0 }, 102 | { 0, 0, 1 } 103 | }; 104 | 105 | /*****************************************************************************/ 106 | /* DATA CONVERSION */ 107 | /*****************************************************************************/ 108 | // conversion of magnetic data to uT units 109 | #define CONVERT_M (1.0f/10000.0f) 110 | #define CONVERT_M_X (CONVERT_M) 111 | #define CONVERT_M_Y (CONVERT_M) 112 | #define CONVERT_M_Z (CONVERT_M) 113 | 114 | 115 | 116 | #endif /* CONFIGURATION_LIS3MDL_H */ 117 | -------------------------------------------------------------------------------- /conf/conf_LPS22HB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LPS22HB_H 20 | #define CONFIGURATION_LPS22HB_H 21 | 22 | #define SENSORS_PRESSURE_ENABLE (1) 23 | #define SENSORS_TEMP_PRESS_ENABLE (1) 24 | 25 | /* PRESSURE SENSOR */ 26 | #define SENSOR_PRESS_LABEL "LPS22HB Pressure sensor" // Label views in Android Applications 27 | #define SENSOR_TEMP_LABEL "LPS22HB Temperature sensor" // Label views in Android Applications 28 | #define SENSOR_DATANAME_BAROMETER "lps22hb" // Name of input device: struct input_dev->name 29 | #define PRESS_DELAY_FILE_NAME "device/poll_period_ms" // name of sysfs file for setting the pollrate 30 | #define PRESS_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 31 | #define PRESS_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 32 | #define PRESS_MAX_RANGE 1260 // Set Max Full-scale [hPa] 33 | #define TEMP_MAX_RANGE 80 // Set Max Full-scale [Celsius] 34 | #define TEMPERATURE_OFFSET 0 35 | #define PRESS_MAX_ODR 75 // Set Max value of ODR [Hz] 36 | #define PRESS_MIN_ODR 1 // Set Min value of ODR [Hz] 37 | #define PRESS_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 38 | #define TEMP_MAX_ODR PRESS_MAX_ODR // Set Max value of ODR [Hz] 39 | #define TEMP_MIN_ODR PRESS_MIN_ODR // Set Min value of ODR [Hz] 40 | #define TEMP_POWER_CONSUMPTION PRESS_POWER_CONSUMPTION // Set sensor's power consumption [mA] 41 | 42 | /*****************************************************************************/ 43 | /* EVENT TYPE */ 44 | /*****************************************************************************/ 45 | 46 | /* Event Type in pressure sensor: see input_set_abs_params() function in your input driver */ 47 | #define EVENT_TYPE_PRESSURE MSC_SERIAL 48 | #define EVENT_TYPE_TEMPERATURE MSC_PULSELED 49 | 50 | /*****************************************************************************/ 51 | /* DATA CONVERSION */ 52 | /*****************************************************************************/ 53 | // conversion of pressure data to SI units (hPa, 1hPa=1mbar) 54 | #define CONVERT_PRESS (1.0f/4096.0f) 55 | 56 | // conversion of temperature data to SI units 57 | #define CONVERT_TEMP (1.0f/100.0f) 58 | 59 | #endif /* CONFIGURATION_LPS22HB_H */ 60 | -------------------------------------------------------------------------------- /conf/conf_LPS22HD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LPS22HD_H 20 | #define CONFIGURATION_LPS22HD_H 21 | 22 | #define SENSORS_PRESSURE_ENABLE (1) 23 | #define SENSORS_TEMP_PRESS_ENABLE (1) 24 | 25 | /* PRESSURE SENSOR */ 26 | #define SENSOR_PRESS_LABEL "LPS22HD Pressure sensor" // Label views in Android Applications 27 | #define SENSOR_TEMP_LABEL "LPS22HD Temperature sensor" // Label views in Android Applications 28 | #define SENSOR_DATANAME_BAROMETER "lps22hd" // Name of input device: struct input_dev->name 29 | #define PRESS_DELAY_FILE_NAME "device/poll_period_ms" // name of sysfs file for setting the pollrate 30 | #define PRESS_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 31 | #define PRESS_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 32 | #define PRESS_MAX_RANGE 1260 // Set Max Full-scale [hPa] 33 | #define TEMP_MAX_RANGE 80 // Set Max Full-scale [Celsius] 34 | #define TEMPERATURE_OFFSET 0 35 | #define PRESS_MAX_ODR 75 // Set Max value of ODR [Hz] 36 | #define PRESS_MIN_ODR 1 // Set Min value of ODR [Hz] 37 | #define PRESS_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 38 | #define TEMP_MAX_ODR PRESS_MAX_ODR // Set Max value of ODR [Hz] 39 | #define TEMP_MIN_ODR PRESS_MIN_ODR // Set Min value of ODR [Hz] 40 | #define TEMP_POWER_CONSUMPTION PRESS_POWER_CONSUMPTION // Set sensor's power consumption [mA] 41 | 42 | /*****************************************************************************/ 43 | /* EVENT TYPE */ 44 | /*****************************************************************************/ 45 | 46 | /* Event Type in pressure sensor: see input_set_abs_params() function in your input driver */ 47 | #define EVENT_TYPE_PRESSURE MSC_SERIAL 48 | #define EVENT_TYPE_TEMPERATURE MSC_PULSELED 49 | 50 | /*****************************************************************************/ 51 | /* DATA CONVERSION */ 52 | /*****************************************************************************/ 53 | // conversion of pressure data to SI units (hPa, 1hPa=1mbar) 54 | #define CONVERT_PRESS (1.0f/4096.0f) 55 | 56 | // conversion of temperature data to SI units 57 | #define CONVERT_TEMP (1.0f/100.0f) 58 | 59 | #endif /* CONFIGURATION_LPS22HD_H */ 60 | -------------------------------------------------------------------------------- /conf/conf_LPS22HH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 STMicroelectronics 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CONFIGURATION_LPS22HH_H 19 | #define CONFIGURATION_LPS22HH_H 20 | 21 | #define SENSORS_PRESSURE_ENABLE (1) 22 | #define SENSORS_TEMP_PRESS_ENABLE (1) 23 | 24 | /* PRESSURE SENSOR */ 25 | #define SENSOR_PRESS_LABEL "LPS22HH Pressure sensor" // Label views in Android Applications 26 | #define SENSOR_TEMP_LABEL "LPS22HH Temperature sensor" // Label views in Android Applications 27 | #define SENSOR_DATANAME_BAROMETER "lps22hh" // Name of input device: struct input_dev->name 28 | #define PRESS_DELAY_FILE_NAME "device/poll_period_ms" // name of sysfs file for setting the pollrate 29 | #define PRESS_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 30 | #define PRESS_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 31 | #define PRESS_MAX_RANGE 1260 // Set Max Full-scale [hPa] 32 | #define TEMP_MAX_RANGE 80 // Set Max Full-scale [Celsius] 33 | #define TEMPERATURE_OFFSET 0 34 | #define PRESS_MAX_ODR 200 // Set Max value of ODR [Hz] 35 | #define PRESS_MIN_ODR 1 // Set Min value of ODR [Hz] 36 | #define PRESS_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 37 | #define TEMP_MAX_ODR PRESS_MAX_ODR // Set Max value of ODR [Hz] 38 | #define TEMP_MIN_ODR PRESS_MIN_ODR // Set Min value of ODR [Hz] 39 | #define TEMP_POWER_CONSUMPTION PRESS_POWER_CONSUMPTION // Set sensor's power consumption [mA] 40 | 41 | /*****************************************************************************/ 42 | /* EVENT TYPE */ 43 | /*****************************************************************************/ 44 | 45 | /* Event Type in pressure sensor: see input_set_abs_params() function in your input driver */ 46 | #define EVENT_TYPE_PRESSURE MSC_SERIAL 47 | #define EVENT_TYPE_TEMPERATURE MSC_PULSELED 48 | 49 | /*****************************************************************************/ 50 | /* DATA CONVERSION */ 51 | /*****************************************************************************/ 52 | // conversion of pressure data to SI units (hPa, 1hPa=1mbar) 53 | #define CONVERT_PRESS (1.0f/4096.0f) 54 | 55 | // conversion of temperature data to SI units 56 | #define CONVERT_TEMP (1.0f/100.0f) 57 | 58 | #endif /* CONFIGURATION_LPS22HH_H */ 59 | -------------------------------------------------------------------------------- /conf/conf_LPS25H.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LPS25H_H 20 | #define CONFIGURATION_LPS25H_H 21 | 22 | #define SENSORS_PRESSURE_ENABLE (1) 23 | #define SENSORS_TEMP_PRESS_ENABLE (1) 24 | 25 | /* PRESSURE SENSOR */ 26 | #define SENSOR_PRESS_LABEL "LPS25H Pressure sensor" // Label views in Android Applications 27 | #define SENSOR_TEMP_LABEL "LPS25H Temperature sensor" // Label views in Android Applications 28 | #define SENSOR_DATANAME_BAROMETER "lps25h" // Name of input device: struct input_dev->name 29 | #define PRESS_DELAY_FILE_NAME "device/poll_period_ms" // name of sysfs file for setting the pollrate 30 | #define PRESS_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 31 | #define PRESS_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 32 | #define PRESS_MAX_RANGE 1260 // Set Max Full-scale [hPa] 33 | #define TEMP_MAX_RANGE 105 // Set Max Full-scale [Celsius] 34 | #define TEMPERATURE_OFFSET 42.5f 35 | #define PRESS_MAX_ODR 25 // Set Max value of ODR [Hz] 36 | #define PRESS_MIN_ODR 1 // Set Min value of ODR [Hz] 37 | #define PRESS_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 38 | #define TEMP_MAX_ODR PRESS_MAX_ODR // Set Max value of ODR [Hz] 39 | #define TEMP_MIN_ODR PRESS_MIN_ODR // Set Min value of ODR [Hz] 40 | #define TEMP_POWER_CONSUMPTION PRESS_POWER_CONSUMPTION // Set sensor's power consumption [mA] 41 | 42 | /*****************************************************************************/ 43 | /* EVENT TYPE */ 44 | /*****************************************************************************/ 45 | 46 | /* Event Type in pressure sensor: see input_set_abs_params() function in your input driver */ 47 | #define EVENT_TYPE_PRESSURE MSC_SERIAL 48 | #define EVENT_TYPE_TEMPERATURE MSC_PULSELED 49 | 50 | /*****************************************************************************/ 51 | /* DATA CONVERSION */ 52 | /*****************************************************************************/ 53 | // conversion of pressure data to SI units (hPa, 1hPa=1mbar) 54 | #define CONVERT_PRESS (1.0f/4096.0f) 55 | 56 | // conversion of temperature data to SI units 57 | #define CONVERT_TEMP (1.0f/480.0f) 58 | 59 | #endif /* CONFIGURATION_LPS25H_H */ 60 | -------------------------------------------------------------------------------- /conf/conf_LPS33HW.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 STMicroelectronics 3 | * Lorenzo Bianconi - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_LPS33HW_H 20 | #define CONFIGURATION_LPS33HW_H 21 | 22 | #define SENSORS_PRESSURE_ENABLE (1) 23 | #define SENSORS_TEMP_PRESS_ENABLE (1) 24 | 25 | /* PRESSURE SENSOR */ 26 | #define SENSOR_PRESS_LABEL "LPS33HW Pressure sensor" // Label views in Android Applications 27 | #define SENSOR_TEMP_LABEL "LPS33HW Temperature sensor" // Label views in Android Applications 28 | #define SENSOR_DATANAME_BAROMETER "lps33hw" // Name of input device: struct input_dev->name 29 | #define PRESS_DELAY_FILE_NAME "device/poll_period_ms" // name of sysfs file for setting the pollrate 30 | #define PRESS_ENABLE_FILE_NAME "device/enable_device" // name of sysfs file for enable/disable the sensor state 31 | #define PRESS_RANGE_FILE_NAME "device/range" // name of sysfs file for setting the full scale 32 | #define PRESS_MAX_RANGE 1260 // Set Max Full-scale [hPa] 33 | #define TEMP_MAX_RANGE 80 // Set Max Full-scale [Celsius] 34 | #define TEMPERATURE_OFFSET 0 35 | #define PRESS_MAX_ODR 75 // Set Max value of ODR [Hz] 36 | #define PRESS_MIN_ODR 1 // Set Min value of ODR [Hz] 37 | #define PRESS_POWER_CONSUMPTION 0.015f // Set sensor's power consumption [mA] 38 | #define TEMP_MAX_ODR PRESS_MAX_ODR // Set Max value of ODR [Hz] 39 | #define TEMP_MIN_ODR PRESS_MIN_ODR // Set Min value of ODR [Hz] 40 | #define TEMP_POWER_CONSUMPTION PRESS_POWER_CONSUMPTION // Set sensor's power consumption [mA] 41 | 42 | /*****************************************************************************/ 43 | /* EVENT TYPE */ 44 | /*****************************************************************************/ 45 | 46 | /* Event Type in pressure sensor: see input_set_abs_params() function in your input driver */ 47 | #define EVENT_TYPE_PRESSURE MSC_SERIAL 48 | #define EVENT_TYPE_TEMPERATURE MSC_PULSELED 49 | 50 | /*****************************************************************************/ 51 | /* DATA CONVERSION */ 52 | /*****************************************************************************/ 53 | // conversion of pressure data to SI units (hPa, 1hPa=1mbar) 54 | #define CONVERT_PRESS (1.0f/4096.0f) 55 | 56 | // conversion of temperature data to SI units 57 | #define CONVERT_TEMP (1.0f/100.0f) 58 | 59 | #endif /* CONFIGURATION_LPS33HW_H */ 60 | -------------------------------------------------------------------------------- /conf/conf_LSM303AGR.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Armando Visconti - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef CONFIGURATION_SENSOR_LSM303AGR_H 20 | #define CONFIGURATION_SENSOR_LSM303AGR_H 21 | 22 | #define SENSORS_ACCELEROMETER_ENABLE (1) 23 | #define SENSORS_MAGNETIC_FIELD_ENABLE (1) 24 | #define SENSORS_UNCALIB_MAGNETIC_FIELD_ENABLE (1 & SENSORS_MAGNETIC_FIELD_ENABLE \ 25 | & OS_VERSION_ENABLE) 26 | 27 | /* ACCELEROMETER SENSOR */ 28 | #define SENSOR_ACC_LABEL "LSM303AGR 3-axis Accelerometer" 29 | #define SENSOR_DATANAME_ACCELEROMETER "lsm303agr_acc" 30 | #define ACCEL_DELAY_FILE_NAME "device/pollrate_ms" 31 | #define ACCEL_ENABLE_FILE_NAME "device/enable_device" 32 | #define ACCEL_RANGE_FILE_NAME "device/range" 33 | #define ACCEL_MAX_RANGE 8*GRAVITY_EARTH 34 | #define ACCEL_MAX_ODR 100 35 | #define ACCEL_POWER_CONSUMPTION 0.033f 36 | #define ACCEL_DEFAULT_FULLSCALE 4 37 | 38 | /* MAGNETOMETER SENSOR */ 39 | #define SENSOR_MAGN_LABEL "LSM303AGR 3-axis Magnetometer Sensor" 40 | #define SENSOR_DATANAME_MAGNETIC_FIELD "lsm303agr_mag" 41 | #define MAGN_DELAY_FILE_NAME "device/pollrate_ms" 42 | #define MAGN_ENABLE_FILE_NAME "device/enable_device" 43 | #define MAGN_RANGE_FILE_NAME "device/full_scale" 44 | #define CALIBRATION_ENABLE 1 45 | #define MAGN_MAX_RANGE 1600.0f 46 | #define MAGN_MAX_ODR 100 47 | #define MAGN_POWER_CONSUMPTION 0.077f 48 | #define MAGN_DEFAULT_FULLSCALE 50 49 | #define MAGN_MIN_ODR 25 50 | 51 | /* INEMO_ENGINE SENSOR */ 52 | #define ACC_DEFAULT_RANGE 4 53 | #define MAG_DEFAULT_RANGE 50 54 | #define ACC_DEFAULT_DELAY 100 55 | #define MAG_DEFAULT_DELAY 100 56 | 57 | /* SENSOR FUSION */ 58 | #define LOCAL_EARTH_MAGNETIC_FIELD 50.0f 59 | #define ACC_GBIAS_THRESHOLD 550e-6 60 | #define MAG_GBIAS_THRESHOLD 1200e-6 61 | 62 | /*****************************************************************************/ 63 | /* EVENT TYPE */ 64 | /*****************************************************************************/ 65 | #define EVENT_TYPE_ACCEL EV_MSC 66 | #define EVENT_TYPE_MAG EV_MSC 67 | 68 | /* Event Type in accelerometer sensor: see input_set_abs_params() function in your input driver */ 69 | #define EVENT_TYPE_ACCEL_X MSC_SERIAL 70 | #define EVENT_TYPE_ACCEL_Y MSC_PULSELED 71 | #define EVENT_TYPE_ACCEL_Z MSC_GESTURE 72 | 73 | /* Event Type in magnetometer sensor: see input_set_abs_params() function in your input driver */ 74 | #define EVENT_TYPE_MAG_X MSC_SERIAL 75 | #define EVENT_TYPE_MAG_Y MSC_PULSELED 76 | #define EVENT_TYPE_MAG_Z MSC_GESTURE 77 | 78 | #define EVENT_TYPE_TIME_MSB MSC_SCAN 79 | #define EVENT_TYPE_TIME_LSB MSC_MAX 80 | 81 | /*****************************************************************************/ 82 | /* AXIS MAPPING */ 83 | /*****************************************************************************/ 84 | 85 | /* In this section you must define the axis mapping for individuate one only coordinate system ENU 86 | * 87 | * Example: 88 | * y' /| z' 89 | * ^ / 90 | * | / You must define this coordinate system (reference system of board) 91 | * | / in accordance to definition of the axis 92 | * |/ definition in sensors.h file 93 | * +----------------------------------------------+---------> x' 94 | * | ^ x | 95 | * | | ^ z | 96 | * | | | | 97 | * | +-----+---> y | | 98 | * | | ACC | <---+-----+ | 99 | * | | | x | GYR | | 100 | * | +-----+ | | | 101 | * | / +-----+ | 102 | * | |/ y ^ /| z / | 103 | * | z | / |/ | 104 | * | |/ y | 105 | * | +-----+---> x | 106 | * | | MAG | | 107 | * | | | | 108 | * | +-----+ | 109 | * | BOARD | 110 | * +----------------------------------------------+ 111 | * 112 | * ACCELEROMETER: 113 | * 114 | * board acc | 0 1 0 | 115 | * [x' y' z'] = [x y z] * | 1 0 0 | 116 | * | 0 0 -1 | 117 | * 118 | * 119 | * MAGNETOMETER: 120 | * 121 | * board mag | 1 0 0 | 122 | * [x' y' z'] = [x y z] * | 0 0 1 | 123 | * | 0 0 1 | 124 | * 125 | */ 126 | 127 | static short matrix_acc[3][3] = { 128 | { 1, 0, 0 }, 129 | { 0, -1, 0 }, 130 | { 0, 0, 1 } 131 | }; 132 | 133 | static short matrix_mag[3][3] = { 134 | { 1, 0, 0 }, 135 | { 0, -1, 0 }, 136 | { 0, 0, 1 } 137 | }; 138 | 139 | /*****************************************************************************/ 140 | /* DATA CONVERSION */ 141 | /*****************************************************************************/ 142 | // conversion of acceleration data to SI units (m/s^2) 143 | #define CONVERT_A (GRAVITY_EARTH / 1000000.0f) 144 | #define CONVERT_A_X (CONVERT_A) 145 | #define CONVERT_A_Y (CONVERT_A) 146 | #define CONVERT_A_Z (CONVERT_A) 147 | 148 | #define CONVERT_M (1.0f/10000.0f)// 1uTESLA = 10 mGauss 149 | #define CONVERT_M_X (CONVERT_M) 150 | #define CONVERT_M_Y (CONVERT_M) 151 | #define CONVERT_M_Z (CONVERT_M) 152 | 153 | #define MAG_EVENT_HAS_TIMESTAMP 1 154 | #define ACC_EVENT_HAS_TIMESTAMP 1 155 | #define NOT_SET_ACC_INITIAL_STATE 1 156 | #define NOT_SET_MAG_INITIAL_STATE 1 157 | 158 | #endif /* CONFIGURATION_SENSOR_LSM303AGR_H */ 159 | -------------------------------------------------------------------------------- /conf/conf_MAGCALIB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 STMicroelectronics 3 | * Giuseppe Barba, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_MAGCAL_H 21 | #define CONFIGURATION_MAGCAL_H 22 | 23 | #define MAG_CALIBRATION_ENABLE (1 & ST_MAG_CALIB_MODULE_PRESENT & SENSORS_MAGNETIC_FIELD_ENABLE) 24 | #define CALIBRATION_FREQUENCY (25) 25 | #define CALIBRATION_PERIOD_MS (1000.0f / CALIBRATION_FREQUENCY) 26 | 27 | #endif /* CONFIGURATION_MAGCAL_H */ 28 | 29 | -------------------------------------------------------------------------------- /conf/conf_VGYRO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Giuseppe Barba - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #ifndef CONFIGURATION_VGYRO_H 21 | #define CONFIGURATION_VGYRO_H 22 | 23 | #define SENSORS_VIRTUAL_GYROSCOPE_ENABLE (1 && SENSORS_ACCELEROMETER_ENABLE && SENSORS_MAGNETIC_FIELD_ENABLE && !SENSORS_GYROSCOPE_ENABLE && GEOMAG_FUSION_MODULE_PRESENT) 24 | #define SENSORS_UNCALIB_GYROSCOPE_ENABLE (0) 25 | 26 | #define SENSOR_VIRTUAL_GYRO_LABEL "STMicroelectronics VGyroscope sensor" 27 | #define VIRTUAL_GYRO_MAX_RANGE (2000) 28 | #define VIRTUAL_GYRO_POWER_CONSUMPTION (ACCEL_POWER_CONSUMPTION + MAGN_POWER_CONSUMPTION) 29 | #define VIRTUAL_GYRO_MAX_ODR 100 30 | #define VIRTUAL_GYRO_DEFAULT_FULLSCALE 2000 31 | #define VGYRO_DEFAULT_DELAY 10 32 | 33 | /* GYROSCOPE STARTUP */ 34 | #define DEFAULT_SAMPLES_TO_DISCARD (0) 35 | #define GYRO_STARTUP_TIME_MS (0) 36 | 37 | #endif /* CONFIGURATION_VGYRO_H */ 38 | -------------------------------------------------------------------------------- /iNemoEngineSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Ciocca Denis, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "configuration.h" 20 | #if (SENSOR_FUSION_ENABLE == 1) 21 | 22 | #ifndef ANDROID_INEMOENGINE_SENSOR_H 23 | #define ANDROID_INEMOENGINE_SENSOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sensors.h" 31 | #include "SensorBase.h" 32 | #include "InputEventReader.h" 33 | 34 | #if (SENSORS_ACCELEROMETER_ENABLE == 1) 35 | #include "AccelSensor.h" 36 | #endif 37 | #if (SENSORS_GYROSCOPE_ENABLE == 1) 38 | #include "GyroSensor.h" 39 | #endif 40 | #if (SENSORS_MAGNETIC_FIELD_ENABLE == 1) 41 | #include "MagnSensor.h" 42 | #endif 43 | 44 | extern "C" 45 | { 46 | #include "iNemoEngineProAPI.h" 47 | }; 48 | 49 | /*****************************************************************************/ 50 | 51 | struct input_event; 52 | 53 | class iNemoEngineSensor : public SensorBase 54 | { 55 | enum { 56 | Acceleration = 0, 57 | MagneticField, 58 | AngularSpeed, 59 | Orientation, 60 | Gravity, 61 | LinearAcceleration, 62 | RotationMatrix, 63 | GameRotation, 64 | UncalibGyro, 65 | CalibGyro, 66 | numSensors 67 | }; 68 | 69 | int initialized; 70 | static int mEnabled; 71 | uint32_t mPendingMask; 72 | InputEventCircularReader mInputReader; 73 | sensors_event_t mPendingEvents[numSensors]; 74 | bool mHasPendingEvent; 75 | int setInitialState(); 76 | 77 | private: 78 | static int startup_samples; 79 | static int samples_to_discard; 80 | sensors_vec_t mSensorsBufferedVectors[3]; 81 | iNemoInitData init_data_api; 82 | iNemoDebugInitData debug_init_data_api; 83 | 84 | #if (SENSORS_GYROSCOPE_ENABLE == 1) 85 | char devices_sysfs_path_gyr[PATH_MAX]; 86 | int devices_sysfs_path_gyr_len; 87 | static GyroSensor *gyr; 88 | #endif 89 | #if(SENSORS_ACCELEROMETER_ENABLE == 1) 90 | char devices_sysfs_path_acc[PATH_MAX]; 91 | int devices_sysfs_path_acc_len; 92 | static AccelSensor *acc; 93 | #endif 94 | #if (SENSORS_MAGNETIC_FIELD_ENABLE == 1) 95 | char devices_sysfs_path_mag[PATH_MAX]; 96 | int devices_sysfs_path_mag_len; 97 | static MagnSensor *mag; 98 | #endif 99 | static int status; 100 | static int64_t gyroDelay_ms; 101 | static int64_t DelayBuffer[numSensors]; 102 | static int DecimationBuffer[numSensors]; 103 | static int DecimationCount[numSensors]; 104 | 105 | int64_t timestamp; 106 | 107 | public: 108 | iNemoEngineSensor(); 109 | virtual ~iNemoEngineSensor(); 110 | virtual int readEvents(sensors_event_t* data, int count); 111 | virtual bool hasPendingEvents() const; 112 | virtual int setDelay(int32_t handle, int64_t ns); 113 | virtual int enable(int32_t handle, int enabled, int type); 114 | virtual void updateDecimations(int64_t Delay_ms); 115 | virtual int getWhatFromHandle(int32_t handle); 116 | }; 117 | 118 | #endif // ANDROID_INEMOENGINE_SENSOR_H 119 | 120 | #endif /* SENSOR_FUSION_ENABLE */ 121 | -------------------------------------------------------------------------------- /lib/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 STMicroelectronics 2 | # Matteo Dameno, Denis Ciocca - Motion MEMS Product Div. 3 | # Copyright (C) 2008 The Android Open Source Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | include $(call all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /linux/hardware/sensors-base.h: -------------------------------------------------------------------------------- 1 | // This file is autogenerated by hidl-gen. Do not edit manually. 2 | // Source: android.hardware.sensors@1.0 3 | // Root: android.hardware:hardware/interfaces 4 | 5 | #ifndef HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ 6 | #define HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | enum { 13 | SENSOR_HAL_NORMAL_MODE = 0, 14 | SENSOR_HAL_DATA_INJECTION_MODE = 1, 15 | }; 16 | 17 | enum { 18 | SENSOR_TYPE_META_DATA = 0, 19 | SENSOR_TYPE_ACCELEROMETER = 1, 20 | SENSOR_TYPE_MAGNETIC_FIELD = 2, 21 | SENSOR_TYPE_ORIENTATION = 3, 22 | SENSOR_TYPE_GYROSCOPE = 4, 23 | SENSOR_TYPE_LIGHT = 5, 24 | SENSOR_TYPE_PRESSURE = 6, 25 | SENSOR_TYPE_TEMPERATURE = 7, 26 | SENSOR_TYPE_PROXIMITY = 8, 27 | SENSOR_TYPE_GRAVITY = 9, 28 | SENSOR_TYPE_LINEAR_ACCELERATION = 10, 29 | SENSOR_TYPE_ROTATION_VECTOR = 11, 30 | SENSOR_TYPE_RELATIVE_HUMIDITY = 12, 31 | SENSOR_TYPE_AMBIENT_TEMPERATURE = 13, 32 | SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14, 33 | SENSOR_TYPE_GAME_ROTATION_VECTOR = 15, 34 | SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 16, 35 | SENSOR_TYPE_SIGNIFICANT_MOTION = 17, 36 | SENSOR_TYPE_STEP_DETECTOR = 18, 37 | SENSOR_TYPE_STEP_COUNTER = 19, 38 | SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20, 39 | SENSOR_TYPE_HEART_RATE = 21, 40 | SENSOR_TYPE_TILT_DETECTOR = 22, 41 | SENSOR_TYPE_WAKE_GESTURE = 23, 42 | SENSOR_TYPE_GLANCE_GESTURE = 24, 43 | SENSOR_TYPE_PICK_UP_GESTURE = 25, 44 | SENSOR_TYPE_WRIST_TILT_GESTURE = 26, 45 | SENSOR_TYPE_DEVICE_ORIENTATION = 27, 46 | SENSOR_TYPE_POSE_6DOF = 28, 47 | SENSOR_TYPE_STATIONARY_DETECT = 29, 48 | SENSOR_TYPE_MOTION_DETECT = 30, 49 | SENSOR_TYPE_HEART_BEAT = 31, 50 | SENSOR_TYPE_DYNAMIC_SENSOR_META = 32, 51 | SENSOR_TYPE_ADDITIONAL_INFO = 33, 52 | SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT = 34, 53 | SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 35, 54 | SENSOR_TYPE_DEVICE_PRIVATE_BASE = 65536, // 0x10000 55 | }; 56 | 57 | enum { 58 | SENSOR_FLAG_WAKE_UP = 1u, // 1 59 | SENSOR_FLAG_CONTINUOUS_MODE = 0u, // 0 60 | SENSOR_FLAG_ON_CHANGE_MODE = 2u, // 2 61 | SENSOR_FLAG_ONE_SHOT_MODE = 4u, // 4 62 | SENSOR_FLAG_SPECIAL_REPORTING_MODE = 6u, // 6 63 | SENSOR_FLAG_DATA_INJECTION = 16u, // 0x10 64 | SENSOR_FLAG_DYNAMIC_SENSOR = 32u, // 0x20 65 | SENSOR_FLAG_ADDITIONAL_INFO = 64u, // 0x40 66 | SENSOR_FLAG_DIRECT_CHANNEL_ASHMEM = 1024u, // 0x400 67 | SENSOR_FLAG_DIRECT_CHANNEL_GRALLOC = 2048u, // 0x800 68 | SENSOR_FLAG_MASK_REPORTING_MODE = 14u, // 0xE 69 | SENSOR_FLAG_MASK_DIRECT_REPORT = 896u, // 0x380 70 | SENSOR_FLAG_MASK_DIRECT_CHANNEL = 3072u, // 0xC00 71 | }; 72 | 73 | typedef enum { 74 | SENSOR_FLAG_SHIFT_REPORTING_MODE = 1, 75 | SENSOR_FLAG_SHIFT_DATA_INJECTION = 4, 76 | SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR = 5, 77 | SENSOR_FLAG_SHIFT_ADDITIONAL_INFO = 6, 78 | SENSOR_FLAG_SHIFT_DIRECT_REPORT = 7, 79 | SENSOR_FLAG_SHIFT_DIRECT_CHANNEL = 10, 80 | } sensor_flag_shift_t; 81 | 82 | enum { 83 | SENSOR_STATUS_NO_CONTACT = -1, // (-1) 84 | SENSOR_STATUS_UNRELIABLE = 0, 85 | SENSOR_STATUS_ACCURACY_LOW = 1, 86 | SENSOR_STATUS_ACCURACY_MEDIUM = 2, 87 | SENSOR_STATUS_ACCURACY_HIGH = 3, 88 | }; 89 | 90 | enum { 91 | META_DATA_FLUSH_COMPLETE = 1u, // 1 92 | }; 93 | 94 | typedef enum { 95 | AINFO_BEGIN = 0u, // 0 96 | AINFO_END = 1u, // 1 97 | AINFO_UNTRACKED_DELAY = 65536u, // 0x10000 98 | AINFO_INTERNAL_TEMPERATURE = 65537u, // 65537 99 | AINFO_VEC3_CALIBRATION = 65538u, // 65538 100 | AINFO_SENSOR_PLACEMENT = 65539u, // 65539 101 | AINFO_SAMPLING = 65540u, // 65540 102 | AINFO_CHANNEL_NOISE = 131072u, // 0x20000 103 | AINFO_CHANNEL_SAMPLER = 131073u, // 131073 104 | AINFO_CHANNEL_FILTER = 131074u, // 131074 105 | AINFO_CHANNEL_LINEAR_TRANSFORM = 131075u, // 131075 106 | AINFO_CHANNEL_NONLINEAR_MAP = 131076u, // 131076 107 | AINFO_CHANNEL_RESAMPLER = 131077u, // 131077 108 | AINFO_LOCAL_GEOMAGNETIC_FIELD = 196608u, // 0x30000 109 | AINFO_LOCAL_GRAVITY = 196609u, // 196609 110 | AINFO_DOCK_STATE = 196610u, // 196610 111 | AINFO_HIGH_PERFORMANCE_MODE = 196611u, // 196611 112 | AINFO_MAGNETIC_FIELD_CALIBRATION = 196612u, // 196612 113 | AINFO_CUSTOM_START = 268435456u, // 0x10000000 114 | AINFO_DEBUGGING_START = 1073741824u, // 0x40000000 115 | } additional_info_type_t; 116 | 117 | typedef enum { 118 | SENSOR_DIRECT_RATE_STOP = 0, 119 | SENSOR_DIRECT_RATE_NORMAL = 1, 120 | SENSOR_DIRECT_RATE_FAST = 2, 121 | SENSOR_DIRECT_RATE_VERY_FAST = 3, 122 | } direct_rate_level_t; 123 | 124 | typedef enum { 125 | SENSOR_DIRECT_MEM_TYPE_ASHMEM = 1, 126 | SENSOR_DIRECT_MEM_TYPE_GRALLOC = 2, 127 | } direct_mem_type_t; 128 | 129 | typedef enum { 130 | SENSOR_DIRECT_FMT_SENSORS_EVENT = 1, 131 | } direct_format_t; 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif // HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ 138 | -------------------------------------------------------------------------------- /sensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 STMicroelectronics 3 | * Matteo Dameno, Denis Ciocca, Alberto Marinoni - Motion MEMS Product Div. 4 | * Copyright (C) 2008 The Android Open Source Project 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef ANDROID_SENSORS_H 20 | #define ANDROID_SENSORS_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include "configuration.h" 32 | 33 | __BEGIN_DECLS 34 | 35 | /*****************************************************************************/ 36 | 37 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 38 | 39 | #define ID_BASE (SENSORS_HANDLE_BASE+1) 40 | #define ID_ACCELEROMETER (ID_BASE+0) 41 | #define ID_MAGNETIC_FIELD (ID_BASE+1) 42 | #define ID_ORIENTATION (ID_BASE+2) 43 | #define ID_GYROSCOPE (ID_BASE+3) 44 | #define ID_LIGHT (ID_BASE+4) 45 | #define ID_PRESSURE (ID_BASE+5) 46 | #define ID_TEMPERATURE (ID_BASE+6) 47 | #define ID_PROXIMITY (ID_BASE+7) 48 | #define ID_GRAVITY (ID_BASE+8) 49 | #define ID_LINEAR_ACCELERATION (ID_BASE+9) 50 | #define ID_ROTATION_VECTOR (ID_BASE+10) 51 | #define ID_GAME_ROTATION (ID_BASE+11) 52 | #define ID_UNCALIB_GYROSCOPE (ID_BASE+12) 53 | #define ID_SIGNIFICANT_MOTION (ID_BASE+13) 54 | #define ID_UNCALIB_MAGNETIC_FIELD (ID_BASE+14) 55 | #define ID_GEOMAG_ROTATION_VECTOR (ID_BASE+15) 56 | #define ID_SENSOR_FUSION (ID_BASE+16) 57 | #define ID_VIRTUAL_GYROSCOPE (ID_BASE+17) 58 | #define ID_TILT_DETECTOR (ID_BASE+18) 59 | #define ID_STEP_COUNTER (ID_BASE+19) 60 | #define ID_STEP_DETECTOR (ID_BASE+20) 61 | #define ID_SIGN_MOTION (ID_BASE+21) 62 | #define ID_ACTIVITY_RECOGNIZER (ID_BASE+22) 63 | #define ID_TAP (ID_BASE+23) 64 | #define ID_HUMIDITY (ID_BASE+24) 65 | #define ID_UNCALIB_ACCELEROMETER (ID_BASE+25) 66 | 67 | #define SENSORS_ACCELEROMETER_HANDLE ID_ACCELEROMETER 68 | #define SENSORS_MAGNETIC_FIELD_HANDLE ID_MAGNETIC_FIELD 69 | #define SENSORS_ORIENTATION_HANDLE ID_ORIENTATION 70 | #define SENSORS_LIGHT_HANDLE ID_LIGHT 71 | #define SENSORS_PROXIMITY_HANDLE ID_PROXIMITY 72 | #define SENSORS_GYROSCOPE_HANDLE ID_GYROSCOPE 73 | #define SENSORS_GRAVITY_HANDLE ID_GRAVITY 74 | #define SENSORS_LINEAR_ACCELERATION_HANDLE ID_LINEAR_ACCELERATION 75 | #define SENSORS_ROTATION_VECTOR_HANDLE ID_ROTATION_VECTOR 76 | #define SENSORS_PRESSURE_HANDLE ID_PRESSURE 77 | #define SENSORS_TEMPERATURE_HANDLE ID_TEMPERATURE 78 | #define SENSORS_GAME_ROTATION_HANDLE ID_GAME_ROTATION 79 | #define SENSORS_UNCALIB_GYROSCOPE_HANDLE ID_UNCALIB_GYROSCOPE 80 | #define SENSORS_SIGNIFICANT_MOTION_HANDLE ID_SIGNIFICANT_MOTION 81 | #define SENSORS_UNCALIB_MAGNETIC_FIELD_HANDLE ID_UNCALIB_MAGNETIC_FIELD 82 | #define SENSORS_GEOMAG_ROTATION_VECTOR_HANDLE ID_GEOMAG_ROTATION_VECTOR 83 | #define SENSORS_SENSOR_FUSION_HANDLE ID_SENSOR_FUSION 84 | #define SENSORS_VIRTUAL_GYROSCOPE_HANDLE ID_VIRTUAL_GYROSCOPE 85 | #define SENSORS_TILT_DETECTOR_HANDLE ID_TILT_DETECTOR 86 | #define SENSORS_STEP_COUNTER_HANDLE ID_STEP_COUNTER 87 | #define SENSORS_STEP_DETECTOR_HANDLE ID_STEP_DETECTOR 88 | #define SENSORS_SIGN_MOTION_HANDLE ID_SIGN_MOTION 89 | #define SENSORS_ACTIVITY_RECOGNIZER_HANDLE ID_ACTIVITY_RECOGNIZER 90 | #define SENSORS_TAP_HANDLE ID_TAP 91 | #define SENSORS_HUMIDITY_HANDLE ID_HUMIDITY 92 | #define SENSORS_UNCALIB_ACCELEROMETER_HANDLE ID_UNCALIB_ACCELEROMETER 93 | 94 | #define SENSOR_TYPE_TAP (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 2) 95 | #define SENSOR_TYPE_ACTIVITY (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 3) 96 | 97 | #define SENSOR_STRING_TYPE_TAP "com.st.tap" 98 | 99 | #define TRACE_FUNCTION_START ALOGD("%s:start at %lld", __func__, SensorBase::getTimestamp()); 100 | #define TRACE_FUNCTION_END ALOGD("%s:end at %lld", __func__, SensorBase::getTimestamp()); 101 | /*****************************************************************************/ 102 | /* EVENT TYPE */ 103 | /*****************************************************************************/ 104 | 105 | #if (ANDROID_VERSION >= ANDROID_JBMR2) 106 | #define SENSOR_POLL_DEVICE sensors_poll_device_1 107 | #else 108 | #define SENSOR_POLL_DEVICE sensors_poll_device_t 109 | #endif 110 | 111 | __END_DECLS 112 | 113 | #endif // ANDROID_SENSORS_H 114 | --------------------------------------------------------------------------------