Skip to content

Commit

Permalink
Define output for logging in ConfigMidi.h
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Aug 28, 2022
1 parent 4ece285 commit 3640d11
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ We also provide some higher level API "Server" classes which can be used for bo
Here is the generated [Class Documentation](https://pschatzmann.github.io/arduino-midi/html/annotated.html).
You can find [further information in my blogs](https://www.pschatzmann.ch/home/tag/midi/).


### Namespace

All the midi classes are defined using the midi namespace. If you include Midi.h the using namespace is already defined. However, if you include the individual class specific header files you need to add a using namespace midi; in your sketch.

### Logging

The library provides some logging functionality. By default the log level is set to MidiDebug. You can change the level with
```
MidiLogLevel = MidiDebug; // or MidiInfo, MidiWarning, MidiError
```

### Namespace

All the midi classes are defined using the midi namespace. If you include Midi.h the using namespace is already defined. However, if you include the individual class specific header files you need to add a using namespace midi; in your sketch.



### Installation in Arduino

Expand Down
10 changes: 9 additions & 1 deletion src/ConfigMidi.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#define MIDI_ACTIVE true

#define NAMESPACE_ACTIVE true
#define LOG_OUT Serial

#if defined(ESP32)
# define MIDI_BLE_ACTIVE true
Expand All @@ -15,11 +17,17 @@
# define MDNS_ACTIVE false
# define UDP_ACTIVE true
# define TCP_ACTIVE true
#else
#elif defined(ARDUINO)
# define APPLE_MIDI_ACTIVE true
# define MIDI_BLE_ACTIVE false
# define MDNS_ACTIVE false
# define UDP_ACTIVE true
# define TCP_ACTIVE true
#else
# define APPLE_MIDI_ACTIVE false
# define MIDI_BLE_ACTIVE false
# define MDNS_ACTIVE false
# define UDP_ACTIVE false
# define TCP_ACTIVE false
#endif

3 changes: 2 additions & 1 deletion src/Midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MidiStreamIn.h"
#include "MidiStreamOut.h"
#include "MidiCallbackAction.h"

#include "MidiBleClient.h"
#include "MidiBleServer.h"
#include "MidiBleParser.h"
Expand All @@ -16,6 +17,6 @@
#if APPLE_MIDI_ACTIVE
#include "AppleMidiServer.h"
#endif
#if NAMESPACE_ACTIVE
#if NAMESPACE_ACTIVE || MIDI_NAMESPACE_ACTIVE
using namespace midi;
#endif
4 changes: 2 additions & 2 deletions src/MidiLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdarg.h>
#include "MidiLogger.h"
#include "MidiConfig.h"

// global actual loggin level for application
MidiLogLevel_t MidiLogLevel= MidiWarning;
Expand All @@ -19,7 +20,6 @@ void midi_log(MidiLogLevel_t level, const char* fmt ...) {
va_start(arg, fmt);
vsprintf(log_buffer+9, fmt, arg);
va_end(arg);
strcat(log_buffer, "\n");
printf(log_buffer);
LOG_OUT.println(log_buffer);
}
}

0 comments on commit 3640d11

Please sign in to comment.