From 672541015f84c0c9f09b93b742bbf3891d25c915 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 21 Jun 2019 20:59:38 -0500 Subject: [PATCH] Add SMX_SetOnlySendLightsOnChange for smx-panel-test. --- sdk/Windows/SMX.cpp | 3 +++ sdk/Windows/SMXManager.cpp | 16 ++++++++++++++++ sdk/Windows/SMXManager.h | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sdk/Windows/SMX.cpp b/sdk/Windows/SMX.cpp index f42a2cd..4df2ac9 100644 --- a/sdk/Windows/SMX.cpp +++ b/sdk/Windows/SMX.cpp @@ -98,3 +98,6 @@ SMX_API void SMX_SetLights2(const char *lightData, int lightDataSize) } SMX_API void SMX_ReenableAutoLights() { SMXManager::g_pSMX->ReenableAutoLights(); } SMX_API const char *SMX_Version() { return SMX_BUILD_VERSION; } + +// This isn't exposed in the public API, since this is only used internally. +SMX_API void SMX_SetOnlySendLightsOnChange(bool value) { SMXManager::g_pSMX->SetOnlySendLightsOnChange(value); } diff --git a/sdk/Windows/SMXManager.cpp b/sdk/Windows/SMXManager.cpp index fe43d70..d39388e 100644 --- a/sdk/Windows/SMXManager.cpp +++ b/sdk/Windows/SMXManager.cpp @@ -253,6 +253,22 @@ void SMX::SMXManager::SetLights(const string sPanelLights[2]) if(m_PanelTestMode != PanelTestMode_Off) return; + // If m_bOnlySendLightsOnChange is true, only send lights commands if the lights have + // actually changed. This is only used for internal testing, and the controllers normally + // expect to receive regular lights updates, even if the lights aren't actually changing. + if(m_bOnlySendLightsOnChange) + { + static string sLastPanelLights[2]; + if(sPanelLights[0] == sLastPanelLights[0] && sPanelLights[1] == sLastPanelLights[1]) + { + Log("no change"); + return; + } + + sLastPanelLights[0] = sPanelLights[0]; + sLastPanelLights[1] = sPanelLights[1]; + } + // Separate top and bottom lights commands. // // sPanelLights[iPad] is diff --git a/sdk/Windows/SMXManager.h b/sdk/Windows/SMXManager.h index 4e4b1f7..cf64fe0 100644 --- a/sdk/Windows/SMXManager.h +++ b/sdk/Windows/SMXManager.h @@ -46,7 +46,8 @@ public: void SetLights(const string sLights[2]); void ReenableAutoLights(); void SetPanelTestMode(PanelTestMode mode); - + void SetOnlySendLightsOnChange(bool value) { m_bOnlySendLightsOnChange = value; } + // Run a function in the user callback thread. void RunInHelperThread(function func); @@ -85,6 +86,8 @@ private: uint32_t m_SentPanelTestModeAtTicks = 0; PanelTestMode m_PanelTestMode = PanelTestMode_Off; PanelTestMode m_LastSentPanelTestMode = PanelTestMode_Off; + + bool m_bOnlySendLightsOnChange = false; }; }