修正未接tof探头时的led显示异常
authorkyz <kongyuzhong@gmail.com>
Tue, 18 Jul 2023 10:17:00 +0000 (18:17 +0800)
committerkyz <kongyuzhong@gmail.com>
Tue, 18 Jul 2023 10:17:00 +0000 (18:17 +0800)
app/inc/mg_version.h
app/src/device_ctrl.c

index 8c6d0498c6af2c3aed4a0e0759f1b7626be7dbb7..efa5c6a17c18661807d9d9a11c4294c784e88ae7 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __MG_VERSION_H__
 #define __MG_VERSION_H__
 
-#define SW_VERSION  "0.0.6"
+#define SW_VERSION  "0.0.7"
 
 #endif //__MG_VERION_H__
 
index 4d7964fd1e5065cd7bd6ecaff78fb694b8933046..9ed4909e34d52104f32b9f93e423adec556506fb 100644 (file)
@@ -170,16 +170,23 @@ void * btn_light_ctrl_task( void* para )
                                if( !row_disabled && tof_sync ){
                                        //联排功能,平台设置人感状态
                                        light_mode_set( dev, LIGHT_MODE_TOF_ACTIVE );
+                               }else if( !dev->tof ){
+                                       //TOF传感器故障,LED按无人显示
+                                       light_mode_set( dev, LIGHT_MODE_TOF_DEACTIVE );
                                }
 
                                if( dev->tof && device_uptime_sec() - tof_check_time > cfg_mg_tof_interval_read( dev ) ){
-
+                                       //printf( "%d - %d > %d\n", device_uptime_sec(), tof_check_time, cfg_mg_tof_interval_read(dev) );
                                        tof_check_time = device_uptime_sec();
                                        memset( &info, 0, sizeof( info ) );
 
                                        //检查周期到达,读取tof状态
                                        if( mg_tof_read( dev->tof, &info )==0 ){
-                                               MG_LOGD( "read tof info, enable:%d, status:%d, dist:%d", info.enable, info.status, info.distance );
+                                               static tof_info_t dbg_info;
+                                               if( dbg_info.enable != info.enable || dbg_info.status != info.status || abs( dbg_info.distance-info.distance)>5 ){
+                                                       memcpy( &dbg_info, &info, sizeof( dbg_info ) );
+                                                       MG_LOGD( "read tof info, enable:%d, status:%d, dist:%d", info.enable, info.status, info.distance );
+                                               }
                                        }else{
                                                MG_LOGW( "read tof info fail, g_tof:%p", dev->tof );
                                        }