LCOV - code coverage report
Current view: top level - AP_ADSB/sagetech-sdk - toGS.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 19 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /**
       2             :  * @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved.
       3             :  *
       4             :  * @file toGS.c
       5             :  * @author Jacob.Garrison
       6             :  *
       7             :  * @date Mar 2, 2021
       8             :  *
       9             :  */
      10             : 
      11             : #include "sgUtil.h"
      12             : 
      13             : /*
      14             :  * Documented in the header file.
      15             :  */
      16           0 : uint8_t toGS(const uint8_t bytes[])
      17             : {
      18           0 :     uint8_t code = bytes[0];
      19           0 :     float gs = 0.0f;
      20             : 
      21           0 :     if (code <= 0x01)
      22             :     {
      23           0 :         gs = 0.0f;
      24             :     }
      25           0 :     else if (code <= 0x08)
      26             :     {
      27           0 :         gs = 1.0f;
      28             :     }
      29           0 :     else if (code <= 0x0C)
      30             :     {
      31           0 :         gs = 1.0f + (code - 0x09) * 0.25f;
      32             :     }
      33           0 :     else if (code <= 0x26)
      34             :     {
      35           0 :         gs = 2.0f + (code - 0x0D) * 0.5f;
      36             :     }
      37           0 :     else if (code <= 0x5D)
      38             :     {
      39           0 :         gs = 15.0f + (code - 0x27) * 1.0f;
      40             :     }
      41           0 :     else if (code <= 0x6C)
      42             :     {
      43           0 :         gs = 70.0f + (code - 0x5E) * 2.0f;
      44             :     }
      45           0 :     else if (code <= 0x7B)
      46             :     {
      47           0 :         gs = 100.0f + (code - 0x6D) * 5.0f;
      48             :     }
      49             :     else
      50             :     {
      51           0 :         gs = 176.0f;
      52             :     }
      53             : 
      54             :     // first converting to an 16 bit integer is necessary
      55             :     // to keep the floating point conversion from
      56             :     // truncating to 0.
      57           0 :     return (uint8_t)((int16_t)gs & 0xFF);
      58             : }

Generated by: LCOV version 1.14