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