2018-11-23 03:45:53 -04:00
|
|
|
#pragma once
|
|
|
|
|
2021-12-23 20:05:30 -04:00
|
|
|
#include "AP_OpticalFlow.h"
|
2021-12-24 01:47:21 -04:00
|
|
|
|
|
|
|
#ifndef AP_OPTICALFLOW_CXOF_ENABLED
|
|
|
|
#define AP_OPTICALFLOW_CXOF_ENABLED AP_OPTICALFLOW_ENABLED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if AP_OPTICALFLOW_CXOF_ENABLED
|
|
|
|
|
2018-11-23 03:45:53 -04:00
|
|
|
#include <AP_HAL/utility/OwnPtr.h>
|
|
|
|
|
|
|
|
class AP_OpticalFlow_CXOF : public OpticalFlow_backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// constructor
|
2022-08-14 22:31:14 -03:00
|
|
|
AP_OpticalFlow_CXOF(AP_OpticalFlow &_frontend, AP_HAL::UARTDriver *uart);
|
2018-11-23 03:45:53 -04:00
|
|
|
|
|
|
|
// initialise the sensor
|
|
|
|
void init() override;
|
|
|
|
|
|
|
|
// read latest values from sensor and fill in x,y and totals.
|
|
|
|
void update(void) override;
|
|
|
|
|
|
|
|
// detect if the sensor is available
|
2022-08-14 22:31:14 -03:00
|
|
|
static AP_OpticalFlow_CXOF *detect(AP_OpticalFlow &_frontend);
|
2018-11-23 03:45:53 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-11-28 07:10:30 -04:00
|
|
|
AP_HAL::UARTDriver *uart; // uart connected to flow sensor
|
2018-11-23 03:45:53 -04:00
|
|
|
uint64_t last_frame_us; // system time of last message from flow sensor
|
|
|
|
uint8_t buf[10]; // buff of characters received from flow sensor
|
2018-11-28 07:10:30 -04:00
|
|
|
uint8_t buf_len; // number of characters in buffer
|
2018-11-23 03:45:53 -04:00
|
|
|
Vector2f gyro_sum; // sum of gyro sensor values since last frame from flow sensor
|
2018-11-28 07:10:30 -04:00
|
|
|
uint16_t gyro_sum_count; // number of gyro sensor values in sum
|
2018-11-23 03:45:53 -04:00
|
|
|
};
|
2021-12-24 01:47:21 -04:00
|
|
|
|
|
|
|
#endif // AP_OPTICALFLOW_CXOF_ENABLED
|