LCOV - code coverage report
Current view: top level - firmware/controllers/gauges - speedometer.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 15 46.7 %
Date: 2024-04-25 02:23:43 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "pch.h"
       2             : 
       3             : #include "speedometer.h"
       4             : 
       5             : static SimplePwm speedoPwm("speedo");
       6             : 
       7             : static bool hasSpeedoInit = false;
       8             : 
       9         226 : void speedoUpdate() {
      10         226 :         if (!hasSpeedoInit) {
      11         226 :                 return;
      12             :         }
      13             : 
      14           0 :         float kph = Sensor::getOrZero(SensorType::VehicleSpeed);
      15           0 :         float kps = kph * (1. / 3600);
      16           0 :         float freq = kps * engineConfiguration->speedometerPulsePerKm;
      17             : 
      18           0 :         if (freq < 1) {
      19           0 :                 freq = NAN;
      20             :         }
      21             : 
      22           0 :         speedoPwm.setFrequency(freq);
      23             : }
      24             : 
      25         306 : void initSpeedometer() {
      26         306 :         hasSpeedoInit = false;
      27             : 
      28         306 :         if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) {
      29         306 :                 return;
      30             :         }
      31             : 
      32           0 :         startSimplePwm(&speedoPwm,
      33             :                                         "Speedometer",
      34             :                                         &engine->executor,
      35             :                                         &enginePins.speedoOut,
      36             :                                         NAN, 0.5f);
      37             : 
      38           0 :         hasSpeedoInit = true;
      39             : }

Generated by: LCOV version 1.14