drawcia: Correct accelerometer orientation
BRANCH=none
TEST=On Drawcia mockup, check the screen rotation was normally.
Make sure x-y-z axis direction is indeed.
@@ -446,6 +446,19 @@ static struct mutex g_base_mutex;
static struct accelgyro_saved_data_t g_bma253_data;
static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA;
+/* Matrix to rotate accelrator into standard reference frame */
+static const mat33_fp_t base_standard_ref = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(-1)}
+};
+
+static const mat33_fp_t lid_standard_ref = {
+ { FLOAT_TO_FP(1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(-1)}
+};
+
/* Drivers */
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
@@ -459,7 +472,7 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_bma253_data,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS,
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &lid_standard_ref,
.default_range = 2,
.min_frequency = BMA255_ACCEL_MIN_FREQ,
.max_frequency = BMA255_ACCEL_MAX_FREQ,
@@ -486,7 +499,7 @@ struct motion_sensor_t motion_sensors[] = {
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
