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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_Tuning_config.h"
       4             : 
       5             : #if AP_TUNING_ENABLED
       6             : 
       7             : #include <AP_Param/AP_Param.h>
       8             : 
       9             : #include "stdint.h"
      10             : 
      11             : /*
      12             :   transmitter tuning library. Meant to be subclassed per vehicle type
      13             :  */
      14             : class AP_Tuning
      15             : {
      16             : public:
      17             :     struct tuning_set {
      18             :         uint8_t set;
      19             :         uint8_t num_parms;
      20             :         const uint8_t *parms;
      21             :     };
      22             : 
      23             :     struct tuning_name {
      24             :         uint8_t parm;
      25             :         const char *name;
      26             :     };
      27             : 
      28             :     // constructor
      29         692 :     AP_Tuning(const struct tuning_set *sets, const struct tuning_name *names) :
      30         692 :         tuning_sets(sets),
      31         692 :         tuning_names(names) {
      32         692 :         AP_Param::setup_object_defaults(this, var_info);
      33         692 :     }
      34             :     
      35             :     // var_info for holding Parameter information
      36             :     static const struct AP_Param::GroupInfo var_info[];
      37             : 
      38             :     // update function called on new radio frames
      39             :     void check_input(uint8_t flightmode);
      40             : 
      41             :     // base parameter number for tuning sets of parameters in one flight
      42             :     static constexpr uint8_t set_base = 100;
      43             :     
      44             : private:
      45             :     AP_Int8 channel;
      46             :     AP_Int16 channel_min;
      47             :     AP_Int16 channel_max;
      48             :     AP_Int8 selector;
      49             :     AP_Float range;
      50             :     AP_Int8 mode_revert;
      51             :     AP_Float error_threshold;
      52             : 
      53             :     // when selector was triggered
      54             :     uint32_t selector_start_ms;
      55             : 
      56             :     // are we waiting for channel mid-point?
      57             :     bool mid_point_wait;
      58             : 
      59             :     // last input from tuning channel
      60             :     float last_channel_value;
      61             :     
      62             :     // mid-value for current parameter
      63             :     float center_value;
      64             : 
      65             :     uint32_t last_check_ms;
      66             : 
      67             :     // last tuning value scaled
      68             :     float old_value;
      69             :     
      70             :     void Log_Write_Parameter_Tuning(float value);
      71             :     
      72             :     // the parameter we are tuning
      73             :     uint8_t current_parm;
      74             : 
      75             :     // current index into the parameter set
      76             :     uint8_t current_parm_index;
      77             : 
      78             :     // current parameter set
      79             :     uint8_t current_set;
      80             : 
      81             :     // true if tune has changed
      82             :     bool changed;
      83             : 
      84             :     // mask of params in set that need reverting
      85             :     uint32_t need_revert;
      86             :     
      87             :     // last flight mode we were tuning in
      88             :     uint8_t last_flightmode;
      89             : 
      90             :     const tuning_set *tuning_sets;
      91             :     const tuning_name *tuning_names;
      92             :     
      93             :     void check_selector_switch(void);
      94             :     void re_center(void);
      95             :     void next_parameter(void);
      96             :     void save_parameters(void);
      97             :     void revert_parameters(void);
      98             :     const char *get_tuning_name(uint8_t parm);
      99             : 
     100             : protected:
     101             :     // virtual functions that must be implemented in vehicle subclass
     102             :     virtual AP_Float *get_param_pointer(uint8_t parm) = 0;
     103             :     virtual void save_value(uint8_t parm) = 0;
     104             :     virtual void reload_value(uint8_t parm) = 0;
     105             :     virtual void set_value(uint8_t parm, float value) = 0;
     106             : 
     107             :     // parmset is in vehicle subclass var table
     108             :     AP_Int16 parmset;
     109             : };
     110             : 
     111             : #endif  // AP_TUNING_ENABLED

Generated by: LCOV version 1.14