Skip to content

Commit

Permalink
v0.3.2 added custom MIDI trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
neroroxxx committed Oct 16, 2020
1 parent 138397a commit fa5ff1c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=BMC
version=0.3.1
version=0.3.2
author=Nero Rox
maintainer=Nero Rox <info@roxxxtar.com>
sentence=Fully featured MIDI Controller Library with a Companion Editor App. For Teensy
Expand Down
5 changes: 5 additions & 0 deletions src/BMC-Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ class BMCApi : public BMC {
void onPageChange(void (*fptr)(uint8_t page)){
callback.pageChanged = fptr;
}
void onTriggerCustom(void (*fptr)(uint8_t id)){
#if BMC_MAX_TRIGGERS > 0
callback.triggerCustom = fptr;
#endif
}
// triggered when EEPROM has been updated either by the editor or the API
void onStoreUpdate(void (*fptr)()){
callback.storeUpdated = fptr;
Expand Down
2 changes: 1 addition & 1 deletion src/BMC-Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// BMC Version stored in EEPROM (for editor usage)
#define BMC_VERSION_MAJ 0
#define BMC_VERSION_MIN 3
#define BMC_VERSION_PATCH 1
#define BMC_VERSION_PATCH 2

//16 bits unsigned, LSB byte is minor, MSB byte is major
#define BMC_VERSION ((BMC_VERSION_MAJ<<8) | BMC_VERSION_MIN)
Expand Down
4 changes: 2 additions & 2 deletions src/BMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ BMC::BMC():
#endif
#if BMC_MAX_LIBRARY > 0
#if BMC_MAX_CUSTOM_SYSEX > 0
,library(midi, store.global, customSysEx)
,library(midi, store.global, callback, customSysEx)
#else
,library(midi, store.global)
,library(midi, store.global, callback)
#endif
#if BMC_MAX_PRESETS > 0
,presets(midi, store.global, library)
Expand Down
5 changes: 5 additions & 0 deletions src/BMC.triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
uint8_t byteC = BMC_GET_BYTE(3,event);

switch(parseMidiEventType(type)){
case BMC_TRIGGER_EVENT_TYPE_CUSTOM:
if(callback.triggerCustom){
callback.triggerCustom(byteA);
}
break;
case BMC_MIDI_NOTE_OFF:
case BMC_MIDI_NOTE_ON:
case BMC_MIDI_CONTROL_CHANGE:
Expand Down
16 changes: 16 additions & 0 deletions src/utility/BMC-Callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class BMCCallbacks {
typerCommand = 0;
typerCustomCommand = 0;

#if BMC_MAX_TRIGGERS > 0
triggerCustom = 0;
#endif

#if BMC_MAX_LIBRARY > 0
libraryCustom = 0;
#endif

buttonDualPress = 0;
buttonActivity = 0;
encoderActivity = 0;
Expand Down Expand Up @@ -117,6 +125,14 @@ class BMCCallbacks {
void (*typerCommand)(uint16_t t_value, uint16_t t_rawValue);
void (*typerCustomCommand)(uint16_t t_value, uint16_t t_rawValue);

#if BMC_MAX_TRIGGERS > 0
void (*triggerCustom)(uint8_t id);
#endif

#if BMC_MAX_LIBRARY > 0
void (*libraryCustom)(uint8_t id);
#endif


void (*buttonDualPress)(uint8_t btn1, uint8_t btn2);
void (*buttonActivity)(uint8_t n, uint8_t eventIndex, uint8_t trigger,
Expand Down
20 changes: 16 additions & 4 deletions src/utility/BMC-Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@
class BMCLibrary {
public:
#if BMC_MAX_CUSTOM_SYSEX > 0
BMCLibrary(BMCMidi& t_midi,bmcStoreGlobal& t_global, BMCCustomSysEx& t_sysex):
BMCLibrary(BMCMidi& t_midi,bmcStoreGlobal& t_global, BMCCallbacks& cb, BMCCustomSysEx& t_sysex):
midi(t_midi),
global(t_global),
callback(cb),
customSysEx(t_sysex)
{

}
#else
BMCLibrary(BMCMidi& t_midi,bmcStoreGlobal& t_global):
BMCLibrary(BMCMidi& t_midi,bmcStoreGlobal& t_global, BMCCallbacks& cb):
midi(t_midi),
global(t_global)
global(t_global),
callback(cb)
{

}
Expand All @@ -84,8 +86,12 @@ class BMCLibrary {
pixelProgram = BMC_GET_BYTE(1, global.library[index].event);
flags.on(BMC_LIBRARY_FLAG_SET_PIXEL_PROGRAM);
flags.on(BMC_LIBRARY_FLAG_CHANGE_AVAILABLE);
} else if(status==BMC_EVENT_TYPE_CUSTOM){
uint8_t value = mergeDataBytes(global.library[index].event) & 0xFF;
if(callback.libraryCustom){
callback.libraryCustom(value);
}
}

}
}
void sendWithDifferentPorts(bmcLibrary_t index, uint8_t ports){
Expand All @@ -109,6 +115,11 @@ class BMCLibrary {
pixelProgram = BMC_GET_BYTE(1, global.library[index].event);
flags.on(BMC_LIBRARY_FLAG_SET_PIXEL_PROGRAM);
flags.on(BMC_LIBRARY_FLAG_CHANGE_AVAILABLE);
} else if(status==BMC_EVENT_TYPE_CUSTOM){
uint8_t value = mergeDataBytes(global.library[index].event) & 0xFF;
if(callback.libraryCustom){
callback.libraryCustom(value);
}
}
}
}
Expand Down Expand Up @@ -203,6 +214,7 @@ class BMCLibrary {
// reference to midi object from BMC
BMCMidi& midi;
bmcStoreGlobal& global;
BMCCallbacks& callback;
BMCFlags <uint8_t> flags;
uint8_t page = 0;
uint8_t pixelProgram = 0;
Expand Down

0 comments on commit fa5ff1c

Please sign in to comment.