From: zf zf <2919300294@qq.com> Date: Mon, 19 Jun 2023 02:45:12 +0000 (+0800) Subject: 更新als的read接口和中间件接口定义 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=1ed2bc7419008679be14bbc39cdb21cec6350784;p=yn%2Falarmmonitor.git 更新als的read接口和中间件接口定义 --- diff --git "a/TW8013\344\270\255\351\227\264\344\273\266\346\216\245\345\217\243\345\256\232\344\271\211.md" "b/TW8013\344\270\255\351\227\264\344\273\266\346\216\245\345\217\243\345\256\232\344\271\211.md" index 7de8b69..457d689 100755 --- "a/TW8013\344\270\255\351\227\264\344\273\266\346\216\245\345\217\243\345\256\232\344\271\211.md" +++ "b/TW8013\344\270\255\351\227\264\344\273\266\346\216\245\345\217\243\345\256\232\344\271\211.md" @@ -434,11 +434,12 @@ 返回值: 无 #### 读取ALS信息 - void mg_als_read( mg_als_t * als_ctrl, als_info_t *info ); - 参数定义: + als_info_t * mg_als_read( mg_als_t * als_ctrl ) + 参数定义: als_ctrl: 按键控制器 - info: 传感器信息 - 返回值: 无 + 返回值: + 读取失败,返回NULL; + 成功,返回传感器信息 #### 设置阈值 void mg_als_cfg( mg_als_t * als_ctrl, uint32_t threshold_high, uint32_t threshold_low ); diff --git a/als/inc/als.h b/als/inc/als.h index 580fe30..b7ed2ca 100644 --- a/als/inc/als.h +++ b/als/inc/als.h @@ -27,7 +27,7 @@ typedef struct mg_als mg_als_t; mg_als_t * mg_als_open( void ); void mg_als_close( mg_als_t * als_ctrl ); -void mg_als_read( mg_als_t * als_ctrl, als_info_t *info ); +als_info_t * mg_als_read( mg_als_t * als_ctrl ); void mg_als_cfg( mg_als_t * als_ctrl, uint32_t threshold_high, uint32_t threshold_low ); #endif //_ALS__H__ diff --git a/als/src/als.c b/als/src/als.c index f4f4188..2381469 100644 --- a/als/src/als.c +++ b/als/src/als.c @@ -95,18 +95,14 @@ void mg_als_close( mg_als_t * als_ctrl ) } -void mg_als_read( mg_als_t * als_ctrl, als_info_t *info ) +als_info_t * mg_als_read( mg_als_t * als_ctrl ) { - usleep(5000); if(!stop){ - info->ad_value = als_ctrl->data.ad_value; + return &als_ctrl->data; }else{ - info->ad_value = 44444; //Invalid value + return NULL; } - info->threshold_high = als_ctrl->data.threshold_high; - info->threshold_low = als_ctrl->data.threshold_low; - info->status = als_ctrl->data.status; }