prova

Dependencies:   X_NUCLEO_53L0A1 mbed

Fork of 53L0A1_HandGestureRecognition by ST

Committer:
mapellil
Date:
Thu Feb 22 15:50:29 2018 +0000
Revision:
9:6205ef056c8a
Parent:
7:d79cbeda2982
AStDay

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mapellil 7:d79cbeda2982 1 /*******************************************************************************
mapellil 7:d79cbeda2982 2 Copyright © 2015, STMicroelectronics International N.V.
mapellil 7:d79cbeda2982 3 All rights reserved.
mapellil 7:d79cbeda2982 4
mapellil 7:d79cbeda2982 5 Use and Redistribution are permitted only in accordance with licensing terms
mapellil 7:d79cbeda2982 6 available at www.st.com under software reference X-CUBE-6180XA1, and provided
mapellil 7:d79cbeda2982 7 that the following conditions are met:
mapellil 7:d79cbeda2982 8 * Redistributions of source code must retain the above copyright
mapellil 7:d79cbeda2982 9 notice, this list of conditions and the following disclaimer.
mapellil 7:d79cbeda2982 10 * Redistributions in binary form must reproduce the above copyright
mapellil 7:d79cbeda2982 11 notice, this list of conditions and the following disclaimer in the
mapellil 7:d79cbeda2982 12 documentation and/or other materials provided with the distribution.
mapellil 7:d79cbeda2982 13 * Neither the name of STMicroelectronics nor the
mapellil 7:d79cbeda2982 14 names of its contributors may be used to endorse or promote products
mapellil 7:d79cbeda2982 15 derived from this software without specific prior written permission.
mapellil 7:d79cbeda2982 16
mapellil 7:d79cbeda2982 17 THIS SOFTWARE IS PROTECTED BY STMICROELECTRONICS PATENTS AND COPYRIGHTS.
mapellil 7:d79cbeda2982 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mapellil 7:d79cbeda2982 19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mapellil 7:d79cbeda2982 20 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
mapellil 7:d79cbeda2982 21 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
mapellil 7:d79cbeda2982 22 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
mapellil 7:d79cbeda2982 23 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mapellil 7:d79cbeda2982 24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mapellil 7:d79cbeda2982 25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
mapellil 7:d79cbeda2982 26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mapellil 7:d79cbeda2982 27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mapellil 7:d79cbeda2982 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mapellil 7:d79cbeda2982 29 ********************************************************************************/
mapellil 7:d79cbeda2982 30
mapellil 7:d79cbeda2982 31 /*
mapellil 7:d79cbeda2982 32 * @file tof_gestures_DIRSWIPE_1.h
mapellil 7:d79cbeda2982 33 * $Date: 2015-11-10 11:21:53 +0100 (Tue, 10 Nov 2015) $
mapellil 7:d79cbeda2982 34 * $Revision: 2612 $
mapellil 7:d79cbeda2982 35 */
mapellil 7:d79cbeda2982 36
mapellil 7:d79cbeda2982 37 #ifndef TOF_GESTURES_DIRSWIPE_1_H_
mapellil 7:d79cbeda2982 38 #define TOF_GESTURES_DIRSWIPE_1_H_
mapellil 7:d79cbeda2982 39
mapellil 7:d79cbeda2982 40 #include "tof_gestures_platform.h"
mapellil 7:d79cbeda2982 41 #include "tof_motion.h"
mapellil 7:d79cbeda2982 42
mapellil 7:d79cbeda2982 43
mapellil 7:d79cbeda2982 44 #ifdef __cplusplus
mapellil 7:d79cbeda2982 45 extern "C" {
mapellil 7:d79cbeda2982 46 #endif
mapellil 7:d79cbeda2982 47
mapellil 7:d79cbeda2982 48 /** @defgroup tof_gestures_DIRSWIPE_1 Directional SWIPE (1)
mapellil 7:d79cbeda2982 49 * @brief Directional (left/right) Swipe gesture detection based on motion detector (dual ToF devices)
mapellil 7:d79cbeda2982 50 @par Description
mapellil 7:d79cbeda2982 51 This tof_gestures module allows to detect a directional swipe (from left to right or from right to left) using
mapellil 7:d79cbeda2982 52 two ToF devices (left and right). It is based on the tof_motion module with simple threshold and timing considerations.
mapellil 7:d79cbeda2982 53 It returns one of the following gestures codes : ::GESTURES_SWIPE_LEFT_RIGHT, ::GESTURES_SWIPE_RIGHT_LEFT when gesture is detected
mapellil 7:d79cbeda2982 54 or ::GESTURES_NULL, ::GESTURES_DISCARDED_TOO_SLOW or ::GESTURES_DISCARDED_TOO_FAST when no gesture is detected.
mapellil 7:d79cbeda2982 55 @par Known Limitations
mapellil 7:d79cbeda2982 56 None (very fast swipes can be detected)
mapellil 7:d79cbeda2982 57 * @ingroup tof_gestures
mapellil 7:d79cbeda2982 58 * @{
mapellil 7:d79cbeda2982 59 */
mapellil 7:d79cbeda2982 60
mapellil 7:d79cbeda2982 61
mapellil 7:d79cbeda2982 62 /** Codes used to detect directional swipes (internal state machine)
mapellil 7:d79cbeda2982 63 */
mapellil 7:d79cbeda2982 64 enum Gestures_DirSwipe1_Code_t{
mapellil 7:d79cbeda2982 65 GESTURES_DIRSWIPE_1_START = 0, /*!< Ready to detect gesture start */
mapellil 7:d79cbeda2982 66 GESTURES_DIRSWIPE_1_END = 1, /*!< Ready to detect gesture end */
mapellil 7:d79cbeda2982 67 };
mapellil 7:d79cbeda2982 68
mapellil 7:d79cbeda2982 69 /**
mapellil 7:d79cbeda2982 70 * @struct Gesture_DIRSWIPE_1_Data_t
mapellil 7:d79cbeda2982 71 * @brief Data structure for directional swipes detection (using two ranging devices)
mapellil 7:d79cbeda2982 72 */
mapellil 7:d79cbeda2982 73 typedef struct {
mapellil 7:d79cbeda2982 74 int minSwipeDuration; /*!< Input : Minimum duration of a swipe to be detected */
mapellil 7:d79cbeda2982 75 int maxSwipeDuration; /*!< Input : Maximum duration of a swipe to be detected */
mapellil 7:d79cbeda2982 76 bool handMustCoverBoth; /*!< Input : If set to true, hand must cover both devices at some point to get a detected swipes */
mapellil 7:d79cbeda2982 77 MotionData_t motionDetectorLeft; /*!< Private : Motion detector associated to the left ranging device */
mapellil 7:d79cbeda2982 78 MotionData_t motionDetectorRight; /*!< Private : Motion detector associated to the right ranging device */
mapellil 7:d79cbeda2982 79 int state; /*!< Private : Internal state machine */
mapellil 7:d79cbeda2982 80 bool gesture_start_from_right; /*!< Private : Obvious */
mapellil 7:d79cbeda2982 81 int timestamp; /*!< Private : Obvious */
mapellil 7:d79cbeda2982 82 } Gesture_DIRSWIPE_1_Data_t;
mapellil 7:d79cbeda2982 83
mapellil 7:d79cbeda2982 84 /**
mapellil 7:d79cbeda2982 85 * @brief Initialize gesture data
mapellil 7:d79cbeda2982 86 * @param threshold Distance below which a SWIPE may be detected. All distances above this threshold are not considered.
mapellil 7:d79cbeda2982 87 * @param minSwipeDuration Minimum duration of a swipe. Set to 0 if no minimum speed is required.
mapellil 7:d79cbeda2982 88 * @param maxSwipeDuration Maximum swipe duration. If a swipe is too slow, it is discarded.
mapellil 7:d79cbeda2982 89 * @param handMustCoverBoth If set to true, hand must cover both devices at some point to validate a swipe.
mapellil 7:d79cbeda2982 90 * This may be useful to get a more robust swipe detection but this requires both sensors to not be too far away from each other.
mapellil 7:d79cbeda2982 91 * If both devices are too far from each other, it is necessary to set this flag to false to detect swipes.
mapellil 7:d79cbeda2982 92 * @return 0 on success
mapellil 7:d79cbeda2982 93 */
mapellil 7:d79cbeda2982 94 int tof_gestures_initDIRSWIPE_1(int32_t threshold, int minSipeDuration, int maxSwipeDuration, bool handMustCoverBoth, Gesture_DIRSWIPE_1_Data_t *data);
mapellil 7:d79cbeda2982 95
mapellil 7:d79cbeda2982 96 /**
mapellil 7:d79cbeda2982 97 * @brief Detect gesture
mapellil 7:d79cbeda2982 98 * @param left_range_mm Ranging distance in mm from left device
mapellil 7:d79cbeda2982 99 * @param right_range_mm Ranging distance in mm from right device
mapellil 7:d79cbeda2982 100 * @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
mapellil 7:d79cbeda2982 101 */
mapellil 7:d79cbeda2982 102 int tof_gestures_detectDIRSWIPE_1(int32_t left_range_mm, int32_t right_range_mm, Gesture_DIRSWIPE_1_Data_t *data);
mapellil 7:d79cbeda2982 103
mapellil 7:d79cbeda2982 104 /** @} */
mapellil 7:d79cbeda2982 105
mapellil 7:d79cbeda2982 106 #ifdef __cplusplus
mapellil 7:d79cbeda2982 107 }
mapellil 7:d79cbeda2982 108 #endif
mapellil 7:d79cbeda2982 109 #endif /* TOF_GESTURES_DIRSWIPE_1_H_ */
mapellil 7:d79cbeda2982 110