Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
print.h
1
/*
2
* Copyright © 2015-2023 Synthstrom Audible Limited
3
*
4
* This file is part of The Synthstrom Audible Deluge Firmware.
5
*
6
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7
* terms of the GNU General Public License as published by the Free Software Foundation,
8
* either version 3 of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along with this program.
15
* If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <cstdint>
21
22
class
MIDICable
;
23
24
namespace
Debug {
25
const
uint32_t sec = 400000000;
26
const
uint32_t mS = 400000;
27
const
uint32_t uS = 400;
28
29
[[gnu::always_inline]]
inline
uint32_t readCycleCounter() {
30
uint32_t cycles = 0;
31
asm
volatile
(
"MRC p15, 0, %0, c9, c13, 0"
:
"=r"
(cycles) :);
32
return
cycles;
33
}
34
35
[[gnu::always_inline]]
inline
void
readCycleCounter(uint32_t& time) {
36
asm
volatile
(
"MRC p15, 0, %0, c9, c13, 0"
:
"=r"
(time) :);
37
}
38
39
void
init();
40
void
print(
char
const
* output);
41
void
println(
char
const
* output);
42
void
println(int32_t number);
43
void
printlnfloat(
float
number);
44
void
printfloat(
float
number);
45
void
print(int32_t number);
46
void
ResetClock();
47
48
class
RTimer {
49
public
:
50
RTimer(
const
char
* label);
51
~RTimer();
52
53
virtual
void
reset();
54
virtual
void
stop();
55
virtual
void
stop(
const
char
* stopLabel);
56
virtual
void
stop(
int
number);
57
58
uint32_t startTime;
59
const
char
* m_label;
60
bool
stopped;
61
};
62
63
class
Averager {
64
public
:
65
Averager(
const
char
* label, uint32_t repeats = 0);
66
67
void
setCount(uint32_t repeats);
68
void
note(int32_t val);
69
void
setN(uint32_t numRepeats);
70
71
const
char
* m_label;
72
int64_t accumulator;
73
uint32_t N;
74
uint32_t c;
75
};
76
77
class
OneOfN {
78
public
:
79
OneOfN(
const
char
* label, uint32_t repeats = 0);
80
81
void
start();
82
void
stop();
83
84
void
split(
const
char
* splitLabel);
85
void
setN(uint32_t numRepeats);
86
87
bool
active;
88
uint32_t N;
89
uint32_t c;
90
RTimer
myRTimer;
91
};
92
93
class
OnceEvery {
94
public
:
95
OnceEvery(
const
char
* label, uint32_t timeBase);
96
97
void
start();
98
void
stop();
99
100
void
split(
const
char
* splitLabel);
101
102
bool
active;
103
uint32_t timeBase;
104
uint32_t t0;
105
RTimer
myRTimer;
106
};
107
108
class
CountsPer {
109
public
:
110
CountsPer(
const
char
* label, uint32_t timeBase);
111
void
bump(uint32_t by = 1);
112
void
clear();
113
const
char
* label;
114
uint32_t timeBase;
115
bool
active;
116
uint32_t count;
117
uint32_t t0;
118
};
119
120
class
AverageDT {
121
public
:
122
AverageDT(
const
char
* label, uint32_t timeBase, uint32_t scaling = 1);
123
void
begin();
124
void
note();
125
void
clear();
126
const
char
* label;
127
uint32_t timeBase;
128
bool
active;
129
uint32_t scaling;
130
int64_t accumulator;
131
uint32_t count;
132
uint32_t t0;
133
uint32_t tnm1;
134
};
135
136
class
AverageVOT {
137
AverageVOT(
const
char
* label, uint32_t timeBase);
138
void
note(uint32_t value);
139
void
clear();
140
const
char
* label;
141
uint32_t timeBase;
142
bool
active;
143
int64_t accumulator;
144
uint32_t count;
145
uint32_t t0;
146
};
147
148
extern
MIDICable
* midiDebugCable;
149
}
// namespace Debug
Debug::RTimer
Definition
print.h:48
MIDICable
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition
midi_device.h:96