tuya_ble_sdk_demo/components/inv_mpu_driver/tuya_gesture_rec.c
/**
 * @brief recognize the direction of the shaking gesture
 * @param[in] none
 * @return gesture code
 */
@brief recognize the direction of the shaking gesture
@param[in] none
@return gesture code
@brief recognize the direction of the shaking gesture @param [ in ] none @return gesture code
GES_CODE_E __rec_shake_gesture(VOID_T)
{
    GES_CODE_E ret = GES_NONE;
    FLOAT_T pitch_d_a_s = __calc_angle_diff_abs_sum(sg_pitch_buf, sg_data_index);
    FLOAT_T yaw_d_a_s = __calc_angle_diff_abs_sum(sg_yaw_buf, sg_data_index);
    TUYA_APP_LOG_DEBUG("pitch_change:%.1f, yaw_change:%.1f", pitch_d_a_s, yaw_d_a_s);
    if (pitch_d_a_s > yaw_d_a_s)
    {
        if (__get_angle_dir_feat(sg_pitch_buf, sg_data_index) < 0)
        {
            ret = GES_SHAKE_UP;
            TUYA_APP_LOG_DEBUG("Gesture: up");
        }
        else
        {
            ret = GES_SHAKE_DOWN;
            TUYA_APP_LOG_DEBUG("Gesture: down");
        }
    }
    else
    {
        if (__get_angle_dir_feat(sg_yaw_buf, sg_data_index) > 0)
        {
            ret = GES_SHAKE_LEFT;
            TUYA_APP_LOG_DEBUG("Gesture: left");
        }
        else
        {
            ret = GES_SHAKE_RIGHT;
            TUYA_APP_LOG_DEBUG("Gesture: right");
        }
    }
    return ret;
}
GES_CODE_E __rec_shake_gesture ( VOID_T ) { GES_CODE_E ret = GES_NONE ; FLOAT_T pitch_d_a_s = __calc_angle_diff_abs_sum ( sg_pitch_buf , sg_data_index ) ; FLOAT_T yaw_d_a_s = __calc_angle_diff_abs_sum ( sg_yaw_buf , sg_data_index ) ; TUYA_APP_LOG_DEBUG ( " " , pitch_d_a_s , yaw_d_a_s ) ; if ( pitch_d_a_s > yaw_d_a_s ) { if ( __get_angle_dir_feat ( sg_pitch_buf , sg_data_index ) < 0 ) { ret = GES_SHAKE_UP ; TUYA_APP_LOG_DEBUG ( " " ) ; } else { ret = GES_SHAKE_DOWN ; TUYA_APP_LOG_DEBUG ( " " ) ; } } else { if ( __get_angle_dir_feat ( sg_yaw_buf , sg_data_index ) > 0 ) { ret = GES_SHAKE_LEFT ; TUYA_APP_LOG_DEBUG ( " " ) ; } else { ret = GES_SHAKE_RIGHT ; TUYA_APP_LOG_DEBUG ( " " ) ; } } return ret ; }
@brief recognize the direction of the shaking gesture
 @param[in] none
 @return gesture code
@brief recognize the direction of the shaking gesture @param [ in ] none @return gesture code