AP_OpticalFlow_CXOF.h 1015 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "OpticalFlow.h"
  3. #include <AP_HAL/utility/OwnPtr.h>
  4. class AP_OpticalFlow_CXOF : public OpticalFlow_backend
  5. {
  6. public:
  7. /// constructor
  8. AP_OpticalFlow_CXOF(OpticalFlow &_frontend, AP_HAL::UARTDriver *uart);
  9. // initialise the sensor
  10. void init() override;
  11. // read latest values from sensor and fill in x,y and totals.
  12. void update(void) override;
  13. // detect if the sensor is available
  14. static AP_OpticalFlow_CXOF *detect(OpticalFlow &_frontend);
  15. private:
  16. AP_HAL::UARTDriver *uart; // uart connected to flow sensor
  17. uint64_t last_frame_us; // system time of last message from flow sensor
  18. uint8_t buf[10]; // buff of characters received from flow sensor
  19. uint8_t buf_len; // number of characters in buffer
  20. Vector2f gyro_sum; // sum of gyro sensor values since last frame from flow sensor
  21. uint16_t gyro_sum_count; // number of gyro sensor values in sum
  22. };