Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
TimeDisplay.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7namespace MCU {
8
9constexpr static uint8_t TimeDisplayLength = 10;
10constexpr static uint8_t TimeDisplayAddress = 0x40;
11
16class TimeDisplay : public SevenSegmentDisplay<TimeDisplayLength> {
17 public:
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 void getBars(char *buff) const {
31 if (getCharacterAt(5) == ' ') {
32 getText(buff, 0, 3);
33 } else if (getCharacterAt(6) == ' ') {
34 getText(buff, 0, 4);
35 } else {
36 getText(buff, 0, 5);
37 }
38 }
39 void getBeats(char *buff) const {
40 if (getCharacterAt(5) == ' ') {
41 getText(buff, 3, 2);
42 } else if (getCharacterAt(6) == ' ') {
43 getText(buff, 4, 2);
44 } else {
45 getText(buff, 5, 2);
46 }
47 }
48 void getFrames(char *buff) const {
49 if (getCharacterAt(5) == ' ') {
50 getText(buff, 7, 3);
51 } else if (getCharacterAt(6) == ' ') {
52 getText(buff, 8, 2);
53 } else {
54 getText(buff, 9, 1);
55 }
56 }
57};
58
59} // namespace MCU
60
constexpr Channel Channel_1
Definition Channel.hpp:118
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI channels.
Definition Channel.hpp:13
Class that receives and saves the text of a Mackie Control Universal 7-segment display like the assig...
char getCharacterAt(uint8_t index) const
Get the character at the given index.
void getText(char *buffer, uint8_t offset=0, uint8_t length=LENGTH) const
Copy the ASCII text into the given buffer.
Class that receives and stores the text of the Mackie Control Universal 7-segment time display.
TimeDisplay(Channel channel=Channel_1)
void getBars(char *buff) const
void print() const
void getBeats(char *buff) const
void getFrames(char *buff) const
#define DEBUG(x)
Print an expression to the debug output if debugging is enabled.
Definition Debug.hpp:95
static constexpr uint8_t TimeDisplayLength
static constexpr uint8_t TimeDisplayAddress