Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | DSCL_OUTPUT |
#define | DSCL_INPUT |
#define | DSDA_OUTPUT |
#define | DSDA_INPUT |
#define | READ_DSDA ((GPIO.in >> 3) & 1) |
#define | DELAY1 i2c_delay(1); |
#define | DELAY2 i2c_delay(2); |
#define | LSM6DSL_ADDRESS 0x6a |
#define | QMC6308_ADDRESS 0x2c |
Enumerations | |
enum | lsm6dslReg_t { LSM6DSL_FUNC_CFG_ACCESS = 0x01 , LSM6DSL_SENSOR_SYNC_TIME_FRAME = 0x04 , LSM6DSL_FIFO_CTRL1 = 0x06 , LSM6DSL_FIFO_CTRL2 = 0x07 , LSM6DSL_FIFO_CTRL3 = 0x08 , LSM6DSL_FIFO_CTRL4 = 0x09 , LSM6DSL_FIFO_CTRL5 = 0x0a , LSM6DSL_ORIENT_CFG_G = 0x0b , LSM6DSL_INT1_CTRL = 0x0d , LSM6DSL_INT2_CTRL = 0x0e , LMS6DS3_WHO_AM_I = 0x0f , LSM6DSL_CTRL1_XL = 0x10 , LSM6DSL_CTRL2_G = 0x11 , LSM6DSL_CTRL3_C = 0x12 , LSM6DSL_CTRL4_C = 0x13 , LSM6DSL_CTRL5_C = 0x14 , LSM6DSL_CTRL6_C = 0x15 , LSM6DSL_CTRL7_G = 0x16 , LSM6DSL_CTRL8_XL = 0x17 , LSM6DSL_CTRL9_XL = 0x18 , LSM6DSL_CTRL10_C = 0x19 , LSM6DSL_MASTER_CONFIG = 0x1a , LSM6DSL_WAKE_UP_SRC = 0x1b , LSM6DSL_TAP_SRC = 0x1c , LSM6DSL_D6D_SRC = 0x1d , LSM6DSL_STATUS_REG = 0x1e , LSM6DSL_OUT_TEMP_L = 0x20 , LSM6DSL_OUT_TEMP_H = 0x21 , LSM6DSL_FIFO_STATUS1 = 0x3A } |
Functions | |
void | i2c_delay (int x) |
float | rsqrtf (float x) |
Perform a fast, approximate reciprocal square root. | |
float | mathsqrtf (float x) |
Perform a fast, approximate square root. | |
void | mathEulerToQuat (float *q, const float *euler) |
convert euler angles (in radians) to a quaternion. | |
void | mathQuatApply (float *qout, const float *q1, const float *q2) |
Rotate one quaternion by another (and do not normalize) | |
void | mathQuatNormalize (float *qout, const float *qin) |
Normalize a quaternion. | |
void | mathCrossProduct (float *p, const float *a, const float *b) |
Perform a 3D cross product. | |
void | mathRotateVectorByInverseOfQuaternion (float *pout, const float *q, const float *p) |
Rotate a 3D vector by the inverse of a quaternion. | |
void | mathRotateVectorByQuaternion (float *pout, const float *q, const float *p) |
Rotate a 3D vector by a quaternion. | |
esp_err_t | initAccelerometer (gpio_num_t sda, gpio_num_t scl, gpio_pullup_t pullup) |
Initialize the IMU. | |
esp_err_t | deInitAccelerometer (void) |
Deinit the accelerometer (nothing to do) | |
esp_err_t | accelIntegrate () |
Read all pending samples in IMU and perform a sensor fusion pass. | |
esp_err_t | accelGetAccelVecRaw (int16_t *x, int16_t *y, int16_t *z) |
Get the RAW accelerometer "up" vector from device point of view. | |
esp_err_t | accelGetOrientVec (int16_t *x, int16_t *y, int16_t *z) |
Get the current orientation "up" vector from device point of view. | |
esp_err_t | accelGetQuaternion (float *q) |
Get the current estimated quaternion of the IMU. | |
esp_err_t | accelPerformCal () |
Initialize calibration of IMU. | |
esp_err_t | accelGetSteeringAngleDegrees (int16_t *xcomp, int16_t *ycomp) |
Get a steering wheel style input. Use getAtan2( xcomp, ycomp ) to get angle. 0..360 with 180 being up. | |
float | accelGetStdDevInCal () |
Get current divergence as the cal algorithm attempts to converge on a good cal. | |
void | accelSetRegistersAndReset (void) |
Reset the IMU's core registers. Should be done any time you are entering a mode with the IMU. | |
Variables | |
LSM6DSLData | LSM6DSL |
#define DSCL_OUTPUT |
#define DSCL_INPUT |
#define DSDA_OUTPUT |
#define DSDA_INPUT |
#define READ_DSDA ((GPIO.in >> 3) & 1) |
#define DELAY1 i2c_delay(1); |
#define DELAY2 i2c_delay(2); |
#define LSM6DSL_ADDRESS 0x6a |
#define QMC6308_ADDRESS 0x2c |
enum lsm6dslReg_t |
void i2c_delay | ( | int | x | ) |
float rsqrtf | ( | float | x | ) |
Perform a fast, approximate reciprocal square root.
x | The number to take a recriprocal square root of. |
float mathsqrtf | ( | float | x | ) |
Perform a fast, approximate square root.
x | The number to take a square root of. |
void mathEulerToQuat | ( | float * | q, |
const float * | euler ) |
convert euler angles (in radians) to a quaternion.
q | Pointer to the wxyz quat (float[4]) to be written. |
euler | Pointer to a float[3] of euler angles. |
void mathQuatApply | ( | float * | qout, |
const float * | q1, | ||
const float * | q2 ) |
Rotate one quaternion by another (and do not normalize)
qout | Pointer to the wxyz quat (float[4]) to be written. |
q1 | First quaternion to be rotated. |
q2 | Quaternion to rotate q1 by. |
void mathQuatNormalize | ( | float * | qout, |
const float * | qin ) |
Normalize a quaternion.
qout | Pointer to the wxyz quat (float[4]) to be written. |
qin | Pointer to the quaterion to normalize. |
void mathCrossProduct | ( | float * | p, |
const float * | a, | ||
const float * | b ) |
Perform a 3D cross product.
p | Pointer to the float[3] output of the cross product (p = a x b) |
a | Pointer to the float[3] of the cross product a vector. |
b | Pointer to the float[3] of the cross product b vector. |
void mathRotateVectorByInverseOfQuaternion | ( | float * | pout, |
const float * | q, | ||
const float * | p ) |
Rotate a 3D vector by the inverse of a quaternion.
pout | Pointer to the float[3] output of the antirotation. |
q | Pointer to the wxyz quaternion (float[4]) opposite of the rotation. |
p | Pointer to the float[3] of the vector to antirotates. |
void mathRotateVectorByQuaternion | ( | float * | pout, |
const float * | q, | ||
const float * | p ) |
Rotate a 3D vector by a quaternion.
pout | Pointer to the float[3] output of the rotation |
q | Pointer to the wxyz quaternion (float[4]) of the rotation. |
p | Pointer to the float[3] of the vector to rotates. |
esp_err_t initAccelerometer | ( | gpio_num_t | sda, |
gpio_num_t | scl, | ||
gpio_pullup_t | pullup ) |
Initialize the IMU.
sda | The GPIO for the Serial DAta line |
scl | The GPIO for the Serial CLock line |
pullup | Either GPIO_PULLUP_DISABLE if there are external pullup resistors on SDA and SCL or GPIO_PULLUP_ENABLE if internal pull-ups should be used |
esp_err_t deInitAccelerometer | ( | void | ) |
Deinit the accelerometer (nothing to do)
esp_err_t accelIntegrate | ( | void | ) |
Read all pending samples in IMU and perform a sensor fusion pass.
esp_err_t accelGetAccelVecRaw | ( | int16_t * | x, |
int16_t * | y, | ||
int16_t * | z ) |
Get the RAW accelerometer "up" vector from device point of view.
esp_err_t accelGetOrientVec | ( | int16_t * | x, |
int16_t * | y, | ||
int16_t * | z ) |
Get the current orientation "up" vector from device point of view.
esp_err_t accelGetQuaternion | ( | float * | q | ) |
Get the current estimated quaternion of the IMU.
esp_err_t accelPerformCal | ( | void | ) |
Initialize calibration of IMU.
esp_err_t accelGetSteeringAngleDegrees | ( | int16_t * | xcomp, |
int16_t * | ycomp ) |
Get a steering wheel style input. Use getAtan2( xcomp, ycomp ) to get angle. 0..360 with 180 being up.
int16_t xcomp; int16_t ycomp; accelGetSteeringAngleDegrees( &xcomp, &ycomp ); ESP_LOGI( "x", "%d %d %d\n", getAtan2( xcomp, ycomp ), xcomp, ycomp );
xcomp | is a pointer to receive the x component of the steering wheel (-4096-4096) +x is "right" |
ycomp | is a pointer to receive the y component of the steering wheel (-4096-4096) +y is "down" |
float accelGetStdDevInCal | ( | void | ) |
Get current divergence as the cal algorithm attempts to converge on a good cal.
void accelSetRegistersAndReset | ( | void | ) |
Reset the IMU's core registers. Should be done any time you are entering a mode with the IMU.
LSM6DSLData LSM6DSL |