51 lines
1017 B
C
51 lines
1017 B
C
/**
|
|
* @file shake_detector.h
|
|
* @brief Shake detection using QMI8658 sensor
|
|
*/
|
|
|
|
#ifndef SHAKE_DETECTOR_H
|
|
#define SHAKE_DETECTOR_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Configuration types of shakes
|
|
typedef enum {
|
|
SHAKE_NONE = 0,
|
|
SHAKE_SURPRISED,
|
|
SHAKE_SAD,
|
|
SHAKE_ANGRY,
|
|
SHAKE_COUNT
|
|
} shake_event_t;
|
|
|
|
/**
|
|
* @brief Initialize the shake detector and QMI8658 sensor
|
|
* @return true on success, false on failure
|
|
*/
|
|
bool shake_detector_init(void);
|
|
|
|
/**
|
|
* @brief Check for shake events. Call this loop periodically.
|
|
* @return Detected shake event, or SHAKE_NONE
|
|
*/
|
|
shake_event_t shake_detector_update(void);
|
|
|
|
/**
|
|
* @brief Get the latest raw accelerometer reading
|
|
* @param x Pointer to store X acceleration
|
|
* @param y Pointer to store Y acceleration
|
|
* @param z Pointer to store Z acceleration
|
|
* @return true if data is available
|
|
*/
|
|
bool shake_detector_get_raw_accel(float *x, float *y, float *z);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // SHAKE_DETECTOR_H
|