LCOV - code coverage report
Current view: top level - AP_OpticalFlow - AP_OpticalFlow_Pixart.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 1 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_OpticalFlow_config.h"
       4             : 
       5             : #if AP_OPTICALFLOW_PIXART_ENABLED
       6             : 
       7             : #include "AP_OpticalFlow_Backend.h"
       8             : 
       9             : #include <AP_HAL/utility/OwnPtr.h>
      10             : 
      11             : class AP_OpticalFlow_Pixart : public OpticalFlow_backend
      12             : {
      13             : public:
      14             :     /// constructor
      15             :     AP_OpticalFlow_Pixart(const char *devname, AP_OpticalFlow &_frontend);
      16             : 
      17             :     // init - initialise the sensor
      18           0 :     void init() override {}
      19             : 
      20             :     // update - read latest values from sensor and fill in x,y and totals.
      21             :     void update(void) override;
      22             : 
      23             :     // detect if the sensor is available
      24             :     static AP_OpticalFlow_Pixart *detect(const char *devname, AP_OpticalFlow &_frontend);
      25             : 
      26             : private:
      27             :     AP_HAL::OwnPtr<AP_HAL::SPIDevice> _dev;
      28             : 
      29             :     enum {
      30             :         PIXART_3900=0,
      31             :         PIXART_3901=1
      32             :     } model;
      33             :     
      34             :     struct RegData {
      35             :         uint8_t reg;
      36             :         uint8_t value;
      37             :     };
      38             : 
      39             :     struct PACKED MotionBurst {
      40             :         uint8_t motion;
      41             :         uint8_t observation;
      42             :         int16_t delta_x;
      43             :         int16_t delta_y;
      44             :         uint8_t squal;
      45             :         uint8_t rawdata_sum;
      46             :         uint8_t max_raw;
      47             :         uint8_t min_raw;
      48             :         uint8_t shutter_upper;
      49             :         uint8_t shutter_lower;
      50             :     } burst;
      51             : 
      52             :     struct {
      53             :         Vector2l sum;
      54             :         uint32_t last_frame_us;
      55             :         uint32_t sum_us;
      56             :         Vector2f gyro;
      57             :     } integral;
      58             :     
      59             :     static const uint8_t srom_data[];
      60             :     static const uint8_t srom_id;
      61             :     static const RegData init_data_3900[];
      62             :     static const RegData init_data_3901_1[];
      63             :     static const RegData init_data_3901_2[];
      64             :     static constexpr float flow_pixel_scaling = 1.26e-3;
      65             : 
      66             :     // setup sensor
      67             :     bool setup_sensor(void);
      68             :     
      69             :     void reg_write(uint8_t reg, uint8_t value);
      70             :     uint8_t reg_read(uint8_t reg);
      71             :     int16_t reg_read16s(uint8_t reg);
      72             :     uint16_t reg_read16u(uint8_t reg);
      73             : 
      74             :     void srom_download(void);
      75             :     void load_configuration(const RegData *init_data, uint16_t n);
      76             : 
      77             :     void timer(void);
      78             :     void motion_burst(void);
      79             : 
      80             :     uint32_t last_burst_us;
      81             :     uint32_t last_update_ms;
      82             : };
      83             : 
      84             : #endif  // AP_OPTICALFLOW_PIXART_ENABLED

Generated by: LCOV version 1.14