This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
TimeDisplay.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
6 
7 namespace MCU {
8 
9 constexpr static uint8_t TimeDisplayLength = 10;
10 constexpr static uint8_t TimeDisplayAddress = 0x40;
11 
12 class TimeDisplay : public SevenSegmentDisplay<TimeDisplayLength> {
13  public:
16  {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  void getBars(char *buff) const {
27  if (getCharacterAt(5) == ' ') {
28  getText(buff, 0, 3);
29  } else if (getCharacterAt(6) == ' ') {
30  getText(buff, 0, 4);
31  } else {
32  getText(buff, 0, 5);
33  }
34  }
35  void getBeats(char *buff) const {
36  if (getCharacterAt(5) == ' ') {
37  getText(buff, 3, 2);
38  } else if (getCharacterAt(6) == ' ') {
39  getText(buff, 4, 2);
40  } else {
41  getText(buff, 5, 2);
42  }
43  }
44  void getFrames(char *buff) const {
45  if (getCharacterAt(5) == ' ') {
46  getText(buff, 7, 3);
47  } else if (getCharacterAt(6) == ' ') {
48  getText(buff, 8, 2);
49  } else {
50  getText(buff, 9, 1);
51  }
52  }
53 };
54 
55 } // namespace MCU
56 
Channel
A type-safe class for MIDI channels.
Definition: Channel.hpp:13
MCU::TimeDisplay::TimeDisplay
TimeDisplay(Channel channel=CHANNEL_1)
Definition: TimeDisplay.hpp:14
MCU
Names and note and controller numbers for the Mackie Control Universal (MCU) protocol.
Definition: LCDDisplay.hpp:10
MCU::TimeDisplay::getFrames
void getFrames(char *buff) const
Definition: TimeDisplay.hpp:44
MCU::TimeDisplayAddress
constexpr static uint8_t TimeDisplayAddress
Definition: TimeDisplay.hpp:10
MCU::SevenSegmentDisplay
Definition: SevenSegmentDisplay.hpp:12
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
MCU::TimeDisplayLength
constexpr static uint8_t TimeDisplayLength
Definition: TimeDisplay.hpp:9
MCU::TimeDisplay::print
void print() const
Definition: TimeDisplay.hpp:18
MCU::TimeDisplay
Definition: TimeDisplay.hpp:12
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
MCU::TimeDisplay::getBars
void getBars(char *buff) const
Definition: TimeDisplay.hpp:26
DEBUG
#define DEBUG(x)
Definition: Debug.hpp:158
SevenSegmentDisplay.hpp
MCU::SevenSegmentDisplay< TimeDisplayLength >::getText
void getText(char *buffer, uint8_t offset=0, uint8_t length=LENGTH) const
Copy the ASCII text into the given buffer.
Definition: SevenSegmentDisplay.hpp:78
MCU::TimeDisplay::getBeats
void getBeats(char *buff) const
Definition: TimeDisplay.hpp:35
CHANNEL_1
constexpr Channel CHANNEL_1
Definition: Channel.hpp:111
MCU::SevenSegmentDisplay< TimeDisplayLength >::getCharacterAt
char getCharacterAt(uint8_t index) const
Get the character at the given index.
Definition: SevenSegmentDisplay.hpp:93