LCOV - code coverage report
Current view: top level - src/MIDI_Inputs/MCU - TimeDisplay.hpp (source / functions) Hit Total Coverage
Test: 90a1b9beff85a60dc6ebcea034a947a845e56960 Lines: 28 28 100.0 %
Date: 2019-11-30 15:53:32 Functions: 5 6 83.3 %
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          13 : class TimeDisplay : public SevenSegmentDisplay<TimeDisplayLength> {
      13             :   public:
      14          13 :     TimeDisplay(Channel channel = CHANNEL_1)
      15          13 :         : SevenSegmentDisplay<TimeDisplayLength>(
      16          26 :               {TimeDisplayAddress, channel}) {}
      17             :     // TODO: add support for 5-digit bar counts
      18             :     void print() const {
      19             :         char barStr[6], beatStr[3], frameStr[4];
      20             :         getBars(barStr);
      21             :         getBeats(beatStr);
      22             :         getFrames(frameStr);
      23             :         DEBUG("Bar: " << barStr << "\tBeat: " << beatStr
      24             :                       << "\tFrame: " << frameStr);
      25             :     }
      26           6 :     void getBars(char *buff) const {
      27           6 :         if (getCharacterAt(5) == ' ') {
      28           4 :             getText(buff, 0, 3);
      29           6 :         } else if (getCharacterAt(6) == ' ') {
      30           1 :             getText(buff, 0, 4);
      31           1 :         } else {
      32           1 :             getText(buff, 0, 5);
      33             :         }
      34           6 :     }
      35           6 :     void getBeats(char *buff) const {
      36           6 :         if (getCharacterAt(5) == ' ') {
      37           4 :             getText(buff, 3, 2);
      38           6 :         } else if (getCharacterAt(6) == ' ') {
      39           1 :             getText(buff, 4, 2);
      40           1 :         } else {
      41           1 :             getText(buff, 5, 2);
      42             :         }
      43           6 :     }
      44           6 :     void getFrames(char *buff) const {
      45           6 :         if (getCharacterAt(5) == ' ') {
      46           4 :             getText(buff, 7, 3);
      47           6 :         } else if (getCharacterAt(6) == ' ') {
      48           1 :             getText(buff, 8, 2);
      49           1 :         } else {
      50           1 :             getText(buff, 9, 1);
      51             :         }
      52           6 :     }
      53             : };
      54             : 
      55             : } // namespace MCU
      56             : 
      57             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6