LCOV - code coverage report
Current view: top level - src/MIDI_Inputs/MCU - TimeDisplay.hpp (source / functions) Hit Total Coverage
Test: b8a30b4b7040ae1abf162fd0a258beaa2de43626 Lines: 24 24 100.0 %
Date: 2024-12-21 21:28:55 Functions: 4 4 100.0 %
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 1.15