• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #define MAX_DUMP_DATA_SIZE 10
31 #define DATA_LENGTH 32
32 
33 enum SensorDataDimension {
34     DATA_X             = 1,
35     DATA_XY            = 2,
36     DATA_XYZ           = 3,
37     DATA_XYZA          = 4,
38     DATA_XYZABC        = 6,
39     DATA_POSTURE       = 8,
40     DATA_MAX_DATA_SIZE = DATA_POSTURE
41 };
42 
43 struct SensorCovertCoff {
44     int32_t sensorTypeId;
45     int32_t sensorId;
46     enum SensorDataDimension dim;
47     float coff[DATA_MAX_DATA_SIZE];
48 };
49 
50 struct SensorDumpDate {
51     int32_t sensorId;
52     int32_t version;
53     int64_t timestamp;
54     uint32_t option;
55     int32_t mode;
56     uint8_t data[DATA_LENGTH];
57     uint32_t dataLen;
58 };
59 
60 struct SensorDatePack {
61     int32_t count;
62     int32_t pos;
63     struct SensorDumpDate listDumpArr[MAX_DUMP_DATA_SIZE];
64 };
65 
66 int32_t Register(int32_t groupId, RecordDataCallback cb);
67 int32_t Unregister(int32_t groupId, RecordDataCallback cb);
68 struct HdfDevEventlistener *GetSensorListener(void);
69 void SetSensorIdBySensorType(enum SensorTypeTag type, int32_t sensorId);
70 struct SensorDatePack *GetEventData(void);
71 void ConvertSensorData(struct SensorEvents *event);
72 
73 #endif /* HDI_SENSOR_CHANNEL_H */
74