diff --git a/sdk/Windows/SMXDevice.cpp b/sdk/Windows/SMXDevice.cpp index 8245eee..40ece1b 100644 --- a/sdk/Windows/SMXDevice.cpp +++ b/sdk/Windows/SMXDevice.cpp @@ -297,6 +297,11 @@ void SMX::SMXDevice::SendConfig() if(!m_bHaveConfig) return; + // If we're still waiting for a previous configuration to read back, don't send + // another yet. + if(m_bWaitingForConfigResponse) + return; + // Write configuration command: string sData = ssprintf("w"); int8_t iSize = sizeof(SMXConfig); @@ -316,9 +321,16 @@ void SMX::SMXDevice::SendConfig() // command below completes. config = wanted_config; + // Don't send another configuration packet until we receive the response to the above + // command. If we're sending updates quickly (eg. dragging the color slider), we can + // send multiple updates before we get a response. + m_bWaitingForConfigResponse = true; + // After we write the configuration, read back the updated configuration to // verify it. - SendCommandLocked("g\n"); + SendCommandLocked("g\n", [this]() { + m_bWaitingForConfigResponse = false; + }); } void SMX::SMXDevice::Update(wstring &sError) diff --git a/sdk/Windows/SMXDevice.h b/sdk/Windows/SMXDevice.h index bdb6e8c..ddff899 100644 --- a/sdk/Windows/SMXDevice.h +++ b/sdk/Windows/SMXDevice.h @@ -110,6 +110,7 @@ private: SMXConfig wanted_config; bool m_bSendConfig = false; bool m_bSendingConfig = false; + bool m_bWaitingForConfigResponse = false; void CallUpdateCallback(SMXUpdateCallbackReason reason); void HandlePackets();