From cb7feb626ed6661399aa2cd40bb8a354a5a2bcc3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 8 Dec 2018 16:30:45 -0600 Subject: [PATCH] Separate out scaleLight. --- sdk/Windows/SMXManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sdk/Windows/SMXManager.cpp b/sdk/Windows/SMXManager.cpp index 18b48eb..c9870cd 100644 --- a/sdk/Windows/SMXManager.cpp +++ b/sdk/Windows/SMXManager.cpp @@ -289,15 +289,18 @@ void SMX::SMXManager::SetLights(const string sPanelLights[2]) sLightCommands[0][iPad] = "2"; sLightCommands[1][iPad] = "3"; int iNextInputByte = 0; + auto scaleLight = [](uint8_t iColor) { + // Apply color scaling. Values over about 170 don't make the LEDs any brighter, so this + // gives better contrast and draws less power. + return uint8_t(iColor * 0.6666f); + }; for(int iPanel = 0; iPanel < 9; ++iPanel) { + // Create the 2 and 3 commands. for(int iByte = 0; iByte < 4*4*3; ++iByte) { uint8_t iColor = sLightsDataForPad[iNextInputByte++]; - - // Apply color scaling. Values over about 170 don't make the LEDs any brighter, so this - // gives better contrast and draws less power. - iColor = uint8_t(iColor * 0.6666f); + iColor = scaleLight(iColor); int iCommandIndex = iByte < 4*2*3? 0:1; sLightCommands[iCommandIndex][iPad].append(1, iColor);