From 091aa24249a81ee70d4848513f1b15ecd9ccb906 Mon Sep 17 00:00:00 2001 From: JOhn Aughey Date: Thu, 28 Apr 2016 13:00:16 -0500 Subject: [PATCH] For fake gyro/acc, set the output to an fake variable. For testing, the gyros and accelerometer values might needed to be artifically set. This change allows a testing loop to set the gyro and acc to values through a global variable. --- src/main/sensors/initialisation.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index 9c49090d4f..415ebbc4a4 100755 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -214,6 +214,7 @@ const extiConfig_t *selectMPUIntExtiConfig(void) } #ifdef USE_FAKE_GYRO +int16_t fake_gyro_values[XYZ_AXIS_COUNT] = { 0,0,0 }; static void fakeGyroInit(uint16_t lpf) { UNUSED(lpf); @@ -221,7 +222,9 @@ static void fakeGyroInit(uint16_t lpf) static bool fakeGyroRead(int16_t *gyroADC) { - memset(gyroADC, 0, sizeof(int16_t[XYZ_AXIS_COUNT])); + for (int i = 0; i < XYZ_AXIS_COUNT; ++i) { + gyroADC[i] = fake_gyro_values[i]; + } return true; } @@ -241,9 +244,13 @@ bool fakeGyroDetect(gyro_t *gyro) #endif #ifdef USE_FAKE_ACC +int16_t fake_acc_values[XYZ_AXIS_COUNT] = {0,0,0}; + static void fakeAccInit(void) {} static bool fakeAccRead(int16_t *accData) { - memset(accData, 0, sizeof(int16_t[XYZ_AXIS_COUNT])); + for(int i=0;i