ActiveSensingTimeout has its own callback handler
removed ErrorActiveSensingTimeout
This commit is contained in:
parent
0db6859802
commit
59fafdbf1a
|
|
@ -22,9 +22,9 @@ struct MyMIDISettings : public MIDI_NAMESPACE::DefaultSettings
|
|||
|
||||
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, MyMIDISettings);
|
||||
|
||||
void errorHandler(int8_t err)
|
||||
void activeSensingTimeoutExceptionHandler(bool active)
|
||||
{
|
||||
if (bitRead(err, ErrorActiveSensingTimeout))
|
||||
if (!active)
|
||||
{
|
||||
MIDI.sendControlChange(AllSoundOff, 0, 1);
|
||||
MIDI.sendControlChange(AllNotesOff, 0, 1);
|
||||
|
|
@ -41,7 +41,7 @@ void setup()
|
|||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
MIDI.setHandleError(errorHandler);
|
||||
MIDI.setHandleActiveSensingTimeout(activeSensingTimeoutExceptionHandler);
|
||||
MIDI.begin(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ private:
|
|||
|
||||
void (*mMessageCallback)(const MidiMessage& message) = nullptr;
|
||||
ErrorCallback mErrorCallback = nullptr;
|
||||
ActiveSensingTimeoutCallback mActiveSensingTimeoutCallback = nullptr;
|
||||
NoteOffCallback mNoteOffCallback = nullptr;
|
||||
NoteOnCallback mNoteOnCallback = nullptr;
|
||||
AfterTouchPolyCallback mAfterTouchPolyCallback = nullptr;
|
||||
|
|
|
|||
26
src/MIDI.hpp
26
src/MIDI.hpp
|
|
@ -769,24 +769,20 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
|
|||
sendActiveSensing();
|
||||
}
|
||||
|
||||
if (Settings::UseReceiverActiveSensing && mReceiverActiveSensingActive)
|
||||
{
|
||||
if ((Platform::now() - mLastMessageReceivedTime > Settings::ReceiverActiveSensingTimeout))
|
||||
{
|
||||
// Once an Active Sensing message is received, the unit will begin monitoring
|
||||
// the intervalbetween all subsequent messages. If there is an interval of 420 ms
|
||||
// or longer betweenmessages while monitoring is active, the same processing
|
||||
// as when All Sound Off, All Notes Off,and Reset All Controllers messages are
|
||||
// received will be carried out. The unit will then stopmonitoring the message interval.
|
||||
if (Settings::UseReceiverActiveSensing && mReceiverActiveSensingActive)
|
||||
{
|
||||
if ((Platform::now() - mLastMessageReceivedTime > Settings::ReceiverActiveSensingTimeout))
|
||||
{
|
||||
mReceiverActiveSensingActive = false;
|
||||
|
||||
// its up to the error handler to send the stop processing messages
|
||||
// its up to the handler to send the stop processing messages
|
||||
// (also, no clue what the channel is on which to send them)
|
||||
|
||||
// no need to check if bit is already set, it is not (due to the mActiveSensingActive switch)
|
||||
mLastError |= 1UL << ErrorActiveSensingTimeout; // set the ErrorActiveSensingTimeout bit
|
||||
if (mErrorCallback)
|
||||
mErrorCallback(mLastError);
|
||||
mActiveSensingTimeoutCallback(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -805,17 +801,9 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
|
|||
|
||||
if (mMessage.type == ActiveSensing && !mReceiverActiveSensingActive)
|
||||
{
|
||||
// Once an Active Sensing message is received, the unit will begin monitoring
|
||||
// the intervalbetween all subsequent messages. If there is an interval of 420 ms
|
||||
// or longer betweenmessages while monitoring is active, the same processing
|
||||
// as when All Sound Off, All Notes Off,and Reset All Controllers messages are
|
||||
// received will be carried out. The unit will then stopmonitoring the message interval.
|
||||
mReceiverActiveSensingActive = true;
|
||||
|
||||
// Clear the ErrorActiveSensingTimeout bit
|
||||
mLastError &= ~(1UL << ErrorActiveSensingTimeout);
|
||||
if (mErrorCallback)
|
||||
mErrorCallback(mLastError);
|
||||
mActiveSensingTimeoutCallback(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ typedef byte Channel;
|
|||
// -----------------------------------------------------------------------------
|
||||
// Errors
|
||||
static const uint8_t ErrorParse = 0;
|
||||
static const uint8_t ErrorActiveSensingTimeout = 1;
|
||||
static const uint8_t WarningSplitSysEx = 2;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Aliasing
|
||||
|
||||
using ErrorCallback = void (*)(int8_t);
|
||||
using ActiveSensingTimeoutCallback = void (*)(bool);
|
||||
using NoteOffCallback = void (*)(Channel channel, byte note, byte velocity);
|
||||
using NoteOnCallback = void (*)(Channel channel, byte note, byte velocity);
|
||||
using AfterTouchPolyCallback = void (*)(Channel channel, byte note, byte velocity);
|
||||
|
|
|
|||
Loading…
Reference in New Issue