Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逆着光、寻觅
rt-thread
提交
452432a1
R
rt-thread
项目概览
逆着光、寻觅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
452432a1
编写于
5月 04, 2015
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Sensor] Fix the call back issue in sensor.
上级
90e95eca
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
15 deletion
+16
-15
components/drivers/sensors/sensor.cpp
components/drivers/sensors/sensor.cpp
+5
-5
components/drivers/sensors/sensor.h
components/drivers/sensors/sensor.h
+11
-10
未找到文件。
components/drivers/sensors/sensor.cpp
浏览文件 @
452432a1
...
...
@@ -58,7 +58,7 @@ int SensorBase::getConfig(SensorConfig *config)
return
0
;
}
int
SensorBase
::
subscribe
(
SensorEventHandler_t
*
handler
,
void
*
user_data
)
int
SensorBase
::
subscribe
(
SensorEventHandler_t
handler
,
void
*
user_data
)
{
this
->
evtHandler
=
handler
;
this
->
userData
=
user_data
;
...
...
@@ -66,12 +66,12 @@ int SensorBase::subscribe(SensorEventHandler_t *handler, void *user_data)
return
0
;
}
int
SensorBase
::
publish
(
sensors_event_t
*
event
)
int
SensorBase
::
publish
(
void
)
{
if
(
this
->
evtHandler
!=
NULL
)
{
/* invoke subscribed handler */
(
*
evtHandler
)(
event
,
this
->
userData
);
(
*
evtHandler
)(
this
->
userData
);
}
return
0
;
...
...
@@ -151,7 +151,7 @@ SensorBase *SensorManager::getDefaultSensor(int type)
return
NULL
;
}
int
SensorManager
::
subscribe
(
int
type
,
SensorEventHandler_t
*
handler
,
void
*
user_data
)
int
SensorManager
::
subscribe
(
int
type
,
SensorEventHandler_t
handler
,
void
*
user_data
)
{
SensorBase
*
sensor
;
...
...
@@ -194,7 +194,7 @@ rt_sensor_t rt_sensor_get_default(int type)
return
(
rt_sensor_t
)
SensorManager
::
getDefaultSensor
(
type
);
}
int
rt_sensor_subscribe
(
rt_sensor_t
sensor
,
SensorEventHandler_t
*
handler
,
void
*
user_data
)
int
rt_sensor_subscribe
(
rt_sensor_t
sensor
,
SensorEventHandler_t
handler
,
void
*
user_data
)
{
SensorBase
*
sensor_base
;
if
(
sensor
==
NULL
)
return
-
1
;
...
...
components/drivers/sensors/sensor.h
浏览文件 @
452432a1
...
...
@@ -992,10 +992,10 @@ enum SensorAccelRange
SENSOR_ACCEL_RANGE_8G
,
SENSOR_ACCEL_RANGE_16G
,
};
#define SENSOR_ACCEL_SENSITIVITY_2G (
0.001F
)
#define SENSOR_ACCEL_SENSITIVITY_4G (
0.002F
)
#define SENSOR_ACCEL_SENSITIVITY_8G (
0.004F
)
#define SENSOR_ACCEL_SENSITIVITY_16G (
0.012F
)
#define SENSOR_ACCEL_SENSITIVITY_2G (
(float)2/32768
)
#define SENSOR_ACCEL_SENSITIVITY_4G (
(float)4/32768
)
#define SENSOR_ACCEL_SENSITIVITY_8G (
(float)8/32768
)
#define SENSOR_ACCEL_SENSITIVITY_16G (
(float)16/32768
)
enum
SensorGyroRange
{
...
...
@@ -1040,12 +1040,13 @@ typedef struct SensorConfig
union
range
{
int
range
;
enum
SensorAccelRange
accel_range
;
enum
SensorGyroRange
gyro_range
;
}
range
;
}
SensorConfig
;
typedef
void
(
*
SensorEventHandler_t
)(
sensors_event_t
*
event
,
void
*
user_data
);
typedef
void
(
*
SensorEventHandler_t
)(
void
*
user_data
);
#ifdef __cplusplus
class
SensorBase
;
...
...
@@ -1074,8 +1075,8 @@ public:
int
setConfig
(
SensorConfig
*
config
);
int
getConfig
(
SensorConfig
*
config
);
int
subscribe
(
SensorEventHandler_t
*
handler
,
void
*
user_data
);
int
publish
(
sensors_event_t
*
event
);
int
subscribe
(
SensorEventHandler_t
handler
,
void
*
user_data
);
int
publish
(
void
);
protected:
SensorBase
*
next
;
...
...
@@ -1084,7 +1085,7 @@ protected:
/* sensor configuration */
SensorConfig
config
;
SensorEventHandler_t
*
evtHandler
;
SensorEventHandler_t
evtHandler
;
void
*
userData
;
friend
class
SensorManager
;
...
...
@@ -1103,7 +1104,7 @@ public:
static
int
unregisterSensor
(
SensorBase
*
sensor
);
static
SensorBase
*
getDefaultSensor
(
int
type
);
static
int
subscribe
(
int
type
,
SensorEventHandler_t
*
handler
,
void
*
user_data
);
static
int
subscribe
(
int
type
,
SensorEventHandler_t
handler
,
void
*
user_data
);
static
int
sensorEventReady
(
SensorBase
*
sensor
);
static
int
pollSensor
(
SensorBase
*
sensor
,
sensors_event_t
*
events
,
int
number
,
int
duration
);
...
...
@@ -1120,7 +1121,7 @@ extern "C" {
rt_sensor_t
rt_sensor_get_default
(
int
type
);
int
rt_sensor_subscribe
(
rt_sensor_t
sensor
,
SensorEventHandler_t
*
handler
,
void
*
user_data
);
int
rt_sensor_subscribe
(
rt_sensor_t
sensor
,
SensorEventHandler_t
handler
,
void
*
user_data
);
int
rt_sensor_activate
(
rt_sensor_t
sensor
,
int
enable
);
int
rt_sensor_configure
(
rt_sensor_t
sensor
,
SensorConfig
*
config
);
int
rt_sensor_poll
(
rt_sensor_t
sensor
,
sensors_event_t
*
event
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录