Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Inputs
MCU
TimeDisplay.hpp
Go to the documentation of this file.
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
16
class
TimeDisplay
:
public
SevenSegmentDisplay
<TimeDisplayLength> {
17
public
:
18
TimeDisplay
(
Channel
channel =
Channel_1
)
19
:
SevenSegmentDisplay
<
TimeDisplayLength
>(
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 << 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
61
END_CS_NAMESPACE
Channel_1
constexpr Channel Channel_1
Definition
Channel.hpp:118
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
SevenSegmentDisplay.hpp
Channel
A type-safe class for MIDI channels.
Definition
Channel.hpp:13
MCU::SevenSegmentDisplay< TimeDisplayLength >::SevenSegmentDisplay
SevenSegmentDisplay(MIDIAddress address)
Definition
SevenSegmentDisplay.hpp:28
MCU::SevenSegmentDisplay< TimeDisplayLength >::getCharacterAt
char getCharacterAt(uint8_t index) const
Definition
SevenSegmentDisplay.hpp:88
MCU::SevenSegmentDisplay< TimeDisplayLength >::getText
void getText(char *buffer, uint8_t offset=0, uint8_t length=LENGTH) const
Definition
SevenSegmentDisplay.hpp:73
MCU::TimeDisplay::TimeDisplay
TimeDisplay(Channel channel=Channel_1)
Definition
TimeDisplay.hpp:18
MCU::TimeDisplay::getBars
void getBars(char *buff) const
Definition
TimeDisplay.hpp:30
MCU::TimeDisplay::print
void print() const
Definition
TimeDisplay.hpp:22
MCU::TimeDisplay::getBeats
void getBeats(char *buff) const
Definition
TimeDisplay.hpp:39
MCU::TimeDisplay::getFrames
void getFrames(char *buff) const
Definition
TimeDisplay.hpp:48
DEBUG
#define DEBUG(x)
Print an expression to the debug output if debugging is enabled.
Definition
Debug.hpp:95
MCU
Definition
LCDDisplay.hpp:10
MCU::TimeDisplayLength
static constexpr uint8_t TimeDisplayLength
Definition
TimeDisplay.hpp:9
MCU::TimeDisplayAddress
static constexpr uint8_t TimeDisplayAddress
Definition
TimeDisplay.hpp:10
Generated by
1.17.0