set ActiveSensing Periodicity in ms

Gives more control over the bool value. Typical value is 300 (ms) - an Active Sensing command is send every 300ms; or 0 (zero) to disable sending ActiveSensing
This commit is contained in:
lathoub 2020-03-07 10:15:59 +01:00
parent 771f923223
commit 35d1d6216a
3 changed files with 10 additions and 7 deletions

View File

@ -247,7 +247,7 @@ private:
MidiMessage mMessage;
unsigned long mLastMessageSentTime;
bool mSenderActiveSensingActivated;
unsigned long mSenderActiveSensingPeriodicity;
private:
inline StatusByte getStatus(MidiType inType,

View File

@ -41,7 +41,7 @@ inline MidiInterface<Encoder, Settings, Platform>::MidiInterface(Encoder& inEnco
, mCurrentRpnNumber(0xffff)
, mCurrentNrpnNumber(0xffff)
, mLastMessageSentTime(0)
, mSenderActiveSensingActivated(false)
, mSenderActiveSensingPeriodicity(0)
, mThruActivated(false)
, mThruFilterMode(Thru::Full)
{
@ -98,7 +98,7 @@ void MidiInterface<Encoder, Settings, Platform>::begin(Channel inChannel)
mCurrentRpnNumber = 0xffff;
mCurrentNrpnNumber = 0xffff;
mSenderActiveSensingActivated = Settings::UseSenderActiveSensing;
mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity;
mLastMessageSentTime = Platform::now();
mMessage.valid = false;
@ -184,7 +184,7 @@ void MidiInterface<Encoder, Settings, Platform>::send(MidiType inType,
sendRealTime(inType); // System Real-time and 1 byte.
}
if (mSenderActiveSensingActivated)
if (mSenderActiveSensingPeriodicity)
mLastMessageSentTime = Platform::now();
}
@ -676,7 +676,7 @@ inline bool MidiInterface<Encoder, Settings, Platform>::read(Channel inChannel)
// assume that the connection has been terminated. At
// termination, the receiver will turn off all voices and return to
// normal (non- active sensing) operation.
if (mSenderActiveSensingActivated && (Platform::now() - mLastMessageSentTime) > 270)
if ((mSenderActiveSensingPeriodicity > 0) && (Platform::now() - mLastMessageSentTime) > mSenderActiveSensingPeriodicity)
{
sendRealTime(ActiveSensing);
mLastMessageSentTime = Platform::now();

View File

@ -68,9 +68,12 @@ struct DefaultSettings
message each 300ms (max), and if it does not then it will
assume that the connection has been terminated. At
termination, the receiver will turn off all voices and return to
normal (non- active sensing) operation..
normal (non- active sensing) operation.
Setting this field to 0 will disable MIDI active sensing.
Typical value is 300 (ms) - an Active Sensing command is send every 300ms.
*/
static const bool UseSenderActiveSensing = false;
static const uint16_t SenderActiveSensingPeriodicity = 0;
/*! Setting this to true will make MIDI.read parse only one byte of data for each
call when data is available. This can speed up your application if receiving