mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
* opticalflow mt sensor added * set the processedFlow to raw when no rotation * use sin and cos approximations Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/sensors/opticalflow.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * refactoring * not needed anymore * update * Update src/main/sensors/opticalflow.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/sensors/opticalflow.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/drivers/rangefinder/rangefinder_lidarmt.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * update * rm prototype * clean up * Update src/main/drivers/opticalflow/opticalflow.h Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/drivers/opticalflow/opticalflow.h Co-authored-by: Mark Haslinghuis <mark@numloq.nl> * update flip_y * Update src/main/drivers/opticalflow/opticalflow.h Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/drivers/rangefinder/rangefinder_lidarmt.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/drivers/rangefinder/rangefinder_lidarmt.h Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/sensors/opticalflow.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/sensors/opticalflow.c Co-authored-by: Petr Ledvina <ledvinap@gmail.com> * Update src/main/sensors/opticalflow.c Co-authored-by: Mark Haslinghuis <mark@numloq.nl> * rm casting * update op rotation --------- Co-authored-by: Petr Ledvina <ledvinap@gmail.com> Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
101 lines
2.2 KiB
C
101 lines
2.2 KiB
C
/*
|
|
* This file is part of Cleanflight and Betaflight.
|
|
*
|
|
* Cleanflight and Betaflight are free software. You can redistribute
|
|
* this software and/or modify this software under the terms of the
|
|
* GNU General Public License as published by the Free Software
|
|
* Foundation, either version 3 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* Cleanflight and Betaflight are distributed in the hope that they
|
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software.
|
|
*
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "common/utils.h"
|
|
|
|
#include "config/config.h"
|
|
#include "config/feature.h"
|
|
|
|
#include "fc/runtime_config.h"
|
|
|
|
#include "flight/pid.h"
|
|
|
|
#include "pg/pg.h"
|
|
#include "pg/pg_ids.h"
|
|
|
|
#include "sensors/acceleration.h"
|
|
#include "sensors/adcinternal.h"
|
|
#include "sensors/barometer.h"
|
|
#include "sensors/compass.h"
|
|
#include "sensors/gyro.h"
|
|
#include "sensors/gyro_init.h"
|
|
#include "sensors/initialisation.h"
|
|
#include "sensors/rangefinder.h"
|
|
#include "sensors/sensors.h"
|
|
#include "sensors/opticalflow.h"
|
|
|
|
// requestedSensors is not actually used
|
|
uint8_t requestedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE, OPTICALFLOW_NONE};
|
|
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE, OPTICALFLOW_NONE};
|
|
|
|
void sensorsPreInit(void)
|
|
{
|
|
gyroPreInit();
|
|
|
|
#ifdef USE_MAG
|
|
compassPreInit();
|
|
#endif
|
|
|
|
#ifdef USE_BARO
|
|
baroPreInit();
|
|
#endif
|
|
}
|
|
|
|
bool sensorsAutodetect(void)
|
|
{
|
|
|
|
// gyro must be initialised before accelerometer
|
|
|
|
bool gyroDetected = gyroInit();
|
|
|
|
#ifdef USE_ACC
|
|
if (gyroDetected) {
|
|
accInit(gyro.accSampleRateHz);
|
|
}
|
|
#endif
|
|
|
|
#ifdef USE_BARO
|
|
baroInit();
|
|
#endif
|
|
|
|
#ifdef USE_MAG
|
|
compassInit();
|
|
#endif
|
|
|
|
#ifdef USE_RANGEFINDER
|
|
rangefinderInit();
|
|
#endif
|
|
|
|
#ifdef USE_OPTICALFLOW
|
|
opticalflowInit();
|
|
#endif
|
|
|
|
#ifdef USE_ADC_INTERNAL
|
|
adcInternalInit();
|
|
#endif
|
|
|
|
return gyroDetected;
|
|
}
|