。。。好坑
1、“手势高低移动检测” 官方是叫单击的。官方例程实现如下:
case TAP_CENTER:
/* Call ToF Gesture module all the time (even if no object is detected) */
if ( VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].RangeStatus == 0 ){
/* Object (hand) detected */
gesture_code = tof_gestures_detectTAP_1(VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].LeakyRange, &gestureTapData1);
}else{
/* No object (hand) detected : call the ToF Gesture module with 1200 mm as distance */
gesture_code = tof_gestures_detectTAP_1(1200, &gestureTapData1);
}
/* Format data to display */
if(gesture_code == GESTURES_SINGLE_TAP){
tap = !tap;
sprintf(StrDisplay, (tap ? " [] " : "[@@]"));
}
看到了吗,tap = !tap;。。。
2、“手势前后移动检测”官方是叫滑动的,跟是否前后没有关系,官方例程实现如下:
case SWIPE_CENTER:
/* Call ToF Gesture module all the time (even if no object is detected) */
if ( VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].RangeStatus == 0 && VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].LeakyRange !=0 ){
/* Object (hand) detected */
gesture_code = tof_gestures_detectSWIPE_1(VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].LeakyRange, &gestureSwipeData1);
}else{
/* No object (hand) detected : call the ToF Gesture module with 1200 mm as distance */
gesture_code = tof_gestures_detectSWIPE_1(1200, &gestureSwipeData1);
}
/* Format data to display */
if(gesture_code == GESTURES_SINGLE_SWIPE){
swipe = !swipe;
sprintf(StrDisplay, (swipe ? "^^^^" : "____"));
}
还是 swipe = !swipe;。。。
3、“手势左右滑动检测”这个确实是了,但是使用了左右两边的传感器。。。一个传感器根本实现不了。
继续贴上官方例程:
①传感器选择:
case DIRECTIONAL_SWIPE:
nSensorEnabled = 2;
/* Enable LEFT and RIGHT devices only */
VL53L0XDevs[XNUCLEO53L0A1_DEV_LEFT].Enabled = 1;
VL53L0XDevs[XNUCLEO53L0A1_DEV_CENTER].Enabled = 0;
VL53L0XDevs[XNUCLEO53L0A1_DEV_RIGHT].Enabled = 1;
②实现:
case DIRECTIONAL_SWIPE:
/* Clip ranging values as tof_gestures_detectDIRSWIPE_1 function must be called all the times to detect the gesture */
leftRange = (VL53L0XDevs[XNUCLEO53L0A1_DEV_LEFT].RangeStatus == 0) ? VL53L0XDevs[XNUCLEO53L0A1_DEV_LEFT].LeakyRange : 1200;
rightRange = (VL53L0XDevs[XNUCLEO53L0A1_DEV_RIGHT].RangeStatus == 0) ? VL53L0XDevs[XNUCLEO53L0A1_DEV_RIGHT].LeakyRange : 1200;
gesture_code = tof_gestures_detectDIRSWIPE_1(leftRange, rightRange, &gestureDirSwipeData);
/* Format data to display */
if(gesture_code == GESTURES_SWIPE_LEFT_RIGHT){
pagePosition++;
pagePosition = (pagePosition>3) ? 0 : pagePosition;
FormatDirSwipe(true, pagePosition, StrDisplay);
}else if(gesture_code == GESTURES_SWIPE_RIGHT_LEFT){
pagePosition--;
pagePosition = (pagePosition