This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
SysExBuffer.cpp
Go to the documentation of this file.
1 #include "SysExBuffer.hpp"
2 
4 
6  SysExLength = 0; // if the previous message wasn't finished, overwrite it
7  receiving = true;
8  DEBUG("Start SysEx");
9 }
10 
12  receiving = false;
13  DEBUG("End SysEx");
14 }
15 
16 bool SysExBuffer::add(uint8_t data) {
17  if (!hasSpaceLeft()) // if the buffer is full
18  return false;
19  SysExBuffer[SysExLength] = data; // add the data to the buffer
20  ++SysExLength;
21  return true;
22 }
23 
25  bool avail = SysExLength < SYSEX_BUFFER_SIZE;
26  if (!avail)
27  DEBUG("SysEx buffer full");
28  return avail;
29 }
30 
31 bool SysExBuffer::isReceiving() const { return receiving; }
32 
33 const uint8_t *SysExBuffer::getBuffer() const { return SysExBuffer; }
34 
35 size_t SysExBuffer::getLength() const { return SysExLength; }
36 
SysExBuffer.hpp
SysExBuffer::add
bool add(uint8_t data)
Add a byte to the current SysEx message.
Definition: SysExBuffer.cpp:16
SysExBuffer::getLength
size_t getLength() const
Get the length of the SysEx message in the buffer.
Definition: SysExBuffer.cpp:35
SysExBuffer::isReceiving
bool isReceiving() const
Check if the buffer is receiving a SysEx message.
Definition: SysExBuffer.cpp:31
SysExBuffer::SysExLength
size_t SysExLength
Definition: SysExBuffer.hpp:10
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
SysExBuffer::receiving
bool receiving
Definition: SysExBuffer.hpp:11
SysExBuffer
Definition: SysExBuffer.hpp:7
SysExBuffer::getBuffer
const uint8_t * getBuffer() const
Get a pointer to the buffer.
Definition: SysExBuffer.cpp:33
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
DEBUG
#define DEBUG(x)
Definition: Debug.hpp:158
SysExBuffer::hasSpaceLeft
bool hasSpaceLeft() const
Check if the buffer has at least 1 byte of free space available.
Definition: SysExBuffer.cpp:24
SysExBuffer::start
void start()
Start a new SysEx message.
Definition: SysExBuffer.cpp:5
SYSEX_BUFFER_SIZE
constexpr size_t SYSEX_BUFFER_SIZE
The length of the maximum System Exclusive message that can be received.
Definition: Settings.hpp:105
SysExBuffer::end
void end()
Finish the current SysEx message.
Definition: SysExBuffer.cpp:11
SysExBuffer::SysExBuffer
uint8_t SysExBuffer[SYSEX_BUFFER_SIZE]
Definition: SysExBuffer.hpp:9