Control Surface stm32
MIDI Control Surface library for Arduino
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:
20 {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
28 << F("\tFrame: ") << 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.
Definition: TimeDisplay.hpp:16
TimeDisplay(Channel channel=CHANNEL_1)
Definition: TimeDisplay.hpp:18
void getBars(char *buff) const
Definition: TimeDisplay.hpp:30
void print() const
Definition: TimeDisplay.hpp:22
void getBeats(char *buff) const
Definition: TimeDisplay.hpp:39
void getFrames(char *buff) const
Definition: TimeDisplay.hpp:48
#define DEBUG(x)
Print an expression to the debug output if debugging is enabled.
Definition: Debug.hpp:98
static constexpr uint8_t TimeDisplayLength
Definition: TimeDisplay.hpp:9
static constexpr uint8_t TimeDisplayAddress
Definition: TimeDisplay.hpp:10