├── src ├── ring_buffer.h ├── tof_motion.h ├── ring_buffer.cpp ├── tof_gestures.h ├── tof_motion.cpp ├── tof_gestures_TAP_1.h ├── tof_gestures_types.h ├── tof_gestures_SWIPE_1.h ├── tof_gestures_TAP_1.cpp ├── tof_gestures_platform.h ├── tof_gestures_SWIPE_1.cpp ├── tof_gestures_DIRSWIPE_1.cpp └── tof_gestures_DIRSWIPE_1.h ├── library.properties ├── README.md └── LICENSE.md /src/ring_buffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/ring_buffer.h -------------------------------------------------------------------------------- /src/tof_motion.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_motion.h -------------------------------------------------------------------------------- /src/ring_buffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/ring_buffer.cpp -------------------------------------------------------------------------------- /src/tof_gestures.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures.h -------------------------------------------------------------------------------- /src/tof_motion.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_motion.cpp -------------------------------------------------------------------------------- /src/tof_gestures_TAP_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_TAP_1.h -------------------------------------------------------------------------------- /src/tof_gestures_types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_types.h -------------------------------------------------------------------------------- /src/tof_gestures_SWIPE_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_SWIPE_1.h -------------------------------------------------------------------------------- /src/tof_gestures_TAP_1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_TAP_1.cpp -------------------------------------------------------------------------------- /src/tof_gestures_platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_platform.h -------------------------------------------------------------------------------- /src/tof_gestures_SWIPE_1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_SWIPE_1.cpp -------------------------------------------------------------------------------- /src/tof_gestures_DIRSWIPE_1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stm32duino/Proximity_Gesture/HEAD/src/tof_gestures_DIRSWIPE_1.cpp -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=STM32duino Proximity Gesture 2 | version=1.0.5 3 | author=AST 4 | maintainer=stm32duino 5 | sentence=Allows performing simple gestures detection using proximity sensors 6 | paragraph=This library provides single swipe gesture detection, directional (left/right) swipe gesture detection and single tap gesture detection. 7 | category=Device Control 8 | url=https://github.com/stm32duino/Proximity_Gesture 9 | architectures=stm32, avr, sam 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Proximity Gesture 2 | 3 | Arduino library to support gesture-detection using proximity sensors (VL53L0X or VL53L1X or VL6180X). 4 | The APIs provide single swipe gesture detection, directional (left/right) swipe gesture detection and 5 | single tap gesture detection. 6 | 7 | ## Note 8 | 9 | You can find examples based on this library in the following packages: 10 | * VL53L0X: https://github.com/stm32duino/VL53L0X 11 | * X-NUCLEO-53L0A1: https://github.com/stm32duino/X-NUCLEO-53L0A1 12 | * X-NUCLEO-53L1A1: https://github.com/stm32duino/X-NUCLEO-53L1A1 13 | * X-NUCLEO-6180XA1: https://github.com/stm32duino/X-NUCLEO-6180XA1 14 | 15 | ## Documentation 16 | 17 | You can find the source files at 18 | https://github.com/stm32duino/Proximity_Gesture 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | COPYRIGHT(c) 2018 STMicroelectronics 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, 6 | this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, 8 | this list of conditions and the following disclaimer in the documentation 9 | and/or other materials provided with the distribution. 10 | 3. Neither the name of STMicroelectronics nor the names of its contributors 11 | may be used to endorse or promote products derived from this software 12 | without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /src/tof_gestures_DIRSWIPE_1.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright © 2015, STMicroelectronics International N.V. 3 | All rights reserved. 4 | 5 | Use and Redistribution are permitted only in accordance with licensing terms 6 | available at www.st.com under software reference X-CUBE-6180XA1, and provided 7 | that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of STMicroelectronics nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROTECTED BY STMICROELECTRONICS PATENTS AND COPYRIGHTS. 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 21 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. 22 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ********************************************************************************/ 30 | 31 | /* 32 | * @file tof_gestures_DIRSWIPE_1.h 33 | * $Date: 2015-11-10 11:21:53 +0100 (Tue, 10 Nov 2015) $ 34 | * $Revision: 2612 $ 35 | */ 36 | 37 | #ifndef TOF_GESTURES_DIRSWIPE_1_H_ 38 | #define TOF_GESTURES_DIRSWIPE_1_H_ 39 | 40 | #include "tof_gestures_platform.h" 41 | #include "tof_motion.h" 42 | 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /** @defgroup tof_gestures_DIRSWIPE_1 Directional SWIPE (1) 49 | * @brief Directional (left/right) Swipe gesture detection based on motion detector (dual ToF devices) 50 | @par Description 51 | This tof_gestures module allows to detect a directional swipe (from left to right or from right to left) using 52 | two ToF devices (left and right). It is based on the tof_motion module with simple threshold and timing considerations. 53 | It returns one of the following gestures codes : ::GESTURES_SWIPE_LEFT_RIGHT, ::GESTURES_SWIPE_RIGHT_LEFT when gesture is detected 54 | or ::GESTURES_NULL, ::GESTURES_DISCARDED_TOO_SLOW or ::GESTURES_DISCARDED_TOO_FAST when no gesture is detected. 55 | @par Known Limitations 56 | None (very fast swipes can be detected) 57 | * @ingroup tof_gestures 58 | * @{ 59 | */ 60 | 61 | 62 | /** Codes used to detect directional swipes (internal state machine) 63 | */ 64 | enum Gestures_DirSwipe_Code_t{ 65 | GESTURES_DIRSWIPE_START = 0, /*!< Ready to detect gesture start */ 66 | GESTURES_DIRSWIPE_END = 1, /*!< Ready to detect gesture end */ 67 | }; 68 | 69 | /** 70 | * @struct Gesture_DIRSWIPE_1_Data_t 71 | * @brief Data structure for directional swipes detection (using two ranging devices) 72 | */ 73 | typedef struct { 74 | long minSwipeDuration; /*!< Input : Minimum duration of a swipe to be detected */ 75 | long maxSwipeDuration; /*!< Input : Maximum duration of a swipe to be detected */ 76 | MotionData_t motionDetectorLeft; /*!< Private : Motion detector associated to the left ranging device */ 77 | MotionData_t motionDetectorRight; /*!< Private : Motion detector associated to the right ranging device */ 78 | int state; /*!< Private : Internal state machine */ 79 | int gesture_start_from_right; /*!< Private : Obvious */ 80 | unsigned long timestamp; /*!< Private : Obvious */ 81 | } Gesture_DIRSWIPE_1_Data_t; 82 | 83 | /** 84 | * @brief Initialize gesture data 85 | * @return 0 on success 86 | */ 87 | int tof_gestures_initDIRSWIPE_1(int32_t threshold, long minSipeDuration, long maxSwipeDuration, Gesture_DIRSWIPE_1_Data_t *data); 88 | /** 89 | * @brief Detect gesture 90 | * @return One of these gestures code from ::Gestures_Code_t : ::GESTURES_SWIPE_LEFT_RIGHT, ::GESTURES_SWIPE_RIGHT_LEFT, ::GESTURES_NULL, ::GESTURES_DISCARDED_TOO_SLOW or ::GESTURES_DISCARDED_TOO_FAST 91 | */ 92 | int tof_gestures_detectDIRSWIPE_1(int32_t left_range_mm, int32_t right_range_mm, Gesture_DIRSWIPE_1_Data_t *data); 93 | 94 | /** @} */ 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif /* TOF_GESTURES_DIRSWIPE_1_H_ */ 100 | --------------------------------------------------------------------------------