![](/media/cache/profiles/89a26a363b87a87ac6a94277e841b7f4.50x50_q85.jpg)
The codebase to run the *spark d-fuser controller www.sparkav.co.uk/dvimixer
Dependencies: SPK-TVOne DMX DmxArtNet NetServicesMin OSC PinDetect mRotaryEncoder iniparser mbed spk_oled_ssd1305 filter
Diff: main.cpp
- Revision:
- 72:f521154be01f
- Parent:
- 71:d6d0ff33cf5b
--- a/main.cpp Mon Jul 29 12:20:16 2013 +0000 +++ b/main.cpp Mon Jul 29 13:09:27 2013 +0000 @@ -476,128 +476,12 @@ return ok; } -void actionMixMode(bool reset = false) -{ - if (debug) debug->printf("Changing mix mode \r\n"); - - bool ok = true; - string sentOK; - char* sentMSGBuffer = "Blend"; - - // Perform unset before set, in case mixMode = mixModeOld - - if (mixModeOld == mixAdditive || reset) - { - // Turn off Additive Mixing on output - if (tvOne.getProcessorType().version == 423) - { - ok = ok && tvOne.command(0, kTV1WindowIDA, 0x298, 0); - } - } - if (mixMode == mixAdditive) - { - sentMSGBuffer = "Additive"; - - // First set B to what you'd expect for additive; it may be left at 100 if optimised blend mixing was previous mixmode. - ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); - // Then turn on Additive Mixing - if (tvOne.getProcessorType().version == 423) - { - ok = ok && tvOne.command(0, kTV1WindowIDA, 0x298, 1); - } - } - - if (mixModeOld == mixKeyLeft || reset) - { - // Turn off Keyer - tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, false); - } - - if (mixMode == mixKeyLeft) - { - sentMSGBuffer = "Key L over R"; - mixKeyWindow = kTV1WindowIDA; - - // Turn on Keyer - ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, true); - } - - if (mixModeOld == mixKeyRight || reset) - { - // Restore window positions - ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, 0); - - // Turn off Keyer - tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustKeyerEnable, false); // Checkme: if check for success, returns failure errantly? - } - if (mixMode == mixKeyRight) - { - sentMSGBuffer = "Key R over L"; - mixKeyWindow = kTV1WindowIDB; - - // Turn on Keyer - ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustKeyerEnable, true); - - - // Set window B above window A - ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsLayerPriority, 0); - } - - if (ok) - { - mixModeOld = mixMode; - sentOK = "Sent: "; - } - else - { - mixMode = mixModeOld; - sentOK = "Send Error: "; - } - - tvOneStatusMessage.addMessage(sentOK + sentMSGBuffer, kTVOneStatusMessageHoldTime); -} - -bool checkTVOneMixStatus() +bool handleTVOneMixStatus() { bool ok = true; int32_t payload; - // Mix Mode - bool mixModeNeedsAction = false; - bool additiveOn = false, keyLeftOn = false, keyRightOn = false; - int windowAPriority = -1; - - if (mixMode == mixBlend) { additiveOn = false; keyLeftOn = false; keyRightOn = false; windowAPriority = 0;} - if (mixMode == mixAdditive) { additiveOn = true; keyLeftOn = false; keyRightOn = false; windowAPriority = 0;} - if (mixMode == mixKeyLeft) { additiveOn = false; keyLeftOn = true; keyRightOn = false; windowAPriority = 0;} - if (mixMode == mixKeyRight) { additiveOn = false; keyLeftOn = false; keyRightOn = true; windowAPriority = 1;} - - if (tvOne.getProcessorType().version == 423) - { - payload = -1; - ok = ok && tvOne.readCommand(0, kTV1WindowIDA, 0x298, payload); - if (payload != additiveOn) mixModeNeedsAction = true; - } - - payload = -1; - ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, payload); - if (payload != keyLeftOn) mixModeNeedsAction = true; - - payload = -1; - ok = ok && tvOne.readCommand(0, kTV1WindowIDB, kTV1FunctionAdjustKeyerEnable, payload); - if (payload != keyRightOn) mixModeNeedsAction = true; - - payload = -1; - ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, payload); - if (payload != windowAPriority) mixModeNeedsAction = true; - - if (ok && mixModeNeedsAction) - { - if (debug) debug->printf("Check TVOne Mix Status requiring mixMode action. mixMode: %i \r\n", mixMode); - actionMixMode(true); - } - // Check Fade payload = -1; ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, payload); @@ -615,6 +499,66 @@ ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); } + // Mix Mode + bool mixModeUpdated = false; + bool additiveOn = false, keyLeftOn = false, keyRightOn = false; + int windowAPriority = -1; + + if (mixMode == mixBlend) { additiveOn = false; keyLeftOn = false; keyRightOn = false; windowAPriority = 0;} + if (mixMode == mixAdditive) { additiveOn = true; keyLeftOn = false; keyRightOn = false; windowAPriority = 0;} + if (mixMode == mixKeyLeft) { additiveOn = false; keyLeftOn = true; keyRightOn = false; windowAPriority = 0;} + if (mixMode == mixKeyRight) { additiveOn = false; keyLeftOn = false; keyRightOn = true; windowAPriority = 1;} + + if (tvOne.getProcessorType().version == 423) + { + payload = -1; + ok = ok && tvOne.readCommand(0, kTV1WindowIDA, 0x298, payload); + if (payload != additiveOn) + { + ok = ok && tvOne.command(0, kTV1WindowIDA, 0x298, additiveOn); + mixModeUpdated = true; + } + } + + payload = -1; + ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, payload); + if (payload != keyLeftOn) + { + ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, keyLeftOn); + mixModeUpdated = true; + } + + payload = -1; + ok = ok && tvOne.readCommand(0, kTV1WindowIDB, kTV1FunctionAdjustKeyerEnable, payload); + if (payload != keyRightOn) + { + ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustKeyerEnable, keyRightOn); + mixModeUpdated = true; + } + + payload = -1; + ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, payload); + if (payload != windowAPriority) + { + ok = ok && tvOne.command(0, windowAPriority == 0 ? kTV1WindowIDA : kTV1WindowIDB, kTV1FunctionAdjustWindowsLayerPriority, 0); + mixModeUpdated = true; + } + + if (mixModeUpdated) + { + if (ok) mixModeOld = mixMode; + + if (debug) debug->printf("Check TVOne Mix Status requiring mixMode action. mixMode: %i \r\n", mixMode); + + string sentOK = ok ? "Sent: " : "Send error: "; + char * mixModeString = "Blend"; + if (mixMode == mixAdditive) mixModeString = "Additive"; + if (mixMode == mixKeyLeft) mixModeString = "Key L over R"; + if (mixMode == mixKeyRight) mixModeString = "Key R over L"; + + tvOneStatusMessage.addMessage(sentOK + mixModeString, kTVOneStatusMessageHoldTime); + } + return ok; } @@ -1421,7 +1365,7 @@ handleTVOneSources(); // Processor can have been power-on saved with a keyer on, lets revert - checkTVOneMixStatus(); + handleTVOneMixStatus(); // Display menu and framing lines screen.horizLineToBuffer(kMenuLine1*pixInPage - 1); @@ -1551,6 +1495,8 @@ { mixMode = mixModeMenuPayload; + if (mixMode == mixKeyLeft) mixKeyWindow = kTV1WindowIDA; + if (mixMode == mixKeyRight) mixKeyWindow = kTV1WindowIDB; if (mixMode == mixModeOld) tvOneStatusMessage.addMessage("Mix mode already active", kTVOneStatusMessageHoldTime); } else @@ -1915,7 +1861,7 @@ fadeBPercentHasChanged = newFadeBPercent != fadeBPercent; // If changing mixMode from additive, we want to do this before updating fade values - if (mixMode != mixModeOld && mixModeOld == mixAdditive) actionMixMode(); + if (mixMode != mixModeOld && mixModeOld == mixAdditive) handleTVOneMixStatus(); // We want to send the higher first, otherwise black flashes can happen on taps if (fadeAPercentHasChanged && newFadeAPercent >= newFadeBPercent) @@ -1954,7 +1900,7 @@ } // If changing mixMode to additive, we want to do this after updating fade values - if (mixMode != mixModeOld) actionMixMode(); + if (mixMode != mixModeOld) handleTVOneMixStatus(); //// TASK: Process Network Comms Out, ie. send out any fade updates if (commsMode == commsOSC && updateFade && !commsInActive) @@ -1980,7 +1926,7 @@ handleTVOneSources(); // Lets check on our fade levels - checkTVOneMixStatus(); + handleTVOneMixStatus(); } } } \ No newline at end of file