未验证 提交 67d73cb5 编写于 作者: O openharmony_ci 提交者: Gitee

!8800 格式优化【需要翻译】

Merge pull request !8800 from duangavin123/master
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
使用实例以sensorTypeId为0的传感器为例,其他类型的传感器使用方式类似。 使用实例以sensorTypeId为0的传感器为例,其他类型的传感器使用方式类似。
``` ```c
#include "sensor_agent.h" #include "sensor_agent.h"
#include "sensor_agent_type.h" #include "sensor_agent_type.h"
#include "stdio.h" #include "stdio.h"
......
...@@ -9,78 +9,78 @@ ...@@ -9,78 +9,78 @@
1. 导入需要的包 1. 导入需要的包
``` ```c
#include "sensor_agent.h" #include "sensor_agent.h"
#include "sensor_agent_type.h" #include "sensor_agent_type.h"
``` ```
2. 创建传感器回调函数 2. 创建传感器回调函数
``` ```c
void SensorDataCallbackImpl(SensorEvent *event) void SensorDataCallbackImpl(SensorEvent *event)
{ {
if(event == NULL){ if(event == NULL){
return; return;
}
float *sensorData=(float *)event->data;
} }
float *sensorData=(float *)event->data; ```
}
``` > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 回调函数的格式为RecordSensorCallback类型。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 回调函数的格式为RecordSensorCallback类型。
3. 获取设备支持sensor列表 3. 获取设备支持sensor列表
``` ```c
SensorInfo *sensorInfo = (SensorInfo *)NULL; SensorInfo *sensorInfo = (SensorInfo *)NULL;
int32_t count = 0; int32_t count = 0;
int32_t ret = GetAllSensors(&sensorInfo, &count); int32_t ret = GetAllSensors(&sensorInfo, &count);
``` ```
4. 创建的传感器用户 4. 创建的传感器用户
``` ```c
SensorUser sensorUser; SensorUser sensorUser;
sensorUser.callback = SensorDataCallbackImpl; //成员变量callback指向创建的回调方法 sensorUser.callback = SensorDataCallbackImpl; //成员变量callback指向创建的回调方法
``` ```
5. 使能传感器 5. 使能传感器
``` ```c
int32_t ret = ActivateSensor(0, &sensorUser); int32_t ret = ActivateSensor(0, &sensorUser);
``` ```
6. 订阅传感器数据 6. 订阅传感器数据
``` ```c
int32_t ret = SubscribeSensor(0, &sensorUser); int32_t ret = SubscribeSensor(0, &sensorUser);
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 到这步就可以在实现的回调方法中获取到传感器数据。 > 到这步就可以在实现的回调方法中获取到传感器数据。
7. 取消传感器数据订阅 7. 取消传感器数据订阅
``` ```c
int32_t ret = UnsubscribeSensor(0, &sensorUser); int32_t ret = UnsubscribeSensor(0, &sensorUser);
``` ```
8. 去使能一个传感器 8. 去使能一个传感器
``` ```c
int32_t ret = DeactivateSensor(0, &sensorUser); int32_t ret = DeactivateSensor(0, &sensorUser);
``` ```
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
5. 配置设备接口 5. 配置设备接口
```cpp ```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true); ret = g_usbClient.ClaimInterface(pip, interface, true); //interface为deviceList中device的interface。
interfacedeviceListdeviceinterface
``` ```
6. 数据传输 6. 数据传输
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册