Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Streaming IMU data may be tricky to interpret for something simple like shake detection. This utility provides a simple interface for shake detection. It should not be used when full orientation data is needed.
Call checkForShake() frequently, like from a Swadge Mode's main loop. You do not need to call accelIntegrate() or accelGetAccelVecRaw() elsewhere. When it returns true
, then the shake state has changed and the isShook
argument can be checked for the current shake state.
Go to the source code of this file.
Data Structures | |
struct | vec3d_t |
A general purpose 3D vector. More... | |
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. | |
struct vec3d_t |
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.
lastOrientation | The last IMU orientation, should only be set by this function |
shakeHistory | A list of shake values to see when the Swadge settles |
isShook | true if the Swadge is shaking, false if it is not |