LCOV - code coverage report
Current view: top level - AP_RangeFinder - AP_RangeFinder_LightWareI2C.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 4 4 100.0 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_RangeFinder_config.h"
       4             : 
       5             : #if AP_RANGEFINDER_LWI2C_ENABLED
       6             : 
       7             : #include "AP_RangeFinder.h"
       8             : #include "AP_RangeFinder_Backend_I2C.h"
       9             : 
      10             : #define NUM_SF20_DATA_STREAMS 1
      11             : 
      12             : class AP_RangeFinder_LightWareI2C : public AP_RangeFinder_Backend_I2C
      13             : {
      14             : 
      15             : public:
      16             :     // static detection function
      17           1 :     static AP_RangeFinder_Backend *detect(RangeFinder::RangeFinder_State &_state,
      18             :                                           AP_RangeFinder_Params &_params,
      19             :                                           class AP_HAL::I2CDevice &dev) {
      20             :         // this will free the object if configuration fails:
      21           1 :         return configure(NEW_NOTHROW AP_RangeFinder_LightWareI2C(_state, _params, dev));
      22             :     }
      23             : 
      24             :     // update state
      25             :     void update(void) override;
      26             : 
      27             : protected:
      28             : 
      29         335 :     virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override
      30             :     {
      31         335 :         return MAV_DISTANCE_SENSOR_LASER;
      32             :     }
      33             : 
      34             : private:
      35             : 
      36             :     float sf20_stream_val[NUM_SF20_DATA_STREAMS];
      37             :     int currentStreamSequenceIndex = 0;
      38             : 
      39             :     // constructor
      40             :     using AP_RangeFinder_Backend_I2C::AP_RangeFinder_Backend_I2C;
      41             : 
      42             :     bool write_bytes(uint8_t *write_buf_u8, uint32_t len_u8);
      43             :     void sf20_disable_address_tagging();
      44             :     bool sf20_send_and_expect(const char* send, const char* expected_reply);
      45             :     bool sf20_set_lost_signal_confirmations();
      46             :     void sf20_get_version(const char* send_msg, const char *reply_prefix, char *reply, uint8_t reply_len);
      47             :     bool sf20_wait_on_reply(uint8_t *rx_two_bytes);
      48             :     bool init() override;
      49             :     bool legacy_init();
      50             :     bool sf20_init();
      51             :     void sf20_init_streamRecovery();
      52             :     void legacy_timer();
      53             :     void sf20_timer();
      54             : 
      55             :     // get a reading
      56             :     bool legacy_get_reading(float &reading_m);
      57             :     bool sf20_get_reading(float &reading_m);
      58             :     bool sf20_parse_stream(uint8_t *stream_buf,
      59             :                            size_t *p_num_processed_chars,
      60             :                            const char *string_identifier,
      61             :                            float &val);
      62             : };
      63             : 
      64             : #endif  // AP_RANGEFINDER_LWI2C_ENABLED

Generated by: LCOV version 1.14