From d5942552b1b7ebaef2640594ffeed9ae04179f3c Mon Sep 17 00:00:00 2001 From: yangjunrui Date: Wed, 19 Jan 2022 07:56:15 +0800 Subject: [PATCH 1/2] feat: move vibrator and light idl to driver_interface Signed-off-by: yangjunrui --- light/v1_0/BUILD.gn | 16 ++++++ light/v1_0/ILightInterface.idl | 23 ++++++++ light/v1_0/LightTypes.idl | 45 +++++++++++++++ vibrator/v1_0/BUILD.gn | 29 ++++++++++ vibrator/v1_0/IVibratorInterface.idl | 84 ++++++++++++++++++++++++++++ vibrator/v1_0/VibratorTypes.idl | 28 ++++++++++ 6 files changed, 225 insertions(+) create mode 100644 light/v1_0/BUILD.gn create mode 100755 light/v1_0/ILightInterface.idl create mode 100755 light/v1_0/LightTypes.idl create mode 100755 vibrator/v1_0/BUILD.gn create mode 100755 vibrator/v1_0/IVibratorInterface.idl create mode 100755 vibrator/v1_0/VibratorTypes.idl diff --git a/light/v1_0/BUILD.gn b/light/v1_0/BUILD.gn new file mode 100644 index 00000000..fc5cb473 --- /dev/null +++ b/light/v1_0/BUILD.gn @@ -0,0 +1,16 @@ +import("//drivers/adapter/uhdf2/hdi.gni") + +hdi("light") { + package = "light.v1_0" + + module_name = "light_service" + + sources = [ + "ILightInterface.idl", + "LightTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "light_device_driver" +} diff --git a/light/v1_0/ILightInterface.idl b/light/v1_0/ILightInterface.idl new file mode 100755 index 00000000..6d347f9e --- /dev/null +++ b/light/v1_0/ILightInterface.idl @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +package light.v1_0; +import light.v1_0.LightTypes; + +interface ILightInterface { + GetLightInfo([out] struct HdfLightInfo[] info); + TurnOnLight([in] int lightId, [in] struct HdfLightEffect effect); + TurnOffLight([in] int LightId); +} \ No newline at end of file diff --git a/light/v1_0/LightTypes.idl b/light/v1_0/LightTypes.idl new file mode 100755 index 00000000..8e151c9e --- /dev/null +++ b/light/v1_0/LightTypes.idl @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +package light.v1_0; + +enum HdfLighType { + HDF_LIGHT_TYPE_BATTERY = 1, + HDF_LIGHT_TYPE_NOTIFICATIONS = 2, + HDF_LIGHT_TYPE_ATTENTION = 3, + HDF_LIGHT_ID_BUTT = 4, +}; + +struct HdfLightInfo { + int lightId; + int reserved; +}; + +enum HdfLightFlashMode { + HDF_LIGHT_FLASH_NONE = 0, + HDF_LIGHT_FLASH_TIMED = 1, + HDF_LIGHT_FLASH_BUTT = 2, +}; + +struct HdfLightFlashEffect { + int flashMode; + int onTime; + int offTime; +}; + +struct HdfLightEffect { + int lightBrightness; + struct HdfLightFlashEffect flashEffect; +}; \ No newline at end of file diff --git a/vibrator/v1_0/BUILD.gn b/vibrator/v1_0/BUILD.gn new file mode 100755 index 00000000..b5549468 --- /dev/null +++ b/vibrator/v1_0/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +import("//drivers/adapter/uhdf2/hdi.gni") + +hdi("vibrator") { + package = "vibrator.v1_0" + + module_name = "vibrator_service" + + sources = [ + "IVibratorInterface.idl", + "VibratorTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "vibrator_device_driver" +} diff --git a/vibrator/v1_0/IVibratorInterface.idl b/vibrator/v1_0/IVibratorInterface.idl new file mode 100755 index 00000000..ad41ce1b --- /dev/null +++ b/vibrator/v1_0/IVibratorInterface.idl @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +/** + * @addtogroup Vibrator + * @{ + * + * @brief Provides a driver for upper-layer vibrator services. + * + * After obtaining a driver object or agent, a vibrator service starts or stops the vibrator + * using the functions provided by the driver object or agent. + * + * @since 2.2 + */ + +/** + * @file VibratorTypes.idl + * + * @brief Declares common APIs in the vibrator module. The APIs can be used to control + * the vibrator to perform a one-shot or periodic vibration. + * + * @since 2.2 + * @version 1.0 + */ + +package vibrator.v1_0; + +import vibrator.v1_0.VibratorTypes; + +interface IVibratorInterface { + /** + * @brief Controls the vibrator to perform a one-shot vibration that lasts for a given duration. + * + * One-shot vibration is mutually exclusive with periodic vibration. Before using one-shot vibration, + * exit periodic vibration. + * + * @param duration Indicates the duration that the one-shot vibration lasts, in milliseconds. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 2.2 + * @version 1.0 + */ + StartOnce([in] unsigned int duration); + /** + * @brief Controls the vibrator to perform a periodic vibration with the preset effect. + * + * One-shot vibration is mutually exclusive with periodic vibration. Before using periodic vibration, + * exit one-shot vibration. + * + * @param effectType Indicates the pointer to the preset effect type. It is recommended that the + * maximum length be 64 bytes. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 2.2 + * @version 1.0 + */ + Start([in] String effectType); + /** + * @brief Stops the vibration. + * + * Before the vibrator starts, it must stop vibrating in any mode. This function can be used during + * and after the vibrating process. + * + * @param mode Indicates the vibration mode, which can be one-shot or periodic. For details, + * see {@link HdfVibratorMode}. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * + * @since 2.2 + * @version 1.0 + */ + Stop([in] enum HdfVibratorMode mode); +} \ No newline at end of file diff --git a/vibrator/v1_0/VibratorTypes.idl b/vibrator/v1_0/VibratorTypes.idl new file mode 100755 index 00000000..2ca65a9b --- /dev/null +++ b/vibrator/v1_0/VibratorTypes.idl @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + +package vibrator.v1_0; + +/** + * @brief Enumerates the vibration modes of this vibrator. + * + * @since 2.2 + */ +enum HdfVibratorMode { + HDF_VIBRATOR_MODE_ONCE, /**< Indicates the one-shot vibration with the given duration. */ + HDF_VIBRATOR_MODE_PRESET, /**< Indicates the periodic vibration with the preset effect. */ + HDF_VIBRATOR_MODE_BUTT, /**< Indicates invalid the effect mode. */ +}; + -- Gitee From 2e945b42f853d8d47c95f0fa8a51834c2b6faf8c Mon Sep 17 00:00:00 2001 From: yangjunrui Date: Wed, 19 Jan 2022 08:30:46 +0800 Subject: [PATCH 2/2] feat: move vibrator and light idl to driver_interface Signed-off-by: yangjunrui --- light/v1_0/BUILD.gn | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/light/v1_0/BUILD.gn b/light/v1_0/BUILD.gn index fc5cb473..715bdbec 100644 --- a/light/v1_0/BUILD.gn +++ b/light/v1_0/BUILD.gn @@ -1,3 +1,16 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import("//drivers/adapter/uhdf2/hdi.gni") hdi("light") { -- Gitee