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

          Line data    Source code
       1             : /*
       2             :  * This file is free software: you can redistribute it and/or modify it
       3             :  * under the terms of the GNU General Public License as published by the
       4             :  * Free Software Foundation, either version 3 of the License, or
       5             :  * (at your option) any later version.
       6             :  *
       7             :  * This file is distributed in the hope that it will be useful, but
       8             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      10             :  * See the GNU General Public License for more details.
      11             :  *
      12             :  * You should have received a copy of the GNU General Public License along
      13             :  * with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : #pragma once
      16             : 
      17             : #include <AP_Param/AP_Param.h>
      18             : #include <AP_Math/AP_Math.h>
      19             : #include "AP_Filter_config.h"
      20             : #include "NotchFilter.h"
      21             : 
      22             : #if AP_FILTER_ENABLED
      23             : 
      24             : class AP_Filter {
      25             : public:
      26             :     enum class FilterType : uint8_t {
      27             :         FILTER_NONE            = 0,
      28             :         FILTER_NOTCH           = 1,
      29             :     };   
      30             : 
      31             :     AP_Filter(FilterType type);
      32             : 
      33             :     void init();
      34             : 
      35           0 :     virtual bool setup_notch_filter(NotchFilterFloat& filter, float sample_rate) { return false; }
      36             : 
      37             :     FilterType _type;
      38             : };
      39             : 
      40             : struct AP_Filter_params {
      41             : public:
      42             :     AP_Filter_params();
      43             : 
      44             :     static const struct AP_Param::GroupInfo var_info[];
      45             : 
      46             :     AP_Enum<AP_Filter::FilterType> _type;
      47             : };
      48             : 
      49             : struct AP_NotchFilter_params : public AP_Filter {
      50             : public:
      51             :     AP_NotchFilter_params();
      52             : 
      53             :     bool setup_notch_filter(NotchFilterFloat& filter, float sample_rate) override;
      54             : 
      55             :     static const struct AP_Param::GroupInfo var_info[];
      56             : 
      57             :     AP_Float _center_freq_hz;
      58             :     AP_Float _quality;
      59             :     AP_Float _attenuation_dB;
      60             : };
      61             : 
      62             : class AP_Filters {
      63             : public:
      64             :     AP_Filters();
      65             : 
      66             :     CLASS_NO_COPY(AP_Filters);
      67             : 
      68         723 :     static AP_Filters *get_singleton(void) { return singleton; }
      69             : 
      70             :     void init();
      71             :     // 1Hz update to process config changes
      72             :     void update();
      73             : 
      74             :     static const struct AP_Param::GroupInfo var_info[];
      75             : 
      76             :     static const struct AP_Param::GroupInfo *backend_var_info[AP_FILTER_NUM_FILTERS];
      77             : 
      78             :     AP_Filter* get_filter(uint8_t filt_num);
      79             : 
      80             : private:
      81             :     AP_Filter* filters[AP_FILTER_NUM_FILTERS];
      82             :     AP_Filter_params params[AP_FILTER_NUM_FILTERS];
      83             : 
      84             :     static AP_Filters *singleton;
      85             : };
      86             : 
      87             : namespace AP {
      88             :     AP_Filters &filters();
      89             : };
      90             : 
      91             : #endif // AP_FILTER_ENABLED
      92             : 

Generated by: LCOV version 1.14