Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
imu_utils.c File Reference

Macros

#define SHAKE_THRESHOLD   300
 
#define SHAKE_HYSTERESIS   10
 

Functions

bool checkForShake (vec3d_t *lastOrientation, list_t *shakeHistory, bool *isShook)
 Check if a shake was detected. All of the arguments for this function are both inputs and outputs.
 

Macro Definition Documentation

◆ SHAKE_THRESHOLD

#define SHAKE_THRESHOLD   300

◆ SHAKE_HYSTERESIS

#define SHAKE_HYSTERESIS   10

Function Documentation

◆ checkForShake()

bool checkForShake ( vec3d_t * lastOrientation,
list_t * shakeHistory,
bool * isShook )

Check if a shake was detected. All of the arguments for this function are both inputs and outputs.

This will return if the shake state changed, not if it is shaking or not. The argument isShook will contain the shake state.

This calls accelIntegrate() and accelGetAccelVecRaw(), so neither of those functions needs to be called elsewhere. Because this function calls accelIntegrate(), it should be called relatively frequently.

Parameters
lastOrientationThe last IMU orientation, should only be set by this function
shakeHistoryA list of shake values to see when the Swadge settles
isShooktrue if the Swadge is shaking, false if it is not
Returns
true if the shake state changed (no shake to shake or vice versa), false if it did not