Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Parsers
SysExBuffer.cpp
Go to the documentation of this file.
1
#include "
SysExBuffer.hpp
"
2
#include <string.h>
3
4
BEGIN_CS_NAMESPACE
5
6
void
SysExBuffer::start
() {
7
length
= 0;
// if the previous message wasn't finished, overwrite it
8
receiving
=
true
;
9
}
10
11
void
SysExBuffer::end
() {
receiving
=
false
; }
12
13
void
SysExBuffer::add
(uint8_t data) {
14
buffer
[
length
] = data;
15
++
length
;
16
}
17
18
void
SysExBuffer::add
(
const
uint8_t *data, uint8_t len) {
19
memcpy(
buffer
+
length
, data, len);
20
length
+= len;
21
}
22
23
bool
SysExBuffer::hasSpaceLeft
(uint8_t amount)
const
{
24
bool
avail =
length
<=
SYSEX_BUFFER_SIZE
- amount;
25
if
(!avail)
26
DEBUG
(F(
"SysEx: Buffer full ("
) << amount <<
')'
);
27
return
avail;
28
}
29
30
bool
SysExBuffer::isReceiving
()
const
{
return
receiving
; }
31
32
const
uint8_t *
SysExBuffer::getBuffer
()
const
{
return
buffer
; }
33
34
uint16_t
SysExBuffer::getLength
()
const
{
return
length
; }
35
36
END_CS_NAMESPACE
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
SYSEX_BUFFER_SIZE
constexpr uint16_t SYSEX_BUFFER_SIZE
The length of the maximum System Exclusive message that can be received.
Definition
Settings/Settings.hpp:48
SysExBuffer.hpp
SysExBuffer::getBuffer
const uint8_t * getBuffer() const
Get a pointer to the buffer.
Definition
SysExBuffer.cpp:32
SysExBuffer::length
uint16_t length
Definition
SysExBuffer.hpp:16
SysExBuffer::receiving
bool receiving
Definition
SysExBuffer.hpp:17
SysExBuffer::buffer
uint8_t buffer[SYSEX_BUFFER_SIZE]
Definition
SysExBuffer.hpp:15
SysExBuffer::hasSpaceLeft
bool hasSpaceLeft(uint8_t amount=1) const
Check if the buffer has at least amount bytes of free space available.
Definition
SysExBuffer.cpp:23
SysExBuffer::start
void start()
Start a new SysEx message.
Definition
SysExBuffer.cpp:6
SysExBuffer::add
void add(uint8_t data)
Add a byte to the current SysEx message.
Definition
SysExBuffer.cpp:13
SysExBuffer::end
void end()
Finish the current SysEx message.
Definition
SysExBuffer.cpp:11
SysExBuffer::getLength
uint16_t getLength() const
Get the length of the SysEx message in the buffer.
Definition
SysExBuffer.cpp:34
SysExBuffer::isReceiving
bool isReceiving() const
Check if the buffer is receiving a SysEx message.
Definition
SysExBuffer.cpp:30
DEBUG
#define DEBUG(x)
Print an expression to the debug output if debugging is enabled.
Definition
Debug.hpp:95
Generated by
1.17.0