in Firmware/ExpressivePixelsCore/EPXApp.cpp [898:997]
void CExpressivePixelsApp::AppProcess(bool disableUSBProcessing)
{
bool bNewConnectionEstablished = false;
// Process USB logic
if (!disableUSBProcessing)
m_CUSBChannel.Process();
// Async process connection state changes
if (m_pendingConnectionStateChange != EPXAPP_PENDINGCONNECTIONSTATE_NONE)
bNewConnectionEstablished = ProcessConnectionStateChange();
// Async process power state changes
if (m_pendingPowerStateChange != EPXAPP_PENDINGPOWERSTATE_NONE)
ProcessPowerStateChange();
// Async process underlying connection establishment
if (m_pendingCommunicationReady)
ProcessCommunicationReady();
// Process appropriate power state actions - eg: go to sleep, keep on sleeping
ProcessPowerState();
// If authnetication see if the host has responded within the time allowed
if (!m_bAuthenticated && m_lastAuthChallengeTime != 0 && millisPassed(m_lastAuthChallengeTime) > EPX_AUTHENTICATION_RESPONSE_TIMEOUT_MS)
{
// Otherwise disconnect from the host
m_lastAuthChallengeTime = 0;
DEBUGLOGLN("\tAuthentication response TIMEOUT");
m_CBLEChannel.Disconnect();
}
// If not beacon has been received from any hosts for the expiry interval then shutdown BeaconActivation and power down
if(m_bBeaconActivation && !m_bBeaconActivationAlwaysOn && m_connectedChannel == EPXAPP_CONNECTIONCHANNEL_NONE && millisPassed(m_CBLEChannel.GetLastBeaconReceived()) > BEACONACTIVATION_DEACTIVATION_EXPIRY_MS)
{
DEBUGLOGLN("ACTIVATION BEACON EXPIRED");
m_CBLEChannel.SetBeaconActivation(false);
m_bBeaconActivation = false;
PowerManage(false);
return;
}
// Process buttons
if(m_lastClearBLEKeyButtonPushed > 0 && millisPassed(m_lastClearBLEKeyButtonPushed) > EPX_CLEARBLEKEY_BUTTONHOLD_MS)
{
// Clear the connection key if requested by long button hold
ClearAESKey();
m_lastClearBLEKeyButtonPushed = 0;
}
else if(m_PendingFeatureButtonPushed) // If a quick feature button press
{
ToggleInvokedAutoPlay(!m_bInvokedAutoPlay);
m_PendingFeatureButtonPushed = false;
}
// Process LED state
ProcessIndicators();
// Process animation triggers
ProcessTriggers();
// Only process if a connection is active
if(m_connectedChannel != EPXAPP_CONNECTIONCHANNEL_NONE || m_renderMode == RENDERMODE_RAINBOWCYCLE || m_bInvokedAutoPlay || m_bBeaconActivation || m_bMIDIActivation || m_triggerPowerMode != EPXAPP_TRIGGERPOWERMODE_OFF)
{
// Process beacon activation
if (m_pPendingBeaconActivationHost != NULL)
{
if (m_bBeaconActivation)
{
AutoPlayClear(); // Clear autoplay if running
// Activate animation if trigger found
BEACONACTIVATIONITEM *pActivation = m_beaconActivation.FindEntry(m_pPendingBeaconActivationHost, m_pendingBeaconData);
if (pActivation != NULL)
ActivateSequenceFromName(pActivation->szAnimationName);
m_lastBeaconData = m_pendingBeaconData;
m_pActiveBeaconActivation = pActivation;
}
m_pendingBeaconData = 0;
m_pPendingBeaconActivationHost = NULL;
}
// Process battery
ProcessBattery();
if (m_bAlternateBLEChannel)
StringProtocolProcess();
else
// Process payload channel reading from COBS channel (USB or BLE)
ProtocolProcess();
// Process rendering
ProcessRendering();
#ifdef EPXMIDI
// Process MIDI
m_CMIDIActivation.Process();
#endif
}
}