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-07-27 03:14:29 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         483 : void speedoUpdate() {
      10         483 :         if (!hasSpeedoInit) {
      11         483 :                 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         353 : void initSpeedometer() {
      26         353 :         hasSpeedoInit = false;
      27             : 
      28         353 :         if (!isBrainPinValid(engineConfiguration->speedometerOutputPin)) {
      29         353 :                 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