#ifndef WAVE_H
#define WAVE_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#define RES_X 8
#define RES_Y 8
#define HISTORY_SIZE 60
typedef enum Gesture {
GestureNone = 0,
GestureStaticHold,
GestureSwipeRight,
GestureSwipeLeft,
GestureSwipeUp,
GestureSwipeDown,
} Gesture;
typedef enum RecognizerStatus {
RecognizerStatusOk = 0,
RecognizerStatusInitFailure,
RecognizerStatusInvalidInput,
} RecognizerStatus;
typedef struct SensorMeasurement_RES_X__RES_Y {
float zone_dist[RES_Y][RES_X];
uint32_t time_ms;
} SensorMeasurement_RES_X__RES_Y;
typedef struct SensorParams {
float fov_horizontal;
float fov_vertical;
} SensorParams;
typedef struct RecognizerParams {
float gesture_threshold_dist;
uint32_t static_hold_time_ms;
float static_hold_tolerance_dist;
float swipe_tolerance_dist;
float swipe_horizontal_travel_dist;
float swipe_vertical_travel_dist;
} RecognizerParams;
typedef struct CoordsSpherical {
float r;
float theta;
float phi;
} CoordsSpherical;
typedef enum HandState_Tag {
HandNotFound,
HandFound,
} HandState_Tag;
typedef struct HandFound_Body {
struct CoordsSpherical hand_pos;
} HandFound_Body;
typedef struct HandState {
HandState_Tag tag;
union {
HandFound_Body hand_found;
};
} HandState;
typedef struct RecognizerResult {
struct HandState hand_state;
enum Gesture gesture;
} RecognizerResult;
typedef struct HistoryEntry_RES_X__RES_Y {
struct SensorMeasurement_RES_X__RES_Y measurement;
struct HandState hand_state;
} HistoryEntry_RES_X__RES_Y;
typedef struct GestureRecognizer_RES_X__RES_Y__HISTORY_SIZE {
struct RecognizerParams params;
struct SensorParams sensor_params;
uint32_t start_time;
struct HistoryEntry_RES_X__RES_Y history[HISTORY_SIZE];
uintptr_t received_measurements;
} GestureRecognizer_RES_X__RES_Y__HISTORY_SIZE;
typedef struct CoordsCartesian {
float x;
float y;
float z;
} CoordsCartesian;
struct SensorMeasurement_RES_X__RES_Y sensor_measurement_invalid(void);
struct SensorParams sensor_params_default_vl53l5cx(void);
struct RecognizerParams recognizer_params_default(void);
struct RecognizerResult recognizer_result_default(void);
struct GestureRecognizer_RES_X__RES_Y__HISTORY_SIZE gesture_recognizer_new(struct RecognizerParams params,
struct SensorParams sensor_params);
enum RecognizerStatus gesture_recognizer_reset(struct GestureRecognizer_RES_X__RES_Y__HISTORY_SIZE *gesture_recognizer,
struct RecognizerParams params,
struct SensorParams sensor_params,
uint32_t now);
enum RecognizerStatus gesture_recognizer_update(struct GestureRecognizer_RES_X__RES_Y__HISTORY_SIZE *gesture_recognizer,
struct SensorMeasurement_RES_X__RES_Y measurement,
struct RecognizerResult *gesture_result);
struct CoordsSpherical coords_spherical_from_cartesian(struct CoordsCartesian coords_cart);
struct CoordsCartesian coords_cartesian_from_spherical(struct CoordsSpherical coords_spher);
#endif