1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_SENSOR_CHANNEL_H 17 #define HDI_SENSOR_CHANNEL_H 18 19 #include "hdf_io_service_if.h" 20 #include "sensor_type.h" 21 22 #define HDI_SENSOR_GRAVITY (9.80665f) 23 #define HDI_SENSOR_ACCEL_LSB 1024 24 #define HDI_SENSOR_UNITS 1000 25 #define HDI_SENSOR_PI (3.14f) 26 #define HDI_SENSOR_SEMICIRCLE (180.0f) 27 #define HDI_SENSOR_FLOAT_UNITS (1000.0f) 28 #define HDI_SENSOR_FLOAT_HUN_UNITS (100.0f) 29 #define HDI_SENSOR_FLOAT_TEN_UNITS (10.0f) 30 31 enum SensorDataDimension { 32 DATA_X = 1, 33 DATA_XY = 2, 34 DATA_XYZ = 3, 35 DATA_XYZA = 4, 36 DATA_XYZABC = 6, 37 DATA_POSTURE = 8, 38 DATA_MAX_DATA_SIZE = DATA_POSTURE 39 }; 40 41 struct SensorCovertCoff { 42 int32_t sensorTypeId; 43 int32_t sensorId; 44 enum SensorDataDimension dim; 45 float coff[DATA_MAX_DATA_SIZE]; 46 }; 47 48 int32_t Register(int32_t groupId, RecordDataCallback cb); 49 int32_t Unregister(int32_t groupId, RecordDataCallback cb); 50 struct HdfDevEventlistener *GetSensorListener(); 51 void SetSensorIdBySensorType(enum SensorTypeTag type, int32_t sensorId); 52 53 #endif /* HDI_SENSOR_CHANNEL_H */