From ab737f90bbc0b95538b6f26a72426d18970cb5c8 Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 22 Feb 2022 06:40:49 +0000 Subject: [PATCH] update zh-cn/device-dev/subsystems/subsys-sensor-guide.md. Signed-off-by: Austin --- .../subsystems/subsys-sensor-guide.md | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/zh-cn/device-dev/subsystems/subsys-sensor-guide.md b/zh-cn/device-dev/subsystems/subsys-sensor-guide.md index b8d7fa3101..1f6be37011 100644 --- a/zh-cn/device-dev/subsystems/subsys-sensor-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-sensor-guide.md @@ -8,65 +8,65 @@ 1. 导入需要的包 -``` -#include "sensor_agent.h" -#include "sensor_agent_type.h" -``` - -1. 创建传感器回调函数 - -``` -void SensorDataCallbackImpl(SensorEvent *event) -{ - if(event == NULL){ - return; - } - float *sensorData=(float *)event->data; -} -``` + ``` + #include "sensor_agent.h" + #include "sensor_agent_type.h" + ``` + +2. 创建传感器回调函数 + + ``` + void SensorDataCallbackImpl(SensorEvent *event) + { + if(event == NULL){ + return; + } + float *sensorData=(float *)event->data; + } + ``` >![](../public_sys-resources/icon-note.gif) **说明:** >回调函数的格式为RecordSensorCallback类型。 -1. 获取设备支持sensor列表 +3. 获取设备支持sensor列表 -``` -SensorInfo *sensorInfo = (SensorInfo *)NULL; -int32_t count = 0; -int32_t ret = GetAllSensors(&sensorInfo, &count); -``` + ``` + SensorInfo *sensorInfo = (SensorInfo *)NULL; + int32_t count = 0; + int32_t ret = GetAllSensors(&sensorInfo, &count); + ``` -1. 创建的传感器用户 +4. 创建的传感器用户 -``` -SensorUser sensorUser; -sensorUser.callback = SensorDataCallbackImpl; //成员变量callback指向创建的回调方法 -``` + ``` + SensorUser sensorUser; + sensorUser.callback = SensorDataCallbackImpl; //成员变量callback指向创建的回调方法 + ``` -1. 使能传感器 +5. 使能传感器 -``` -int32_t ret = ActivateSensor(0, &sensorUser); -``` + ``` + int32_t ret = ActivateSensor(0, &sensorUser); + ``` -1. 订阅传感器数据 +6. 订阅传感器数据 -``` -int32_t ret = SubscribeSensor(0, &sensorUser); -``` + ``` + int32_t ret = SubscribeSensor(0, &sensorUser); + ``` >![](../public_sys-resources/icon-note.gif) **说明:** >到这步就可以在实现的回调方法中获取到传感器数据。 -1. 取消传感器数据订阅 +7. 取消传感器数据订阅 -``` -int32_t ret = UnsubscribeSensor(0, &sensorUser); -``` + ``` + int32_t ret = UnsubscribeSensor(0, &sensorUser); + ``` -1. 去使能一个传感器 +8. 去使能一个传感器 -``` -int32_t ret = DeactivateSensor(0, &sensorUser); -``` + ``` + int32_t ret = DeactivateSensor(0, &sensorUser); + ``` -- GitLab