1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#ifndef HDI_SENSOR_CHANNEL_H
17094332d3Sopenharmony_ci#define HDI_SENSOR_CHANNEL_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include "hdf_io_service_if.h"
20094332d3Sopenharmony_ci#include "sensor_type.h"
21094332d3Sopenharmony_ci
22094332d3Sopenharmony_ci#define HDI_SENSOR_GRAVITY          (9.80665f)
23094332d3Sopenharmony_ci#define HDI_SENSOR_ACCEL_LSB        1024
24094332d3Sopenharmony_ci#define HDI_SENSOR_UNITS            1000
25094332d3Sopenharmony_ci#define HDI_SENSOR_PI               (3.14f)
26094332d3Sopenharmony_ci#define HDI_SENSOR_SEMICIRCLE       (180.0f)
27094332d3Sopenharmony_ci#define HDI_SENSOR_FLOAT_UNITS      (1000.0f)
28094332d3Sopenharmony_ci#define HDI_SENSOR_FLOAT_HUN_UNITS  (100.0f)
29094332d3Sopenharmony_ci#define HDI_SENSOR_FLOAT_TEN_UNITS  (10.0f)
30094332d3Sopenharmony_ci#define MAX_DUMP_DATA_SIZE 10
31094332d3Sopenharmony_ci#define DATA_LENGTH 32
32094332d3Sopenharmony_ci
33094332d3Sopenharmony_cienum SensorDataDimension {
34094332d3Sopenharmony_ci    DATA_X             = 1,
35094332d3Sopenharmony_ci    DATA_XY            = 2,
36094332d3Sopenharmony_ci    DATA_XYZ           = 3,
37094332d3Sopenharmony_ci    DATA_XYZA          = 4,
38094332d3Sopenharmony_ci    DATA_XYZABC        = 6,
39094332d3Sopenharmony_ci    DATA_POSTURE       = 8,
40094332d3Sopenharmony_ci    DATA_MAX_DATA_SIZE = DATA_POSTURE
41094332d3Sopenharmony_ci};
42094332d3Sopenharmony_ci
43094332d3Sopenharmony_cienum SensorStatusAccuracy {
44094332d3Sopenharmony_ci    SENSOR_STATUS_UNRELIABLE = 0,
45094332d3Sopenharmony_ci    SENSOR_STATUS_ACCURACY_LOW = 1,
46094332d3Sopenharmony_ci    SENSOR_STATUS_ACCURACY_MEDIUM = 2,
47094332d3Sopenharmony_ci    SENSOR_STATUS_ACCURACY_HIGH = 3,
48094332d3Sopenharmony_ci};
49094332d3Sopenharmony_ci
50094332d3Sopenharmony_cistruct SensorCovertCoff {
51094332d3Sopenharmony_ci    int32_t sensorTypeId;
52094332d3Sopenharmony_ci    int32_t sensorId;
53094332d3Sopenharmony_ci    enum SensorDataDimension dim;
54094332d3Sopenharmony_ci    float coff[DATA_MAX_DATA_SIZE];
55094332d3Sopenharmony_ci};
56094332d3Sopenharmony_ci
57094332d3Sopenharmony_cistruct SensorDumpDate {
58094332d3Sopenharmony_ci    int32_t sensorId;
59094332d3Sopenharmony_ci    int32_t version;
60094332d3Sopenharmony_ci    int64_t timestamp;
61094332d3Sopenharmony_ci    uint32_t option;
62094332d3Sopenharmony_ci    int32_t mode;
63094332d3Sopenharmony_ci    uint8_t data[DATA_LENGTH];
64094332d3Sopenharmony_ci    uint32_t dataLen;
65094332d3Sopenharmony_ci};
66094332d3Sopenharmony_ci
67094332d3Sopenharmony_cistruct SensorDatePack {
68094332d3Sopenharmony_ci    int32_t count;
69094332d3Sopenharmony_ci    int32_t pos;
70094332d3Sopenharmony_ci    struct SensorDumpDate listDumpArr[MAX_DUMP_DATA_SIZE];
71094332d3Sopenharmony_ci};
72094332d3Sopenharmony_ci
73094332d3Sopenharmony_ciint32_t Register(int32_t groupId, RecordDataCallback cb);
74094332d3Sopenharmony_ciint32_t Unregister(int32_t groupId, RecordDataCallback cb);
75094332d3Sopenharmony_cistruct HdfDevEventlistener *GetSensorListener(void);
76094332d3Sopenharmony_civoid SetSensorIdBySensorType(enum SensorTypeTag type, int32_t sensorId);
77094332d3Sopenharmony_cistruct SensorDatePack *GetEventData(void);
78094332d3Sopenharmony_civoid ConvertSensorData(struct SensorEvents *event);
79094332d3Sopenharmony_ci
80094332d3Sopenharmony_ci#endif /* HDI_SENSOR_CHANNEL_H */
81