LCOV - code coverage report
Current view: top level - AP_EFI - AP_EFI_ThrottleLinearisation.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 11 54.5 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "AP_EFI_config.h"
       2             : 
       3             : #if AP_EFI_THROTTLE_LINEARISATION_ENABLED
       4             : 
       5             : #include "AP_EFI.h"
       6             : #include <AP_Param/AP_Param.h>
       7             : 
       8             : // settings for throttle linearisation
       9             : const AP_Param::GroupInfo AP_EFI_ThrLin::var_info[] = {
      10             : 
      11             :     // @Param: _EN
      12             :     // @DisplayName: Enable throttle linearisation
      13             :     // @Description: Enable EFI throttle linearisation
      14             :     // @Values: 0:Disabled, 1:Enabled
      15             :     // @User: Advanced
      16             :     AP_GROUPINFO_FLAGS("_EN", 1, AP_EFI_ThrLin, enable, 0, AP_PARAM_FLAG_ENABLE),
      17             : 
      18             :     // @Param: _COEF1
      19             :     // @DisplayName: Throttle linearisation - First Order
      20             :     // @Description: First Order Polynomial Coefficient. (=1, if throttle is first order polynomial trendline)
      21             :     // @Range: -1 1
      22             :     // @User: Advanced
      23             :     // @RebootRequired: True
      24             :     AP_GROUPINFO("_COEF1", 2, AP_EFI_ThrLin, coefficient[0], 1),
      25             : 
      26             :     // @Param: _COEF2
      27             :     // @DisplayName: Throttle linearisation - Second Order
      28             :     // @Description: Second Order Polynomial Coefficient (=0, if throttle is second order polynomial trendline)
      29             :     // @Range: -1 1
      30             :     // @User: Advanced
      31             :     // @RebootRequired: True
      32             :     AP_GROUPINFO("_COEF2", 3, AP_EFI_ThrLin, coefficient[1], 0),
      33             : 
      34             :     // @Param: _COEF3
      35             :     // @DisplayName: Throttle linearisation - Third Order
      36             :     // @Description: Third Order Polynomial Coefficient. (=0, if throttle is third order polynomial trendline)
      37             :     // @Range: -1 1
      38             :     // @User: Advanced
      39             :     // @RebootRequired: True
      40             :     AP_GROUPINFO("_COEF3", 4, AP_EFI_ThrLin, coefficient[2], 0),
      41             : 
      42             :     // @Param: _OFS
      43             :     // @DisplayName: throttle linearization offset
      44             :     // @Description: Offset for throttle linearization 
      45             :     // @Range: 0 100
      46             :     // @User: Advanced
      47             :     // @RebootRequired: True
      48             :     AP_GROUPINFO("_OFS", 5, AP_EFI_ThrLin, offset, 0),
      49             : 
      50             :     AP_GROUPEND
      51             : };
      52             : 
      53        8392 : AP_EFI_ThrLin::AP_EFI_ThrLin(void)
      54             : {
      55        2098 :     AP_Param::setup_object_defaults(this, var_info);
      56        2098 : }
      57             : 
      58             : /*
      59             :   apply throttle linearisation
      60             :  */
      61          48 : float AP_EFI_ThrLin::linearise_throttle(float throttle_percent)
      62             : {
      63          48 :     if (!enable) {
      64          48 :         return throttle_percent;
      65             :     }
      66           0 :     float ret = coefficient[0] * throttle_percent;
      67           0 :     ret += coefficient[1] * throttle_percent * throttle_percent;
      68           0 :     ret += coefficient[2] * throttle_percent * throttle_percent * throttle_percent;
      69           0 :     ret += offset;
      70           0 :     return ret;
      71             : }
      72             : 
      73             : #endif // AP_EFI_THROTTLE_LINEARISATION_ENABLED
      74             : 

Generated by: LCOV version 1.14