LCOV - code coverage report
Current view: top level - src/MIDI_Inputs/MCU - TimeDisplay.hpp (source / functions) Coverage Total Hit
Test: 73449d9b107c772cf65493691543348214e5d5eb Lines: 100.0 % 24 24
Test Date: 2026-06-06 17:44:35 Functions: 100.0 % 4 4
Legend: Lines:     hit not hit

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "SevenSegmentDisplay.hpp"
       4              : 
       5              : BEGIN_CS_NAMESPACE
       6              : 
       7              : namespace MCU {
       8              : 
       9              : constexpr static uint8_t TimeDisplayLength = 10;
      10              : constexpr static uint8_t TimeDisplayAddress = 0x40;
      11              : 
      12              : /// Class that receives and stores the text of the Mackie Control Universal
      13              : /// 7-segment time display.
      14              : ///
      15              : /// @ingroup MIDIInputElements
      16              : class TimeDisplay : public SevenSegmentDisplay<TimeDisplayLength> {
      17              :   public:
      18           15 :     TimeDisplay(Channel channel = Channel_1)
      19           15 :         : SevenSegmentDisplay<TimeDisplayLength>(
      20           15 :               {TimeDisplayAddress, channel}) {}
      21              :     // TODO: add support for 5-digit bar counts
      22              :     void print() const {
      23              :         char barStr[6], beatStr[3], frameStr[4];
      24              :         getBars(barStr);
      25              :         getBeats(beatStr);
      26              :         getFrames(frameStr);
      27              :         DEBUG(F("Bar: ") << barStr << F("\tBeat: ") << beatStr << F("\tFrame: ")
      28              :                          << frameStr);
      29              :     }
      30            6 :     void getBars(char *buff) const {
      31            6 :         if (getCharacterAt(5) == ' ') {
      32            4 :             getText(buff, 0, 3);
      33            2 :         } else if (getCharacterAt(6) == ' ') {
      34            1 :             getText(buff, 0, 4);
      35              :         } else {
      36            1 :             getText(buff, 0, 5);
      37              :         }
      38            6 :     }
      39            6 :     void getBeats(char *buff) const {
      40            6 :         if (getCharacterAt(5) == ' ') {
      41            4 :             getText(buff, 3, 2);
      42            2 :         } else if (getCharacterAt(6) == ' ') {
      43            1 :             getText(buff, 4, 2);
      44              :         } else {
      45            1 :             getText(buff, 5, 2);
      46              :         }
      47            6 :     }
      48            6 :     void getFrames(char *buff) const {
      49            6 :         if (getCharacterAt(5) == ' ') {
      50            4 :             getText(buff, 7, 3);
      51            2 :         } else if (getCharacterAt(6) == ' ') {
      52            1 :             getText(buff, 8, 2);
      53              :         } else {
      54            1 :             getText(buff, 9, 1);
      55              :         }
      56            6 :     }
      57              : };
      58              : 
      59              : } // namespace MCU
      60              : 
      61              : END_CS_NAMESPACE
        

Generated by: LCOV version 2.4-beta