![](/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
main.cpp@54:e8606eaa47a3, 2013-02-08 (annotated)
- Committer:
- tobyspark
- Date:
- Fri Feb 08 15:58:08 2013 +0000
- Revision:
- 54:e8606eaa47a3
- Parent:
- 53:0993424e1529
- Child:
- 55:35a295d36d23
Fix for OSC out
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 47:ff6b98459548 | 1 | /* *SPARK D-FUSER |
tobyspark | 8:d46cc49f0f37 | 2 | * A project by Toby Harris |
tobyspark | 8:d46cc49f0f37 | 3 | * |
tobyspark | 8:d46cc49f0f37 | 4 | * 'DJ' controller styke RS232 Control for TV-One products |
tobyspark | 8:d46cc49f0f37 | 5 | * Good for 1T-C2-750, others will need some extra work |
tobyspark | 8:d46cc49f0f37 | 6 | * |
tobyspark | 8:d46cc49f0f37 | 7 | * www.sparkav.co.uk/dvimixer |
tobyspark | 8:d46cc49f0f37 | 8 | */ |
tobyspark | 0:87aab40d5806 | 9 | |
tobyspark | 8:d46cc49f0f37 | 10 | /* Copyright (c) 2011 Toby Harris, MIT License |
tobyspark | 8:d46cc49f0f37 | 11 | * |
tobyspark | 8:d46cc49f0f37 | 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
tobyspark | 8:d46cc49f0f37 | 13 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
tobyspark | 8:d46cc49f0f37 | 14 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
tobyspark | 8:d46cc49f0f37 | 15 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
tobyspark | 8:d46cc49f0f37 | 16 | * furnished to do so, subject to the following conditions: |
tobyspark | 8:d46cc49f0f37 | 17 | * |
tobyspark | 8:d46cc49f0f37 | 18 | * The above copyright notice and this permission notice shall be included in all copies or |
tobyspark | 8:d46cc49f0f37 | 19 | * substantial portions of the Software. |
tobyspark | 8:d46cc49f0f37 | 20 | * |
tobyspark | 8:d46cc49f0f37 | 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
tobyspark | 8:d46cc49f0f37 | 22 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
tobyspark | 8:d46cc49f0f37 | 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
tobyspark | 8:d46cc49f0f37 | 24 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tobyspark | 8:d46cc49f0f37 | 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
tobyspark | 8:d46cc49f0f37 | 26 | */ |
tobyspark | 8:d46cc49f0f37 | 27 | |
tobyspark | 8:d46cc49f0f37 | 28 | /* ROADMAP / HISTORY |
tobyspark | 8:d46cc49f0f37 | 29 | * v10 - Port to mBed, keying redux - Apr'11 |
tobyspark | 8:d46cc49f0f37 | 30 | * v11 - Sign callbacks, code clean-up - Apr'11 |
tobyspark | 8:d46cc49f0f37 | 31 | * v12 - TVOne header split into two: defines and mbed class. v002 header updates pulled down. Removed sign callbacks, rewrite of debug and signing. - Apr'11 |
tobyspark | 8:d46cc49f0f37 | 32 | * v13 - Menu system for Resolution + Keying implemented, it writing to debug, it sending TVOne commands - Apr'11 |
tobyspark | 8:d46cc49f0f37 | 33 | * v14 - Fixes for new PCB - Oct'11 |
tobyspark | 8:d46cc49f0f37 | 34 | * v15 - TBZ PCB, OLED - Mar'12 |
tobyspark | 8:d46cc49f0f37 | 35 | * v16 - Comms menu, OSC, ArtNet - April'12 |
tobyspark | 8:d46cc49f0f37 | 36 | * v17 - RJ45 - May'12 |
tobyspark | 8:d46cc49f0f37 | 37 | * v18 - DMX - July'12 |
tobyspark | 13:3796bde6ba8f | 38 | * v19 - TVOne mixing comms further optimised - August'12 |
tobyspark | 30:873979018850 | 39 | * v20 - Keying values and resolutions load from USB mass storage - September'12 |
tobyspark | 30:873979018850 | 40 | * v21 - Mixing behaviour upgrade: blend-additive as continuum, test cards on startup if no valid source - October'12 |
tobyspark | 35:d5d9f0838f99 | 41 | * v22 - EDID passthrough override and EDID upload from USB mass storage |
tobyspark | 49:16309f39cead | 42 | * v23 - Set keying values from controller |
tobyspark | 44:723e65413ebe | 43 | * v24 - Conform uploads SIS image; now once firmware is loaded controller is all that is required |
tobyspark | 49:16309f39cead | 44 | * v25 - UX work |
tobyspark | 36:8b5c75c8bc23 | 45 | * vxx - TODO: Writes back to .ini on USB mass storage: keyer updates, comms, hdcp, edid internal/passthrough, ...? |
tobyspark | 8:d46cc49f0f37 | 46 | * vxx - TODO: EDID creation from resolution |
tobyspark | 8:d46cc49f0f37 | 47 | */ |
tobyspark | 8:d46cc49f0f37 | 48 | |
tobyspark | 0:87aab40d5806 | 49 | #include "mbed.h" |
tobyspark | 0:87aab40d5806 | 50 | |
tobyspark | 0:87aab40d5806 | 51 | #include "spk_tvone_mbed.h" |
tobyspark | 0:87aab40d5806 | 52 | #include "spk_utils.h" |
tobyspark | 0:87aab40d5806 | 53 | #include "spk_mRotaryEncoder.h" |
tobyspark | 0:87aab40d5806 | 54 | #include "spk_oled_ssd1305.h" |
tobyspark | 2:50043054e4f7 | 55 | #include "spk_oled_gfx.h" |
tobyspark | 11:0783cfbeb746 | 56 | #include "spk_settings.h" |
tobyspark | 1:f9fca21102e0 | 57 | #include "EthernetNetIf.h" |
tobyspark | 1:f9fca21102e0 | 58 | #include "mbedOSC.h" |
tobyspark | 3:033d2b7768f3 | 59 | #include "DmxArtNet.h" |
tobyspark | 5:f8b285ca41ba | 60 | #include "DMX.h" |
tobyspark | 17:fc68d40b8b1f | 61 | #include "filter.h" |
tobyspark | 0:87aab40d5806 | 62 | |
tobyspark | 49:16309f39cead | 63 | #define kSPKDFSoftwareVersion "25" |
tobyspark | 13:3796bde6ba8f | 64 | |
tobyspark | 5:f8b285ca41ba | 65 | // MBED PINS |
tobyspark | 5:f8b285ca41ba | 66 | |
tobyspark | 5:f8b285ca41ba | 67 | #define kMBED_AIN_XFADE p20 |
tobyspark | 5:f8b285ca41ba | 68 | #define kMBED_AIN_FADEUP p19 |
tobyspark | 5:f8b285ca41ba | 69 | #define kMBED_DIN_TAP_L p24 |
tobyspark | 5:f8b285ca41ba | 70 | #define kMBED_DIN_TAP_R p23 |
tobyspark | 5:f8b285ca41ba | 71 | #define kMBED_ENC_SW p15 |
tobyspark | 5:f8b285ca41ba | 72 | #define kMBED_ENC_A p16 |
tobyspark | 5:f8b285ca41ba | 73 | #define kMBED_ENC_B p17 |
tobyspark | 5:f8b285ca41ba | 74 | |
tobyspark | 5:f8b285ca41ba | 75 | #define kMBED_RS232_TTLTX p13 |
tobyspark | 5:f8b285ca41ba | 76 | #define kMBED_RS232_TTLRX p14 |
tobyspark | 5:f8b285ca41ba | 77 | |
tobyspark | 5:f8b285ca41ba | 78 | #define kMBED_OLED_MOSI p5 |
tobyspark | 5:f8b285ca41ba | 79 | #define kMBED_OLED_SCK p7 |
tobyspark | 5:f8b285ca41ba | 80 | #define kMBED_OLED_CS p8 |
tobyspark | 5:f8b285ca41ba | 81 | #define kMBED_OLED_RES p9 |
tobyspark | 5:f8b285ca41ba | 82 | #define kMBED_OLED_DC p10 |
tobyspark | 5:f8b285ca41ba | 83 | |
tobyspark | 5:f8b285ca41ba | 84 | #define kMBED_DIN_ETHLO_DMXHI p30 |
tobyspark | 5:f8b285ca41ba | 85 | #define kMBED_DOUT_RS485_TXHI_RXLO p29 |
tobyspark | 5:f8b285ca41ba | 86 | #define kMBED_RS485_TTLTX p28 |
tobyspark | 5:f8b285ca41ba | 87 | #define kMBED_RS485_TTLRX p27 |
tobyspark | 5:f8b285ca41ba | 88 | |
tobyspark | 5:f8b285ca41ba | 89 | // DISPLAY |
tobyspark | 5:f8b285ca41ba | 90 | |
tobyspark | 1:f9fca21102e0 | 91 | #define kMenuLine1 3 |
tobyspark | 1:f9fca21102e0 | 92 | #define kMenuLine2 4 |
tobyspark | 1:f9fca21102e0 | 93 | #define kCommsStatusLine 6 |
tobyspark | 1:f9fca21102e0 | 94 | #define kTVOneStatusLine 7 |
tobyspark | 48:c0fedfa8c525 | 95 | #define kTVOneStatusMessageHoldTime 5 |
tobyspark | 1:f9fca21102e0 | 96 | |
tobyspark | 5:f8b285ca41ba | 97 | // NETWORKING |
tobyspark | 5:f8b285ca41ba | 98 | |
tobyspark | 1:f9fca21102e0 | 99 | #define kOSCMbedPort 10000 |
tobyspark | 1:f9fca21102e0 | 100 | #define kOSCMbedIPAddress 10,0,0,2 |
tobyspark | 1:f9fca21102e0 | 101 | #define kOSCMbedSubnetMask 255,255,255,0 |
tobyspark | 1:f9fca21102e0 | 102 | #define kOSCMbedGateway 10,0,0,1 |
tobyspark | 1:f9fca21102e0 | 103 | #define kOSCMbedDNS 10,0,0,1 |
tobyspark | 0:87aab40d5806 | 104 | |
tobyspark | 54:e8606eaa47a3 | 105 | #define kOSCDestIPAddress 10,0,0,1 |
tobyspark | 54:e8606eaa47a3 | 106 | #define kOSCDestPort 12000 |
tobyspark | 54:e8606eaa47a3 | 107 | |
tobyspark | 3:033d2b7768f3 | 108 | #define kArtNetBindIPAddress 2,0,0,100 |
tobyspark | 3:033d2b7768f3 | 109 | #define kArtNetBroadcastAddress 2,255,255,255 |
tobyspark | 3:033d2b7768f3 | 110 | |
tobyspark | 5:f8b285ca41ba | 111 | #define kDMXInChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 112 | #define kDMXInChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 113 | #define kDMXOutChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 114 | #define kDMXOutChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 115 | |
tobyspark | 13:3796bde6ba8f | 116 | // 8.3 format filename only, no subdirs |
tobyspark | 13:3796bde6ba8f | 117 | #define kSPKDFSettingsFilename "SPKDF.ini" |
tobyspark | 11:0783cfbeb746 | 118 | |
tobyspark | 26:0299f8760715 | 119 | #define kStringBufferLength 30 |
tobyspark | 26:0299f8760715 | 120 | |
tobyspark | 0:87aab40d5806 | 121 | //// DEBUG |
tobyspark | 0:87aab40d5806 | 122 | |
tobyspark | 0:87aab40d5806 | 123 | // Comment out one or the other... |
tobyspark | 41:00d1cd3b2af2 | 124 | //Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial |
tobyspark | 37:744bef2e8be8 | 125 | Serial *debug = NULL; // For release (no debugging) |
tobyspark | 0:87aab40d5806 | 126 | |
tobyspark | 15:4b394c64b461 | 127 | //// SOFT RESET |
tobyspark | 15:4b394c64b461 | 128 | |
tobyspark | 15:4b394c64b461 | 129 | extern "C" void mbed_reset(); |
tobyspark | 15:4b394c64b461 | 130 | |
tobyspark | 0:87aab40d5806 | 131 | //// mBED PIN ASSIGNMENTS |
tobyspark | 0:87aab40d5806 | 132 | |
tobyspark | 0:87aab40d5806 | 133 | // Inputs |
tobyspark | 5:f8b285ca41ba | 134 | AnalogIn xFadeAIN(kMBED_AIN_XFADE); |
tobyspark | 5:f8b285ca41ba | 135 | AnalogIn fadeUpAIN(kMBED_AIN_FADEUP); |
tobyspark | 5:f8b285ca41ba | 136 | DigitalIn tapLeftDIN(kMBED_DIN_TAP_L); |
tobyspark | 5:f8b285ca41ba | 137 | DigitalIn tapRightDIN(kMBED_DIN_TAP_R); |
tobyspark | 17:fc68d40b8b1f | 138 | medianFilter xFadeFilter(9); |
tobyspark | 17:fc68d40b8b1f | 139 | medianFilter fadeUpFilter(9); |
tobyspark | 0:87aab40d5806 | 140 | |
tobyspark | 5:f8b285ca41ba | 141 | SPKRotaryEncoder menuEnc(kMBED_ENC_A, kMBED_ENC_B, kMBED_ENC_SW); |
tobyspark | 5:f8b285ca41ba | 142 | |
tobyspark | 5:f8b285ca41ba | 143 | DigitalIn rj45ModeDIN(kMBED_DIN_ETHLO_DMXHI); |
tobyspark | 0:87aab40d5806 | 144 | |
tobyspark | 0:87aab40d5806 | 145 | // Outputs |
tobyspark | 0:87aab40d5806 | 146 | PwmOut fadeAPO(LED1); |
tobyspark | 0:87aab40d5806 | 147 | PwmOut fadeBPO(LED2); |
tobyspark | 0:87aab40d5806 | 148 | |
tobyspark | 5:f8b285ca41ba | 149 | DigitalOut dmxDirectionDOUT(kMBED_DOUT_RS485_TXHI_RXLO); |
tobyspark | 5:f8b285ca41ba | 150 | |
tobyspark | 0:87aab40d5806 | 151 | // SPKTVOne(PinName txPin, PinName rxPin, PinName signWritePin, PinName signErrorPin, Serial *debugSerial) |
tobyspark | 5:f8b285ca41ba | 152 | SPKTVOne tvOne(kMBED_RS232_TTLTX, kMBED_RS232_TTLRX, LED3, LED4, debug); |
tobyspark | 0:87aab40d5806 | 153 | |
tobyspark | 0:87aab40d5806 | 154 | // SPKDisplay(PinName mosi, PinName clk, PinName cs, PinName dc, PinName res, Serial *debugSerial = NULL); |
tobyspark | 5:f8b285ca41ba | 155 | SPKDisplay screen(kMBED_OLED_MOSI, kMBED_OLED_SCK, kMBED_OLED_CS, kMBED_OLED_DC, kMBED_OLED_RES, debug); |
tobyspark | 48:c0fedfa8c525 | 156 | SPKMessageHold tvOneStatusMessage; |
tobyspark | 0:87aab40d5806 | 157 | |
tobyspark | 11:0783cfbeb746 | 158 | // Saved Settings |
tobyspark | 11:0783cfbeb746 | 159 | SPKSettings settings; |
tobyspark | 11:0783cfbeb746 | 160 | |
tobyspark | 0:87aab40d5806 | 161 | // Menu |
tobyspark | 0:87aab40d5806 | 162 | SPKMenu *selectedMenu; |
tobyspark | 23:909928cafb95 | 163 | SPKMenu mainMenu; |
tobyspark | 23:909928cafb95 | 164 | SPKMenu resolutionMenu; |
tobyspark | 12:c270870bdd23 | 165 | |
tobyspark | 24:49c6624119ae | 166 | SPKMenu mixModeMenu; |
tobyspark | 36:8b5c75c8bc23 | 167 | SPKMenu mixModeAdditiveMenu; |
tobyspark | 49:16309f39cead | 168 | SPKMenu mixModeUpdateKeyMenu; |
tobyspark | 36:8b5c75c8bc23 | 169 | enum { mixBlend, mixAdditive, mixKey }; |
tobyspark | 36:8b5c75c8bc23 | 170 | int mixKeyStartIndex = 1; // need this hard coded as mixBlend and mixAdditive are now combined into the same menu item |
tobyspark | 30:873979018850 | 171 | int mixMode = mixBlend; // Start with safe mix mode, and test to get out of it. Safe mode will work with inputs missing and without hold frames. |
tobyspark | 49:16309f39cead | 172 | int mixModeOld = mixMode; |
tobyspark | 29:95a7efe30527 | 173 | float fadeCurve = 0.0f; // 0 = "X", ie. as per blend, 1 = "/\", ie. as per additive <-- pictograms! |
tobyspark | 22:90054fe6d86c | 174 | |
tobyspark | 23:909928cafb95 | 175 | SPKMenu commsMenu; |
tobyspark | 5:f8b285ca41ba | 176 | enum { commsNone, commsOSC, commsArtNet, commsDMXIn, commsDMXOut}; |
tobyspark | 5:f8b285ca41ba | 177 | int commsMode = commsNone; |
tobyspark | 22:90054fe6d86c | 178 | |
tobyspark | 51:98cc27390484 | 179 | SPKMenu troubleshootingMenu; |
tobyspark | 51:98cc27390484 | 180 | SPKMenu troubleshootingMenuHDCP; |
tobyspark | 51:98cc27390484 | 181 | SPKMenu troubleshootingMenuEDID; |
tobyspark | 51:98cc27390484 | 182 | SPKMenu troubleshootingMenuReset; |
tobyspark | 51:98cc27390484 | 183 | |
tobyspark | 23:909928cafb95 | 184 | SPKMenu advancedMenu; |
tobyspark | 51:98cc27390484 | 185 | enum { advancedConformUploadProcessor, advancedSetResolutions }; |
tobyspark | 1:f9fca21102e0 | 186 | |
tobyspark | 5:f8b285ca41ba | 187 | // RJ45 Comms |
tobyspark | 5:f8b285ca41ba | 188 | enum { rj45Ethernet = 0, rj45DMX = 1}; // These values from circuit |
tobyspark | 5:f8b285ca41ba | 189 | int rj45Mode = -1; |
tobyspark | 1:f9fca21102e0 | 190 | EthernetNetIf *ethernet = NULL; |
tobyspark | 1:f9fca21102e0 | 191 | OSCClass *osc = NULL; |
tobyspark | 33:e6672a9bd571 | 192 | OSCMessage sendMessage; |
tobyspark | 33:e6672a9bd571 | 193 | OSCMessage receiveMessage; |
tobyspark | 3:033d2b7768f3 | 194 | DmxArtNet *artNet = NULL; |
tobyspark | 5:f8b285ca41ba | 195 | DMX *dmx = NULL; |
tobyspark | 0:87aab40d5806 | 196 | |
tobyspark | 3:033d2b7768f3 | 197 | // Fade logic constants |
tobyspark | 0:87aab40d5806 | 198 | const float xFadeTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 199 | const float fadeUpTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 200 | |
tobyspark | 0:87aab40d5806 | 201 | // A&B Fade as resolved percent |
tobyspark | 0:87aab40d5806 | 202 | int fadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 203 | int fadeBPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 204 | int oldFadeAPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 205 | int oldFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 206 | |
tobyspark | 0:87aab40d5806 | 207 | // Tap button states |
tobyspark | 5:f8b285ca41ba | 208 | bool tapLeftWasFirstPressed = false; |
tobyspark | 0:87aab40d5806 | 209 | |
tobyspark | 0:87aab40d5806 | 210 | // Key mode parameters |
tobyspark | 0:87aab40d5806 | 211 | int keyerParamsSet = -1; // last keyParams index uploaded to unit |
tobyspark | 0:87aab40d5806 | 212 | |
tobyspark | 30:873979018850 | 213 | // TVOne input sources stable flag |
tobyspark | 34:69dfe64e7e6b | 214 | bool tvOneRGB1Stable = false; |
tobyspark | 34:69dfe64e7e6b | 215 | bool tvOneRGB2Stable = false; |
tobyspark | 30:873979018850 | 216 | |
tobyspark | 31:01845a2347ff | 217 | // TVOne behaviour flags |
tobyspark | 31:01845a2347ff | 218 | bool tvOneHDCPOn = false; |
tobyspark | 34:69dfe64e7e6b | 219 | bool tvOneEDIDPassthrough = false; |
tobyspark | 31:01845a2347ff | 220 | const int32_t EDIDPassthroughSlot = 7; |
tobyspark | 31:01845a2347ff | 221 | |
tobyspark | 34:69dfe64e7e6b | 222 | |
tobyspark | 33:e6672a9bd571 | 223 | void processOSCIn(float &xFade, float &fadeUp) { |
tobyspark | 25:3b519ef70341 | 224 | string statusMessage; |
tobyspark | 3:033d2b7768f3 | 225 | |
tobyspark | 33:e6672a9bd571 | 226 | if (!strcmp( receiveMessage.getTopAddress() , "dvimxr" )) |
tobyspark | 3:033d2b7768f3 | 227 | { |
tobyspark | 25:3b519ef70341 | 228 | statusMessage = "OSC: /dvimxr"; |
tobyspark | 33:e6672a9bd571 | 229 | if (!strcmp( receiveMessage.getSubAddress() , "xFade" )) |
tobyspark | 25:3b519ef70341 | 230 | { |
tobyspark | 33:e6672a9bd571 | 231 | if (receiveMessage.getArgNum() == 1) |
tobyspark | 33:e6672a9bd571 | 232 | if (receiveMessage.getTypeTag(0) == 'f') |
tobyspark | 25:3b519ef70341 | 233 | { |
tobyspark | 33:e6672a9bd571 | 234 | xFade = receiveMessage.getArgFloat(0); |
tobyspark | 25:3b519ef70341 | 235 | char buffer[15]; |
tobyspark | 26:0299f8760715 | 236 | snprintf(buffer, kStringBufferLength, "/xFade %1.2f", xFade); |
tobyspark | 25:3b519ef70341 | 237 | statusMessage += buffer; |
tobyspark | 25:3b519ef70341 | 238 | } |
tobyspark | 25:3b519ef70341 | 239 | } |
tobyspark | 33:e6672a9bd571 | 240 | else if (!strcmp( receiveMessage.getSubAddress() , "fadeUp" )) |
tobyspark | 25:3b519ef70341 | 241 | { |
tobyspark | 33:e6672a9bd571 | 242 | if (receiveMessage.getArgNum() == 1) |
tobyspark | 33:e6672a9bd571 | 243 | if (receiveMessage.getTypeTag(0) == 'f') |
tobyspark | 3:033d2b7768f3 | 244 | { |
tobyspark | 33:e6672a9bd571 | 245 | fadeUp = receiveMessage.getArgFloat(0); |
tobyspark | 25:3b519ef70341 | 246 | char buffer[15]; |
tobyspark | 26:0299f8760715 | 247 | snprintf(buffer, kStringBufferLength, "/fadeUp %1.2f", fadeUp); |
tobyspark | 25:3b519ef70341 | 248 | statusMessage += buffer; |
tobyspark | 3:033d2b7768f3 | 249 | } |
tobyspark | 25:3b519ef70341 | 250 | } |
tobyspark | 25:3b519ef70341 | 251 | else |
tobyspark | 25:3b519ef70341 | 252 | { |
tobyspark | 33:e6672a9bd571 | 253 | statusMessage += receiveMessage.getSubAddress(); |
tobyspark | 25:3b519ef70341 | 254 | statusMessage += " - Ignoring"; |
tobyspark | 25:3b519ef70341 | 255 | } |
tobyspark | 3:033d2b7768f3 | 256 | } |
tobyspark | 3:033d2b7768f3 | 257 | else |
tobyspark | 3:033d2b7768f3 | 258 | { |
tobyspark | 25:3b519ef70341 | 259 | statusMessage = "OSC: "; |
tobyspark | 33:e6672a9bd571 | 260 | statusMessage += receiveMessage.getTopAddress(); |
tobyspark | 25:3b519ef70341 | 261 | statusMessage += " - Ignoring"; |
tobyspark | 3:033d2b7768f3 | 262 | } |
tobyspark | 3:033d2b7768f3 | 263 | |
tobyspark | 3:033d2b7768f3 | 264 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 25:3b519ef70341 | 265 | screen.textToBuffer(statusMessage, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 266 | |
tobyspark | 25:3b519ef70341 | 267 | if (debug) debug->printf("%s \r\n", statusMessage.c_str()); |
tobyspark | 3:033d2b7768f3 | 268 | |
tobyspark | 3:033d2b7768f3 | 269 | } |
tobyspark | 3:033d2b7768f3 | 270 | |
tobyspark | 33:e6672a9bd571 | 271 | void processOSCOut(float &xFade, float &fadeUp) |
tobyspark | 33:e6672a9bd571 | 272 | { |
tobyspark | 33:e6672a9bd571 | 273 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 33:e6672a9bd571 | 274 | |
tobyspark | 33:e6672a9bd571 | 275 | sendMessage.setAddress("dvimxr", "xFadeFadeUp"); |
tobyspark | 33:e6672a9bd571 | 276 | sendMessage.setArgs("ff", &xFade, &fadeUp); |
tobyspark | 33:e6672a9bd571 | 277 | osc->sendOsc(&sendMessage); |
tobyspark | 33:e6672a9bd571 | 278 | |
tobyspark | 33:e6672a9bd571 | 279 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 280 | snprintf(statusMessageBuffer, kStringBufferLength, "OSC Out: xF %.2f fUp %.2f", xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 281 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 282 | |
tobyspark | 33:e6672a9bd571 | 283 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 33:e6672a9bd571 | 284 | } |
tobyspark | 33:e6672a9bd571 | 285 | |
tobyspark | 33:e6672a9bd571 | 286 | void processArtNetIn(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 287 | { |
tobyspark | 3:033d2b7768f3 | 288 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 289 | screen.textToBuffer("ArtNet activity", kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 290 | |
tobyspark | 3:033d2b7768f3 | 291 | if (debug) debug->printf("ArtNet activity"); |
tobyspark | 3:033d2b7768f3 | 292 | } |
tobyspark | 0:87aab40d5806 | 293 | |
tobyspark | 33:e6672a9bd571 | 294 | void processArtNetOut(float &xFade, float &fadeUp) |
tobyspark | 33:e6672a9bd571 | 295 | { |
tobyspark | 33:e6672a9bd571 | 296 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 33:e6672a9bd571 | 297 | |
tobyspark | 33:e6672a9bd571 | 298 | int xFadeDMX = xFade*255; |
tobyspark | 33:e6672a9bd571 | 299 | int fadeUpDMX = fadeUp*255; |
tobyspark | 33:e6672a9bd571 | 300 | |
tobyspark | 33:e6672a9bd571 | 301 | // Universe 0, Channel 0 = xFade, Channel 1 = fadeUp |
tobyspark | 33:e6672a9bd571 | 302 | char dmxData[2] = {xFadeDMX, fadeUpDMX}; |
tobyspark | 33:e6672a9bd571 | 303 | artNet->Send_ArtDmx(0, 0, dmxData, 2); |
tobyspark | 33:e6672a9bd571 | 304 | |
tobyspark | 33:e6672a9bd571 | 305 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 306 | snprintf(statusMessageBuffer, kStringBufferLength, "A'Net Out: xF%3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 33:e6672a9bd571 | 307 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 308 | |
tobyspark | 33:e6672a9bd571 | 309 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 33:e6672a9bd571 | 310 | } |
tobyspark | 33:e6672a9bd571 | 311 | |
tobyspark | 8:d46cc49f0f37 | 312 | void processDMXIn(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 313 | { |
tobyspark | 26:0299f8760715 | 314 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 5:f8b285ca41ba | 315 | |
tobyspark | 5:f8b285ca41ba | 316 | int xFadeDMX = dmx->get(kDMXInChannelXFade); |
tobyspark | 7:e6717468c18d | 317 | int fadeUpDMX = dmx->get(kDMXInChannelFadeUp); |
tobyspark | 5:f8b285ca41ba | 318 | |
tobyspark | 51:98cc27390484 | 319 | xFade = (float)xFadeDMX/255; |
tobyspark | 51:98cc27390484 | 320 | fadeUp = (float)fadeUpDMX/255; |
tobyspark | 5:f8b285ca41ba | 321 | |
tobyspark | 5:f8b285ca41ba | 322 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 26:0299f8760715 | 323 | snprintf(statusMessageBuffer, kStringBufferLength, "DMX In: xF %3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 25:3b519ef70341 | 324 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 325 | |
tobyspark | 25:3b519ef70341 | 326 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 5:f8b285ca41ba | 327 | } |
tobyspark | 5:f8b285ca41ba | 328 | |
tobyspark | 8:d46cc49f0f37 | 329 | void processDMXOut(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 330 | { |
tobyspark | 26:0299f8760715 | 331 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 5:f8b285ca41ba | 332 | |
tobyspark | 51:98cc27390484 | 333 | int xFadeDMX = xFade*255; |
tobyspark | 51:98cc27390484 | 334 | int fadeUpDMX = fadeUp*255; |
tobyspark | 5:f8b285ca41ba | 335 | |
tobyspark | 5:f8b285ca41ba | 336 | dmx->put(kDMXOutChannelXFade, xFadeDMX); |
tobyspark | 5:f8b285ca41ba | 337 | dmx->put(kDMXOutChannelFadeUp, fadeUpDMX); |
tobyspark | 5:f8b285ca41ba | 338 | |
tobyspark | 5:f8b285ca41ba | 339 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 26:0299f8760715 | 340 | snprintf(statusMessageBuffer, kStringBufferLength, "DMX Out: xF %3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 25:3b519ef70341 | 341 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 342 | |
tobyspark | 25:3b519ef70341 | 343 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 5:f8b285ca41ba | 344 | } |
tobyspark | 0:87aab40d5806 | 345 | |
tobyspark | 8:d46cc49f0f37 | 346 | inline float fadeCalc (const float AIN, const float tolerance) |
tobyspark | 8:d46cc49f0f37 | 347 | { |
tobyspark | 0:87aab40d5806 | 348 | float pos ; |
tobyspark | 0:87aab40d5806 | 349 | if (AIN < tolerance) pos = 0; |
tobyspark | 0:87aab40d5806 | 350 | else if (AIN > 1.0 - tolerance) pos = 1; |
tobyspark | 0:87aab40d5806 | 351 | else pos = (AIN - tolerance) / (1 - 2*tolerance); |
tobyspark | 0:87aab40d5806 | 352 | if (debug && false) debug->printf("fadeCalc in: %f out: %f \r\n", AIN, pos); |
tobyspark | 0:87aab40d5806 | 353 | return pos; |
tobyspark | 0:87aab40d5806 | 354 | } |
tobyspark | 0:87aab40d5806 | 355 | |
tobyspark | 34:69dfe64e7e6b | 356 | bool handleTVOneSources() |
tobyspark | 30:873979018850 | 357 | { |
tobyspark | 49:16309f39cead | 358 | static int notOKCounter = 0; |
tobyspark | 49:16309f39cead | 359 | |
tobyspark | 30:873979018850 | 360 | bool ok = true; |
tobyspark | 30:873979018850 | 361 | |
tobyspark | 30:873979018850 | 362 | int32_t payload = 0; |
tobyspark | 30:873979018850 | 363 | |
tobyspark | 30:873979018850 | 364 | ok = ok && tvOne.readCommand(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceSourceStable, payload); |
tobyspark | 34:69dfe64e7e6b | 365 | bool RGB1 = (payload == 1); |
tobyspark | 30:873979018850 | 366 | |
tobyspark | 30:873979018850 | 367 | ok = ok && tvOne.readCommand(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceSourceStable, payload); |
tobyspark | 30:873979018850 | 368 | bool RGB2 = (payload == 1); |
tobyspark | 30:873979018850 | 369 | |
tobyspark | 34:69dfe64e7e6b | 370 | ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, payload); |
tobyspark | 34:69dfe64e7e6b | 371 | int sourceA = payload; |
tobyspark | 34:69dfe64e7e6b | 372 | |
tobyspark | 34:69dfe64e7e6b | 373 | ok = ok && tvOne.readCommand(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, payload); |
tobyspark | 34:69dfe64e7e6b | 374 | int sourceB = payload; |
tobyspark | 34:69dfe64e7e6b | 375 | |
tobyspark | 44:723e65413ebe | 376 | if (debug) debug->printf("HandleTVOneSources: RGB1: %i, RGB2: %i, sourceA: %#x, sourceB: %#x \r\n", RGB1, RGB2, sourceA, sourceB); |
tobyspark | 45:cf8c2400be5c | 377 | |
tobyspark | 45:cf8c2400be5c | 378 | string tvOneDetectString = "TVOne: "; |
tobyspark | 45:cf8c2400be5c | 379 | |
tobyspark | 45:cf8c2400be5c | 380 | if (ok) |
tobyspark | 30:873979018850 | 381 | { |
tobyspark | 45:cf8c2400be5c | 382 | string right = RGB1 ? "Live" : (tvOneRGB1Stable ? "Hold" : "Logo"); |
tobyspark | 45:cf8c2400be5c | 383 | string left = RGB2 ? "Live" : (tvOneRGB2Stable ? "Hold" : "Logo"); |
tobyspark | 45:cf8c2400be5c | 384 | |
tobyspark | 45:cf8c2400be5c | 385 | tvOneDetectString += "L: "; |
tobyspark | 45:cf8c2400be5c | 386 | tvOneDetectString += left; |
tobyspark | 45:cf8c2400be5c | 387 | tvOneDetectString += " R: "; |
tobyspark | 45:cf8c2400be5c | 388 | tvOneDetectString += right; |
tobyspark | 30:873979018850 | 389 | } |
tobyspark | 49:16309f39cead | 390 | |
tobyspark | 48:c0fedfa8c525 | 391 | tvOneStatusMessage.addMessage(tvOneDetectString, 0); |
tobyspark | 34:69dfe64e7e6b | 392 | |
tobyspark | 34:69dfe64e7e6b | 393 | // Assign appropriate source depending on whether DVI input is good |
tobyspark | 34:69dfe64e7e6b | 394 | // If that assign command completes ok, and the DVI input is good, finally flag the unit has had a live source |
tobyspark | 34:69dfe64e7e6b | 395 | // Note any further losses on this input will be handled by the unit holding the last frame, so we don't need to switch back to SIS. |
tobyspark | 34:69dfe64e7e6b | 396 | if (ok && !tvOneRGB1Stable) |
tobyspark | 30:873979018850 | 397 | { |
tobyspark | 34:69dfe64e7e6b | 398 | if (RGB1 && (sourceB != kTV1SourceRGB1)) ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB1); |
tobyspark | 34:69dfe64e7e6b | 399 | if (!RGB1 && (sourceB != kTV1SourceSIS2)) ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceSIS2); // Wierd: Can't set to SIS1 sometimes. |
tobyspark | 34:69dfe64e7e6b | 400 | if (ok && RGB1) tvOneRGB1Stable = true; |
tobyspark | 30:873979018850 | 401 | } |
tobyspark | 34:69dfe64e7e6b | 402 | if (ok && !tvOneRGB2Stable) |
tobyspark | 34:69dfe64e7e6b | 403 | { |
tobyspark | 34:69dfe64e7e6b | 404 | if (RGB2 && (sourceA != kTV1SourceRGB2)) ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB2); |
tobyspark | 34:69dfe64e7e6b | 405 | if (!RGB2 && (sourceA != kTV1SourceSIS2)) ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceSIS2); |
tobyspark | 34:69dfe64e7e6b | 406 | if (ok && RGB2) tvOneRGB2Stable = true; |
tobyspark | 34:69dfe64e7e6b | 407 | } |
tobyspark | 48:c0fedfa8c525 | 408 | |
tobyspark | 49:16309f39cead | 409 | // It seems there is an occasional RS232 choke around power-on of the processor. |
tobyspark | 49:16309f39cead | 410 | // Hard to reproduce, doubly so when in debug mode, this may fix. |
tobyspark | 49:16309f39cead | 411 | if (ok) |
tobyspark | 49:16309f39cead | 412 | { |
tobyspark | 49:16309f39cead | 413 | notOKCounter = 0; |
tobyspark | 49:16309f39cead | 414 | tvOne.resetCommandPeriods(); |
tobyspark | 49:16309f39cead | 415 | } |
tobyspark | 51:98cc27390484 | 416 | else |
tobyspark | 49:16309f39cead | 417 | { |
tobyspark | 51:98cc27390484 | 418 | notOKCounter++; |
tobyspark | 51:98cc27390484 | 419 | if (notOKCounter == 5) |
tobyspark | 51:98cc27390484 | 420 | { |
tobyspark | 51:98cc27390484 | 421 | tvOne.increaseCommandPeriods(200); |
tobyspark | 51:98cc27390484 | 422 | } |
tobyspark | 51:98cc27390484 | 423 | if (notOKCounter == 6) |
tobyspark | 51:98cc27390484 | 424 | { |
tobyspark | 51:98cc27390484 | 425 | tvOne.resetCommandPeriods(); |
tobyspark | 51:98cc27390484 | 426 | } |
tobyspark | 51:98cc27390484 | 427 | if (notOKCounter % 15 == 0) |
tobyspark | 51:98cc27390484 | 428 | { |
tobyspark | 51:98cc27390484 | 429 | tvOneStatusMessage.addMessage("TVOne: Resetting link", 2.0f); |
tobyspark | 51:98cc27390484 | 430 | screen.textToBuffer(tvOneStatusMessage.message(), kTVOneStatusLine); |
tobyspark | 51:98cc27390484 | 431 | screen.sendBuffer(); |
tobyspark | 51:98cc27390484 | 432 | |
tobyspark | 52:98f557fe93a3 | 433 | tvOne.increaseCommandPeriods(1500); |
tobyspark | 51:98cc27390484 | 434 | } |
tobyspark | 51:98cc27390484 | 435 | if (notOKCounter % 15 == 1) |
tobyspark | 51:98cc27390484 | 436 | { |
tobyspark | 51:98cc27390484 | 437 | tvOne.resetCommandPeriods(); |
tobyspark | 51:98cc27390484 | 438 | } |
tobyspark | 49:16309f39cead | 439 | } |
tobyspark | 49:16309f39cead | 440 | |
tobyspark | 51:98cc27390484 | 441 | return ok; |
tobyspark | 30:873979018850 | 442 | } |
tobyspark | 30:873979018850 | 443 | |
tobyspark | 8:d46cc49f0f37 | 444 | bool setKeyParamsTo(int index) |
tobyspark | 8:d46cc49f0f37 | 445 | { |
tobyspark | 0:87aab40d5806 | 446 | // Only spend the time uploading six parameters if we need to |
tobyspark | 0:87aab40d5806 | 447 | // Might want to bounds check here |
tobyspark | 0:87aab40d5806 | 448 | |
tobyspark | 9:f83eadd8917a | 449 | bool ok; |
tobyspark | 0:87aab40d5806 | 450 | |
tobyspark | 0:87aab40d5806 | 451 | if (index != keyerParamsSet) |
tobyspark | 0:87aab40d5806 | 452 | { |
tobyspark | 31:01845a2347ff | 453 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, settings.keyerParamSet(index)[SPKSettings::minY]); |
tobyspark | 31:01845a2347ff | 454 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, settings.keyerParamSet(index)[SPKSettings::maxY]); |
tobyspark | 31:01845a2347ff | 455 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, settings.keyerParamSet(index)[SPKSettings::minU]); |
tobyspark | 31:01845a2347ff | 456 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, settings.keyerParamSet(index)[SPKSettings::maxU]); |
tobyspark | 31:01845a2347ff | 457 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, settings.keyerParamSet(index)[SPKSettings::minV]); |
tobyspark | 31:01845a2347ff | 458 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, settings.keyerParamSet(index)[SPKSettings::maxV]); |
tobyspark | 0:87aab40d5806 | 459 | |
tobyspark | 0:87aab40d5806 | 460 | keyerParamsSet = index; |
tobyspark | 9:f83eadd8917a | 461 | } |
tobyspark | 9:f83eadd8917a | 462 | else |
tobyspark | 9:f83eadd8917a | 463 | { |
tobyspark | 9:f83eadd8917a | 464 | ok = true; |
tobyspark | 9:f83eadd8917a | 465 | } |
tobyspark | 0:87aab40d5806 | 466 | |
tobyspark | 0:87aab40d5806 | 467 | return ok; |
tobyspark | 0:87aab40d5806 | 468 | } |
tobyspark | 0:87aab40d5806 | 469 | |
tobyspark | 24:49c6624119ae | 470 | void actionMixMode() |
tobyspark | 24:49c6624119ae | 471 | { |
tobyspark | 31:01845a2347ff | 472 | if (debug) debug->printf("Changing mix mode \r\n"); |
tobyspark | 31:01845a2347ff | 473 | |
tobyspark | 24:49c6624119ae | 474 | bool ok = true; |
tobyspark | 25:3b519ef70341 | 475 | string sentOK; |
tobyspark | 26:0299f8760715 | 476 | char sentMSGBuffer[kStringBufferLength]; |
tobyspark | 24:49c6624119ae | 477 | |
tobyspark | 24:49c6624119ae | 478 | // Set Keyer |
tobyspark | 39:7d9a5eef93c9 | 479 | if (mixMode < mixKey) |
tobyspark | 24:49c6624119ae | 480 | { |
tobyspark | 31:01845a2347ff | 481 | // Set Keyer Off. Quicker to set and fail than to test for on and then turn off |
tobyspark | 35:d5d9f0838f99 | 482 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, false); |
tobyspark | 31:01845a2347ff | 483 | |
tobyspark | 31:01845a2347ff | 484 | if (mixMode == mixBlend) |
tobyspark | 24:49c6624119ae | 485 | { |
tobyspark | 31:01845a2347ff | 486 | // Turn off Additive Mixing on output |
tobyspark | 52:98f557fe93a3 | 487 | if (tvOne.getProcessorType().version == 423) |
tobyspark | 52:98f557fe93a3 | 488 | { |
tobyspark | 52:98f557fe93a3 | 489 | ok = tvOne.command(0, kTV1WindowIDA, 0x298, 0); |
tobyspark | 52:98f557fe93a3 | 490 | } |
tobyspark | 31:01845a2347ff | 491 | snprintf(sentMSGBuffer, kStringBufferLength, "Blend"); |
tobyspark | 24:49c6624119ae | 492 | } |
tobyspark | 31:01845a2347ff | 493 | if (mixMode == mixAdditive) |
tobyspark | 31:01845a2347ff | 494 | { |
tobyspark | 31:01845a2347ff | 495 | // First set B to what you'd expect for additive; it may be left at 100 if optimised blend mixing was previous mixmode. |
tobyspark | 31:01845a2347ff | 496 | ok = tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 31:01845a2347ff | 497 | // Then turn on Additive Mixing |
tobyspark | 52:98f557fe93a3 | 498 | if (tvOne.getProcessorType().version == 423) |
tobyspark | 52:98f557fe93a3 | 499 | { |
tobyspark | 52:98f557fe93a3 | 500 | ok = ok && tvOne.command(0, kTV1WindowIDA, 0x298, 1); |
tobyspark | 52:98f557fe93a3 | 501 | } |
tobyspark | 31:01845a2347ff | 502 | snprintf(sentMSGBuffer, kStringBufferLength, "Additive"); |
tobyspark | 31:01845a2347ff | 503 | } |
tobyspark | 24:49c6624119ae | 504 | } |
tobyspark | 24:49c6624119ae | 505 | else |
tobyspark | 24:49c6624119ae | 506 | { |
tobyspark | 39:7d9a5eef93c9 | 507 | int index = mixModeMenu.selectedIndex() - mixKeyStartIndex; |
tobyspark | 49:16309f39cead | 508 | |
tobyspark | 49:16309f39cead | 509 | // Turn off Additive Mixing on output |
tobyspark | 52:98f557fe93a3 | 510 | if (tvOne.getProcessorType().version == 423) |
tobyspark | 52:98f557fe93a3 | 511 | { |
tobyspark | 52:98f557fe93a3 | 512 | ok = tvOne.command(0, kTV1WindowIDA, 0x298, 0); |
tobyspark | 52:98f557fe93a3 | 513 | } |
tobyspark | 49:16309f39cead | 514 | // Turn on Keyer |
tobyspark | 49:16309f39cead | 515 | ok = ok && setKeyParamsTo(index); |
tobyspark | 24:49c6624119ae | 516 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, true); |
tobyspark | 49:16309f39cead | 517 | |
tobyspark | 26:0299f8760715 | 518 | snprintf(sentMSGBuffer, kStringBufferLength, "Keyer On with %i", index); |
tobyspark | 24:49c6624119ae | 519 | } |
tobyspark | 49:16309f39cead | 520 | |
tobyspark | 49:16309f39cead | 521 | mixModeOld = mixMode; |
tobyspark | 24:49c6624119ae | 522 | |
tobyspark | 24:49c6624119ae | 523 | if (ok) sentOK = "Sent:"; |
tobyspark | 24:49c6624119ae | 524 | else sentOK = "Send Error:"; |
tobyspark | 24:49c6624119ae | 525 | |
tobyspark | 48:c0fedfa8c525 | 526 | tvOneStatusMessage.addMessage(sentOK + sentMSGBuffer, kTVOneStatusMessageHoldTime); |
tobyspark | 24:49c6624119ae | 527 | } |
tobyspark | 24:49c6624119ae | 528 | |
tobyspark | 49:16309f39cead | 529 | bool checkTVOneMixStatus() |
tobyspark | 49:16309f39cead | 530 | { |
tobyspark | 49:16309f39cead | 531 | bool ok = true; |
tobyspark | 49:16309f39cead | 532 | |
tobyspark | 49:16309f39cead | 533 | int32_t payload; |
tobyspark | 49:16309f39cead | 534 | |
tobyspark | 49:16309f39cead | 535 | // Mix Mode |
tobyspark | 49:16309f39cead | 536 | bool mixModeNeedsAction = false; |
tobyspark | 49:16309f39cead | 537 | bool additiveOn = false, keyerOn = false; |
tobyspark | 49:16309f39cead | 538 | |
tobyspark | 49:16309f39cead | 539 | if (mixMode == mixBlend) { additiveOn = false; keyerOn = false;} |
tobyspark | 49:16309f39cead | 540 | if (mixMode == mixAdditive) { additiveOn = true; keyerOn = false;} |
tobyspark | 49:16309f39cead | 541 | if (mixMode >= mixKey) { additiveOn = false; keyerOn = true; } |
tobyspark | 49:16309f39cead | 542 | |
tobyspark | 52:98f557fe93a3 | 543 | if (tvOne.getProcessorType().version == 423) |
tobyspark | 52:98f557fe93a3 | 544 | { |
tobyspark | 52:98f557fe93a3 | 545 | payload = -1; |
tobyspark | 52:98f557fe93a3 | 546 | ok = ok && tvOne.readCommand(0, kTV1WindowIDA, 0x298, payload); |
tobyspark | 52:98f557fe93a3 | 547 | if (payload != additiveOn) mixModeNeedsAction = true; |
tobyspark | 52:98f557fe93a3 | 548 | } |
tobyspark | 52:98f557fe93a3 | 549 | |
tobyspark | 49:16309f39cead | 550 | payload = -1; |
tobyspark | 49:16309f39cead | 551 | ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, payload); |
tobyspark | 49:16309f39cead | 552 | if (payload != keyerOn) mixModeNeedsAction = true; |
tobyspark | 49:16309f39cead | 553 | |
tobyspark | 49:16309f39cead | 554 | if (ok && mixModeNeedsAction) |
tobyspark | 49:16309f39cead | 555 | { |
tobyspark | 49:16309f39cead | 556 | if (debug) debug->printf("Check TVOne Mix Status requiring mixMode action. mixMode: %i \r\n", mixMode); |
tobyspark | 49:16309f39cead | 557 | actionMixMode(); |
tobyspark | 49:16309f39cead | 558 | } |
tobyspark | 49:16309f39cead | 559 | |
tobyspark | 49:16309f39cead | 560 | // Check Fade |
tobyspark | 49:16309f39cead | 561 | payload = -1; |
tobyspark | 49:16309f39cead | 562 | ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, payload); |
tobyspark | 49:16309f39cead | 563 | if (ok && (payload != fadeAPercent)) |
tobyspark | 49:16309f39cead | 564 | { |
tobyspark | 49:16309f39cead | 565 | if (debug) debug->printf("Check TVOne Mix Status requiring fadeA action"); |
tobyspark | 49:16309f39cead | 566 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 49:16309f39cead | 567 | } |
tobyspark | 49:16309f39cead | 568 | |
tobyspark | 49:16309f39cead | 569 | payload = -1; |
tobyspark | 49:16309f39cead | 570 | ok = ok && tvOne.readCommand(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, payload); |
tobyspark | 49:16309f39cead | 571 | if (ok && (payload != fadeBPercent)) |
tobyspark | 49:16309f39cead | 572 | { |
tobyspark | 49:16309f39cead | 573 | if (debug) debug->printf("Check TVOne Mix Status requiring fadeB action"); |
tobyspark | 49:16309f39cead | 574 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 49:16309f39cead | 575 | } |
tobyspark | 49:16309f39cead | 576 | |
tobyspark | 49:16309f39cead | 577 | return ok; |
tobyspark | 49:16309f39cead | 578 | } |
tobyspark | 24:49c6624119ae | 579 | |
tobyspark | 17:fc68d40b8b1f | 580 | bool conformProcessor() |
tobyspark | 17:fc68d40b8b1f | 581 | { |
tobyspark | 44:723e65413ebe | 582 | bool ok; |
tobyspark | 17:fc68d40b8b1f | 583 | |
tobyspark | 17:fc68d40b8b1f | 584 | int32_t on = 1; |
tobyspark | 17:fc68d40b8b1f | 585 | int32_t off = 0; |
tobyspark | 17:fc68d40b8b1f | 586 | int32_t fit = 1; |
tobyspark | 38:2701101dcd56 | 587 | int32_t oneToOne = 4; |
tobyspark | 17:fc68d40b8b1f | 588 | |
tobyspark | 44:723e65413ebe | 589 | for (int i=0; i < 3; i++) |
tobyspark | 44:723e65413ebe | 590 | { |
tobyspark | 44:723e65413ebe | 591 | // Independent output |
tobyspark | 44:723e65413ebe | 592 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionMode, 2); |
tobyspark | 44:723e65413ebe | 593 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsOutputEnable, on); |
tobyspark | 44:723e65413ebe | 594 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsLockMethod, off); |
tobyspark | 44:723e65413ebe | 595 | |
tobyspark | 44:723e65413ebe | 596 | // Make sure our windows exist |
tobyspark | 44:723e65413ebe | 597 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 44:723e65413ebe | 598 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 44:723e65413ebe | 599 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, 0); |
tobyspark | 44:723e65413ebe | 600 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsLayerPriority, 1); |
tobyspark | 44:723e65413ebe | 601 | |
tobyspark | 44:723e65413ebe | 602 | // Assign inputs to windows, so that left on the crossfader is left on the processor viewed from front |
tobyspark | 44:723e65413ebe | 603 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB2); |
tobyspark | 44:723e65413ebe | 604 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB1); |
tobyspark | 44:723e65413ebe | 605 | |
tobyspark | 44:723e65413ebe | 606 | // Set scaling to fit source within output, maintaining aspect ratio |
tobyspark | 44:723e65413ebe | 607 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 44:723e65413ebe | 608 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 44:723e65413ebe | 609 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 44:723e65413ebe | 610 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 44:723e65413ebe | 611 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 44:723e65413ebe | 612 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 44:723e65413ebe | 613 | ok = ok && tvOne.command(kTV1SourceSIS2, kTV1WindowIDA, kTV1FunctionAdjustSourceTestCard, 1); |
tobyspark | 44:723e65413ebe | 614 | ok = ok && tvOne.command(kTV1SourceSIS2, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, oneToOne); |
tobyspark | 44:723e65413ebe | 615 | |
tobyspark | 44:723e65413ebe | 616 | // On source loss, hold on the last frame received. |
tobyspark | 44:723e65413ebe | 617 | int32_t freeze = 1; |
tobyspark | 44:723e65413ebe | 618 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 44:723e65413ebe | 619 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 44:723e65413ebe | 620 | |
tobyspark | 44:723e65413ebe | 621 | // Set resolution and fade levels for maximum chance of being seen |
tobyspark | 44:723e65413ebe | 622 | ok = ok && tvOne.setResolution(kTV1ResolutionVGA, tvOneEDIDPassthrough ? EDIDPassthroughSlot : 5); |
tobyspark | 48:c0fedfa8c525 | 623 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, 50); |
tobyspark | 44:723e65413ebe | 624 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, 100); |
tobyspark | 44:723e65413ebe | 625 | |
tobyspark | 44:723e65413ebe | 626 | // Set evil, evil HDCP off |
tobyspark | 44:723e65413ebe | 627 | ok = ok && tvOne.setHDCPOn(false); |
tobyspark | 30:873979018850 | 628 | |
tobyspark | 44:723e65413ebe | 629 | if (ok) break; |
tobyspark | 44:723e65413ebe | 630 | else tvOne.increaseCommandPeriods(500); |
tobyspark | 44:723e65413ebe | 631 | } |
tobyspark | 40:bfddeb2a7fcf | 632 | |
tobyspark | 44:723e65413ebe | 633 | if (ok) |
tobyspark | 44:723e65413ebe | 634 | { |
tobyspark | 44:723e65413ebe | 635 | // Save current state in preset one |
tobyspark | 44:723e65413ebe | 636 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPreset, 1); // Set Preset 1 |
tobyspark | 44:723e65413ebe | 637 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPresetStore, 1); // Store |
tobyspark | 44:723e65413ebe | 638 | |
tobyspark | 44:723e65413ebe | 639 | // Save current state for power on |
tobyspark | 44:723e65413ebe | 640 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 44:723e65413ebe | 641 | } |
tobyspark | 41:00d1cd3b2af2 | 642 | |
tobyspark | 44:723e65413ebe | 643 | tvOne.resetCommandPeriods(); |
tobyspark | 41:00d1cd3b2af2 | 644 | |
tobyspark | 41:00d1cd3b2af2 | 645 | return ok; |
tobyspark | 41:00d1cd3b2af2 | 646 | } |
tobyspark | 41:00d1cd3b2af2 | 647 | |
tobyspark | 41:00d1cd3b2af2 | 648 | bool uploadToProcessor() |
tobyspark | 41:00d1cd3b2af2 | 649 | { |
tobyspark | 41:00d1cd3b2af2 | 650 | bool ok = true; |
tobyspark | 41:00d1cd3b2af2 | 651 | |
tobyspark | 41:00d1cd3b2af2 | 652 | LocalFileSystem local("local"); |
tobyspark | 41:00d1cd3b2af2 | 653 | FILE *file; |
tobyspark | 41:00d1cd3b2af2 | 654 | |
tobyspark | 34:69dfe64e7e6b | 655 | // Upload Matrox EDID to mem4 (ie. index 3). Use this EDID slot when setting Matrox resolutions. |
tobyspark | 44:723e65413ebe | 656 | if (tvOne.getProcessorType().version < 415) |
tobyspark | 44:723e65413ebe | 657 | { |
tobyspark | 44:723e65413ebe | 658 | if (debug) debug->printf("Skipping EDID upload as unsupported on detected TV One firmware\r\n"); |
tobyspark | 44:723e65413ebe | 659 | } |
tobyspark | 44:723e65413ebe | 660 | else |
tobyspark | 34:69dfe64e7e6b | 661 | { |
tobyspark | 41:00d1cd3b2af2 | 662 | file = fopen("/local/matroxe.did", "r"); // 8.3, avoid .bin as mbed executable extension |
tobyspark | 35:d5d9f0838f99 | 663 | if (file) |
tobyspark | 34:69dfe64e7e6b | 664 | { |
tobyspark | 41:00d1cd3b2af2 | 665 | ok = ok && tvOne.uploadEDID(file, 3); |
tobyspark | 35:d5d9f0838f99 | 666 | fclose(file); |
tobyspark | 34:69dfe64e7e6b | 667 | } |
tobyspark | 35:d5d9f0838f99 | 668 | else |
tobyspark | 35:d5d9f0838f99 | 669 | { |
tobyspark | 44:723e65413ebe | 670 | if (debug) debug->printf("Could not open Matrox EDID file 'matroxe.did'\r\n"); |
tobyspark | 35:d5d9f0838f99 | 671 | } |
tobyspark | 34:69dfe64e7e6b | 672 | } |
tobyspark | 41:00d1cd3b2af2 | 673 | |
tobyspark | 41:00d1cd3b2af2 | 674 | // Upload Logo to SIS2. Use this (minimal) image when no sources are connected. |
tobyspark | 41:00d1cd3b2af2 | 675 | { |
tobyspark | 41:00d1cd3b2af2 | 676 | file = fopen("/local/spark.dat", "r"); // 8.3, avoid .bin as mbed executable extension |
tobyspark | 41:00d1cd3b2af2 | 677 | if (file) |
tobyspark | 41:00d1cd3b2af2 | 678 | { |
tobyspark | 52:98f557fe93a3 | 679 | ok = ok && tvOne.uploadImage(file, 0); |
tobyspark | 41:00d1cd3b2af2 | 680 | fclose(file); |
tobyspark | 41:00d1cd3b2af2 | 681 | } |
tobyspark | 41:00d1cd3b2af2 | 682 | else |
tobyspark | 41:00d1cd3b2af2 | 683 | { |
tobyspark | 41:00d1cd3b2af2 | 684 | if (debug) debug->printf("Could not open image file 'spark.dat'"); |
tobyspark | 41:00d1cd3b2af2 | 685 | } |
tobyspark | 41:00d1cd3b2af2 | 686 | } |
tobyspark | 17:fc68d40b8b1f | 687 | |
tobyspark | 17:fc68d40b8b1f | 688 | return ok; |
tobyspark | 17:fc68d40b8b1f | 689 | } |
tobyspark | 17:fc68d40b8b1f | 690 | |
tobyspark | 27:27851d3d2bba | 691 | void setResolutionMenuItems() |
tobyspark | 27:27851d3d2bba | 692 | { |
tobyspark | 27:27851d3d2bba | 693 | resolutionMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 694 | for (int i=0; i < settings.resolutionsCount(); i++) |
tobyspark | 27:27851d3d2bba | 695 | { |
tobyspark | 27:27851d3d2bba | 696 | resolutionMenu.addMenuItem(SPKMenuItem(settings.resolutionName(i), settings.resolutionIndex(i), settings.resolutionEDIDIndex(i))); |
tobyspark | 27:27851d3d2bba | 697 | } |
tobyspark | 27:27851d3d2bba | 698 | resolutionMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 27:27851d3d2bba | 699 | } |
tobyspark | 27:27851d3d2bba | 700 | |
tobyspark | 27:27851d3d2bba | 701 | void setMixModeMenuItems() |
tobyspark | 27:27851d3d2bba | 702 | { |
tobyspark | 27:27851d3d2bba | 703 | mixModeMenu.clearMenuItems(); |
tobyspark | 44:723e65413ebe | 704 | |
tobyspark | 46:491229c97336 | 705 | if (tvOne.getProcessorType().version == 423 || tvOne.getProcessorType().version == -1) |
tobyspark | 44:723e65413ebe | 706 | { |
tobyspark | 44:723e65413ebe | 707 | mixModeMenu.addMenuItem(SPKMenuItem("Crossfade", &mixModeAdditiveMenu)); |
tobyspark | 44:723e65413ebe | 708 | } |
tobyspark | 44:723e65413ebe | 709 | else |
tobyspark | 44:723e65413ebe | 710 | { |
tobyspark | 44:723e65413ebe | 711 | mixModeMenu.addMenuItem(SPKMenuItem("Blend", mixBlend)); |
tobyspark | 44:723e65413ebe | 712 | } |
tobyspark | 44:723e65413ebe | 713 | |
tobyspark | 27:27851d3d2bba | 714 | for (int i=0; i < settings.keyerSetCount(); i++) |
tobyspark | 27:27851d3d2bba | 715 | { |
tobyspark | 49:16309f39cead | 716 | mixModeMenu.addMenuItem(SPKMenuItem(settings.keyerParamName(i), mixKeyStartIndex + i)); |
tobyspark | 27:27851d3d2bba | 717 | } |
tobyspark | 27:27851d3d2bba | 718 | mixModeMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 27:27851d3d2bba | 719 | } |
tobyspark | 27:27851d3d2bba | 720 | |
tobyspark | 27:27851d3d2bba | 721 | void setCommsMenuItems() |
tobyspark | 27:27851d3d2bba | 722 | { |
tobyspark | 27:27851d3d2bba | 723 | if (rj45Mode == rj45Ethernet) |
tobyspark | 27:27851d3d2bba | 724 | { |
tobyspark | 27:27851d3d2bba | 725 | commsMenu.title = "Network Mode [Ethernet]"; |
tobyspark | 27:27851d3d2bba | 726 | commsMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 727 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 27:27851d3d2bba | 728 | commsMenu.addMenuItem(SPKMenuItem("OSC", commsOSC)); |
tobyspark | 27:27851d3d2bba | 729 | commsMenu.addMenuItem(SPKMenuItem("ArtNet", commsArtNet)); |
tobyspark | 27:27851d3d2bba | 730 | commsMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 33:e6672a9bd571 | 731 | commsMenu = 0; |
tobyspark | 27:27851d3d2bba | 732 | } |
tobyspark | 27:27851d3d2bba | 733 | else if (rj45Mode == rj45DMX) |
tobyspark | 27:27851d3d2bba | 734 | { |
tobyspark | 27:27851d3d2bba | 735 | commsMenu.title = "Network Mode [DMX]"; |
tobyspark | 27:27851d3d2bba | 736 | commsMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 737 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 27:27851d3d2bba | 738 | commsMenu.addMenuItem(SPKMenuItem("DMX In", commsDMXIn)); |
tobyspark | 27:27851d3d2bba | 739 | commsMenu.addMenuItem(SPKMenuItem("DMX Out", commsDMXOut)); |
tobyspark | 27:27851d3d2bba | 740 | commsMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 33:e6672a9bd571 | 741 | commsMenu = 0; |
tobyspark | 27:27851d3d2bba | 742 | } |
tobyspark | 27:27851d3d2bba | 743 | } |
tobyspark | 27:27851d3d2bba | 744 | |
tobyspark | 49:16309f39cead | 745 | void mixModeAdditiveMenuHandler(int change, bool action) |
tobyspark | 49:16309f39cead | 746 | { |
tobyspark | 49:16309f39cead | 747 | fadeCurve += change * 0.05f; |
tobyspark | 49:16309f39cead | 748 | if (fadeCurve > 1.0f) fadeCurve = 1.0f; |
tobyspark | 49:16309f39cead | 749 | if (fadeCurve < 0.0f) fadeCurve = 0.0f; |
tobyspark | 49:16309f39cead | 750 | |
tobyspark | 49:16309f39cead | 751 | mixMode = (fadeCurve > 0.001f) ? mixAdditive: mixBlend; |
tobyspark | 49:16309f39cead | 752 | |
tobyspark | 49:16309f39cead | 753 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 754 | screen.textToBuffer("Blend [ ----- ] Add", kMenuLine2); |
tobyspark | 49:16309f39cead | 755 | screen.characterToBuffer('X', 38 + fadeCurve*20.0f, kMenuLine2); |
tobyspark | 49:16309f39cead | 756 | |
tobyspark | 49:16309f39cead | 757 | if (debug) debug->printf("Fade curve changed by %i to %f \r\n", change, fadeCurve); |
tobyspark | 49:16309f39cead | 758 | |
tobyspark | 49:16309f39cead | 759 | if (action) |
tobyspark | 49:16309f39cead | 760 | { |
tobyspark | 49:16309f39cead | 761 | selectedMenu = &mixModeMenu; |
tobyspark | 49:16309f39cead | 762 | |
tobyspark | 49:16309f39cead | 763 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 764 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 765 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 766 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 49:16309f39cead | 767 | } |
tobyspark | 49:16309f39cead | 768 | } |
tobyspark | 49:16309f39cead | 769 | |
tobyspark | 51:98cc27390484 | 770 | void troubleshootingMenuHDCPHandler(int change, bool action) |
tobyspark | 49:16309f39cead | 771 | { |
tobyspark | 49:16309f39cead | 772 | static int currentHDCP; |
tobyspark | 53:0993424e1529 | 773 | static int state = 0; |
tobyspark | 49:16309f39cead | 774 | |
tobyspark | 49:16309f39cead | 775 | if (change == 0 && !action) |
tobyspark | 49:16309f39cead | 776 | { |
tobyspark | 49:16309f39cead | 777 | // We check the control not the status, as status depends on connection etc. |
tobyspark | 49:16309f39cead | 778 | |
tobyspark | 49:16309f39cead | 779 | int32_t payloadOutput = -1; |
tobyspark | 49:16309f39cead | 780 | tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsHDCPRequired, payloadOutput); |
tobyspark | 49:16309f39cead | 781 | |
tobyspark | 49:16309f39cead | 782 | int32_t payload1 = -1; |
tobyspark | 49:16309f39cead | 783 | tvOne.readCommand(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceHDCPAdvertize, payload1); |
tobyspark | 49:16309f39cead | 784 | |
tobyspark | 49:16309f39cead | 785 | int32_t payload2 = -1; |
tobyspark | 49:16309f39cead | 786 | tvOne.readCommand(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceHDCPAdvertize, payload2); |
tobyspark | 49:16309f39cead | 787 | |
tobyspark | 49:16309f39cead | 788 | if ((payloadOutput == payload1) && (payload1 == payload2) && (payload2 == 0)) |
tobyspark | 49:16309f39cead | 789 | { |
tobyspark | 49:16309f39cead | 790 | currentHDCP = 0; // Change to on |
tobyspark | 49:16309f39cead | 791 | } |
tobyspark | 49:16309f39cead | 792 | else if ((payloadOutput == payload1) && (payload1 == payload2) && (payload2 == 1)) |
tobyspark | 49:16309f39cead | 793 | { |
tobyspark | 49:16309f39cead | 794 | currentHDCP = 1; // Change to off |
tobyspark | 49:16309f39cead | 795 | } |
tobyspark | 49:16309f39cead | 796 | else |
tobyspark | 49:16309f39cead | 797 | { |
tobyspark | 49:16309f39cead | 798 | currentHDCP = -1; // Change to off |
tobyspark | 49:16309f39cead | 799 | } |
tobyspark | 49:16309f39cead | 800 | |
tobyspark | 49:16309f39cead | 801 | if (debug) debug->printf("HDCP detected O: %i 1: %i 2: %i", payloadOutput, payload1, payload2); |
tobyspark | 49:16309f39cead | 802 | } |
tobyspark | 49:16309f39cead | 803 | |
tobyspark | 49:16309f39cead | 804 | state += change; |
tobyspark | 53:0993424e1529 | 805 | if (state > 1) state = 1; |
tobyspark | 53:0993424e1529 | 806 | if (state < 0) state = 0; |
tobyspark | 49:16309f39cead | 807 | |
tobyspark | 49:16309f39cead | 808 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 809 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 810 | |
tobyspark | 49:16309f39cead | 811 | const char* current = currentHDCP == -1 ? "Mixed" : ( currentHDCP == 1 ? "On" : "Off"); |
tobyspark | 49:16309f39cead | 812 | |
tobyspark | 53:0993424e1529 | 813 | if (state == 0) snprintf(paramLine, kStringBufferLength, "%s. Set: [%s/ ]?", current, currentHDCP == 0 ? "On " : "Off" ); |
tobyspark | 49:16309f39cead | 814 | else snprintf(paramLine, kStringBufferLength, "%s. Set: [ /Cancel]?", current); |
tobyspark | 49:16309f39cead | 815 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 816 | |
tobyspark | 49:16309f39cead | 817 | if (action) |
tobyspark | 49:16309f39cead | 818 | { |
tobyspark | 53:0993424e1529 | 819 | if (state == 0) |
tobyspark | 49:16309f39cead | 820 | { |
tobyspark | 49:16309f39cead | 821 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 822 | screen.textToBuffer("Setting HDCP...", kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 823 | screen.sendBuffer(); |
tobyspark | 49:16309f39cead | 824 | |
tobyspark | 49:16309f39cead | 825 | // Do the action |
tobyspark | 49:16309f39cead | 826 | bool ok = tvOne.setHDCPOn(currentHDCP == 0); |
tobyspark | 49:16309f39cead | 827 | |
tobyspark | 49:16309f39cead | 828 | if (ok) tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 49:16309f39cead | 829 | |
tobyspark | 49:16309f39cead | 830 | std::string sendOK = ok ? "Sent: HDCP " : "Send Error: HDCP "; |
tobyspark | 49:16309f39cead | 831 | sendOK += currentHDCP == 0 ? "On" : "Off"; |
tobyspark | 49:16309f39cead | 832 | |
tobyspark | 49:16309f39cead | 833 | tvOneStatusMessage.addMessage(sendOK, kTVOneStatusMessageHoldTime); |
tobyspark | 49:16309f39cead | 834 | } |
tobyspark | 49:16309f39cead | 835 | |
tobyspark | 49:16309f39cead | 836 | // Get back to menu |
tobyspark | 51:98cc27390484 | 837 | selectedMenu = &troubleshootingMenu; |
tobyspark | 49:16309f39cead | 838 | |
tobyspark | 49:16309f39cead | 839 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 840 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 841 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 842 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 49:16309f39cead | 843 | } |
tobyspark | 49:16309f39cead | 844 | } |
tobyspark | 49:16309f39cead | 845 | |
tobyspark | 51:98cc27390484 | 846 | void troubleshootingMenuEDIDHandler(int change, bool action) |
tobyspark | 49:16309f39cead | 847 | { |
tobyspark | 49:16309f39cead | 848 | static int currentEDIDPassthrough; |
tobyspark | 53:0993424e1529 | 849 | static int state = 0; |
tobyspark | 49:16309f39cead | 850 | |
tobyspark | 49:16309f39cead | 851 | if (change == 0 && !action) |
tobyspark | 49:16309f39cead | 852 | { |
tobyspark | 49:16309f39cead | 853 | int32_t payload1 = -1; |
tobyspark | 49:16309f39cead | 854 | tvOne.readCommand(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, payload1); |
tobyspark | 49:16309f39cead | 855 | |
tobyspark | 49:16309f39cead | 856 | int32_t payload2 = -1; |
tobyspark | 49:16309f39cead | 857 | tvOne.readCommand(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, payload2); |
tobyspark | 49:16309f39cead | 858 | |
tobyspark | 49:16309f39cead | 859 | if ((payload1 == payload2) && (payload2 == EDIDPassthroughSlot)) |
tobyspark | 49:16309f39cead | 860 | { |
tobyspark | 49:16309f39cead | 861 | currentEDIDPassthrough = 1; |
tobyspark | 49:16309f39cead | 862 | } |
tobyspark | 49:16309f39cead | 863 | else if ((payload1 == payload2) && (payload2 != EDIDPassthroughSlot)) |
tobyspark | 49:16309f39cead | 864 | { |
tobyspark | 49:16309f39cead | 865 | currentEDIDPassthrough = 0; |
tobyspark | 49:16309f39cead | 866 | } |
tobyspark | 49:16309f39cead | 867 | else |
tobyspark | 49:16309f39cead | 868 | { |
tobyspark | 49:16309f39cead | 869 | currentEDIDPassthrough = -1; |
tobyspark | 49:16309f39cead | 870 | } |
tobyspark | 49:16309f39cead | 871 | } |
tobyspark | 49:16309f39cead | 872 | |
tobyspark | 49:16309f39cead | 873 | state += change; |
tobyspark | 53:0993424e1529 | 874 | if (state > 1) state = 1; |
tobyspark | 53:0993424e1529 | 875 | if (state < 0) state = 0; |
tobyspark | 49:16309f39cead | 876 | |
tobyspark | 49:16309f39cead | 877 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 878 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 879 | |
tobyspark | 51:98cc27390484 | 880 | const char* current = currentEDIDPassthrough == -1 ? "Mixed" : ( currentEDIDPassthrough == 1 ? "Thru" : "Internal"); |
tobyspark | 49:16309f39cead | 881 | |
tobyspark | 53:0993424e1529 | 882 | if (state == 0) snprintf(paramLine, kStringBufferLength, "%s. Set: [%s/ ]?", current, currentEDIDPassthrough == 0 ? "Thru" : "Int"); |
tobyspark | 49:16309f39cead | 883 | else snprintf(paramLine, kStringBufferLength, "%s. Set: [ /Cancel]?", current); |
tobyspark | 49:16309f39cead | 884 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 885 | |
tobyspark | 49:16309f39cead | 886 | if (action) |
tobyspark | 49:16309f39cead | 887 | { |
tobyspark | 53:0993424e1529 | 888 | if (state == 0) |
tobyspark | 49:16309f39cead | 889 | { |
tobyspark | 49:16309f39cead | 890 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 891 | screen.textToBuffer("Setting EDID...", kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 892 | screen.sendBuffer(); |
tobyspark | 49:16309f39cead | 893 | |
tobyspark | 49:16309f39cead | 894 | // Do the action |
tobyspark | 49:16309f39cead | 895 | tvOneEDIDPassthrough = currentEDIDPassthrough == 0; |
tobyspark | 49:16309f39cead | 896 | |
tobyspark | 49:16309f39cead | 897 | bool ok = true; |
tobyspark | 49:16309f39cead | 898 | |
tobyspark | 49:16309f39cead | 899 | int32_t slot = tvOneEDIDPassthrough ? EDIDPassthroughSlot : resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 49:16309f39cead | 900 | |
tobyspark | 49:16309f39cead | 901 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 49:16309f39cead | 902 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 49:16309f39cead | 903 | |
tobyspark | 49:16309f39cead | 904 | if (ok) tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 49:16309f39cead | 905 | |
tobyspark | 49:16309f39cead | 906 | std::string sendOK = ok ? "Sent: EDID " : "Send Error: EDID "; |
tobyspark | 49:16309f39cead | 907 | sendOK += tvOneEDIDPassthrough ? "Passthrough" : "Internal"; |
tobyspark | 49:16309f39cead | 908 | |
tobyspark | 49:16309f39cead | 909 | tvOneStatusMessage.addMessage(sendOK, kTVOneStatusMessageHoldTime); |
tobyspark | 49:16309f39cead | 910 | } |
tobyspark | 49:16309f39cead | 911 | |
tobyspark | 49:16309f39cead | 912 | // Get back to menu |
tobyspark | 51:98cc27390484 | 913 | selectedMenu = &troubleshootingMenu; |
tobyspark | 49:16309f39cead | 914 | |
tobyspark | 49:16309f39cead | 915 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 916 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 917 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 918 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 49:16309f39cead | 919 | } |
tobyspark | 49:16309f39cead | 920 | } |
tobyspark | 49:16309f39cead | 921 | |
tobyspark | 49:16309f39cead | 922 | void mixModeUpdateKeyMenuHandler(int menuChange, bool action) |
tobyspark | 49:16309f39cead | 923 | { |
tobyspark | 49:16309f39cead | 924 | static int actionCount = 0; |
tobyspark | 53:0993424e1529 | 925 | static int state = 0; |
tobyspark | 49:16309f39cead | 926 | |
tobyspark | 49:16309f39cead | 927 | if (action) actionCount++; |
tobyspark | 49:16309f39cead | 928 | |
tobyspark | 49:16309f39cead | 929 | if (actionCount == 0) |
tobyspark | 49:16309f39cead | 930 | { |
tobyspark | 49:16309f39cead | 931 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 932 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 933 | screen.textToBuffer("Edit current key?", kMenuLine1); |
tobyspark | 49:16309f39cead | 934 | |
tobyspark | 49:16309f39cead | 935 | state += menuChange; |
tobyspark | 53:0993424e1529 | 936 | if (state > 2) state = 2; |
tobyspark | 53:0993424e1529 | 937 | if (state < 0) state = 0; |
tobyspark | 53:0993424e1529 | 938 | |
tobyspark | 53:0993424e1529 | 939 | switch (state) |
tobyspark | 49:16309f39cead | 940 | { |
tobyspark | 49:16309f39cead | 941 | case 0: screen.textToBuffer("[Tweak/ / ]", kMenuLine2); break; |
tobyspark | 49:16309f39cead | 942 | case 1: screen.textToBuffer("[ /Start Over/ ]", kMenuLine2); break; |
tobyspark | 49:16309f39cead | 943 | case 2: screen.textToBuffer("[ / /Cancel]", kMenuLine2); break; |
tobyspark | 49:16309f39cead | 944 | } |
tobyspark | 49:16309f39cead | 945 | } |
tobyspark | 49:16309f39cead | 946 | if (actionCount == 1) |
tobyspark | 49:16309f39cead | 947 | { |
tobyspark | 49:16309f39cead | 948 | if (state == 0) |
tobyspark | 49:16309f39cead | 949 | { |
tobyspark | 49:16309f39cead | 950 | settings.editingKeyerSetIndex = mixModeMenu.selectedIndex() - mixKeyStartIndex; |
tobyspark | 49:16309f39cead | 951 | actionCount++; |
tobyspark | 49:16309f39cead | 952 | } |
tobyspark | 49:16309f39cead | 953 | else if (state == 1) |
tobyspark | 49:16309f39cead | 954 | { |
tobyspark | 49:16309f39cead | 955 | settings.editingKeyerSetIndex = mixModeMenu.selectedIndex() - mixKeyStartIndex; |
tobyspark | 49:16309f39cead | 956 | settings.setEditingKeyerSetValue(SPKSettings::minY, 0); |
tobyspark | 49:16309f39cead | 957 | settings.setEditingKeyerSetValue(SPKSettings::maxY, 255); |
tobyspark | 49:16309f39cead | 958 | settings.setEditingKeyerSetValue(SPKSettings::minU, 0); |
tobyspark | 49:16309f39cead | 959 | settings.setEditingKeyerSetValue(SPKSettings::maxU, 255); |
tobyspark | 49:16309f39cead | 960 | settings.setEditingKeyerSetValue(SPKSettings::minV, 0); |
tobyspark | 49:16309f39cead | 961 | settings.setEditingKeyerSetValue(SPKSettings::maxV, 255); |
tobyspark | 51:98cc27390484 | 962 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, 0); |
tobyspark | 51:98cc27390484 | 963 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, 255); |
tobyspark | 51:98cc27390484 | 964 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, 0); |
tobyspark | 51:98cc27390484 | 965 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, 255); |
tobyspark | 51:98cc27390484 | 966 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, 0); |
tobyspark | 51:98cc27390484 | 967 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, 255); |
tobyspark | 49:16309f39cead | 968 | actionCount++; |
tobyspark | 49:16309f39cead | 969 | state = 0; |
tobyspark | 49:16309f39cead | 970 | } |
tobyspark | 49:16309f39cead | 971 | else if (state == 2) |
tobyspark | 49:16309f39cead | 972 | { |
tobyspark | 49:16309f39cead | 973 | settings.editingKeyerSetIndex = -1; |
tobyspark | 49:16309f39cead | 974 | |
tobyspark | 49:16309f39cead | 975 | // Get back to menu |
tobyspark | 49:16309f39cead | 976 | actionCount = 0; |
tobyspark | 49:16309f39cead | 977 | state = 0; |
tobyspark | 49:16309f39cead | 978 | selectedMenu = &mixModeMenu; |
tobyspark | 49:16309f39cead | 979 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 980 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 981 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 982 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 49:16309f39cead | 983 | |
tobyspark | 49:16309f39cead | 984 | return; |
tobyspark | 49:16309f39cead | 985 | } |
tobyspark | 49:16309f39cead | 986 | } |
tobyspark | 49:16309f39cead | 987 | if (actionCount == 2) |
tobyspark | 49:16309f39cead | 988 | { |
tobyspark | 49:16309f39cead | 989 | int value = settings.editingKeyerSetValue(SPKSettings::maxY); |
tobyspark | 49:16309f39cead | 990 | value += menuChange; |
tobyspark | 49:16309f39cead | 991 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 992 | if (value > 255) value = 255; |
tobyspark | 49:16309f39cead | 993 | settings.setEditingKeyerSetValue(SPKSettings::maxY, value); |
tobyspark | 49:16309f39cead | 994 | |
tobyspark | 49:16309f39cead | 995 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 996 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 997 | screen.textToBuffer("Down until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 998 | |
tobyspark | 49:16309f39cead | 999 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1000 | snprintf(paramLine, kStringBufferLength, "[ /%3i][ / ][ / ]", value); |
tobyspark | 49:16309f39cead | 1001 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1002 | |
tobyspark | 49:16309f39cead | 1003 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, value); |
tobyspark | 49:16309f39cead | 1004 | } |
tobyspark | 49:16309f39cead | 1005 | else if (actionCount == 3) |
tobyspark | 49:16309f39cead | 1006 | { |
tobyspark | 49:16309f39cead | 1007 | int value = settings.editingKeyerSetValue(SPKSettings::minY); |
tobyspark | 49:16309f39cead | 1008 | value += menuChange; |
tobyspark | 49:16309f39cead | 1009 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 1010 | if (value > settings.editingKeyerSetValue(SPKSettings::maxY)) value = settings.editingKeyerSetValue(SPKSettings::maxY); |
tobyspark | 49:16309f39cead | 1011 | settings.setEditingKeyerSetValue(SPKSettings::minY, value); |
tobyspark | 49:16309f39cead | 1012 | |
tobyspark | 49:16309f39cead | 1013 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1014 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1015 | screen.textToBuffer("Up until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 1016 | |
tobyspark | 49:16309f39cead | 1017 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1018 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ / ][ / ]", value, |
tobyspark | 49:16309f39cead | 1019 | settings.editingKeyerSetValue(SPKSettings::maxY)); |
tobyspark | 49:16309f39cead | 1020 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1021 | |
tobyspark | 49:16309f39cead | 1022 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, value); |
tobyspark | 49:16309f39cead | 1023 | } |
tobyspark | 49:16309f39cead | 1024 | else if (actionCount == 4) |
tobyspark | 49:16309f39cead | 1025 | { |
tobyspark | 49:16309f39cead | 1026 | int value = settings.editingKeyerSetValue(SPKSettings::maxU); |
tobyspark | 49:16309f39cead | 1027 | value += menuChange; |
tobyspark | 49:16309f39cead | 1028 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 1029 | if (value > 255) value = 255; |
tobyspark | 49:16309f39cead | 1030 | settings.setEditingKeyerSetValue(SPKSettings::maxU, value); |
tobyspark | 49:16309f39cead | 1031 | |
tobyspark | 49:16309f39cead | 1032 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1033 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1034 | screen.textToBuffer("Down until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 1035 | |
tobyspark | 49:16309f39cead | 1036 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1037 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ /%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 49:16309f39cead | 1038 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 49:16309f39cead | 1039 | value); |
tobyspark | 49:16309f39cead | 1040 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1041 | |
tobyspark | 49:16309f39cead | 1042 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, value); |
tobyspark | 49:16309f39cead | 1043 | } |
tobyspark | 49:16309f39cead | 1044 | else if (actionCount == 5) |
tobyspark | 49:16309f39cead | 1045 | { |
tobyspark | 49:16309f39cead | 1046 | int value = settings.editingKeyerSetValue(SPKSettings::minU); |
tobyspark | 49:16309f39cead | 1047 | value += menuChange; |
tobyspark | 49:16309f39cead | 1048 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 1049 | if (value > settings.editingKeyerSetValue(SPKSettings::maxU)) value = settings.editingKeyerSetValue(SPKSettings::maxU); |
tobyspark | 49:16309f39cead | 1050 | settings.setEditingKeyerSetValue(SPKSettings::minU, value); |
tobyspark | 49:16309f39cead | 1051 | |
tobyspark | 49:16309f39cead | 1052 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1053 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1054 | screen.textToBuffer("Up until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 1055 | |
tobyspark | 49:16309f39cead | 1056 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1057 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 49:16309f39cead | 1058 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 49:16309f39cead | 1059 | value, |
tobyspark | 49:16309f39cead | 1060 | settings.editingKeyerSetValue(SPKSettings::maxU)); |
tobyspark | 49:16309f39cead | 1061 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1062 | |
tobyspark | 49:16309f39cead | 1063 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, value); |
tobyspark | 49:16309f39cead | 1064 | } |
tobyspark | 49:16309f39cead | 1065 | else if (actionCount == 6) |
tobyspark | 49:16309f39cead | 1066 | { |
tobyspark | 49:16309f39cead | 1067 | int value = settings.editingKeyerSetValue(SPKSettings::maxV); |
tobyspark | 49:16309f39cead | 1068 | value += menuChange; |
tobyspark | 49:16309f39cead | 1069 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 1070 | if (value > 255) value = 255; |
tobyspark | 49:16309f39cead | 1071 | settings.setEditingKeyerSetValue(SPKSettings::maxV, value); |
tobyspark | 49:16309f39cead | 1072 | |
tobyspark | 49:16309f39cead | 1073 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1074 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1075 | screen.textToBuffer("Down until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 1076 | |
tobyspark | 49:16309f39cead | 1077 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1078 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ /%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 49:16309f39cead | 1079 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 49:16309f39cead | 1080 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 49:16309f39cead | 1081 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 49:16309f39cead | 1082 | value); |
tobyspark | 49:16309f39cead | 1083 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1084 | |
tobyspark | 49:16309f39cead | 1085 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, value); |
tobyspark | 49:16309f39cead | 1086 | } |
tobyspark | 49:16309f39cead | 1087 | else if (actionCount == 7) |
tobyspark | 49:16309f39cead | 1088 | { |
tobyspark | 49:16309f39cead | 1089 | int value = settings.editingKeyerSetValue(SPKSettings::minV); |
tobyspark | 49:16309f39cead | 1090 | value += menuChange; |
tobyspark | 49:16309f39cead | 1091 | if (value < 0) value = 0; |
tobyspark | 49:16309f39cead | 1092 | if (value > settings.editingKeyerSetValue(SPKSettings::maxV)) value = settings.editingKeyerSetValue(SPKSettings::maxV); |
tobyspark | 49:16309f39cead | 1093 | settings.setEditingKeyerSetValue(SPKSettings::minV, value); |
tobyspark | 49:16309f39cead | 1094 | |
tobyspark | 49:16309f39cead | 1095 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1096 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1097 | screen.textToBuffer("Up until unmasked", kMenuLine1); |
tobyspark | 49:16309f39cead | 1098 | |
tobyspark | 49:16309f39cead | 1099 | char paramLine[kStringBufferLength]; |
tobyspark | 49:16309f39cead | 1100 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][%3i/%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 49:16309f39cead | 1101 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 49:16309f39cead | 1102 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 49:16309f39cead | 1103 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 49:16309f39cead | 1104 | value, |
tobyspark | 49:16309f39cead | 1105 | settings.editingKeyerSetValue(SPKSettings::maxV)); |
tobyspark | 49:16309f39cead | 1106 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 49:16309f39cead | 1107 | |
tobyspark | 49:16309f39cead | 1108 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, value); |
tobyspark | 49:16309f39cead | 1109 | } |
tobyspark | 49:16309f39cead | 1110 | else if (actionCount == 8) |
tobyspark | 49:16309f39cead | 1111 | { |
tobyspark | 51:98cc27390484 | 1112 | // A save dialog would go here |
tobyspark | 49:16309f39cead | 1113 | |
tobyspark | 49:16309f39cead | 1114 | // Get back to menu |
tobyspark | 49:16309f39cead | 1115 | actionCount = 0; |
tobyspark | 49:16309f39cead | 1116 | selectedMenu = &mixModeMenu; |
tobyspark | 49:16309f39cead | 1117 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1118 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 49:16309f39cead | 1119 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 1120 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 49:16309f39cead | 1121 | } |
tobyspark | 49:16309f39cead | 1122 | } |
tobyspark | 49:16309f39cead | 1123 | |
tobyspark | 51:98cc27390484 | 1124 | void troubleshootingMenuResetHandler(int menuChange, bool action) |
tobyspark | 51:98cc27390484 | 1125 | { |
tobyspark | 51:98cc27390484 | 1126 | static int actionCount = 0; |
tobyspark | 53:0993424e1529 | 1127 | static int state = 0; |
tobyspark | 51:98cc27390484 | 1128 | |
tobyspark | 51:98cc27390484 | 1129 | if (action) actionCount++; |
tobyspark | 51:98cc27390484 | 1130 | |
tobyspark | 51:98cc27390484 | 1131 | if (actionCount == 0) |
tobyspark | 51:98cc27390484 | 1132 | { |
tobyspark | 51:98cc27390484 | 1133 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1134 | |
tobyspark | 51:98cc27390484 | 1135 | state += menuChange; |
tobyspark | 53:0993424e1529 | 1136 | if (state > 1) state = 1; |
tobyspark | 53:0993424e1529 | 1137 | if (state < 0) state = 0; |
tobyspark | 53:0993424e1529 | 1138 | |
tobyspark | 53:0993424e1529 | 1139 | switch (state) |
tobyspark | 51:98cc27390484 | 1140 | { |
tobyspark | 51:98cc27390484 | 1141 | case 0: screen.textToBuffer("1. Controller [Reset/ ]", kMenuLine2); break; |
tobyspark | 51:98cc27390484 | 1142 | case 1: screen.textToBuffer("1. Controller [ /Skip]", kMenuLine2); break; |
tobyspark | 51:98cc27390484 | 1143 | } |
tobyspark | 51:98cc27390484 | 1144 | } |
tobyspark | 51:98cc27390484 | 1145 | if (actionCount == 1) |
tobyspark | 51:98cc27390484 | 1146 | { |
tobyspark | 51:98cc27390484 | 1147 | if (state == 0) |
tobyspark | 51:98cc27390484 | 1148 | { |
tobyspark | 51:98cc27390484 | 1149 | tvOneRGB1Stable = false; |
tobyspark | 51:98cc27390484 | 1150 | tvOneRGB2Stable = false; |
tobyspark | 51:98cc27390484 | 1151 | handleTVOneSources(); |
tobyspark | 51:98cc27390484 | 1152 | |
tobyspark | 51:98cc27390484 | 1153 | settings.editingKeyerSetIndex = -1; |
tobyspark | 51:98cc27390484 | 1154 | keyerParamsSet = -1; |
tobyspark | 51:98cc27390484 | 1155 | bool ok = settings.load(kSPKDFSettingsFilename); |
tobyspark | 51:98cc27390484 | 1156 | if (!ok) settings.loadDefaults(); |
tobyspark | 51:98cc27390484 | 1157 | |
tobyspark | 51:98cc27390484 | 1158 | setMixModeMenuItems(); |
tobyspark | 51:98cc27390484 | 1159 | setResolutionMenuItems(); |
tobyspark | 51:98cc27390484 | 1160 | |
tobyspark | 52:98f557fe93a3 | 1161 | tvOneStatusMessage.addMessage("Controller Reset", kTVOneStatusMessageHoldTime); |
tobyspark | 52:98f557fe93a3 | 1162 | |
tobyspark | 51:98cc27390484 | 1163 | actionCount++; |
tobyspark | 51:98cc27390484 | 1164 | } |
tobyspark | 51:98cc27390484 | 1165 | else if (state == 1) |
tobyspark | 51:98cc27390484 | 1166 | { |
tobyspark | 51:98cc27390484 | 1167 | actionCount++; |
tobyspark | 51:98cc27390484 | 1168 | } |
tobyspark | 51:98cc27390484 | 1169 | |
tobyspark | 51:98cc27390484 | 1170 | state = 0; |
tobyspark | 51:98cc27390484 | 1171 | } |
tobyspark | 51:98cc27390484 | 1172 | if (actionCount == 2) |
tobyspark | 51:98cc27390484 | 1173 | { |
tobyspark | 51:98cc27390484 | 1174 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1175 | |
tobyspark | 51:98cc27390484 | 1176 | state += menuChange; |
tobyspark | 53:0993424e1529 | 1177 | if (state > 1) state = 1; |
tobyspark | 53:0993424e1529 | 1178 | if (state < 0) state = 0; |
tobyspark | 53:0993424e1529 | 1179 | switch (state) |
tobyspark | 51:98cc27390484 | 1180 | { |
tobyspark | 51:98cc27390484 | 1181 | case 0: screen.textToBuffer("2. Processor [Reset/ ]", kMenuLine2); break; |
tobyspark | 51:98cc27390484 | 1182 | case 1: screen.textToBuffer("2. Processor [ /Skip]", kMenuLine2); break; |
tobyspark | 51:98cc27390484 | 1183 | } |
tobyspark | 51:98cc27390484 | 1184 | } |
tobyspark | 51:98cc27390484 | 1185 | if (actionCount == 3) |
tobyspark | 51:98cc27390484 | 1186 | { |
tobyspark | 51:98cc27390484 | 1187 | if (state == 0) |
tobyspark | 51:98cc27390484 | 1188 | { |
tobyspark | 51:98cc27390484 | 1189 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 52:98f557fe93a3 | 1190 | screen.textToBuffer("Find MENU+STANDBY [NEXT]", kMenuLine2); |
tobyspark | 51:98cc27390484 | 1191 | } |
tobyspark | 51:98cc27390484 | 1192 | else if (state == 1) |
tobyspark | 51:98cc27390484 | 1193 | { |
tobyspark | 51:98cc27390484 | 1194 | actionCount = actionCount + 3; // extra stage to skip |
tobyspark | 51:98cc27390484 | 1195 | } |
tobyspark | 51:98cc27390484 | 1196 | |
tobyspark | 51:98cc27390484 | 1197 | state = 0; |
tobyspark | 51:98cc27390484 | 1198 | } |
tobyspark | 51:98cc27390484 | 1199 | if (actionCount == 4) |
tobyspark | 51:98cc27390484 | 1200 | { |
tobyspark | 51:98cc27390484 | 1201 | Timer timer; |
tobyspark | 51:98cc27390484 | 1202 | timer.start(); |
tobyspark | 51:98cc27390484 | 1203 | |
tobyspark | 51:98cc27390484 | 1204 | while (timer.read_ms() < 16000) |
tobyspark | 51:98cc27390484 | 1205 | { |
tobyspark | 51:98cc27390484 | 1206 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1207 | char messageBuffer[kStringBufferLength]; |
tobyspark | 52:98f557fe93a3 | 1208 | snprintf(messageBuffer, kStringBufferLength,"Hold buttons for [%i s]", 15 - (timer.read_ms() / 1000)); |
tobyspark | 51:98cc27390484 | 1209 | screen.textToBuffer(messageBuffer, kMenuLine2); |
tobyspark | 51:98cc27390484 | 1210 | screen.sendBuffer(); |
tobyspark | 51:98cc27390484 | 1211 | } |
tobyspark | 51:98cc27390484 | 1212 | |
tobyspark | 51:98cc27390484 | 1213 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1214 | screen.textToBuffer("Hold buttons for [NEXT]", kMenuLine2); |
tobyspark | 51:98cc27390484 | 1215 | } |
tobyspark | 51:98cc27390484 | 1216 | if (actionCount == 5) |
tobyspark | 51:98cc27390484 | 1217 | { |
tobyspark | 51:98cc27390484 | 1218 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1219 | screen.textToBuffer("Updating processor [---]", kMenuLine2); |
tobyspark | 51:98cc27390484 | 1220 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 51:98cc27390484 | 1221 | screen.textToBuffer("Sending...", kTVOneStatusLine); |
tobyspark | 51:98cc27390484 | 1222 | screen.sendBuffer(); |
tobyspark | 51:98cc27390484 | 1223 | |
tobyspark | 51:98cc27390484 | 1224 | bool ok = conformProcessor(); |
tobyspark | 51:98cc27390484 | 1225 | |
tobyspark | 51:98cc27390484 | 1226 | std::string sendOK = ok ? "TVOne: Reset success" : "Send Error: Reset"; |
tobyspark | 51:98cc27390484 | 1227 | |
tobyspark | 51:98cc27390484 | 1228 | tvOneStatusMessage.addMessage(sendOK, kTVOneStatusMessageHoldTime); |
tobyspark | 51:98cc27390484 | 1229 | |
tobyspark | 51:98cc27390484 | 1230 | tvOneRGB1Stable = false; |
tobyspark | 51:98cc27390484 | 1231 | tvOneRGB2Stable = false; |
tobyspark | 51:98cc27390484 | 1232 | handleTVOneSources(); |
tobyspark | 51:98cc27390484 | 1233 | |
tobyspark | 51:98cc27390484 | 1234 | actionCount++; |
tobyspark | 51:98cc27390484 | 1235 | } |
tobyspark | 51:98cc27390484 | 1236 | if (actionCount == 6) |
tobyspark | 51:98cc27390484 | 1237 | { |
tobyspark | 52:98f557fe93a3 | 1238 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1239 | screen.textToBuffer("3. No more steps [DONE]", kMenuLine2); |
tobyspark | 51:98cc27390484 | 1240 | } |
tobyspark | 51:98cc27390484 | 1241 | if (actionCount == 7) |
tobyspark | 51:98cc27390484 | 1242 | { |
tobyspark | 51:98cc27390484 | 1243 | // Get back to menu |
tobyspark | 51:98cc27390484 | 1244 | actionCount = 0; |
tobyspark | 51:98cc27390484 | 1245 | selectedMenu = &troubleshootingMenu; |
tobyspark | 51:98cc27390484 | 1246 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 51:98cc27390484 | 1247 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 51:98cc27390484 | 1248 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 51:98cc27390484 | 1249 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 51:98cc27390484 | 1250 | } |
tobyspark | 51:98cc27390484 | 1251 | } |
tobyspark | 51:98cc27390484 | 1252 | |
tobyspark | 0:87aab40d5806 | 1253 | int main() |
tobyspark | 0:87aab40d5806 | 1254 | { |
tobyspark | 0:87aab40d5806 | 1255 | if (debug) |
tobyspark | 0:87aab40d5806 | 1256 | { |
tobyspark | 0:87aab40d5806 | 1257 | debug->printf("\r\n\r\n"); |
tobyspark | 0:87aab40d5806 | 1258 | debug->printf("*spark d-fuser -----------\r\n"); |
tobyspark | 0:87aab40d5806 | 1259 | debug->printf(" debug channel\r\n"); |
tobyspark | 0:87aab40d5806 | 1260 | } |
tobyspark | 2:50043054e4f7 | 1261 | |
tobyspark | 2:50043054e4f7 | 1262 | // Set display font |
tobyspark | 2:50043054e4f7 | 1263 | screen.fontStartCharacter = &characterBytesStartChar; |
tobyspark | 2:50043054e4f7 | 1264 | screen.fontEndCharacter = &characterBytesEndChar; |
tobyspark | 2:50043054e4f7 | 1265 | screen.fontCharacters = characterBytes; |
tobyspark | 2:50043054e4f7 | 1266 | |
tobyspark | 0:87aab40d5806 | 1267 | // Splash screen |
tobyspark | 30:873979018850 | 1268 | string softwareLine = "SW "; |
tobyspark | 30:873979018850 | 1269 | softwareLine += kSPKDFSoftwareVersion; |
tobyspark | 2:50043054e4f7 | 1270 | screen.imageToBuffer(spkDisplayLogo); |
tobyspark | 0:87aab40d5806 | 1271 | screen.textToBuffer("SPK:D-Fuser",0); |
tobyspark | 30:873979018850 | 1272 | screen.textToBuffer(softwareLine,1); |
tobyspark | 5:f8b285ca41ba | 1273 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 1274 | |
tobyspark | 11:0783cfbeb746 | 1275 | // Load saved settings |
tobyspark | 16:52484666b323 | 1276 | bool settingsAreCustom = false; |
tobyspark | 16:52484666b323 | 1277 | settingsAreCustom = settings.load(kSPKDFSettingsFilename); |
tobyspark | 30:873979018850 | 1278 | if (settingsAreCustom) |
tobyspark | 30:873979018850 | 1279 | { |
tobyspark | 30:873979018850 | 1280 | softwareLine += "; ini OK"; |
tobyspark | 30:873979018850 | 1281 | screen.textToBuffer(softwareLine, 1); |
tobyspark | 30:873979018850 | 1282 | } |
tobyspark | 30:873979018850 | 1283 | |
tobyspark | 0:87aab40d5806 | 1284 | // Set menu structure |
tobyspark | 0:87aab40d5806 | 1285 | mixModeMenu.title = "Mix Mode"; |
tobyspark | 27:27851d3d2bba | 1286 | setMixModeMenuItems(); |
tobyspark | 24:49c6624119ae | 1287 | |
tobyspark | 29:95a7efe30527 | 1288 | mixModeAdditiveMenu.title = "Crossfade"; |
tobyspark | 49:16309f39cead | 1289 | mixModeAdditiveMenu.addMenuItem(SPKMenuItem(&mixModeAdditiveMenuHandler)); |
tobyspark | 36:8b5c75c8bc23 | 1290 | |
tobyspark | 49:16309f39cead | 1291 | mixModeUpdateKeyMenu.title = "Update Keyer Settings?"; |
tobyspark | 49:16309f39cead | 1292 | mixModeUpdateKeyMenu.addMenuItem(SPKMenuItem(mixModeUpdateKeyMenuHandler)); |
tobyspark | 36:8b5c75c8bc23 | 1293 | |
tobyspark | 0:87aab40d5806 | 1294 | resolutionMenu.title = "Resolution"; |
tobyspark | 27:27851d3d2bba | 1295 | setResolutionMenuItems(); |
tobyspark | 0:87aab40d5806 | 1296 | |
tobyspark | 27:27851d3d2bba | 1297 | commsMenu.title = "Network Mode"; |
tobyspark | 27:27851d3d2bba | 1298 | setCommsMenuItems(); |
tobyspark | 23:909928cafb95 | 1299 | |
tobyspark | 51:98cc27390484 | 1300 | advancedMenu.title = "Advanced Commands"; |
tobyspark | 51:98cc27390484 | 1301 | advancedMenu.addMenuItem(SPKMenuItem("Processor full conform", advancedConformUploadProcessor)); |
tobyspark | 51:98cc27390484 | 1302 | advancedMenu.addMenuItem(SPKMenuItem("Back to Troubleshooting Menu", &troubleshootingMenu)); |
tobyspark | 51:98cc27390484 | 1303 | |
tobyspark | 51:98cc27390484 | 1304 | troubleshootingMenu.title = "Troubleshooting"; |
tobyspark | 51:98cc27390484 | 1305 | troubleshootingMenuHDCP.title = "HDCP - Can Block DVI"; |
tobyspark | 51:98cc27390484 | 1306 | troubleshootingMenuHDCP.addMenuItem(SPKMenuItem(&troubleshootingMenuHDCPHandler)); |
tobyspark | 51:98cc27390484 | 1307 | troubleshootingMenu.addMenuItem(SPKMenuItem(troubleshootingMenuHDCP.title, &troubleshootingMenuHDCP)); |
tobyspark | 51:98cc27390484 | 1308 | troubleshootingMenuEDID.title = "EDID - Advertises Res's"; |
tobyspark | 51:98cc27390484 | 1309 | troubleshootingMenuEDID.addMenuItem(SPKMenuItem(troubleshootingMenuEDIDHandler)); |
tobyspark | 51:98cc27390484 | 1310 | troubleshootingMenu.addMenuItem(SPKMenuItem(troubleshootingMenuEDID.title, &troubleshootingMenuEDID)); |
tobyspark | 51:98cc27390484 | 1311 | troubleshootingMenuReset.title = "Output - Mixing Wrong"; |
tobyspark | 51:98cc27390484 | 1312 | troubleshootingMenuReset.addMenuItem(SPKMenuItem(&troubleshootingMenuResetHandler)); |
tobyspark | 51:98cc27390484 | 1313 | troubleshootingMenu.addMenuItem(SPKMenuItem(troubleshootingMenuReset.title, &troubleshootingMenuReset)); |
tobyspark | 51:98cc27390484 | 1314 | troubleshootingMenu.addMenuItem(SPKMenuItem(advancedMenu.title, &advancedMenu)); |
tobyspark | 51:98cc27390484 | 1315 | troubleshootingMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 23:909928cafb95 | 1316 | |
tobyspark | 0:87aab40d5806 | 1317 | mainMenu.title = "Main Menu"; |
tobyspark | 24:49c6624119ae | 1318 | mainMenu.addMenuItem(SPKMenuItem(mixModeMenu.title, &mixModeMenu)); |
tobyspark | 24:49c6624119ae | 1319 | mainMenu.addMenuItem(SPKMenuItem(resolutionMenu.title, &resolutionMenu)); |
tobyspark | 24:49c6624119ae | 1320 | mainMenu.addMenuItem(SPKMenuItem(commsMenu.title, &commsMenu)); |
tobyspark | 51:98cc27390484 | 1321 | mainMenu.addMenuItem(SPKMenuItem(troubleshootingMenu.title, &troubleshootingMenu)); |
tobyspark | 23:909928cafb95 | 1322 | |
tobyspark | 0:87aab40d5806 | 1323 | selectedMenu = &mainMenu; |
tobyspark | 23:909928cafb95 | 1324 | |
tobyspark | 0:87aab40d5806 | 1325 | // Misc I/O stuff |
tobyspark | 0:87aab40d5806 | 1326 | |
tobyspark | 0:87aab40d5806 | 1327 | fadeAPO.period(0.001); |
tobyspark | 0:87aab40d5806 | 1328 | fadeBPO.period(0.001); |
tobyspark | 48:c0fedfa8c525 | 1329 | |
tobyspark | 48:c0fedfa8c525 | 1330 | // If we do not have two solid sources, act on this as we rely on the window having a source for crossfade behaviour |
tobyspark | 48:c0fedfa8c525 | 1331 | // Once we've had two solid inputs, don't check any more as we're ok as the unit is set to hold on last frame. |
tobyspark | 49:16309f39cead | 1332 | handleTVOneSources(); |
tobyspark | 49:16309f39cead | 1333 | |
tobyspark | 49:16309f39cead | 1334 | // Processor can have been power-on saved with a keyer on, lets revert |
tobyspark | 49:16309f39cead | 1335 | actionMixMode(); |
tobyspark | 0:87aab40d5806 | 1336 | |
tobyspark | 12:c270870bdd23 | 1337 | // Display menu and framing lines |
tobyspark | 0:87aab40d5806 | 1338 | screen.horizLineToBuffer(kMenuLine1*pixInPage - 1); |
tobyspark | 0:87aab40d5806 | 1339 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 1340 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 1341 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 1342 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 1343 | screen.horizLineToBuffer(kMenuLine2*pixInPage + pixInPage); |
tobyspark | 1:f9fca21102e0 | 1344 | screen.horizLineToBuffer(kCommsStatusLine*pixInPage - 1); |
tobyspark | 1:f9fca21102e0 | 1345 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 48:c0fedfa8c525 | 1346 | screen.textToBuffer(tvOneStatusMessage.message(), kTVOneStatusLine); |
tobyspark | 33:e6672a9bd571 | 1347 | screen.sendBuffer(); |
tobyspark | 33:e6672a9bd571 | 1348 | |
tobyspark | 0:87aab40d5806 | 1349 | //// CONTROLS TEST |
tobyspark | 0:87aab40d5806 | 1350 | |
tobyspark | 0:87aab40d5806 | 1351 | while (0) { |
tobyspark | 0:87aab40d5806 | 1352 | if (debug) debug->printf("xFade: %f, fadeOut: %f, tapLeft %i, tapRight: %i encPos: %i encChange:%i encHasPressed:%i \r\n" , xFadeAIN.read(), fadeUpAIN.read(), tapLeftDIN.read(), tapRightDIN.read(), menuEnc.getPos(), menuEnc.getChange(), menuEnc.hasPressed()); |
tobyspark | 0:87aab40d5806 | 1353 | } |
tobyspark | 0:87aab40d5806 | 1354 | |
tobyspark | 0:87aab40d5806 | 1355 | //// MIXER RUN |
tobyspark | 0:87aab40d5806 | 1356 | |
tobyspark | 8:d46cc49f0f37 | 1357 | while (1) |
tobyspark | 49:16309f39cead | 1358 | { |
tobyspark | 1:f9fca21102e0 | 1359 | //// Task background things |
tobyspark | 33:e6672a9bd571 | 1360 | if ((osc || artNet) && rj45Mode == rj45Ethernet) |
tobyspark | 5:f8b285ca41ba | 1361 | { |
tobyspark | 5:f8b285ca41ba | 1362 | Net::poll(); |
tobyspark | 5:f8b285ca41ba | 1363 | } |
tobyspark | 5:f8b285ca41ba | 1364 | |
tobyspark | 5:f8b285ca41ba | 1365 | //// RJ45 SWITCH |
tobyspark | 5:f8b285ca41ba | 1366 | |
tobyspark | 5:f8b285ca41ba | 1367 | if (rj45ModeDIN != rj45Mode) |
tobyspark | 1:f9fca21102e0 | 1368 | { |
tobyspark | 23:909928cafb95 | 1369 | if (debug) debug->printf("Handling RJ45 mode change\r\n"); |
tobyspark | 27:27851d3d2bba | 1370 | |
tobyspark | 5:f8b285ca41ba | 1371 | // update state |
tobyspark | 5:f8b285ca41ba | 1372 | rj45Mode = rj45ModeDIN; |
tobyspark | 27:27851d3d2bba | 1373 | |
tobyspark | 27:27851d3d2bba | 1374 | setCommsMenuItems(); |
tobyspark | 5:f8b285ca41ba | 1375 | |
tobyspark | 5:f8b285ca41ba | 1376 | // cancel old comms |
tobyspark | 5:f8b285ca41ba | 1377 | commsMode = commsNone; |
tobyspark | 5:f8b285ca41ba | 1378 | commsMenu = commsMode; |
tobyspark | 5:f8b285ca41ba | 1379 | |
tobyspark | 5:f8b285ca41ba | 1380 | // refresh display |
tobyspark | 23:909928cafb95 | 1381 | if (selectedMenu == &commsMenu) |
tobyspark | 23:909928cafb95 | 1382 | { |
tobyspark | 33:e6672a9bd571 | 1383 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 33:e6672a9bd571 | 1384 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 23:909928cafb95 | 1385 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 23:909928cafb95 | 1386 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 23:909928cafb95 | 1387 | } |
tobyspark | 5:f8b285ca41ba | 1388 | if (rj45Mode == rj45Ethernet) screen.textToBuffer("RJ45: Ethernet Engaged", kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 1389 | if (rj45Mode == rj45DMX) screen.textToBuffer("RJ45: DMX Engaged", kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 1390 | } |
tobyspark | 1:f9fca21102e0 | 1391 | |
tobyspark | 0:87aab40d5806 | 1392 | //// MENU |
tobyspark | 0:87aab40d5806 | 1393 | |
tobyspark | 0:87aab40d5806 | 1394 | int menuChange = menuEnc.getChange(); |
tobyspark | 0:87aab40d5806 | 1395 | |
tobyspark | 0:87aab40d5806 | 1396 | // Update GUI |
tobyspark | 0:87aab40d5806 | 1397 | if (menuChange != 0) |
tobyspark | 0:87aab40d5806 | 1398 | { |
tobyspark | 49:16309f39cead | 1399 | if (selectedMenu->selectedItem().type == SPKMenuItem::hasHandler) |
tobyspark | 24:49c6624119ae | 1400 | { |
tobyspark | 49:16309f39cead | 1401 | selectedMenu->selectedItem().payload.handler(menuChange, false); |
tobyspark | 24:49c6624119ae | 1402 | } |
tobyspark | 24:49c6624119ae | 1403 | else |
tobyspark | 24:49c6624119ae | 1404 | { |
tobyspark | 24:49c6624119ae | 1405 | if (debug) debug->printf("Menu changed by %i\r\n", menuChange); |
tobyspark | 24:49c6624119ae | 1406 | |
tobyspark | 24:49c6624119ae | 1407 | *selectedMenu = selectedMenu->selectedIndex() + menuChange; |
tobyspark | 24:49c6624119ae | 1408 | |
tobyspark | 24:49c6624119ae | 1409 | // update OLED line 2 here |
tobyspark | 24:49c6624119ae | 1410 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 24:49c6624119ae | 1411 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 24:49c6624119ae | 1412 | |
tobyspark | 24:49c6624119ae | 1413 | if (debug) debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 24:49c6624119ae | 1414 | } |
tobyspark | 0:87aab40d5806 | 1415 | } |
tobyspark | 0:87aab40d5806 | 1416 | |
tobyspark | 0:87aab40d5806 | 1417 | // Action menu item |
tobyspark | 0:87aab40d5806 | 1418 | if (menuEnc.hasPressed()) |
tobyspark | 0:87aab40d5806 | 1419 | { |
tobyspark | 0:87aab40d5806 | 1420 | if (debug) debug->printf("Action Menu Item!\r\n"); |
tobyspark | 21:f9d63cb7cedb | 1421 | |
tobyspark | 0:87aab40d5806 | 1422 | // Are we changing menus? |
tobyspark | 23:909928cafb95 | 1423 | if (selectedMenu->selectedItem().type == SPKMenuItem::changesToMenu) |
tobyspark | 0:87aab40d5806 | 1424 | { |
tobyspark | 31:01845a2347ff | 1425 | // If we're exiting the menu, we should set its selected index back to the menu's beginning... |
tobyspark | 31:01845a2347ff | 1426 | SPKMenu* menuToReset = selectedMenu->selectedItem().payload.menu == &mainMenu? selectedMenu : NULL; |
tobyspark | 31:01845a2347ff | 1427 | |
tobyspark | 31:01845a2347ff | 1428 | // point selected menu pointer to the new menu pointer |
tobyspark | 23:909928cafb95 | 1429 | selectedMenu = selectedMenu->selectedItem().payload.menu; |
tobyspark | 0:87aab40d5806 | 1430 | |
tobyspark | 31:01845a2347ff | 1431 | // ...doing this, of course, after we've used the value |
tobyspark | 31:01845a2347ff | 1432 | if (menuToReset) *menuToReset = 0; |
tobyspark | 31:01845a2347ff | 1433 | |
tobyspark | 0:87aab40d5806 | 1434 | // update OLED lines 1&2 |
tobyspark | 0:87aab40d5806 | 1435 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 1436 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 1437 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 1438 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 1439 | |
tobyspark | 49:16309f39cead | 1440 | if (selectedMenu->selectedItem().type == SPKMenuItem::hasHandler) |
tobyspark | 49:16309f39cead | 1441 | { |
tobyspark | 49:16309f39cead | 1442 | selectedMenu->selectedItem().payload.handler(0, false); |
tobyspark | 49:16309f39cead | 1443 | } |
tobyspark | 49:16309f39cead | 1444 | |
tobyspark | 0:87aab40d5806 | 1445 | if (debug) |
tobyspark | 0:87aab40d5806 | 1446 | { |
tobyspark | 0:87aab40d5806 | 1447 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 1448 | debug->printf("%s \r\n", selectedMenu->title.c_str()); |
tobyspark | 0:87aab40d5806 | 1449 | debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 0:87aab40d5806 | 1450 | } |
tobyspark | 49:16309f39cead | 1451 | } |
tobyspark | 49:16309f39cead | 1452 | else if (selectedMenu->selectedItem().type == SPKMenuItem::hasHandler) |
tobyspark | 49:16309f39cead | 1453 | { |
tobyspark | 49:16309f39cead | 1454 | selectedMenu->selectedItem().payload.handler(0, true); |
tobyspark | 0:87aab40d5806 | 1455 | } |
tobyspark | 0:87aab40d5806 | 1456 | // With that out of the way, we should be actioning a specific menu's payload? |
tobyspark | 44:723e65413ebe | 1457 | else if (selectedMenu == &mixModeMenu) |
tobyspark | 44:723e65413ebe | 1458 | { |
tobyspark | 44:723e65413ebe | 1459 | mixMode = mixModeMenu.selectedItem().payload.command[0]; |
tobyspark | 49:16309f39cead | 1460 | |
tobyspark | 49:16309f39cead | 1461 | // the spanner in the works: mixBlend and mixAdditive are now both index 0 in the menu |
tobyspark | 49:16309f39cead | 1462 | if (mixMode >= mixKeyStartIndex) |
tobyspark | 49:16309f39cead | 1463 | { |
tobyspark | 49:16309f39cead | 1464 | // adjust for the two-into-one spanner |
tobyspark | 49:16309f39cead | 1465 | mixMode += 1; |
tobyspark | 49:16309f39cead | 1466 | |
tobyspark | 49:16309f39cead | 1467 | // if its the second click on the keying mode, lets edit the parameters |
tobyspark | 49:16309f39cead | 1468 | if (mixMode == mixModeOld) |
tobyspark | 49:16309f39cead | 1469 | { |
tobyspark | 49:16309f39cead | 1470 | selectedMenu = &mixModeUpdateKeyMenu; |
tobyspark | 49:16309f39cead | 1471 | |
tobyspark | 49:16309f39cead | 1472 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 49:16309f39cead | 1473 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 49:16309f39cead | 1474 | |
tobyspark | 49:16309f39cead | 1475 | selectedMenu->selectedItem().payload.handler(0, false); |
tobyspark | 49:16309f39cead | 1476 | } |
tobyspark | 49:16309f39cead | 1477 | } |
tobyspark | 44:723e65413ebe | 1478 | } |
tobyspark | 0:87aab40d5806 | 1479 | else if (selectedMenu == &resolutionMenu) |
tobyspark | 0:87aab40d5806 | 1480 | { |
tobyspark | 49:16309f39cead | 1481 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 1482 | screen.textToBuffer("Setting Resolution...", kTVOneStatusLine); |
tobyspark | 49:16309f39cead | 1483 | screen.sendBuffer(); |
tobyspark | 49:16309f39cead | 1484 | |
tobyspark | 44:723e65413ebe | 1485 | bool ok; |
tobyspark | 31:01845a2347ff | 1486 | int32_t slot = tvOneEDIDPassthrough ? EDIDPassthroughSlot : resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 31:01845a2347ff | 1487 | |
tobyspark | 44:723e65413ebe | 1488 | ok = tvOne.setResolution(resolutionMenu.selectedItem().payload.command[0], slot); |
tobyspark | 0:87aab40d5806 | 1489 | |
tobyspark | 35:d5d9f0838f99 | 1490 | // Save new resolution and EDID into TV One unit for power-on. Cycling TV One power sometimes needed for EDID. Pffft. |
tobyspark | 44:723e65413ebe | 1491 | if (ok) tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 35:d5d9f0838f99 | 1492 | |
tobyspark | 25:3b519ef70341 | 1493 | string sentOK; |
tobyspark | 0:87aab40d5806 | 1494 | if (ok) sentOK = "Sent: "; |
tobyspark | 0:87aab40d5806 | 1495 | else sentOK = "Send Error: "; |
tobyspark | 0:87aab40d5806 | 1496 | |
tobyspark | 26:0299f8760715 | 1497 | char sentMSGBuffer[kStringBufferLength]; |
tobyspark | 26:0299f8760715 | 1498 | snprintf(sentMSGBuffer, kStringBufferLength,"Res %i, EDID %i", resolutionMenu.selectedItem().payload.command[0], resolutionMenu.selectedItem().payload.command[1]); |
tobyspark | 0:87aab40d5806 | 1499 | |
tobyspark | 48:c0fedfa8c525 | 1500 | tvOneStatusMessage.addMessage(sentOK + sentMSGBuffer, kTVOneStatusMessageHoldTime); |
tobyspark | 0:87aab40d5806 | 1501 | |
tobyspark | 0:87aab40d5806 | 1502 | if (debug) { debug->printf("Changing resolution"); } |
tobyspark | 0:87aab40d5806 | 1503 | } |
tobyspark | 1:f9fca21102e0 | 1504 | else if (selectedMenu == &commsMenu) |
tobyspark | 1:f9fca21102e0 | 1505 | { |
tobyspark | 26:0299f8760715 | 1506 | string commsTypeString = "Network:"; |
tobyspark | 26:0299f8760715 | 1507 | char commsStatusBuffer[kStringBufferLength] = "--"; |
tobyspark | 1:f9fca21102e0 | 1508 | |
tobyspark | 1:f9fca21102e0 | 1509 | // Tear down any existing comms |
tobyspark | 1:f9fca21102e0 | 1510 | // This is the action of commsNone |
tobyspark | 1:f9fca21102e0 | 1511 | // And also clears the way for other comms actions |
tobyspark | 26:0299f8760715 | 1512 | commsMode = commsNone; |
tobyspark | 5:f8b285ca41ba | 1513 | if (osc) {delete osc; osc = NULL;} |
tobyspark | 5:f8b285ca41ba | 1514 | if (ethernet) {delete ethernet; ethernet = NULL;} |
tobyspark | 33:e6672a9bd571 | 1515 | if (artNet) |
tobyspark | 33:e6672a9bd571 | 1516 | { |
tobyspark | 33:e6672a9bd571 | 1517 | artNet->ArtPollReply.NumPorts = 0; |
tobyspark | 33:e6672a9bd571 | 1518 | strcpy(artNet->ArtPollReply.NodeReport, "Shutdown"); |
tobyspark | 33:e6672a9bd571 | 1519 | artNet->SendArtPollReply(); |
tobyspark | 33:e6672a9bd571 | 1520 | artNet->Done(); |
tobyspark | 33:e6672a9bd571 | 1521 | delete artNet; |
tobyspark | 33:e6672a9bd571 | 1522 | artNet = NULL; |
tobyspark | 33:e6672a9bd571 | 1523 | } |
tobyspark | 5:f8b285ca41ba | 1524 | if (dmx) {delete dmx; dmx = NULL;} |
tobyspark | 5:f8b285ca41ba | 1525 | |
tobyspark | 5:f8b285ca41ba | 1526 | // Ensure we can't change to comms modes the hardware isn't switched to |
tobyspark | 23:909928cafb95 | 1527 | if (rj45Mode == rj45DMX && (commsMenu.selectedItem().payload.command[0] == commsOSC || commsMenu.selectedItem().payload.command[0] == commsArtNet)) |
tobyspark | 1:f9fca21102e0 | 1528 | { |
tobyspark | 5:f8b285ca41ba | 1529 | commsTypeString = "RJ45 not in Ethernet mode"; |
tobyspark | 5:f8b285ca41ba | 1530 | } |
tobyspark | 23:909928cafb95 | 1531 | else if (rj45Mode == rj45Ethernet && (commsMenu.selectedItem().payload.command[0] == commsDMXIn || commsMenu.selectedItem().payload.command[0] == commsDMXOut)) |
tobyspark | 5:f8b285ca41ba | 1532 | { |
tobyspark | 5:f8b285ca41ba | 1533 | commsTypeString = "RJ45 not in DMX mode"; |
tobyspark | 5:f8b285ca41ba | 1534 | } |
tobyspark | 5:f8b285ca41ba | 1535 | // Action! |
tobyspark | 23:909928cafb95 | 1536 | else if (commsMenu.selectedItem().payload.command[0] == commsOSC) |
tobyspark | 5:f8b285ca41ba | 1537 | { |
tobyspark | 5:f8b285ca41ba | 1538 | commsMode = commsOSC; |
tobyspark | 5:f8b285ca41ba | 1539 | commsTypeString = "OSC: "; |
tobyspark | 1:f9fca21102e0 | 1540 | |
tobyspark | 1:f9fca21102e0 | 1541 | ethernet = new EthernetNetIf( |
tobyspark | 1:f9fca21102e0 | 1542 | IpAddr(kOSCMbedIPAddress), |
tobyspark | 1:f9fca21102e0 | 1543 | IpAddr(kOSCMbedSubnetMask), |
tobyspark | 1:f9fca21102e0 | 1544 | IpAddr(kOSCMbedGateway), |
tobyspark | 1:f9fca21102e0 | 1545 | IpAddr(kOSCMbedDNS) |
tobyspark | 1:f9fca21102e0 | 1546 | ); |
tobyspark | 3:033d2b7768f3 | 1547 | |
tobyspark | 1:f9fca21102e0 | 1548 | EthernetErr ethError = ethernet->setup(); |
tobyspark | 1:f9fca21102e0 | 1549 | if(ethError) |
tobyspark | 1:f9fca21102e0 | 1550 | { |
tobyspark | 1:f9fca21102e0 | 1551 | if (debug) debug->printf("Ethernet setup error, %d", ethError); |
tobyspark | 26:0299f8760715 | 1552 | snprintf(commsStatusBuffer, kStringBufferLength, "Ethernet setup failed"); |
tobyspark | 5:f8b285ca41ba | 1553 | commsMenu = commsNone; |
tobyspark | 1:f9fca21102e0 | 1554 | // break out of here. this setup should be a function that returns a boolean |
tobyspark | 1:f9fca21102e0 | 1555 | } |
tobyspark | 1:f9fca21102e0 | 1556 | |
tobyspark | 1:f9fca21102e0 | 1557 | osc = new OSCClass(); |
tobyspark | 33:e6672a9bd571 | 1558 | osc->setReceiveMessage(&receiveMessage); |
tobyspark | 1:f9fca21102e0 | 1559 | osc->begin(kOSCMbedPort); |
tobyspark | 1:f9fca21102e0 | 1560 | |
tobyspark | 54:e8606eaa47a3 | 1561 | uint8_t destIP[] = { kOSCDestIPAddress }; |
tobyspark | 54:e8606eaa47a3 | 1562 | sendMessage.setIp( destIP ); |
tobyspark | 54:e8606eaa47a3 | 1563 | sendMessage.setPort( kOSCDestPort ); |
tobyspark | 54:e8606eaa47a3 | 1564 | |
tobyspark | 26:0299f8760715 | 1565 | snprintf(commsStatusBuffer, kStringBufferLength, "Listening on %i", kOSCMbedPort); |
tobyspark | 1:f9fca21102e0 | 1566 | } |
tobyspark | 23:909928cafb95 | 1567 | else if (commsMenu.selectedItem().payload.command[0] == commsArtNet) |
tobyspark | 1:f9fca21102e0 | 1568 | { |
tobyspark | 5:f8b285ca41ba | 1569 | commsMode = commsArtNet; |
tobyspark | 5:f8b285ca41ba | 1570 | commsTypeString = "ArtNet: "; |
tobyspark | 3:033d2b7768f3 | 1571 | |
tobyspark | 3:033d2b7768f3 | 1572 | artNet = new DmxArtNet(); |
tobyspark | 1:f9fca21102e0 | 1573 | |
tobyspark | 3:033d2b7768f3 | 1574 | artNet->BindIpAddress = IpAddr(kArtNetBindIPAddress); |
tobyspark | 3:033d2b7768f3 | 1575 | artNet->BCastAddress = IpAddr(kArtNetBroadcastAddress); |
tobyspark | 3:033d2b7768f3 | 1576 | |
tobyspark | 3:033d2b7768f3 | 1577 | artNet->InitArtPollReplyDefaults(); |
tobyspark | 3:033d2b7768f3 | 1578 | |
tobyspark | 33:e6672a9bd571 | 1579 | artNet->ArtPollReply.PortType[0] = 128; // Bit 7 = Set is this channel can output data from the Art-Net Network. |
tobyspark | 33:e6672a9bd571 | 1580 | artNet->ArtPollReply.GoodOutput[0] = 128; // Bit 7 = Set – Data is being transmitted. |
tobyspark | 33:e6672a9bd571 | 1581 | artNet->ArtPollReply.PortType[2] = 64; // Bit 6 = Set if this channel can input onto the Art-NetNetwork. |
tobyspark | 33:e6672a9bd571 | 1582 | artNet->ArtPollReply.GoodInput[2] = 128; // Bit 7 = Set – Data received. |
tobyspark | 3:033d2b7768f3 | 1583 | |
tobyspark | 3:033d2b7768f3 | 1584 | artNet->Init(); |
tobyspark | 3:033d2b7768f3 | 1585 | artNet->SendArtPollReply(); // announce to art-net nodes |
tobyspark | 3:033d2b7768f3 | 1586 | |
tobyspark | 26:0299f8760715 | 1587 | snprintf(commsStatusBuffer, kStringBufferLength, "Listening"); |
tobyspark | 1:f9fca21102e0 | 1588 | } |
tobyspark | 23:909928cafb95 | 1589 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXIn) |
tobyspark | 1:f9fca21102e0 | 1590 | { |
tobyspark | 5:f8b285ca41ba | 1591 | commsMode = commsDMXIn; |
tobyspark | 5:f8b285ca41ba | 1592 | commsTypeString = "DMX In: "; |
tobyspark | 1:f9fca21102e0 | 1593 | |
tobyspark | 5:f8b285ca41ba | 1594 | dmxDirectionDOUT = 0; |
tobyspark | 5:f8b285ca41ba | 1595 | |
tobyspark | 5:f8b285ca41ba | 1596 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 1:f9fca21102e0 | 1597 | } |
tobyspark | 23:909928cafb95 | 1598 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 1599 | { |
tobyspark | 5:f8b285ca41ba | 1600 | commsMode = commsDMXOut; |
tobyspark | 5:f8b285ca41ba | 1601 | commsTypeString = "DMX Out: "; |
tobyspark | 5:f8b285ca41ba | 1602 | |
tobyspark | 5:f8b285ca41ba | 1603 | dmxDirectionDOUT = 1; |
tobyspark | 5:f8b285ca41ba | 1604 | |
tobyspark | 5:f8b285ca41ba | 1605 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 5:f8b285ca41ba | 1606 | } |
tobyspark | 5:f8b285ca41ba | 1607 | |
tobyspark | 1:f9fca21102e0 | 1608 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 25:3b519ef70341 | 1609 | screen.textToBuffer(commsTypeString + commsStatusBuffer, kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 1610 | } |
tobyspark | 12:c270870bdd23 | 1611 | else if (selectedMenu == &advancedMenu) |
tobyspark | 12:c270870bdd23 | 1612 | { |
tobyspark | 51:98cc27390484 | 1613 | if (advancedMenu.selectedItem().payload.command[0] == advancedConformUploadProcessor) |
tobyspark | 41:00d1cd3b2af2 | 1614 | { |
tobyspark | 41:00d1cd3b2af2 | 1615 | bool ok = true; |
tobyspark | 41:00d1cd3b2af2 | 1616 | |
tobyspark | 41:00d1cd3b2af2 | 1617 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1618 | screen.textToBuffer("Uploading...", kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1619 | screen.sendBuffer(); |
tobyspark | 41:00d1cd3b2af2 | 1620 | |
tobyspark | 41:00d1cd3b2af2 | 1621 | ok = ok && uploadToProcessor(); |
tobyspark | 41:00d1cd3b2af2 | 1622 | |
tobyspark | 41:00d1cd3b2af2 | 1623 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 1624 | screen.textToBuffer("Conforming...", kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 1625 | screen.sendBuffer(); |
tobyspark | 20:8b92d7922c48 | 1626 | |
tobyspark | 41:00d1cd3b2af2 | 1627 | ok = ok && conformProcessor(); |
tobyspark | 17:fc68d40b8b1f | 1628 | |
tobyspark | 17:fc68d40b8b1f | 1629 | std::string sendOK = ok ? "Conform success" : "Send Error: Conform"; |
tobyspark | 17:fc68d40b8b1f | 1630 | |
tobyspark | 48:c0fedfa8c525 | 1631 | tvOneStatusMessage.addMessage(sendOK, kTVOneStatusMessageHoldTime); |
tobyspark | 17:fc68d40b8b1f | 1632 | } |
tobyspark | 51:98cc27390484 | 1633 | // else if (advancedMenu.selectedItem().payload.command[0] == advancedSetResolutions) |
tobyspark | 51:98cc27390484 | 1634 | // { |
tobyspark | 51:98cc27390484 | 1635 | // bool ok; |
tobyspark | 51:98cc27390484 | 1636 | // ok = tvOne.uploadCustomResolutions(); |
tobyspark | 51:98cc27390484 | 1637 | // |
tobyspark | 51:98cc27390484 | 1638 | // tvOneStatusMessage.addMessage(ok ? "Resolutions set" : "Res' could not be set", kTVOneStatusMessageHoldTime); |
tobyspark | 51:98cc27390484 | 1639 | // } |
tobyspark | 12:c270870bdd23 | 1640 | } |
tobyspark | 0:87aab40d5806 | 1641 | else |
tobyspark | 0:87aab40d5806 | 1642 | { |
tobyspark | 0:87aab40d5806 | 1643 | if (debug) { debug->printf("Warning: No action identified"); } |
tobyspark | 0:87aab40d5806 | 1644 | } |
tobyspark | 0:87aab40d5806 | 1645 | } |
tobyspark | 0:87aab40d5806 | 1646 | |
tobyspark | 34:69dfe64e7e6b | 1647 | // Send any updates to the display |
tobyspark | 48:c0fedfa8c525 | 1648 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 48:c0fedfa8c525 | 1649 | screen.textToBuffer(tvOneStatusMessage.message(), kTVOneStatusLine); |
tobyspark | 34:69dfe64e7e6b | 1650 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 1651 | |
tobyspark | 5:f8b285ca41ba | 1652 | //// MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIXMIX MIX MIXMIX MIX MIX MIX MIX MIXMIX MIX MIX |
tobyspark | 0:87aab40d5806 | 1653 | |
tobyspark | 0:87aab40d5806 | 1654 | bool updateFade = false; |
tobyspark | 3:033d2b7768f3 | 1655 | float xFade = 0; |
tobyspark | 3:033d2b7768f3 | 1656 | float fadeUp = 1; |
tobyspark | 3:033d2b7768f3 | 1657 | |
tobyspark | 3:033d2b7768f3 | 1658 | //// TASK: Process control surface |
tobyspark | 3:033d2b7768f3 | 1659 | |
tobyspark | 0:87aab40d5806 | 1660 | // Get new states of tap buttons, remembering at end of loop() assign these current values to the previous variables |
tobyspark | 5:f8b285ca41ba | 1661 | const bool tapLeft = !tapLeftDIN; |
tobyspark | 5:f8b285ca41ba | 1662 | const bool tapRight = !tapRightDIN; |
tobyspark | 0:87aab40d5806 | 1663 | |
tobyspark | 17:fc68d40b8b1f | 1664 | // We're taking a further median of the AINs on top of mbed libs v29. |
tobyspark | 17:fc68d40b8b1f | 1665 | // This takes some values from last passes and most from now. With debug off, seem to need median size > 5 |
tobyspark | 17:fc68d40b8b1f | 1666 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1667 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1668 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1669 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1670 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1671 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1672 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1673 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1674 | const float xFadeAINCached = xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1675 | const float fadeUpAINCached = fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 1676 | |
tobyspark | 0:87aab40d5806 | 1677 | // When a tap is depressed, we can ignore any move of the crossfader but not fade to black |
tobyspark | 0:87aab40d5806 | 1678 | if (tapLeft || tapRight) |
tobyspark | 0:87aab40d5806 | 1679 | { |
tobyspark | 5:f8b285ca41ba | 1680 | // If both are pressed, take to the one that is new, ie. not the first pressed. |
tobyspark | 0:87aab40d5806 | 1681 | if (tapLeft && tapRight) |
tobyspark | 0:87aab40d5806 | 1682 | { |
tobyspark | 5:f8b285ca41ba | 1683 | xFade = tapLeftWasFirstPressed ? 1 : 0; |
tobyspark | 0:87aab40d5806 | 1684 | } |
tobyspark | 5:f8b285ca41ba | 1685 | // If just one is pressed, take to that and remember which is pressed |
tobyspark | 5:f8b285ca41ba | 1686 | else if (tapLeft) |
tobyspark | 5:f8b285ca41ba | 1687 | { |
tobyspark | 5:f8b285ca41ba | 1688 | xFade = 0; |
tobyspark | 5:f8b285ca41ba | 1689 | tapLeftWasFirstPressed = 1; |
tobyspark | 5:f8b285ca41ba | 1690 | } |
tobyspark | 5:f8b285ca41ba | 1691 | else if (tapRight) |
tobyspark | 5:f8b285ca41ba | 1692 | { |
tobyspark | 5:f8b285ca41ba | 1693 | xFade = 1; |
tobyspark | 5:f8b285ca41ba | 1694 | tapLeftWasFirstPressed = 0; |
tobyspark | 5:f8b285ca41ba | 1695 | } |
tobyspark | 5:f8b285ca41ba | 1696 | } |
tobyspark | 18:ebe5da639a6a | 1697 | else xFade = 1.0 - fadeCalc(xFadeAINCached, xFadeTolerance); |
tobyspark | 0:87aab40d5806 | 1698 | |
tobyspark | 0:87aab40d5806 | 1699 | fadeUp = 1.0 - fadeCalc(fadeUpAINCached, fadeUpTolerance); |
tobyspark | 0:87aab40d5806 | 1700 | |
tobyspark | 33:e6672a9bd571 | 1701 | //// TASK: Process Network Comms In, ie. modify TVOne state |
tobyspark | 5:f8b285ca41ba | 1702 | if (commsMode == commsOSC) |
tobyspark | 3:033d2b7768f3 | 1703 | { |
tobyspark | 3:033d2b7768f3 | 1704 | if (osc->newMessage) |
tobyspark | 3:033d2b7768f3 | 1705 | { |
tobyspark | 3:033d2b7768f3 | 1706 | osc->newMessage = false; // fixme! |
tobyspark | 33:e6672a9bd571 | 1707 | processOSCIn(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 1708 | } |
tobyspark | 3:033d2b7768f3 | 1709 | } |
tobyspark | 3:033d2b7768f3 | 1710 | |
tobyspark | 5:f8b285ca41ba | 1711 | if (commsMode == commsArtNet) |
tobyspark | 3:033d2b7768f3 | 1712 | { |
tobyspark | 33:e6672a9bd571 | 1713 | if (artNet->Work()) processArtNetIn(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 1714 | } |
tobyspark | 3:033d2b7768f3 | 1715 | |
tobyspark | 5:f8b285ca41ba | 1716 | if (commsMode == commsDMXIn) |
tobyspark | 5:f8b285ca41ba | 1717 | { |
tobyspark | 5:f8b285ca41ba | 1718 | processDMXIn(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 1719 | } |
tobyspark | 5:f8b285ca41ba | 1720 | |
tobyspark | 5:f8b285ca41ba | 1721 | if (commsMode == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 1722 | { |
tobyspark | 5:f8b285ca41ba | 1723 | processDMXOut(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 1724 | } |
tobyspark | 0:87aab40d5806 | 1725 | |
tobyspark | 0:87aab40d5806 | 1726 | // Calculate new A&B fade percents |
tobyspark | 0:87aab40d5806 | 1727 | int newFadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 1728 | int newFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 1729 | |
tobyspark | 30:873979018850 | 1730 | if (mixMode == mixBlend) |
tobyspark | 11:0783cfbeb746 | 1731 | { |
tobyspark | 51:98cc27390484 | 1732 | // This is the correct algorithm for blend where window A occludes B. |
tobyspark | 51:98cc27390484 | 1733 | // Who knew a crossfade could be so tricky. The level of B has to be factored by what A is letting through. |
tobyspark | 51:98cc27390484 | 1734 | // ie. if fully faded up, top window = xfade, bottom window = 100% |
tobyspark | 51:98cc27390484 | 1735 | // This will however look very wrong if A is not occluding B, ie. mismatched aspect ratios. |
tobyspark | 51:98cc27390484 | 1736 | if (xFade > 0) // avoids div by zero (if xFade = 0 and fadeUp = 1, B sum = 0 / 0) |
tobyspark | 51:98cc27390484 | 1737 | { |
tobyspark | 51:98cc27390484 | 1738 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 51:98cc27390484 | 1739 | newFadeBPercent = (xFade*fadeUp) / (1.0 - fadeUp + xFade*fadeUp) * 100.0; |
tobyspark | 51:98cc27390484 | 1740 | } |
tobyspark | 51:98cc27390484 | 1741 | else |
tobyspark | 51:98cc27390484 | 1742 | { |
tobyspark | 51:98cc27390484 | 1743 | newFadeAPercent = fadeUp * 100.0; |
tobyspark | 51:98cc27390484 | 1744 | newFadeBPercent = 0; |
tobyspark | 51:98cc27390484 | 1745 | } |
tobyspark | 11:0783cfbeb746 | 1746 | } |
tobyspark | 15:4b394c64b461 | 1747 | else if (mixMode == mixAdditive) |
tobyspark | 11:0783cfbeb746 | 1748 | { |
tobyspark | 22:90054fe6d86c | 1749 | // we need to set fade level of both windows according to the fade curve profile |
tobyspark | 22:90054fe6d86c | 1750 | float newFadeA = (1.0-xFade) * (1.0 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 1751 | float newFadeB = xFade * (1 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 1752 | if (newFadeA > 1.0) newFadeA = 1.0; |
tobyspark | 22:90054fe6d86c | 1753 | if (newFadeB > 1.0) newFadeB = 1.0; |
tobyspark | 22:90054fe6d86c | 1754 | |
tobyspark | 22:90054fe6d86c | 1755 | newFadeAPercent = newFadeA * fadeUp * 100.0; |
tobyspark | 22:90054fe6d86c | 1756 | newFadeBPercent = newFadeB * fadeUp * 100.0; |
tobyspark | 11:0783cfbeb746 | 1757 | } |
tobyspark | 36:8b5c75c8bc23 | 1758 | else if (mixMode >= mixKeyStartIndex) |
tobyspark | 11:0783cfbeb746 | 1759 | { |
tobyspark | 0:87aab40d5806 | 1760 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 1761 | newFadeBPercent = fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 1762 | } |
tobyspark | 0:87aab40d5806 | 1763 | |
tobyspark | 17:fc68d40b8b1f | 1764 | //// TASK: Send to TVOne if percents have changed |
tobyspark | 17:fc68d40b8b1f | 1765 | |
tobyspark | 17:fc68d40b8b1f | 1766 | // No amount of median filtering is stopping flipflopping between two adjacent percents, so... |
tobyspark | 17:fc68d40b8b1f | 1767 | bool fadeAPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 1768 | bool fadeBPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 1769 | if (oldFadeAPercent == newFadeAPercent && (newFadeAPercent == fadeAPercent - 1 || newFadeAPercent == fadeAPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 1770 | fadeAPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 1771 | else |
tobyspark | 17:fc68d40b8b1f | 1772 | fadeAPercentHasChanged = newFadeAPercent != fadeAPercent; |
tobyspark | 17:fc68d40b8b1f | 1773 | if (oldFadeBPercent == newFadeBPercent && (newFadeBPercent == fadeBPercent - 1 || newFadeBPercent == fadeBPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 1774 | fadeBPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 1775 | else |
tobyspark | 17:fc68d40b8b1f | 1776 | fadeBPercentHasChanged = newFadeBPercent != fadeBPercent; |
tobyspark | 17:fc68d40b8b1f | 1777 | |
tobyspark | 35:d5d9f0838f99 | 1778 | // If changing mixMode from additive, we want to do this before updating fade values |
tobyspark | 49:16309f39cead | 1779 | if (mixMode != mixModeOld && mixModeOld == mixAdditive) actionMixMode(); |
tobyspark | 35:d5d9f0838f99 | 1780 | |
tobyspark | 9:f83eadd8917a | 1781 | // We want to send the higher first, otherwise black flashes can happen on taps |
tobyspark | 17:fc68d40b8b1f | 1782 | if (fadeAPercentHasChanged && newFadeAPercent >= newFadeBPercent) |
tobyspark | 8:d46cc49f0f37 | 1783 | { |
tobyspark | 17:fc68d40b8b1f | 1784 | oldFadeAPercent = fadeAPercent; |
tobyspark | 0:87aab40d5806 | 1785 | fadeAPercent = newFadeAPercent; |
tobyspark | 0:87aab40d5806 | 1786 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1787 | |
tobyspark | 0:87aab40d5806 | 1788 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1789 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 0:87aab40d5806 | 1790 | } |
tobyspark | 17:fc68d40b8b1f | 1791 | if (fadeBPercentHasChanged) |
tobyspark | 8:d46cc49f0f37 | 1792 | { |
tobyspark | 17:fc68d40b8b1f | 1793 | oldFadeBPercent = fadeBPercent; |
tobyspark | 0:87aab40d5806 | 1794 | fadeBPercent = newFadeBPercent; |
tobyspark | 0:87aab40d5806 | 1795 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1796 | |
tobyspark | 0:87aab40d5806 | 1797 | fadeBPO = fadeBPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1798 | tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 0:87aab40d5806 | 1799 | } |
tobyspark | 17:fc68d40b8b1f | 1800 | if (fadeAPercentHasChanged && newFadeAPercent < newFadeBPercent) |
tobyspark | 9:f83eadd8917a | 1801 | { |
tobyspark | 17:fc68d40b8b1f | 1802 | oldFadeAPercent = fadeAPercent; |
tobyspark | 9:f83eadd8917a | 1803 | fadeAPercent = newFadeAPercent; |
tobyspark | 9:f83eadd8917a | 1804 | updateFade = true; |
tobyspark | 9:f83eadd8917a | 1805 | |
tobyspark | 9:f83eadd8917a | 1806 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 9:f83eadd8917a | 1807 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 9:f83eadd8917a | 1808 | } |
tobyspark | 8:d46cc49f0f37 | 1809 | if (updateFade && debug) |
tobyspark | 8:d46cc49f0f37 | 1810 | { |
tobyspark | 0:87aab40d5806 | 1811 | //debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAIN.read(), fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 1812 | debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAINCached, fadeUpAINCached); |
tobyspark | 0:87aab40d5806 | 1813 | debug->printf("xFade = %3f fadeUp = %3f fadeA% = %i fadeB% = %i \r\n", xFade, fadeUp, fadeAPercent, fadeBPercent); |
tobyspark | 18:ebe5da639a6a | 1814 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 1815 | } |
tobyspark | 30:873979018850 | 1816 | |
tobyspark | 49:16309f39cead | 1817 | // If changing mixMode to additive, we want to do this after updating fade values |
tobyspark | 49:16309f39cead | 1818 | if (mixMode != mixModeOld) actionMixMode(); |
tobyspark | 35:d5d9f0838f99 | 1819 | |
tobyspark | 33:e6672a9bd571 | 1820 | //// TASK: Process Network Comms Out, ie. send out any fade updates |
tobyspark | 33:e6672a9bd571 | 1821 | if (commsMode == commsOSC && updateFade) |
tobyspark | 33:e6672a9bd571 | 1822 | { |
tobyspark | 33:e6672a9bd571 | 1823 | processOSCOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1824 | } |
tobyspark | 33:e6672a9bd571 | 1825 | |
tobyspark | 33:e6672a9bd571 | 1826 | if (commsMode == commsArtNet && updateFade) |
tobyspark | 33:e6672a9bd571 | 1827 | { |
tobyspark | 33:e6672a9bd571 | 1828 | processArtNetOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1829 | } |
tobyspark | 33:e6672a9bd571 | 1830 | |
tobyspark | 33:e6672a9bd571 | 1831 | if (commsMode == commsDMXOut && updateFade) |
tobyspark | 33:e6672a9bd571 | 1832 | { |
tobyspark | 33:e6672a9bd571 | 1833 | processDMXOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1834 | } |
tobyspark | 33:e6672a9bd571 | 1835 | |
tobyspark | 45:cf8c2400be5c | 1836 | //// TASK: Housekeeping |
tobyspark | 45:cf8c2400be5c | 1837 | |
tobyspark | 49:16309f39cead | 1838 | if (tvOne.millisSinceLastCommandSent() > tvOne.getCommandTimeoutPeriod() + 1000) |
tobyspark | 30:873979018850 | 1839 | { |
tobyspark | 45:cf8c2400be5c | 1840 | // Lets check on our sources |
tobyspark | 45:cf8c2400be5c | 1841 | handleTVOneSources(); |
tobyspark | 49:16309f39cead | 1842 | |
tobyspark | 49:16309f39cead | 1843 | // Lets check on our fade levels |
tobyspark | 49:16309f39cead | 1844 | checkTVOneMixStatus(); |
tobyspark | 30:873979018850 | 1845 | } |
tobyspark | 0:87aab40d5806 | 1846 | } |
tobyspark | 30:873979018850 | 1847 | } |