![](/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@46:491229c97336, 2012-12-06 (annotated)
- Committer:
- tobyspark
- Date:
- Thu Dec 06 14:18:42 2012 +0000
- Revision:
- 46:491229c97336
- Parent:
- 45:cf8c2400be5c
- Child:
- 47:ff6b98459548
Additive Mix Menu default if no processor connected on power-on
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 46:491229c97336 | 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 | 36:8b5c75c8bc23 | 42 | * v23 - Set keying values from controller, requires a guided, step-through process for user |
tobyspark | 44:723e65413ebe | 43 | * v24 - Conform uploads SIS image; now once firmware is loaded controller is all that is required |
tobyspark | 36:8b5c75c8bc23 | 44 | * vxx - TODO: Writes back to .ini on USB mass storage: keyer updates, comms, hdcp, edid internal/passthrough, ...? |
tobyspark | 8:d46cc49f0f37 | 45 | * vxx - TODO: EDID creation from resolution |
tobyspark | 8:d46cc49f0f37 | 46 | */ |
tobyspark | 8:d46cc49f0f37 | 47 | |
tobyspark | 0:87aab40d5806 | 48 | #include "mbed.h" |
tobyspark | 0:87aab40d5806 | 49 | |
tobyspark | 0:87aab40d5806 | 50 | #include "spk_tvone_mbed.h" |
tobyspark | 0:87aab40d5806 | 51 | #include "spk_utils.h" |
tobyspark | 0:87aab40d5806 | 52 | #include "spk_mRotaryEncoder.h" |
tobyspark | 0:87aab40d5806 | 53 | #include "spk_oled_ssd1305.h" |
tobyspark | 2:50043054e4f7 | 54 | #include "spk_oled_gfx.h" |
tobyspark | 11:0783cfbeb746 | 55 | #include "spk_settings.h" |
tobyspark | 1:f9fca21102e0 | 56 | #include "EthernetNetIf.h" |
tobyspark | 1:f9fca21102e0 | 57 | #include "mbedOSC.h" |
tobyspark | 3:033d2b7768f3 | 58 | #include "DmxArtNet.h" |
tobyspark | 5:f8b285ca41ba | 59 | #include "DMX.h" |
tobyspark | 17:fc68d40b8b1f | 60 | #include "filter.h" |
tobyspark | 0:87aab40d5806 | 61 | |
tobyspark | 45:cf8c2400be5c | 62 | #define kSPKDFSoftwareVersion "24.2" |
tobyspark | 13:3796bde6ba8f | 63 | |
tobyspark | 5:f8b285ca41ba | 64 | // MBED PINS |
tobyspark | 5:f8b285ca41ba | 65 | |
tobyspark | 5:f8b285ca41ba | 66 | #define kMBED_AIN_XFADE p20 |
tobyspark | 5:f8b285ca41ba | 67 | #define kMBED_AIN_FADEUP p19 |
tobyspark | 5:f8b285ca41ba | 68 | #define kMBED_DIN_TAP_L p24 |
tobyspark | 5:f8b285ca41ba | 69 | #define kMBED_DIN_TAP_R p23 |
tobyspark | 5:f8b285ca41ba | 70 | #define kMBED_ENC_SW p15 |
tobyspark | 5:f8b285ca41ba | 71 | #define kMBED_ENC_A p16 |
tobyspark | 5:f8b285ca41ba | 72 | #define kMBED_ENC_B p17 |
tobyspark | 5:f8b285ca41ba | 73 | |
tobyspark | 5:f8b285ca41ba | 74 | #define kMBED_RS232_TTLTX p13 |
tobyspark | 5:f8b285ca41ba | 75 | #define kMBED_RS232_TTLRX p14 |
tobyspark | 5:f8b285ca41ba | 76 | |
tobyspark | 5:f8b285ca41ba | 77 | #define kMBED_OLED_MOSI p5 |
tobyspark | 5:f8b285ca41ba | 78 | #define kMBED_OLED_SCK p7 |
tobyspark | 5:f8b285ca41ba | 79 | #define kMBED_OLED_CS p8 |
tobyspark | 5:f8b285ca41ba | 80 | #define kMBED_OLED_RES p9 |
tobyspark | 5:f8b285ca41ba | 81 | #define kMBED_OLED_DC p10 |
tobyspark | 5:f8b285ca41ba | 82 | |
tobyspark | 5:f8b285ca41ba | 83 | #define kMBED_DIN_ETHLO_DMXHI p30 |
tobyspark | 5:f8b285ca41ba | 84 | #define kMBED_DOUT_RS485_TXHI_RXLO p29 |
tobyspark | 5:f8b285ca41ba | 85 | #define kMBED_RS485_TTLTX p28 |
tobyspark | 5:f8b285ca41ba | 86 | #define kMBED_RS485_TTLRX p27 |
tobyspark | 5:f8b285ca41ba | 87 | |
tobyspark | 5:f8b285ca41ba | 88 | // DISPLAY |
tobyspark | 5:f8b285ca41ba | 89 | |
tobyspark | 1:f9fca21102e0 | 90 | #define kMenuLine1 3 |
tobyspark | 1:f9fca21102e0 | 91 | #define kMenuLine2 4 |
tobyspark | 1:f9fca21102e0 | 92 | #define kCommsStatusLine 6 |
tobyspark | 1:f9fca21102e0 | 93 | #define kTVOneStatusLine 7 |
tobyspark | 1:f9fca21102e0 | 94 | |
tobyspark | 5:f8b285ca41ba | 95 | // NETWORKING |
tobyspark | 5:f8b285ca41ba | 96 | |
tobyspark | 1:f9fca21102e0 | 97 | #define kOSCMbedPort 10000 |
tobyspark | 1:f9fca21102e0 | 98 | #define kOSCMbedIPAddress 10,0,0,2 |
tobyspark | 1:f9fca21102e0 | 99 | #define kOSCMbedSubnetMask 255,255,255,0 |
tobyspark | 1:f9fca21102e0 | 100 | #define kOSCMbedGateway 10,0,0,1 |
tobyspark | 1:f9fca21102e0 | 101 | #define kOSCMbedDNS 10,0,0,1 |
tobyspark | 0:87aab40d5806 | 102 | |
tobyspark | 3:033d2b7768f3 | 103 | #define kArtNetBindIPAddress 2,0,0,100 |
tobyspark | 3:033d2b7768f3 | 104 | #define kArtNetBroadcastAddress 2,255,255,255 |
tobyspark | 3:033d2b7768f3 | 105 | |
tobyspark | 5:f8b285ca41ba | 106 | #define kDMXInChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 107 | #define kDMXInChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 108 | #define kDMXOutChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 109 | #define kDMXOutChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 110 | |
tobyspark | 13:3796bde6ba8f | 111 | // 8.3 format filename only, no subdirs |
tobyspark | 13:3796bde6ba8f | 112 | #define kSPKDFSettingsFilename "SPKDF.ini" |
tobyspark | 11:0783cfbeb746 | 113 | |
tobyspark | 26:0299f8760715 | 114 | #define kStringBufferLength 30 |
tobyspark | 26:0299f8760715 | 115 | |
tobyspark | 0:87aab40d5806 | 116 | //// DEBUG |
tobyspark | 0:87aab40d5806 | 117 | |
tobyspark | 0:87aab40d5806 | 118 | // Comment out one or the other... |
tobyspark | 41:00d1cd3b2af2 | 119 | //Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial |
tobyspark | 37:744bef2e8be8 | 120 | Serial *debug = NULL; // For release (no debugging) |
tobyspark | 0:87aab40d5806 | 121 | |
tobyspark | 15:4b394c64b461 | 122 | //// SOFT RESET |
tobyspark | 15:4b394c64b461 | 123 | |
tobyspark | 15:4b394c64b461 | 124 | extern "C" void mbed_reset(); |
tobyspark | 15:4b394c64b461 | 125 | |
tobyspark | 0:87aab40d5806 | 126 | //// mBED PIN ASSIGNMENTS |
tobyspark | 0:87aab40d5806 | 127 | |
tobyspark | 0:87aab40d5806 | 128 | // Inputs |
tobyspark | 5:f8b285ca41ba | 129 | AnalogIn xFadeAIN(kMBED_AIN_XFADE); |
tobyspark | 5:f8b285ca41ba | 130 | AnalogIn fadeUpAIN(kMBED_AIN_FADEUP); |
tobyspark | 5:f8b285ca41ba | 131 | DigitalIn tapLeftDIN(kMBED_DIN_TAP_L); |
tobyspark | 5:f8b285ca41ba | 132 | DigitalIn tapRightDIN(kMBED_DIN_TAP_R); |
tobyspark | 17:fc68d40b8b1f | 133 | medianFilter xFadeFilter(9); |
tobyspark | 17:fc68d40b8b1f | 134 | medianFilter fadeUpFilter(9); |
tobyspark | 0:87aab40d5806 | 135 | |
tobyspark | 5:f8b285ca41ba | 136 | SPKRotaryEncoder menuEnc(kMBED_ENC_A, kMBED_ENC_B, kMBED_ENC_SW); |
tobyspark | 5:f8b285ca41ba | 137 | |
tobyspark | 5:f8b285ca41ba | 138 | DigitalIn rj45ModeDIN(kMBED_DIN_ETHLO_DMXHI); |
tobyspark | 0:87aab40d5806 | 139 | |
tobyspark | 0:87aab40d5806 | 140 | // Outputs |
tobyspark | 0:87aab40d5806 | 141 | PwmOut fadeAPO(LED1); |
tobyspark | 0:87aab40d5806 | 142 | PwmOut fadeBPO(LED2); |
tobyspark | 0:87aab40d5806 | 143 | |
tobyspark | 5:f8b285ca41ba | 144 | DigitalOut dmxDirectionDOUT(kMBED_DOUT_RS485_TXHI_RXLO); |
tobyspark | 5:f8b285ca41ba | 145 | |
tobyspark | 0:87aab40d5806 | 146 | // SPKTVOne(PinName txPin, PinName rxPin, PinName signWritePin, PinName signErrorPin, Serial *debugSerial) |
tobyspark | 5:f8b285ca41ba | 147 | SPKTVOne tvOne(kMBED_RS232_TTLTX, kMBED_RS232_TTLRX, LED3, LED4, debug); |
tobyspark | 0:87aab40d5806 | 148 | |
tobyspark | 0:87aab40d5806 | 149 | // SPKDisplay(PinName mosi, PinName clk, PinName cs, PinName dc, PinName res, Serial *debugSerial = NULL); |
tobyspark | 5:f8b285ca41ba | 150 | SPKDisplay screen(kMBED_OLED_MOSI, kMBED_OLED_SCK, kMBED_OLED_CS, kMBED_OLED_DC, kMBED_OLED_RES, debug); |
tobyspark | 0:87aab40d5806 | 151 | |
tobyspark | 11:0783cfbeb746 | 152 | // Saved Settings |
tobyspark | 11:0783cfbeb746 | 153 | SPKSettings settings; |
tobyspark | 11:0783cfbeb746 | 154 | |
tobyspark | 0:87aab40d5806 | 155 | // Menu |
tobyspark | 0:87aab40d5806 | 156 | SPKMenu *selectedMenu; |
tobyspark | 23:909928cafb95 | 157 | SPKMenu mainMenu; |
tobyspark | 23:909928cafb95 | 158 | SPKMenu resolutionMenu; |
tobyspark | 12:c270870bdd23 | 159 | |
tobyspark | 24:49c6624119ae | 160 | SPKMenu mixModeMenu; |
tobyspark | 36:8b5c75c8bc23 | 161 | SPKMenu mixModeAdditiveMenu; |
tobyspark | 36:8b5c75c8bc23 | 162 | SPKMenu mixModeKeyerMenuUpdate; |
tobyspark | 36:8b5c75c8bc23 | 163 | SPKMenu mixModeKeyerMenuMinY; |
tobyspark | 36:8b5c75c8bc23 | 164 | SPKMenu mixModeKeyerMenuMaxY; |
tobyspark | 36:8b5c75c8bc23 | 165 | SPKMenu mixModeKeyerMenuMinU; |
tobyspark | 36:8b5c75c8bc23 | 166 | SPKMenu mixModeKeyerMenuMaxU; |
tobyspark | 36:8b5c75c8bc23 | 167 | SPKMenu mixModeKeyerMenuMinV; |
tobyspark | 36:8b5c75c8bc23 | 168 | SPKMenu mixModeKeyerMenuMaxV; |
tobyspark | 36:8b5c75c8bc23 | 169 | enum { mixBlend, mixAdditive, mixKey }; |
tobyspark | 36:8b5c75c8bc23 | 170 | int mixKeyStartIndex = 1; // need this hard coded as mixBlend and mixAdditive are now combined into the same menu item |
tobyspark | 30:873979018850 | 171 | int mixMode = mixBlend; // Start with safe mix mode, and test to get out of it. Safe mode will work with inputs missing and without hold frames. |
tobyspark | 29:95a7efe30527 | 172 | float fadeCurve = 0.0f; // 0 = "X", ie. as per blend, 1 = "/\", ie. as per additive <-- pictograms! |
tobyspark | 22:90054fe6d86c | 173 | |
tobyspark | 23:909928cafb95 | 174 | SPKMenu commsMenu; |
tobyspark | 5:f8b285ca41ba | 175 | enum { commsNone, commsOSC, commsArtNet, commsDMXIn, commsDMXOut}; |
tobyspark | 5:f8b285ca41ba | 176 | int commsMode = commsNone; |
tobyspark | 22:90054fe6d86c | 177 | |
tobyspark | 23:909928cafb95 | 178 | SPKMenu advancedMenu; |
tobyspark | 41:00d1cd3b2af2 | 179 | enum { advancedHDCPOn, advancedHDCPOff, advancedEDIDPassthrough, advancedEDIDInternal, advancedTestSources, advancedConformProcessor, advancedConformUploadProcessor, advancedLoadDefaults, advancedSetResolutions }; |
tobyspark | 1:f9fca21102e0 | 180 | |
tobyspark | 5:f8b285ca41ba | 181 | // RJ45 Comms |
tobyspark | 5:f8b285ca41ba | 182 | enum { rj45Ethernet = 0, rj45DMX = 1}; // These values from circuit |
tobyspark | 5:f8b285ca41ba | 183 | int rj45Mode = -1; |
tobyspark | 1:f9fca21102e0 | 184 | EthernetNetIf *ethernet = NULL; |
tobyspark | 1:f9fca21102e0 | 185 | OSCClass *osc = NULL; |
tobyspark | 33:e6672a9bd571 | 186 | OSCMessage sendMessage; |
tobyspark | 33:e6672a9bd571 | 187 | OSCMessage receiveMessage; |
tobyspark | 3:033d2b7768f3 | 188 | DmxArtNet *artNet = NULL; |
tobyspark | 5:f8b285ca41ba | 189 | DMX *dmx = NULL; |
tobyspark | 0:87aab40d5806 | 190 | |
tobyspark | 3:033d2b7768f3 | 191 | // Fade logic constants |
tobyspark | 0:87aab40d5806 | 192 | const float xFadeTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 193 | const float fadeUpTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 194 | |
tobyspark | 0:87aab40d5806 | 195 | // A&B Fade as resolved percent |
tobyspark | 0:87aab40d5806 | 196 | int fadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 197 | int fadeBPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 198 | int oldFadeAPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 199 | int oldFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 200 | |
tobyspark | 0:87aab40d5806 | 201 | // Tap button states |
tobyspark | 5:f8b285ca41ba | 202 | bool tapLeftWasFirstPressed = false; |
tobyspark | 0:87aab40d5806 | 203 | |
tobyspark | 0:87aab40d5806 | 204 | // Key mode parameters |
tobyspark | 0:87aab40d5806 | 205 | int keyerParamsSet = -1; // last keyParams index uploaded to unit |
tobyspark | 0:87aab40d5806 | 206 | |
tobyspark | 30:873979018850 | 207 | // TVOne input sources stable flag |
tobyspark | 34:69dfe64e7e6b | 208 | bool tvOneRGB1Stable = false; |
tobyspark | 34:69dfe64e7e6b | 209 | bool tvOneRGB2Stable = false; |
tobyspark | 30:873979018850 | 210 | |
tobyspark | 31:01845a2347ff | 211 | // TVOne behaviour flags |
tobyspark | 31:01845a2347ff | 212 | bool tvOneHDCPOn = false; |
tobyspark | 34:69dfe64e7e6b | 213 | bool tvOneEDIDPassthrough = false; |
tobyspark | 31:01845a2347ff | 214 | const int32_t EDIDPassthroughSlot = 7; |
tobyspark | 31:01845a2347ff | 215 | |
tobyspark | 34:69dfe64e7e6b | 216 | |
tobyspark | 33:e6672a9bd571 | 217 | void processOSCIn(float &xFade, float &fadeUp) { |
tobyspark | 25:3b519ef70341 | 218 | string statusMessage; |
tobyspark | 3:033d2b7768f3 | 219 | |
tobyspark | 33:e6672a9bd571 | 220 | if (!strcmp( receiveMessage.getTopAddress() , "dvimxr" )) |
tobyspark | 3:033d2b7768f3 | 221 | { |
tobyspark | 25:3b519ef70341 | 222 | statusMessage = "OSC: /dvimxr"; |
tobyspark | 33:e6672a9bd571 | 223 | if (!strcmp( receiveMessage.getSubAddress() , "xFade" )) |
tobyspark | 25:3b519ef70341 | 224 | { |
tobyspark | 33:e6672a9bd571 | 225 | if (receiveMessage.getArgNum() == 1) |
tobyspark | 33:e6672a9bd571 | 226 | if (receiveMessage.getTypeTag(0) == 'f') |
tobyspark | 25:3b519ef70341 | 227 | { |
tobyspark | 33:e6672a9bd571 | 228 | xFade = receiveMessage.getArgFloat(0); |
tobyspark | 25:3b519ef70341 | 229 | char buffer[15]; |
tobyspark | 26:0299f8760715 | 230 | snprintf(buffer, kStringBufferLength, "/xFade %1.2f", xFade); |
tobyspark | 25:3b519ef70341 | 231 | statusMessage += buffer; |
tobyspark | 25:3b519ef70341 | 232 | } |
tobyspark | 25:3b519ef70341 | 233 | } |
tobyspark | 33:e6672a9bd571 | 234 | else if (!strcmp( receiveMessage.getSubAddress() , "fadeUp" )) |
tobyspark | 25:3b519ef70341 | 235 | { |
tobyspark | 33:e6672a9bd571 | 236 | if (receiveMessage.getArgNum() == 1) |
tobyspark | 33:e6672a9bd571 | 237 | if (receiveMessage.getTypeTag(0) == 'f') |
tobyspark | 3:033d2b7768f3 | 238 | { |
tobyspark | 33:e6672a9bd571 | 239 | fadeUp = receiveMessage.getArgFloat(0); |
tobyspark | 25:3b519ef70341 | 240 | char buffer[15]; |
tobyspark | 26:0299f8760715 | 241 | snprintf(buffer, kStringBufferLength, "/fadeUp %1.2f", fadeUp); |
tobyspark | 25:3b519ef70341 | 242 | statusMessage += buffer; |
tobyspark | 3:033d2b7768f3 | 243 | } |
tobyspark | 25:3b519ef70341 | 244 | } |
tobyspark | 25:3b519ef70341 | 245 | else |
tobyspark | 25:3b519ef70341 | 246 | { |
tobyspark | 33:e6672a9bd571 | 247 | statusMessage += receiveMessage.getSubAddress(); |
tobyspark | 25:3b519ef70341 | 248 | statusMessage += " - Ignoring"; |
tobyspark | 25:3b519ef70341 | 249 | } |
tobyspark | 3:033d2b7768f3 | 250 | } |
tobyspark | 3:033d2b7768f3 | 251 | else |
tobyspark | 3:033d2b7768f3 | 252 | { |
tobyspark | 25:3b519ef70341 | 253 | statusMessage = "OSC: "; |
tobyspark | 33:e6672a9bd571 | 254 | statusMessage += receiveMessage.getTopAddress(); |
tobyspark | 25:3b519ef70341 | 255 | statusMessage += " - Ignoring"; |
tobyspark | 3:033d2b7768f3 | 256 | } |
tobyspark | 3:033d2b7768f3 | 257 | |
tobyspark | 3:033d2b7768f3 | 258 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 25:3b519ef70341 | 259 | screen.textToBuffer(statusMessage, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 260 | |
tobyspark | 25:3b519ef70341 | 261 | if (debug) debug->printf("%s \r\n", statusMessage.c_str()); |
tobyspark | 3:033d2b7768f3 | 262 | |
tobyspark | 3:033d2b7768f3 | 263 | } |
tobyspark | 3:033d2b7768f3 | 264 | |
tobyspark | 33:e6672a9bd571 | 265 | void processOSCOut(float &xFade, float &fadeUp) |
tobyspark | 33:e6672a9bd571 | 266 | { |
tobyspark | 33:e6672a9bd571 | 267 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 33:e6672a9bd571 | 268 | |
tobyspark | 33:e6672a9bd571 | 269 | sendMessage.setAddress("dvimxr", "xFadeFadeUp"); |
tobyspark | 33:e6672a9bd571 | 270 | sendMessage.setArgs("ff", &xFade, &fadeUp); |
tobyspark | 33:e6672a9bd571 | 271 | osc->sendOsc(&sendMessage); |
tobyspark | 33:e6672a9bd571 | 272 | |
tobyspark | 33:e6672a9bd571 | 273 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 274 | snprintf(statusMessageBuffer, kStringBufferLength, "OSC Out: xF %.2f fUp %.2f", xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 275 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 276 | |
tobyspark | 33:e6672a9bd571 | 277 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 33:e6672a9bd571 | 278 | } |
tobyspark | 33:e6672a9bd571 | 279 | |
tobyspark | 33:e6672a9bd571 | 280 | void processArtNetIn(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 281 | { |
tobyspark | 3:033d2b7768f3 | 282 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 283 | screen.textToBuffer("ArtNet activity", kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 284 | |
tobyspark | 3:033d2b7768f3 | 285 | if (debug) debug->printf("ArtNet activity"); |
tobyspark | 3:033d2b7768f3 | 286 | } |
tobyspark | 0:87aab40d5806 | 287 | |
tobyspark | 33:e6672a9bd571 | 288 | void processArtNetOut(float &xFade, float &fadeUp) |
tobyspark | 33:e6672a9bd571 | 289 | { |
tobyspark | 33:e6672a9bd571 | 290 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 33:e6672a9bd571 | 291 | |
tobyspark | 33:e6672a9bd571 | 292 | int xFadeDMX = xFade*255; |
tobyspark | 33:e6672a9bd571 | 293 | int fadeUpDMX = fadeUp*255; |
tobyspark | 33:e6672a9bd571 | 294 | |
tobyspark | 33:e6672a9bd571 | 295 | // Universe 0, Channel 0 = xFade, Channel 1 = fadeUp |
tobyspark | 33:e6672a9bd571 | 296 | char dmxData[2] = {xFadeDMX, fadeUpDMX}; |
tobyspark | 33:e6672a9bd571 | 297 | artNet->Send_ArtDmx(0, 0, dmxData, 2); |
tobyspark | 33:e6672a9bd571 | 298 | |
tobyspark | 33:e6672a9bd571 | 299 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 300 | snprintf(statusMessageBuffer, kStringBufferLength, "A'Net Out: xF%3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 33:e6672a9bd571 | 301 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 302 | |
tobyspark | 33:e6672a9bd571 | 303 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 33:e6672a9bd571 | 304 | } |
tobyspark | 33:e6672a9bd571 | 305 | |
tobyspark | 8:d46cc49f0f37 | 306 | void processDMXIn(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 307 | { |
tobyspark | 26:0299f8760715 | 308 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 5:f8b285ca41ba | 309 | |
tobyspark | 5:f8b285ca41ba | 310 | int xFadeDMX = dmx->get(kDMXInChannelXFade); |
tobyspark | 7:e6717468c18d | 311 | int fadeUpDMX = dmx->get(kDMXInChannelFadeUp); |
tobyspark | 5:f8b285ca41ba | 312 | |
tobyspark | 5:f8b285ca41ba | 313 | xFade = (float)xFadeDMX/255; |
tobyspark | 5:f8b285ca41ba | 314 | fadeUp = (float)fadeUpDMX/255; |
tobyspark | 5:f8b285ca41ba | 315 | |
tobyspark | 5:f8b285ca41ba | 316 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 26:0299f8760715 | 317 | snprintf(statusMessageBuffer, kStringBufferLength, "DMX In: xF %3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 25:3b519ef70341 | 318 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 319 | |
tobyspark | 25:3b519ef70341 | 320 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 5:f8b285ca41ba | 321 | } |
tobyspark | 5:f8b285ca41ba | 322 | |
tobyspark | 8:d46cc49f0f37 | 323 | void processDMXOut(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 324 | { |
tobyspark | 26:0299f8760715 | 325 | char statusMessageBuffer[kStringBufferLength]; |
tobyspark | 5:f8b285ca41ba | 326 | |
tobyspark | 5:f8b285ca41ba | 327 | int xFadeDMX = xFade*255; |
tobyspark | 5:f8b285ca41ba | 328 | int fadeUpDMX = fadeUp*255; |
tobyspark | 5:f8b285ca41ba | 329 | |
tobyspark | 5:f8b285ca41ba | 330 | dmx->put(kDMXOutChannelXFade, xFadeDMX); |
tobyspark | 5:f8b285ca41ba | 331 | dmx->put(kDMXOutChannelFadeUp, fadeUpDMX); |
tobyspark | 5:f8b285ca41ba | 332 | |
tobyspark | 5:f8b285ca41ba | 333 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 26:0299f8760715 | 334 | snprintf(statusMessageBuffer, kStringBufferLength, "DMX Out: xF %3i fUp %3i", xFadeDMX, fadeUpDMX); |
tobyspark | 25:3b519ef70341 | 335 | screen.textToBuffer(statusMessageBuffer, kCommsStatusLine); |
tobyspark | 33:e6672a9bd571 | 336 | |
tobyspark | 25:3b519ef70341 | 337 | if (debug) debug->printf(statusMessageBuffer); |
tobyspark | 5:f8b285ca41ba | 338 | } |
tobyspark | 0:87aab40d5806 | 339 | |
tobyspark | 8:d46cc49f0f37 | 340 | inline float fadeCalc (const float AIN, const float tolerance) |
tobyspark | 8:d46cc49f0f37 | 341 | { |
tobyspark | 0:87aab40d5806 | 342 | float pos ; |
tobyspark | 0:87aab40d5806 | 343 | if (AIN < tolerance) pos = 0; |
tobyspark | 0:87aab40d5806 | 344 | else if (AIN > 1.0 - tolerance) pos = 1; |
tobyspark | 0:87aab40d5806 | 345 | else pos = (AIN - tolerance) / (1 - 2*tolerance); |
tobyspark | 0:87aab40d5806 | 346 | if (debug && false) debug->printf("fadeCalc in: %f out: %f \r\n", AIN, pos); |
tobyspark | 0:87aab40d5806 | 347 | return pos; |
tobyspark | 0:87aab40d5806 | 348 | } |
tobyspark | 0:87aab40d5806 | 349 | |
tobyspark | 34:69dfe64e7e6b | 350 | bool handleTVOneSources() |
tobyspark | 30:873979018850 | 351 | { |
tobyspark | 30:873979018850 | 352 | bool ok = true; |
tobyspark | 30:873979018850 | 353 | |
tobyspark | 30:873979018850 | 354 | int32_t payload = 0; |
tobyspark | 30:873979018850 | 355 | |
tobyspark | 30:873979018850 | 356 | ok = ok && tvOne.readCommand(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceSourceStable, payload); |
tobyspark | 34:69dfe64e7e6b | 357 | bool RGB1 = (payload == 1); |
tobyspark | 30:873979018850 | 358 | |
tobyspark | 30:873979018850 | 359 | ok = ok && tvOne.readCommand(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceSourceStable, payload); |
tobyspark | 30:873979018850 | 360 | bool RGB2 = (payload == 1); |
tobyspark | 30:873979018850 | 361 | |
tobyspark | 34:69dfe64e7e6b | 362 | ok = ok && tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, payload); |
tobyspark | 34:69dfe64e7e6b | 363 | int sourceA = payload; |
tobyspark | 34:69dfe64e7e6b | 364 | |
tobyspark | 34:69dfe64e7e6b | 365 | ok = ok && tvOne.readCommand(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, payload); |
tobyspark | 34:69dfe64e7e6b | 366 | int sourceB = payload; |
tobyspark | 34:69dfe64e7e6b | 367 | |
tobyspark | 44:723e65413ebe | 368 | if (debug) debug->printf("HandleTVOneSources: RGB1: %i, RGB2: %i, sourceA: %#x, sourceB: %#x \r\n", RGB1, RGB2, sourceA, sourceB); |
tobyspark | 45:cf8c2400be5c | 369 | |
tobyspark | 45:cf8c2400be5c | 370 | string tvOneDetectString = "TVOne: "; |
tobyspark | 45:cf8c2400be5c | 371 | |
tobyspark | 45:cf8c2400be5c | 372 | if (ok) |
tobyspark | 30:873979018850 | 373 | { |
tobyspark | 45:cf8c2400be5c | 374 | string right = RGB1 ? "Live" : (tvOneRGB1Stable ? "Hold" : "Logo"); |
tobyspark | 45:cf8c2400be5c | 375 | string left = RGB2 ? "Live" : (tvOneRGB2Stable ? "Hold" : "Logo"); |
tobyspark | 45:cf8c2400be5c | 376 | |
tobyspark | 45:cf8c2400be5c | 377 | tvOneDetectString += "L: "; |
tobyspark | 45:cf8c2400be5c | 378 | tvOneDetectString += left; |
tobyspark | 45:cf8c2400be5c | 379 | tvOneDetectString += " R: "; |
tobyspark | 45:cf8c2400be5c | 380 | tvOneDetectString += right; |
tobyspark | 30:873979018850 | 381 | } |
tobyspark | 30:873979018850 | 382 | |
tobyspark | 34:69dfe64e7e6b | 383 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 34:69dfe64e7e6b | 384 | screen.textToBuffer(tvOneDetectString, kTVOneStatusLine); |
tobyspark | 34:69dfe64e7e6b | 385 | |
tobyspark | 34:69dfe64e7e6b | 386 | // Assign appropriate source depending on whether DVI input is good |
tobyspark | 34:69dfe64e7e6b | 387 | // If that assign command completes ok, and the DVI input is good, finally flag the unit has had a live source |
tobyspark | 34:69dfe64e7e6b | 388 | // 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 | 389 | if (ok && !tvOneRGB1Stable) |
tobyspark | 30:873979018850 | 390 | { |
tobyspark | 34:69dfe64e7e6b | 391 | if (RGB1 && (sourceB != kTV1SourceRGB1)) ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB1); |
tobyspark | 34:69dfe64e7e6b | 392 | if (!RGB1 && (sourceB != kTV1SourceSIS2)) ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceSIS2); // Wierd: Can't set to SIS1 sometimes. |
tobyspark | 34:69dfe64e7e6b | 393 | if (ok && RGB1) tvOneRGB1Stable = true; |
tobyspark | 30:873979018850 | 394 | } |
tobyspark | 34:69dfe64e7e6b | 395 | if (ok && !tvOneRGB2Stable) |
tobyspark | 34:69dfe64e7e6b | 396 | { |
tobyspark | 34:69dfe64e7e6b | 397 | if (RGB2 && (sourceA != kTV1SourceRGB2)) ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB2); |
tobyspark | 34:69dfe64e7e6b | 398 | if (!RGB2 && (sourceA != kTV1SourceSIS2)) ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceSIS2); |
tobyspark | 34:69dfe64e7e6b | 399 | if (ok && RGB2) tvOneRGB2Stable = true; |
tobyspark | 34:69dfe64e7e6b | 400 | } |
tobyspark | 30:873979018850 | 401 | |
tobyspark | 30:873979018850 | 402 | return ok; |
tobyspark | 30:873979018850 | 403 | } |
tobyspark | 30:873979018850 | 404 | |
tobyspark | 8:d46cc49f0f37 | 405 | bool setKeyParamsTo(int index) |
tobyspark | 8:d46cc49f0f37 | 406 | { |
tobyspark | 0:87aab40d5806 | 407 | // Only spend the time uploading six parameters if we need to |
tobyspark | 0:87aab40d5806 | 408 | // Might want to bounds check here |
tobyspark | 0:87aab40d5806 | 409 | |
tobyspark | 9:f83eadd8917a | 410 | bool ok; |
tobyspark | 0:87aab40d5806 | 411 | |
tobyspark | 0:87aab40d5806 | 412 | if (index != keyerParamsSet) |
tobyspark | 0:87aab40d5806 | 413 | { |
tobyspark | 31:01845a2347ff | 414 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, settings.keyerParamSet(index)[SPKSettings::minY]); |
tobyspark | 31:01845a2347ff | 415 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, settings.keyerParamSet(index)[SPKSettings::maxY]); |
tobyspark | 31:01845a2347ff | 416 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, settings.keyerParamSet(index)[SPKSettings::minU]); |
tobyspark | 31:01845a2347ff | 417 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, settings.keyerParamSet(index)[SPKSettings::maxU]); |
tobyspark | 31:01845a2347ff | 418 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, settings.keyerParamSet(index)[SPKSettings::minV]); |
tobyspark | 31:01845a2347ff | 419 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, settings.keyerParamSet(index)[SPKSettings::maxV]); |
tobyspark | 0:87aab40d5806 | 420 | |
tobyspark | 0:87aab40d5806 | 421 | keyerParamsSet = index; |
tobyspark | 9:f83eadd8917a | 422 | } |
tobyspark | 9:f83eadd8917a | 423 | else |
tobyspark | 9:f83eadd8917a | 424 | { |
tobyspark | 9:f83eadd8917a | 425 | ok = true; |
tobyspark | 9:f83eadd8917a | 426 | } |
tobyspark | 0:87aab40d5806 | 427 | |
tobyspark | 0:87aab40d5806 | 428 | return ok; |
tobyspark | 0:87aab40d5806 | 429 | } |
tobyspark | 0:87aab40d5806 | 430 | |
tobyspark | 24:49c6624119ae | 431 | void actionMixMode() |
tobyspark | 24:49c6624119ae | 432 | { |
tobyspark | 31:01845a2347ff | 433 | if (debug) debug->printf("Changing mix mode \r\n"); |
tobyspark | 31:01845a2347ff | 434 | |
tobyspark | 24:49c6624119ae | 435 | bool ok = true; |
tobyspark | 25:3b519ef70341 | 436 | string sentOK; |
tobyspark | 26:0299f8760715 | 437 | char sentMSGBuffer[kStringBufferLength]; |
tobyspark | 24:49c6624119ae | 438 | |
tobyspark | 24:49c6624119ae | 439 | // Set Keyer |
tobyspark | 39:7d9a5eef93c9 | 440 | if (mixMode < mixKey) |
tobyspark | 24:49c6624119ae | 441 | { |
tobyspark | 31:01845a2347ff | 442 | // Set Keyer Off. Quicker to set and fail than to test for on and then turn off |
tobyspark | 35:d5d9f0838f99 | 443 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, false); |
tobyspark | 31:01845a2347ff | 444 | |
tobyspark | 31:01845a2347ff | 445 | if (mixMode == mixBlend) |
tobyspark | 24:49c6624119ae | 446 | { |
tobyspark | 31:01845a2347ff | 447 | // Turn off Additive Mixing on output |
tobyspark | 31:01845a2347ff | 448 | ok = tvOne.command(0, kTV1WindowIDA, 0x298, 0); |
tobyspark | 31:01845a2347ff | 449 | snprintf(sentMSGBuffer, kStringBufferLength, "Blend"); |
tobyspark | 24:49c6624119ae | 450 | } |
tobyspark | 31:01845a2347ff | 451 | if (mixMode == mixAdditive) |
tobyspark | 31:01845a2347ff | 452 | { |
tobyspark | 31:01845a2347ff | 453 | // 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 | 454 | ok = tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 31:01845a2347ff | 455 | // Then turn on Additive Mixing |
tobyspark | 31:01845a2347ff | 456 | ok = ok && tvOne.command(0, kTV1WindowIDA, 0x298, 1); |
tobyspark | 31:01845a2347ff | 457 | snprintf(sentMSGBuffer, kStringBufferLength, "Additive"); |
tobyspark | 31:01845a2347ff | 458 | } |
tobyspark | 24:49c6624119ae | 459 | } |
tobyspark | 24:49c6624119ae | 460 | else |
tobyspark | 24:49c6624119ae | 461 | { |
tobyspark | 39:7d9a5eef93c9 | 462 | int index = mixModeMenu.selectedIndex() - mixKeyStartIndex; |
tobyspark | 25:3b519ef70341 | 463 | |
tobyspark | 24:49c6624119ae | 464 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, true); |
tobyspark | 24:49c6624119ae | 465 | ok = ok && setKeyParamsTo(index); |
tobyspark | 25:3b519ef70341 | 466 | |
tobyspark | 26:0299f8760715 | 467 | snprintf(sentMSGBuffer, kStringBufferLength, "Keyer On with %i", index); |
tobyspark | 24:49c6624119ae | 468 | } |
tobyspark | 24:49c6624119ae | 469 | |
tobyspark | 24:49c6624119ae | 470 | if (ok) sentOK = "Sent:"; |
tobyspark | 24:49c6624119ae | 471 | else sentOK = "Send Error:"; |
tobyspark | 24:49c6624119ae | 472 | |
tobyspark | 24:49c6624119ae | 473 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 25:3b519ef70341 | 474 | screen.textToBuffer(sentOK + sentMSGBuffer, kTVOneStatusLine); |
tobyspark | 24:49c6624119ae | 475 | } |
tobyspark | 24:49c6624119ae | 476 | |
tobyspark | 24:49c6624119ae | 477 | |
tobyspark | 17:fc68d40b8b1f | 478 | bool conformProcessor() |
tobyspark | 17:fc68d40b8b1f | 479 | { |
tobyspark | 44:723e65413ebe | 480 | bool ok; |
tobyspark | 17:fc68d40b8b1f | 481 | |
tobyspark | 17:fc68d40b8b1f | 482 | int32_t on = 1; |
tobyspark | 17:fc68d40b8b1f | 483 | int32_t off = 0; |
tobyspark | 17:fc68d40b8b1f | 484 | int32_t fit = 1; |
tobyspark | 38:2701101dcd56 | 485 | int32_t oneToOne = 4; |
tobyspark | 17:fc68d40b8b1f | 486 | |
tobyspark | 44:723e65413ebe | 487 | for (int i=0; i < 3; i++) |
tobyspark | 44:723e65413ebe | 488 | { |
tobyspark | 44:723e65413ebe | 489 | // Independent output |
tobyspark | 44:723e65413ebe | 490 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionMode, 2); |
tobyspark | 44:723e65413ebe | 491 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsOutputEnable, on); |
tobyspark | 44:723e65413ebe | 492 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsLockMethod, off); |
tobyspark | 44:723e65413ebe | 493 | |
tobyspark | 44:723e65413ebe | 494 | // Make sure our windows exist |
tobyspark | 44:723e65413ebe | 495 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 44:723e65413ebe | 496 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 44:723e65413ebe | 497 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, 0); |
tobyspark | 44:723e65413ebe | 498 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsLayerPriority, 1); |
tobyspark | 44:723e65413ebe | 499 | |
tobyspark | 44:723e65413ebe | 500 | // Assign inputs to windows, so that left on the crossfader is left on the processor viewed from front |
tobyspark | 44:723e65413ebe | 501 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB2); |
tobyspark | 44:723e65413ebe | 502 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB1); |
tobyspark | 44:723e65413ebe | 503 | |
tobyspark | 44:723e65413ebe | 504 | // Set scaling to fit source within output, maintaining aspect ratio |
tobyspark | 44:723e65413ebe | 505 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 44:723e65413ebe | 506 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 44:723e65413ebe | 507 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 44:723e65413ebe | 508 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 44:723e65413ebe | 509 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 44:723e65413ebe | 510 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 44:723e65413ebe | 511 | ok = ok && tvOne.command(kTV1SourceSIS2, kTV1WindowIDA, kTV1FunctionAdjustSourceTestCard, 1); |
tobyspark | 44:723e65413ebe | 512 | ok = ok && tvOne.command(kTV1SourceSIS2, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, oneToOne); |
tobyspark | 44:723e65413ebe | 513 | |
tobyspark | 44:723e65413ebe | 514 | // On source loss, hold on the last frame received. |
tobyspark | 44:723e65413ebe | 515 | int32_t freeze = 1; |
tobyspark | 44:723e65413ebe | 516 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 44:723e65413ebe | 517 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 44:723e65413ebe | 518 | |
tobyspark | 44:723e65413ebe | 519 | // Set resolution and fade levels for maximum chance of being seen |
tobyspark | 44:723e65413ebe | 520 | ok = ok && tvOne.setResolution(kTV1ResolutionVGA, tvOneEDIDPassthrough ? EDIDPassthroughSlot : 5); |
tobyspark | 44:723e65413ebe | 521 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, 100); |
tobyspark | 44:723e65413ebe | 522 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, 100); |
tobyspark | 44:723e65413ebe | 523 | |
tobyspark | 44:723e65413ebe | 524 | // Set evil, evil HDCP off |
tobyspark | 44:723e65413ebe | 525 | ok = ok && tvOne.setHDCPOn(false); |
tobyspark | 30:873979018850 | 526 | |
tobyspark | 44:723e65413ebe | 527 | if (ok) break; |
tobyspark | 44:723e65413ebe | 528 | else tvOne.increaseCommandPeriods(500); |
tobyspark | 44:723e65413ebe | 529 | } |
tobyspark | 40:bfddeb2a7fcf | 530 | |
tobyspark | 44:723e65413ebe | 531 | if (ok) |
tobyspark | 44:723e65413ebe | 532 | { |
tobyspark | 44:723e65413ebe | 533 | // Save current state in preset one |
tobyspark | 44:723e65413ebe | 534 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPreset, 1); // Set Preset 1 |
tobyspark | 44:723e65413ebe | 535 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPresetStore, 1); // Store |
tobyspark | 44:723e65413ebe | 536 | |
tobyspark | 44:723e65413ebe | 537 | // Save current state for power on |
tobyspark | 44:723e65413ebe | 538 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 44:723e65413ebe | 539 | } |
tobyspark | 41:00d1cd3b2af2 | 540 | |
tobyspark | 44:723e65413ebe | 541 | tvOne.resetCommandPeriods(); |
tobyspark | 41:00d1cd3b2af2 | 542 | |
tobyspark | 41:00d1cd3b2af2 | 543 | return ok; |
tobyspark | 41:00d1cd3b2af2 | 544 | } |
tobyspark | 41:00d1cd3b2af2 | 545 | |
tobyspark | 41:00d1cd3b2af2 | 546 | bool uploadToProcessor() |
tobyspark | 41:00d1cd3b2af2 | 547 | { |
tobyspark | 41:00d1cd3b2af2 | 548 | bool ok = true; |
tobyspark | 41:00d1cd3b2af2 | 549 | |
tobyspark | 41:00d1cd3b2af2 | 550 | LocalFileSystem local("local"); |
tobyspark | 41:00d1cd3b2af2 | 551 | FILE *file; |
tobyspark | 41:00d1cd3b2af2 | 552 | |
tobyspark | 34:69dfe64e7e6b | 553 | // Upload Matrox EDID to mem4 (ie. index 3). Use this EDID slot when setting Matrox resolutions. |
tobyspark | 44:723e65413ebe | 554 | if (tvOne.getProcessorType().version < 415) |
tobyspark | 44:723e65413ebe | 555 | { |
tobyspark | 44:723e65413ebe | 556 | if (debug) debug->printf("Skipping EDID upload as unsupported on detected TV One firmware\r\n"); |
tobyspark | 44:723e65413ebe | 557 | } |
tobyspark | 44:723e65413ebe | 558 | else |
tobyspark | 34:69dfe64e7e6b | 559 | { |
tobyspark | 41:00d1cd3b2af2 | 560 | file = fopen("/local/matroxe.did", "r"); // 8.3, avoid .bin as mbed executable extension |
tobyspark | 35:d5d9f0838f99 | 561 | if (file) |
tobyspark | 34:69dfe64e7e6b | 562 | { |
tobyspark | 41:00d1cd3b2af2 | 563 | ok = ok && tvOne.uploadEDID(file, 3); |
tobyspark | 35:d5d9f0838f99 | 564 | fclose(file); |
tobyspark | 34:69dfe64e7e6b | 565 | } |
tobyspark | 35:d5d9f0838f99 | 566 | else |
tobyspark | 35:d5d9f0838f99 | 567 | { |
tobyspark | 44:723e65413ebe | 568 | if (debug) debug->printf("Could not open Matrox EDID file 'matroxe.did'\r\n"); |
tobyspark | 35:d5d9f0838f99 | 569 | } |
tobyspark | 34:69dfe64e7e6b | 570 | } |
tobyspark | 41:00d1cd3b2af2 | 571 | |
tobyspark | 41:00d1cd3b2af2 | 572 | // Upload Logo to SIS2. Use this (minimal) image when no sources are connected. |
tobyspark | 41:00d1cd3b2af2 | 573 | { |
tobyspark | 41:00d1cd3b2af2 | 574 | file = fopen("/local/spark.dat", "r"); // 8.3, avoid .bin as mbed executable extension |
tobyspark | 41:00d1cd3b2af2 | 575 | if (file) |
tobyspark | 41:00d1cd3b2af2 | 576 | { |
tobyspark | 41:00d1cd3b2af2 | 577 | ok = ok && tvOne.uploadImage(file, 1); |
tobyspark | 41:00d1cd3b2af2 | 578 | fclose(file); |
tobyspark | 41:00d1cd3b2af2 | 579 | } |
tobyspark | 41:00d1cd3b2af2 | 580 | else |
tobyspark | 41:00d1cd3b2af2 | 581 | { |
tobyspark | 41:00d1cd3b2af2 | 582 | if (debug) debug->printf("Could not open image file 'spark.dat'"); |
tobyspark | 41:00d1cd3b2af2 | 583 | } |
tobyspark | 41:00d1cd3b2af2 | 584 | } |
tobyspark | 17:fc68d40b8b1f | 585 | |
tobyspark | 17:fc68d40b8b1f | 586 | return ok; |
tobyspark | 17:fc68d40b8b1f | 587 | } |
tobyspark | 17:fc68d40b8b1f | 588 | |
tobyspark | 27:27851d3d2bba | 589 | void setResolutionMenuItems() |
tobyspark | 27:27851d3d2bba | 590 | { |
tobyspark | 27:27851d3d2bba | 591 | resolutionMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 592 | for (int i=0; i < settings.resolutionsCount(); i++) |
tobyspark | 27:27851d3d2bba | 593 | { |
tobyspark | 27:27851d3d2bba | 594 | resolutionMenu.addMenuItem(SPKMenuItem(settings.resolutionName(i), settings.resolutionIndex(i), settings.resolutionEDIDIndex(i))); |
tobyspark | 27:27851d3d2bba | 595 | } |
tobyspark | 27:27851d3d2bba | 596 | resolutionMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 27:27851d3d2bba | 597 | } |
tobyspark | 27:27851d3d2bba | 598 | |
tobyspark | 27:27851d3d2bba | 599 | void setMixModeMenuItems() |
tobyspark | 27:27851d3d2bba | 600 | { |
tobyspark | 27:27851d3d2bba | 601 | mixModeMenu.clearMenuItems(); |
tobyspark | 44:723e65413ebe | 602 | |
tobyspark | 46:491229c97336 | 603 | if (tvOne.getProcessorType().version == 423 || tvOne.getProcessorType().version == -1) |
tobyspark | 44:723e65413ebe | 604 | { |
tobyspark | 44:723e65413ebe | 605 | mixModeMenu.addMenuItem(SPKMenuItem("Crossfade", &mixModeAdditiveMenu)); |
tobyspark | 44:723e65413ebe | 606 | } |
tobyspark | 44:723e65413ebe | 607 | else |
tobyspark | 44:723e65413ebe | 608 | { |
tobyspark | 44:723e65413ebe | 609 | mixModeMenu.addMenuItem(SPKMenuItem("Blend", mixBlend)); |
tobyspark | 44:723e65413ebe | 610 | } |
tobyspark | 44:723e65413ebe | 611 | |
tobyspark | 27:27851d3d2bba | 612 | for (int i=0; i < settings.keyerSetCount(); i++) |
tobyspark | 27:27851d3d2bba | 613 | { |
tobyspark | 36:8b5c75c8bc23 | 614 | mixModeMenu.addMenuItem(SPKMenuItem(settings.keyerParamName(i), &mixModeKeyerMenuUpdate)); |
tobyspark | 27:27851d3d2bba | 615 | } |
tobyspark | 27:27851d3d2bba | 616 | mixModeMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 27:27851d3d2bba | 617 | } |
tobyspark | 27:27851d3d2bba | 618 | |
tobyspark | 27:27851d3d2bba | 619 | void setCommsMenuItems() |
tobyspark | 27:27851d3d2bba | 620 | { |
tobyspark | 27:27851d3d2bba | 621 | if (rj45Mode == rj45Ethernet) |
tobyspark | 27:27851d3d2bba | 622 | { |
tobyspark | 27:27851d3d2bba | 623 | commsMenu.title = "Network Mode [Ethernet]"; |
tobyspark | 27:27851d3d2bba | 624 | commsMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 625 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 27:27851d3d2bba | 626 | commsMenu.addMenuItem(SPKMenuItem("OSC", commsOSC)); |
tobyspark | 27:27851d3d2bba | 627 | commsMenu.addMenuItem(SPKMenuItem("ArtNet", commsArtNet)); |
tobyspark | 27:27851d3d2bba | 628 | commsMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 33:e6672a9bd571 | 629 | commsMenu = 0; |
tobyspark | 27:27851d3d2bba | 630 | } |
tobyspark | 27:27851d3d2bba | 631 | else if (rj45Mode == rj45DMX) |
tobyspark | 27:27851d3d2bba | 632 | { |
tobyspark | 27:27851d3d2bba | 633 | commsMenu.title = "Network Mode [DMX]"; |
tobyspark | 27:27851d3d2bba | 634 | commsMenu.clearMenuItems(); |
tobyspark | 27:27851d3d2bba | 635 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 27:27851d3d2bba | 636 | commsMenu.addMenuItem(SPKMenuItem("DMX In", commsDMXIn)); |
tobyspark | 27:27851d3d2bba | 637 | commsMenu.addMenuItem(SPKMenuItem("DMX Out", commsDMXOut)); |
tobyspark | 27:27851d3d2bba | 638 | commsMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 33:e6672a9bd571 | 639 | commsMenu = 0; |
tobyspark | 27:27851d3d2bba | 640 | } |
tobyspark | 27:27851d3d2bba | 641 | } |
tobyspark | 27:27851d3d2bba | 642 | |
tobyspark | 0:87aab40d5806 | 643 | int main() |
tobyspark | 0:87aab40d5806 | 644 | { |
tobyspark | 0:87aab40d5806 | 645 | if (debug) |
tobyspark | 0:87aab40d5806 | 646 | { |
tobyspark | 0:87aab40d5806 | 647 | debug->printf("\r\n\r\n"); |
tobyspark | 0:87aab40d5806 | 648 | debug->printf("*spark d-fuser -----------\r\n"); |
tobyspark | 0:87aab40d5806 | 649 | debug->printf(" debug channel\r\n"); |
tobyspark | 0:87aab40d5806 | 650 | } |
tobyspark | 2:50043054e4f7 | 651 | |
tobyspark | 2:50043054e4f7 | 652 | // Set display font |
tobyspark | 2:50043054e4f7 | 653 | screen.fontStartCharacter = &characterBytesStartChar; |
tobyspark | 2:50043054e4f7 | 654 | screen.fontEndCharacter = &characterBytesEndChar; |
tobyspark | 2:50043054e4f7 | 655 | screen.fontCharacters = characterBytes; |
tobyspark | 2:50043054e4f7 | 656 | |
tobyspark | 0:87aab40d5806 | 657 | // Splash screen |
tobyspark | 30:873979018850 | 658 | string softwareLine = "SW "; |
tobyspark | 30:873979018850 | 659 | softwareLine += kSPKDFSoftwareVersion; |
tobyspark | 2:50043054e4f7 | 660 | screen.imageToBuffer(spkDisplayLogo); |
tobyspark | 0:87aab40d5806 | 661 | screen.textToBuffer("SPK:D-Fuser",0); |
tobyspark | 30:873979018850 | 662 | screen.textToBuffer(softwareLine,1); |
tobyspark | 5:f8b285ca41ba | 663 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 664 | |
tobyspark | 11:0783cfbeb746 | 665 | // Load saved settings |
tobyspark | 16:52484666b323 | 666 | bool settingsAreCustom = false; |
tobyspark | 16:52484666b323 | 667 | settingsAreCustom = settings.load(kSPKDFSettingsFilename); |
tobyspark | 30:873979018850 | 668 | if (settingsAreCustom) |
tobyspark | 30:873979018850 | 669 | { |
tobyspark | 30:873979018850 | 670 | softwareLine += "; ini OK"; |
tobyspark | 30:873979018850 | 671 | screen.textToBuffer(softwareLine, 1); |
tobyspark | 30:873979018850 | 672 | } |
tobyspark | 30:873979018850 | 673 | |
tobyspark | 0:87aab40d5806 | 674 | // Set menu structure |
tobyspark | 0:87aab40d5806 | 675 | mixModeMenu.title = "Mix Mode"; |
tobyspark | 27:27851d3d2bba | 676 | setMixModeMenuItems(); |
tobyspark | 24:49c6624119ae | 677 | |
tobyspark | 29:95a7efe30527 | 678 | mixModeAdditiveMenu.title = "Crossfade"; |
tobyspark | 30:873979018850 | 679 | mixModeAdditiveMenu.addMenuItem(SPKMenuItem("[title overridden]", &mixModeMenu, true)); |
tobyspark | 36:8b5c75c8bc23 | 680 | |
tobyspark | 36:8b5c75c8bc23 | 681 | mixModeKeyerMenuUpdate.title = "Update Keyer Settings?"; |
tobyspark | 36:8b5c75c8bc23 | 682 | mixModeKeyerMenuUpdate.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMaxY, true)); |
tobyspark | 36:8b5c75c8bc23 | 683 | |
tobyspark | 36:8b5c75c8bc23 | 684 | mixModeKeyerMenuMaxY.title = "UP until lighter gone"; |
tobyspark | 36:8b5c75c8bc23 | 685 | mixModeKeyerMenuMaxY.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMinY, true)); |
tobyspark | 36:8b5c75c8bc23 | 686 | |
tobyspark | 36:8b5c75c8bc23 | 687 | mixModeKeyerMenuMinY.title = "UP to bring back darker"; |
tobyspark | 36:8b5c75c8bc23 | 688 | mixModeKeyerMenuMinY.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMaxU, true)); |
tobyspark | 36:8b5c75c8bc23 | 689 | |
tobyspark | 36:8b5c75c8bc23 | 690 | mixModeKeyerMenuMaxU.title = "UP until lighter gone"; |
tobyspark | 36:8b5c75c8bc23 | 691 | mixModeKeyerMenuMaxU.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMinU, true)); |
tobyspark | 36:8b5c75c8bc23 | 692 | |
tobyspark | 36:8b5c75c8bc23 | 693 | mixModeKeyerMenuMinU.title = "UP to bring back darker"; |
tobyspark | 36:8b5c75c8bc23 | 694 | mixModeKeyerMenuMinU.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMaxV, true)); |
tobyspark | 36:8b5c75c8bc23 | 695 | |
tobyspark | 36:8b5c75c8bc23 | 696 | mixModeKeyerMenuMaxV.title = "UP until lighter gone"; |
tobyspark | 36:8b5c75c8bc23 | 697 | mixModeKeyerMenuMaxV.addMenuItem(SPKMenuItem("[title overridden]", &mixModeKeyerMenuMinV, true)); |
tobyspark | 36:8b5c75c8bc23 | 698 | |
tobyspark | 36:8b5c75c8bc23 | 699 | mixModeKeyerMenuMinV.title = "UP to bring back darker"; |
tobyspark | 36:8b5c75c8bc23 | 700 | mixModeKeyerMenuMinV.addMenuItem(SPKMenuItem("[title overridden]", &mixModeMenu, true)); |
tobyspark | 36:8b5c75c8bc23 | 701 | |
tobyspark | 0:87aab40d5806 | 702 | |
tobyspark | 0:87aab40d5806 | 703 | resolutionMenu.title = "Resolution"; |
tobyspark | 27:27851d3d2bba | 704 | setResolutionMenuItems(); |
tobyspark | 0:87aab40d5806 | 705 | |
tobyspark | 27:27851d3d2bba | 706 | commsMenu.title = "Network Mode"; |
tobyspark | 27:27851d3d2bba | 707 | setCommsMenuItems(); |
tobyspark | 23:909928cafb95 | 708 | |
tobyspark | 15:4b394c64b461 | 709 | advancedMenu.title = "Troubleshooting"; |
tobyspark | 23:909928cafb95 | 710 | advancedMenu.addMenuItem(SPKMenuItem("HDCP Off", advancedHDCPOff)); |
tobyspark | 23:909928cafb95 | 711 | advancedMenu.addMenuItem(SPKMenuItem("HDCP On", advancedHDCPOn)); |
tobyspark | 35:d5d9f0838f99 | 712 | advancedMenu.addMenuItem(SPKMenuItem("EDID Passthrough", advancedEDIDPassthrough)); |
tobyspark | 31:01845a2347ff | 713 | advancedMenu.addMenuItem(SPKMenuItem("EDID Internal", advancedEDIDInternal)); |
tobyspark | 45:cf8c2400be5c | 714 | //advancedMenu.addMenuItem(SPKMenuItem("Test Processor Sources", advancedTestSources)); |
tobyspark | 45:cf8c2400be5c | 715 | //if (settingsAreCustom) advancedMenu.addMenuItem(SPKMenuItem("Revert Controller", advancedLoadDefaults)); |
tobyspark | 41:00d1cd3b2af2 | 716 | advancedMenu.addMenuItem(SPKMenuItem("Revert Processor", advancedConformProcessor)); |
tobyspark | 41:00d1cd3b2af2 | 717 | advancedMenu.addMenuItem(SPKMenuItem("Conform Processor", advancedConformUploadProcessor)); |
tobyspark | 24:49c6624119ae | 718 | advancedMenu.addMenuItem(SPKMenuItem("Back to Main Menu", &mainMenu)); |
tobyspark | 23:909928cafb95 | 719 | |
tobyspark | 0:87aab40d5806 | 720 | mainMenu.title = "Main Menu"; |
tobyspark | 24:49c6624119ae | 721 | mainMenu.addMenuItem(SPKMenuItem(mixModeMenu.title, &mixModeMenu)); |
tobyspark | 24:49c6624119ae | 722 | mainMenu.addMenuItem(SPKMenuItem(resolutionMenu.title, &resolutionMenu)); |
tobyspark | 24:49c6624119ae | 723 | mainMenu.addMenuItem(SPKMenuItem(commsMenu.title, &commsMenu)); |
tobyspark | 24:49c6624119ae | 724 | mainMenu.addMenuItem(SPKMenuItem(advancedMenu.title, &advancedMenu)); |
tobyspark | 23:909928cafb95 | 725 | |
tobyspark | 0:87aab40d5806 | 726 | selectedMenu = &mainMenu; |
tobyspark | 23:909928cafb95 | 727 | |
tobyspark | 0:87aab40d5806 | 728 | // Misc I/O stuff |
tobyspark | 0:87aab40d5806 | 729 | |
tobyspark | 0:87aab40d5806 | 730 | fadeAPO.period(0.001); |
tobyspark | 0:87aab40d5806 | 731 | fadeBPO.period(0.001); |
tobyspark | 0:87aab40d5806 | 732 | |
tobyspark | 12:c270870bdd23 | 733 | // Display menu and framing lines |
tobyspark | 0:87aab40d5806 | 734 | screen.horizLineToBuffer(kMenuLine1*pixInPage - 1); |
tobyspark | 0:87aab40d5806 | 735 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 736 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 737 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 738 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 739 | screen.horizLineToBuffer(kMenuLine2*pixInPage + pixInPage); |
tobyspark | 1:f9fca21102e0 | 740 | screen.horizLineToBuffer(kCommsStatusLine*pixInPage - 1); |
tobyspark | 1:f9fca21102e0 | 741 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 34:69dfe64e7e6b | 742 | screen.textToBuffer("TVOne: OK", kTVOneStatusLine); // handleTVOneSources will update this |
tobyspark | 30:873979018850 | 743 | |
tobyspark | 30:873979018850 | 744 | // If we do not have two solid sources, act on this as we rely on the window having a source for crossfade behaviour |
tobyspark | 30:873979018850 | 745 | // 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 | 34:69dfe64e7e6b | 746 | bool ok = handleTVOneSources(); |
tobyspark | 33:e6672a9bd571 | 747 | |
tobyspark | 33:e6672a9bd571 | 748 | // Update display before starting mixer loop |
tobyspark | 33:e6672a9bd571 | 749 | screen.sendBuffer(); |
tobyspark | 33:e6672a9bd571 | 750 | |
tobyspark | 0:87aab40d5806 | 751 | //// CONTROLS TEST |
tobyspark | 0:87aab40d5806 | 752 | |
tobyspark | 0:87aab40d5806 | 753 | while (0) { |
tobyspark | 0:87aab40d5806 | 754 | 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 | 755 | } |
tobyspark | 0:87aab40d5806 | 756 | |
tobyspark | 0:87aab40d5806 | 757 | //// MIXER RUN |
tobyspark | 0:87aab40d5806 | 758 | |
tobyspark | 8:d46cc49f0f37 | 759 | while (1) |
tobyspark | 8:d46cc49f0f37 | 760 | { |
tobyspark | 35:d5d9f0838f99 | 761 | bool updateMixMode = false; |
tobyspark | 35:d5d9f0838f99 | 762 | |
tobyspark | 1:f9fca21102e0 | 763 | //// Task background things |
tobyspark | 33:e6672a9bd571 | 764 | if ((osc || artNet) && rj45Mode == rj45Ethernet) |
tobyspark | 5:f8b285ca41ba | 765 | { |
tobyspark | 5:f8b285ca41ba | 766 | Net::poll(); |
tobyspark | 5:f8b285ca41ba | 767 | } |
tobyspark | 5:f8b285ca41ba | 768 | |
tobyspark | 5:f8b285ca41ba | 769 | //// RJ45 SWITCH |
tobyspark | 5:f8b285ca41ba | 770 | |
tobyspark | 5:f8b285ca41ba | 771 | if (rj45ModeDIN != rj45Mode) |
tobyspark | 1:f9fca21102e0 | 772 | { |
tobyspark | 23:909928cafb95 | 773 | if (debug) debug->printf("Handling RJ45 mode change\r\n"); |
tobyspark | 27:27851d3d2bba | 774 | |
tobyspark | 5:f8b285ca41ba | 775 | // update state |
tobyspark | 5:f8b285ca41ba | 776 | rj45Mode = rj45ModeDIN; |
tobyspark | 27:27851d3d2bba | 777 | |
tobyspark | 27:27851d3d2bba | 778 | setCommsMenuItems(); |
tobyspark | 5:f8b285ca41ba | 779 | |
tobyspark | 5:f8b285ca41ba | 780 | // cancel old comms |
tobyspark | 5:f8b285ca41ba | 781 | commsMode = commsNone; |
tobyspark | 5:f8b285ca41ba | 782 | commsMenu = commsMode; |
tobyspark | 5:f8b285ca41ba | 783 | |
tobyspark | 5:f8b285ca41ba | 784 | // refresh display |
tobyspark | 23:909928cafb95 | 785 | if (selectedMenu == &commsMenu) |
tobyspark | 23:909928cafb95 | 786 | { |
tobyspark | 33:e6672a9bd571 | 787 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 33:e6672a9bd571 | 788 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 23:909928cafb95 | 789 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 23:909928cafb95 | 790 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 23:909928cafb95 | 791 | } |
tobyspark | 5:f8b285ca41ba | 792 | if (rj45Mode == rj45Ethernet) screen.textToBuffer("RJ45: Ethernet Engaged", kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 793 | if (rj45Mode == rj45DMX) screen.textToBuffer("RJ45: DMX Engaged", kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 794 | } |
tobyspark | 1:f9fca21102e0 | 795 | |
tobyspark | 0:87aab40d5806 | 796 | //// MENU |
tobyspark | 0:87aab40d5806 | 797 | |
tobyspark | 0:87aab40d5806 | 798 | int menuChange = menuEnc.getChange(); |
tobyspark | 0:87aab40d5806 | 799 | |
tobyspark | 0:87aab40d5806 | 800 | // Update GUI |
tobyspark | 0:87aab40d5806 | 801 | if (menuChange != 0) |
tobyspark | 0:87aab40d5806 | 802 | { |
tobyspark | 24:49c6624119ae | 803 | if (selectedMenu->selectedItem().handlingControls) |
tobyspark | 24:49c6624119ae | 804 | { |
tobyspark | 24:49c6624119ae | 805 | if (selectedMenu == &mixModeAdditiveMenu) |
tobyspark | 24:49c6624119ae | 806 | { |
tobyspark | 24:49c6624119ae | 807 | fadeCurve += menuChange * 0.05; |
tobyspark | 24:49c6624119ae | 808 | if (fadeCurve > 1.0f) fadeCurve = 1.0f; |
tobyspark | 24:49c6624119ae | 809 | if (fadeCurve < 0.0f) fadeCurve = 0.0f; |
tobyspark | 29:95a7efe30527 | 810 | |
tobyspark | 31:01845a2347ff | 811 | int newMixMode = (fadeCurve > 0.0f) ? mixAdditive: mixBlend; |
tobyspark | 31:01845a2347ff | 812 | |
tobyspark | 31:01845a2347ff | 813 | if (newMixMode != mixMode) |
tobyspark | 31:01845a2347ff | 814 | { |
tobyspark | 31:01845a2347ff | 815 | mixMode = newMixMode; |
tobyspark | 35:d5d9f0838f99 | 816 | updateMixMode = true; |
tobyspark | 31:01845a2347ff | 817 | } |
tobyspark | 29:95a7efe30527 | 818 | |
tobyspark | 24:49c6624119ae | 819 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 29:95a7efe30527 | 820 | screen.textToBuffer("Blend [ ----- ] Add", kMenuLine2); |
tobyspark | 29:95a7efe30527 | 821 | screen.characterToBuffer('X', 38 + fadeCurve*20.0f, kMenuLine2); |
tobyspark | 24:49c6624119ae | 822 | |
tobyspark | 31:01845a2347ff | 823 | if (debug) debug->printf("Fade curve changed by %i to %f \r\n", menuChange, fadeCurve); |
tobyspark | 24:49c6624119ae | 824 | } |
tobyspark | 36:8b5c75c8bc23 | 825 | else if (selectedMenu == &mixModeKeyerMenuUpdate) |
tobyspark | 36:8b5c75c8bc23 | 826 | { |
tobyspark | 36:8b5c75c8bc23 | 827 | if (menuChange < 0) |
tobyspark | 36:8b5c75c8bc23 | 828 | { |
tobyspark | 36:8b5c75c8bc23 | 829 | settings.editingKeyerSetIndex = mixModeMenu.selectedIndex() - mixKeyStartIndex; |
tobyspark | 36:8b5c75c8bc23 | 830 | screen.textToBuffer("[Yes/ ]", kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 831 | } |
tobyspark | 36:8b5c75c8bc23 | 832 | else |
tobyspark | 36:8b5c75c8bc23 | 833 | { |
tobyspark | 36:8b5c75c8bc23 | 834 | settings.editingKeyerSetIndex = -1; |
tobyspark | 36:8b5c75c8bc23 | 835 | screen.textToBuffer("[ /No]", kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 836 | } |
tobyspark | 36:8b5c75c8bc23 | 837 | } |
tobyspark | 36:8b5c75c8bc23 | 838 | else if (selectedMenu == &mixModeKeyerMenuMinY) |
tobyspark | 36:8b5c75c8bc23 | 839 | { |
tobyspark | 36:8b5c75c8bc23 | 840 | int value = settings.editingKeyerSetValue(SPKSettings::minY); |
tobyspark | 36:8b5c75c8bc23 | 841 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 842 | if (value < 0) value = 0; |
tobyspark | 36:8b5c75c8bc23 | 843 | if (value > settings.editingKeyerSetValue(SPKSettings::maxY)) value = settings.editingKeyerSetValue(SPKSettings::maxY); |
tobyspark | 36:8b5c75c8bc23 | 844 | settings.setEditingKeyerSetValue(SPKSettings::minY, value); |
tobyspark | 36:8b5c75c8bc23 | 845 | |
tobyspark | 36:8b5c75c8bc23 | 846 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 847 | |
tobyspark | 36:8b5c75c8bc23 | 848 | char paramLine[kStringBufferLength]; |
tobyspark | 37:744bef2e8be8 | 849 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ / ][ / ]", value, |
tobyspark | 37:744bef2e8be8 | 850 | settings.editingKeyerSetValue(SPKSettings::maxY)); |
tobyspark | 36:8b5c75c8bc23 | 851 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 852 | |
tobyspark | 36:8b5c75c8bc23 | 853 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, value); |
tobyspark | 36:8b5c75c8bc23 | 854 | } |
tobyspark | 36:8b5c75c8bc23 | 855 | else if (selectedMenu == &mixModeKeyerMenuMaxY) |
tobyspark | 36:8b5c75c8bc23 | 856 | { |
tobyspark | 36:8b5c75c8bc23 | 857 | int value = settings.editingKeyerSetValue(SPKSettings::maxY); |
tobyspark | 36:8b5c75c8bc23 | 858 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 859 | if (value < 0) value = 0; |
tobyspark | 36:8b5c75c8bc23 | 860 | if (value > 255) value = 255; |
tobyspark | 36:8b5c75c8bc23 | 861 | settings.setEditingKeyerSetValue(SPKSettings::maxY, value); |
tobyspark | 36:8b5c75c8bc23 | 862 | |
tobyspark | 36:8b5c75c8bc23 | 863 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 864 | |
tobyspark | 36:8b5c75c8bc23 | 865 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 866 | snprintf(paramLine, kStringBufferLength, "[ /%3i][ / ][ / ]", value); |
tobyspark | 36:8b5c75c8bc23 | 867 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 868 | |
tobyspark | 36:8b5c75c8bc23 | 869 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, value); |
tobyspark | 36:8b5c75c8bc23 | 870 | } |
tobyspark | 36:8b5c75c8bc23 | 871 | else if (selectedMenu == &mixModeKeyerMenuMinU) |
tobyspark | 36:8b5c75c8bc23 | 872 | { |
tobyspark | 36:8b5c75c8bc23 | 873 | int value = settings.editingKeyerSetValue(SPKSettings::minU); |
tobyspark | 36:8b5c75c8bc23 | 874 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 875 | if (value > settings.editingKeyerSetValue(SPKSettings::maxU)) value = settings.editingKeyerSetValue(SPKSettings::maxU); |
tobyspark | 36:8b5c75c8bc23 | 876 | if (value > 255) value = 255; |
tobyspark | 36:8b5c75c8bc23 | 877 | settings.setEditingKeyerSetValue(SPKSettings::minU, value); |
tobyspark | 36:8b5c75c8bc23 | 878 | |
tobyspark | 36:8b5c75c8bc23 | 879 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 880 | |
tobyspark | 36:8b5c75c8bc23 | 881 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 882 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 883 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 37:744bef2e8be8 | 884 | value, |
tobyspark | 37:744bef2e8be8 | 885 | settings.editingKeyerSetValue(SPKSettings::maxU)); |
tobyspark | 36:8b5c75c8bc23 | 886 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 887 | |
tobyspark | 36:8b5c75c8bc23 | 888 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, value); |
tobyspark | 36:8b5c75c8bc23 | 889 | } |
tobyspark | 36:8b5c75c8bc23 | 890 | else if (selectedMenu == &mixModeKeyerMenuMaxU) |
tobyspark | 36:8b5c75c8bc23 | 891 | { |
tobyspark | 36:8b5c75c8bc23 | 892 | int value = settings.editingKeyerSetValue(SPKSettings::maxU); |
tobyspark | 36:8b5c75c8bc23 | 893 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 894 | if (value < 0) value = 0; |
tobyspark | 36:8b5c75c8bc23 | 895 | if (value > 255) value = 255; |
tobyspark | 36:8b5c75c8bc23 | 896 | settings.setEditingKeyerSetValue(SPKSettings::maxU, value); |
tobyspark | 36:8b5c75c8bc23 | 897 | |
tobyspark | 36:8b5c75c8bc23 | 898 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 899 | |
tobyspark | 36:8b5c75c8bc23 | 900 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 901 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ /%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 902 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 903 | value); |
tobyspark | 36:8b5c75c8bc23 | 904 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 905 | |
tobyspark | 36:8b5c75c8bc23 | 906 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, value); |
tobyspark | 36:8b5c75c8bc23 | 907 | } |
tobyspark | 36:8b5c75c8bc23 | 908 | else if (selectedMenu == &mixModeKeyerMenuMinV) |
tobyspark | 36:8b5c75c8bc23 | 909 | { |
tobyspark | 36:8b5c75c8bc23 | 910 | int value = settings.editingKeyerSetValue(SPKSettings::minV); |
tobyspark | 36:8b5c75c8bc23 | 911 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 912 | if (value > settings.editingKeyerSetValue(SPKSettings::maxV)) value = settings.editingKeyerSetValue(SPKSettings::maxV); |
tobyspark | 36:8b5c75c8bc23 | 913 | if (value > 255) value = 255; |
tobyspark | 36:8b5c75c8bc23 | 914 | settings.setEditingKeyerSetValue(SPKSettings::minV, value); |
tobyspark | 36:8b5c75c8bc23 | 915 | |
tobyspark | 36:8b5c75c8bc23 | 916 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 917 | |
tobyspark | 36:8b5c75c8bc23 | 918 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 919 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][%3i/%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 920 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 921 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 37:744bef2e8be8 | 922 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 37:744bef2e8be8 | 923 | value, |
tobyspark | 37:744bef2e8be8 | 924 | settings.editingKeyerSetValue(SPKSettings::maxV)); |
tobyspark | 36:8b5c75c8bc23 | 925 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 926 | |
tobyspark | 36:8b5c75c8bc23 | 927 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, value); |
tobyspark | 36:8b5c75c8bc23 | 928 | } |
tobyspark | 36:8b5c75c8bc23 | 929 | else if (selectedMenu == &mixModeKeyerMenuMaxV) |
tobyspark | 36:8b5c75c8bc23 | 930 | { |
tobyspark | 36:8b5c75c8bc23 | 931 | int value = settings.editingKeyerSetValue(SPKSettings::maxV); |
tobyspark | 36:8b5c75c8bc23 | 932 | value += menuChange; |
tobyspark | 36:8b5c75c8bc23 | 933 | if (value < 0) value = 0; |
tobyspark | 36:8b5c75c8bc23 | 934 | if (value > 255) value = 255; |
tobyspark | 36:8b5c75c8bc23 | 935 | settings.setEditingKeyerSetValue(SPKSettings::maxV, value); |
tobyspark | 36:8b5c75c8bc23 | 936 | |
tobyspark | 36:8b5c75c8bc23 | 937 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 938 | |
tobyspark | 36:8b5c75c8bc23 | 939 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 940 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ /%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 941 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 942 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 36:8b5c75c8bc23 | 943 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 36:8b5c75c8bc23 | 944 | value); |
tobyspark | 36:8b5c75c8bc23 | 945 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 946 | |
tobyspark | 36:8b5c75c8bc23 | 947 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, value); |
tobyspark | 36:8b5c75c8bc23 | 948 | } |
tobyspark | 24:49c6624119ae | 949 | } |
tobyspark | 24:49c6624119ae | 950 | else |
tobyspark | 24:49c6624119ae | 951 | { |
tobyspark | 24:49c6624119ae | 952 | if (debug) debug->printf("Menu changed by %i\r\n", menuChange); |
tobyspark | 24:49c6624119ae | 953 | |
tobyspark | 24:49c6624119ae | 954 | *selectedMenu = selectedMenu->selectedIndex() + menuChange; |
tobyspark | 24:49c6624119ae | 955 | |
tobyspark | 24:49c6624119ae | 956 | // update OLED line 2 here |
tobyspark | 24:49c6624119ae | 957 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 24:49c6624119ae | 958 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 24:49c6624119ae | 959 | |
tobyspark | 24:49c6624119ae | 960 | if (debug) debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 24:49c6624119ae | 961 | } |
tobyspark | 0:87aab40d5806 | 962 | } |
tobyspark | 0:87aab40d5806 | 963 | |
tobyspark | 0:87aab40d5806 | 964 | // Action menu item |
tobyspark | 0:87aab40d5806 | 965 | if (menuEnc.hasPressed()) |
tobyspark | 0:87aab40d5806 | 966 | { |
tobyspark | 0:87aab40d5806 | 967 | if (debug) debug->printf("Action Menu Item!\r\n"); |
tobyspark | 21:f9d63cb7cedb | 968 | |
tobyspark | 0:87aab40d5806 | 969 | // Are we changing menus? |
tobyspark | 23:909928cafb95 | 970 | if (selectedMenu->selectedItem().type == SPKMenuItem::changesToMenu) |
tobyspark | 0:87aab40d5806 | 971 | { |
tobyspark | 31:01845a2347ff | 972 | // If we're exiting the menu, we should set its selected index back to the menu's beginning... |
tobyspark | 31:01845a2347ff | 973 | SPKMenu* menuToReset = selectedMenu->selectedItem().payload.menu == &mainMenu? selectedMenu : NULL; |
tobyspark | 31:01845a2347ff | 974 | |
tobyspark | 31:01845a2347ff | 975 | // point selected menu pointer to the new menu pointer |
tobyspark | 23:909928cafb95 | 976 | selectedMenu = selectedMenu->selectedItem().payload.menu; |
tobyspark | 0:87aab40d5806 | 977 | |
tobyspark | 31:01845a2347ff | 978 | // ...doing this, of course, after we've used the value |
tobyspark | 31:01845a2347ff | 979 | if (menuToReset) *menuToReset = 0; |
tobyspark | 31:01845a2347ff | 980 | |
tobyspark | 0:87aab40d5806 | 981 | // update OLED lines 1&2 |
tobyspark | 0:87aab40d5806 | 982 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 983 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 984 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 985 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 986 | |
tobyspark | 0:87aab40d5806 | 987 | if (debug) |
tobyspark | 0:87aab40d5806 | 988 | { |
tobyspark | 0:87aab40d5806 | 989 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 990 | debug->printf("%s \r\n", selectedMenu->title.c_str()); |
tobyspark | 0:87aab40d5806 | 991 | debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 0:87aab40d5806 | 992 | } |
tobyspark | 24:49c6624119ae | 993 | |
tobyspark | 24:49c6624119ae | 994 | // Are we changing menus that should have a command attached? |
tobyspark | 24:49c6624119ae | 995 | if (selectedMenu == &mixModeAdditiveMenu) |
tobyspark | 24:49c6624119ae | 996 | { |
tobyspark | 29:95a7efe30527 | 997 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 29:95a7efe30527 | 998 | screen.textToBuffer("Blend [ ----- ] Add", kMenuLine2); |
tobyspark | 29:95a7efe30527 | 999 | screen.characterToBuffer('X', 38 + fadeCurve*20.0f, kMenuLine2); |
tobyspark | 29:95a7efe30527 | 1000 | |
tobyspark | 29:95a7efe30527 | 1001 | mixMode = fadeCurve > 0 ? mixAdditive : mixBlend; |
tobyspark | 35:d5d9f0838f99 | 1002 | updateMixMode = true; |
tobyspark | 24:49c6624119ae | 1003 | } |
tobyspark | 36:8b5c75c8bc23 | 1004 | else if (selectedMenu == &mixModeKeyerMenuUpdate) |
tobyspark | 36:8b5c75c8bc23 | 1005 | { |
tobyspark | 36:8b5c75c8bc23 | 1006 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1007 | if (settings.editingKeyerSetIndex == mixModeMenu.selectedIndex() - mixKeyStartIndex) |
tobyspark | 36:8b5c75c8bc23 | 1008 | screen.textToBuffer("[Yes/ ]", kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1009 | else |
tobyspark | 36:8b5c75c8bc23 | 1010 | screen.textToBuffer("[ /No]", kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1011 | |
tobyspark | 36:8b5c75c8bc23 | 1012 | mixMode = mixKey; |
tobyspark | 36:8b5c75c8bc23 | 1013 | updateMixMode = true; |
tobyspark | 36:8b5c75c8bc23 | 1014 | } |
tobyspark | 36:8b5c75c8bc23 | 1015 | else if (selectedMenu == &mixModeKeyerMenuMinY) |
tobyspark | 36:8b5c75c8bc23 | 1016 | { |
tobyspark | 36:8b5c75c8bc23 | 1017 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1018 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1019 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ / ][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 1020 | settings.editingKeyerSetValue(SPKSettings::maxY)); |
tobyspark | 36:8b5c75c8bc23 | 1021 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1022 | } |
tobyspark | 36:8b5c75c8bc23 | 1023 | else if (selectedMenu == &mixModeKeyerMenuMaxY) |
tobyspark | 36:8b5c75c8bc23 | 1024 | { |
tobyspark | 36:8b5c75c8bc23 | 1025 | // First, check outcome of menu that got us here: mixModeKeyerMenuUpdate |
tobyspark | 36:8b5c75c8bc23 | 1026 | if (settings.editingKeyerSetIndex == -1) |
tobyspark | 36:8b5c75c8bc23 | 1027 | { |
tobyspark | 36:8b5c75c8bc23 | 1028 | selectedMenu = &mixModeMenu; |
tobyspark | 36:8b5c75c8bc23 | 1029 | |
tobyspark | 36:8b5c75c8bc23 | 1030 | // update OLED lines 1&2 |
tobyspark | 36:8b5c75c8bc23 | 1031 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 36:8b5c75c8bc23 | 1032 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1033 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 36:8b5c75c8bc23 | 1034 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1035 | } |
tobyspark | 36:8b5c75c8bc23 | 1036 | else |
tobyspark | 36:8b5c75c8bc23 | 1037 | { |
tobyspark | 36:8b5c75c8bc23 | 1038 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1039 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1040 | snprintf(paramLine, kStringBufferLength, "[ /%3i][ / ][ / ]", settings.editingKeyerSetValue(SPKSettings::maxY)); |
tobyspark | 36:8b5c75c8bc23 | 1041 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1042 | } |
tobyspark | 36:8b5c75c8bc23 | 1043 | } |
tobyspark | 36:8b5c75c8bc23 | 1044 | else if (selectedMenu == &mixModeKeyerMenuMinU) |
tobyspark | 36:8b5c75c8bc23 | 1045 | { |
tobyspark | 36:8b5c75c8bc23 | 1046 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1047 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1048 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 1049 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 1050 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 36:8b5c75c8bc23 | 1051 | settings.editingKeyerSetValue(SPKSettings::maxU)); |
tobyspark | 36:8b5c75c8bc23 | 1052 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1053 | } |
tobyspark | 36:8b5c75c8bc23 | 1054 | else if (selectedMenu == &mixModeKeyerMenuMaxU) |
tobyspark | 36:8b5c75c8bc23 | 1055 | { |
tobyspark | 36:8b5c75c8bc23 | 1056 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1057 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1058 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][ /%3i][ / ]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 1059 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 1060 | settings.editingKeyerSetValue(SPKSettings::maxU)); |
tobyspark | 36:8b5c75c8bc23 | 1061 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1062 | } |
tobyspark | 36:8b5c75c8bc23 | 1063 | else if (selectedMenu == &mixModeKeyerMenuMinV) |
tobyspark | 36:8b5c75c8bc23 | 1064 | { |
tobyspark | 36:8b5c75c8bc23 | 1065 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1066 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1067 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][%3i/%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 1068 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 1069 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 36:8b5c75c8bc23 | 1070 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 36:8b5c75c8bc23 | 1071 | settings.editingKeyerSetValue(SPKSettings::minV), |
tobyspark | 36:8b5c75c8bc23 | 1072 | settings.editingKeyerSetValue(SPKSettings::maxV)); |
tobyspark | 36:8b5c75c8bc23 | 1073 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1074 | } |
tobyspark | 36:8b5c75c8bc23 | 1075 | else if (selectedMenu == &mixModeKeyerMenuMaxV) |
tobyspark | 36:8b5c75c8bc23 | 1076 | { |
tobyspark | 36:8b5c75c8bc23 | 1077 | char paramLine[kStringBufferLength]; |
tobyspark | 36:8b5c75c8bc23 | 1078 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1079 | snprintf(paramLine, kStringBufferLength, "[%3i/%3i][%3i/%3i][ /%3i]", settings.editingKeyerSetValue(SPKSettings::minY), |
tobyspark | 36:8b5c75c8bc23 | 1080 | settings.editingKeyerSetValue(SPKSettings::maxY), |
tobyspark | 36:8b5c75c8bc23 | 1081 | settings.editingKeyerSetValue(SPKSettings::minU), |
tobyspark | 36:8b5c75c8bc23 | 1082 | settings.editingKeyerSetValue(SPKSettings::maxU), |
tobyspark | 36:8b5c75c8bc23 | 1083 | settings.editingKeyerSetValue(SPKSettings::maxV)); |
tobyspark | 36:8b5c75c8bc23 | 1084 | screen.textToBuffer(paramLine, kMenuLine2); |
tobyspark | 36:8b5c75c8bc23 | 1085 | } |
tobyspark | 0:87aab40d5806 | 1086 | } |
tobyspark | 0:87aab40d5806 | 1087 | // With that out of the way, we should be actioning a specific menu's payload? |
tobyspark | 44:723e65413ebe | 1088 | else if (selectedMenu == &mixModeMenu) |
tobyspark | 44:723e65413ebe | 1089 | { |
tobyspark | 44:723e65413ebe | 1090 | // mixAdditive and mixKeyXYZ are now SPKMenus so are handled above. |
tobyspark | 44:723e65413ebe | 1091 | // This should only ever do mixBlend for non d-fuser firmware processors |
tobyspark | 44:723e65413ebe | 1092 | mixMode = mixModeMenu.selectedItem().payload.command[0]; |
tobyspark | 44:723e65413ebe | 1093 | updateMixMode = true; |
tobyspark | 44:723e65413ebe | 1094 | } |
tobyspark | 0:87aab40d5806 | 1095 | else if (selectedMenu == &resolutionMenu) |
tobyspark | 0:87aab40d5806 | 1096 | { |
tobyspark | 44:723e65413ebe | 1097 | bool ok; |
tobyspark | 31:01845a2347ff | 1098 | int32_t slot = tvOneEDIDPassthrough ? EDIDPassthroughSlot : resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 31:01845a2347ff | 1099 | |
tobyspark | 44:723e65413ebe | 1100 | ok = tvOne.setResolution(resolutionMenu.selectedItem().payload.command[0], slot); |
tobyspark | 0:87aab40d5806 | 1101 | |
tobyspark | 35:d5d9f0838f99 | 1102 | // Save new resolution and EDID into TV One unit for power-on. Cycling TV One power sometimes needed for EDID. Pffft. |
tobyspark | 44:723e65413ebe | 1103 | if (ok) tvOne.command(0, kTV1WindowIDA, kTV1FunctionPowerOnPresetStore, 1); |
tobyspark | 35:d5d9f0838f99 | 1104 | |
tobyspark | 25:3b519ef70341 | 1105 | string sentOK; |
tobyspark | 0:87aab40d5806 | 1106 | if (ok) sentOK = "Sent: "; |
tobyspark | 0:87aab40d5806 | 1107 | else sentOK = "Send Error: "; |
tobyspark | 0:87aab40d5806 | 1108 | |
tobyspark | 26:0299f8760715 | 1109 | char sentMSGBuffer[kStringBufferLength]; |
tobyspark | 26:0299f8760715 | 1110 | snprintf(sentMSGBuffer, kStringBufferLength,"Res %i, EDID %i", resolutionMenu.selectedItem().payload.command[0], resolutionMenu.selectedItem().payload.command[1]); |
tobyspark | 0:87aab40d5806 | 1111 | |
tobyspark | 1:f9fca21102e0 | 1112 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 25:3b519ef70341 | 1113 | screen.textToBuffer(sentOK + sentMSGBuffer, kTVOneStatusLine); |
tobyspark | 0:87aab40d5806 | 1114 | |
tobyspark | 0:87aab40d5806 | 1115 | if (debug) { debug->printf("Changing resolution"); } |
tobyspark | 0:87aab40d5806 | 1116 | } |
tobyspark | 1:f9fca21102e0 | 1117 | else if (selectedMenu == &commsMenu) |
tobyspark | 1:f9fca21102e0 | 1118 | { |
tobyspark | 26:0299f8760715 | 1119 | string commsTypeString = "Network:"; |
tobyspark | 26:0299f8760715 | 1120 | char commsStatusBuffer[kStringBufferLength] = "--"; |
tobyspark | 1:f9fca21102e0 | 1121 | |
tobyspark | 1:f9fca21102e0 | 1122 | // Tear down any existing comms |
tobyspark | 1:f9fca21102e0 | 1123 | // This is the action of commsNone |
tobyspark | 1:f9fca21102e0 | 1124 | // And also clears the way for other comms actions |
tobyspark | 26:0299f8760715 | 1125 | commsMode = commsNone; |
tobyspark | 5:f8b285ca41ba | 1126 | if (osc) {delete osc; osc = NULL;} |
tobyspark | 5:f8b285ca41ba | 1127 | if (ethernet) {delete ethernet; ethernet = NULL;} |
tobyspark | 33:e6672a9bd571 | 1128 | if (artNet) |
tobyspark | 33:e6672a9bd571 | 1129 | { |
tobyspark | 33:e6672a9bd571 | 1130 | artNet->ArtPollReply.NumPorts = 0; |
tobyspark | 33:e6672a9bd571 | 1131 | strcpy(artNet->ArtPollReply.NodeReport, "Shutdown"); |
tobyspark | 33:e6672a9bd571 | 1132 | artNet->SendArtPollReply(); |
tobyspark | 33:e6672a9bd571 | 1133 | artNet->Done(); |
tobyspark | 33:e6672a9bd571 | 1134 | delete artNet; |
tobyspark | 33:e6672a9bd571 | 1135 | artNet = NULL; |
tobyspark | 33:e6672a9bd571 | 1136 | } |
tobyspark | 5:f8b285ca41ba | 1137 | if (dmx) {delete dmx; dmx = NULL;} |
tobyspark | 5:f8b285ca41ba | 1138 | |
tobyspark | 5:f8b285ca41ba | 1139 | // Ensure we can't change to comms modes the hardware isn't switched to |
tobyspark | 23:909928cafb95 | 1140 | if (rj45Mode == rj45DMX && (commsMenu.selectedItem().payload.command[0] == commsOSC || commsMenu.selectedItem().payload.command[0] == commsArtNet)) |
tobyspark | 1:f9fca21102e0 | 1141 | { |
tobyspark | 5:f8b285ca41ba | 1142 | commsTypeString = "RJ45 not in Ethernet mode"; |
tobyspark | 5:f8b285ca41ba | 1143 | } |
tobyspark | 23:909928cafb95 | 1144 | else if (rj45Mode == rj45Ethernet && (commsMenu.selectedItem().payload.command[0] == commsDMXIn || commsMenu.selectedItem().payload.command[0] == commsDMXOut)) |
tobyspark | 5:f8b285ca41ba | 1145 | { |
tobyspark | 5:f8b285ca41ba | 1146 | commsTypeString = "RJ45 not in DMX mode"; |
tobyspark | 5:f8b285ca41ba | 1147 | } |
tobyspark | 5:f8b285ca41ba | 1148 | // Action! |
tobyspark | 23:909928cafb95 | 1149 | else if (commsMenu.selectedItem().payload.command[0] == commsOSC) |
tobyspark | 5:f8b285ca41ba | 1150 | { |
tobyspark | 5:f8b285ca41ba | 1151 | commsMode = commsOSC; |
tobyspark | 5:f8b285ca41ba | 1152 | commsTypeString = "OSC: "; |
tobyspark | 1:f9fca21102e0 | 1153 | |
tobyspark | 1:f9fca21102e0 | 1154 | ethernet = new EthernetNetIf( |
tobyspark | 1:f9fca21102e0 | 1155 | IpAddr(kOSCMbedIPAddress), |
tobyspark | 1:f9fca21102e0 | 1156 | IpAddr(kOSCMbedSubnetMask), |
tobyspark | 1:f9fca21102e0 | 1157 | IpAddr(kOSCMbedGateway), |
tobyspark | 1:f9fca21102e0 | 1158 | IpAddr(kOSCMbedDNS) |
tobyspark | 1:f9fca21102e0 | 1159 | ); |
tobyspark | 3:033d2b7768f3 | 1160 | |
tobyspark | 1:f9fca21102e0 | 1161 | EthernetErr ethError = ethernet->setup(); |
tobyspark | 1:f9fca21102e0 | 1162 | if(ethError) |
tobyspark | 1:f9fca21102e0 | 1163 | { |
tobyspark | 1:f9fca21102e0 | 1164 | if (debug) debug->printf("Ethernet setup error, %d", ethError); |
tobyspark | 26:0299f8760715 | 1165 | snprintf(commsStatusBuffer, kStringBufferLength, "Ethernet setup failed"); |
tobyspark | 5:f8b285ca41ba | 1166 | commsMenu = commsNone; |
tobyspark | 1:f9fca21102e0 | 1167 | // break out of here. this setup should be a function that returns a boolean |
tobyspark | 1:f9fca21102e0 | 1168 | } |
tobyspark | 1:f9fca21102e0 | 1169 | |
tobyspark | 1:f9fca21102e0 | 1170 | osc = new OSCClass(); |
tobyspark | 33:e6672a9bd571 | 1171 | osc->setReceiveMessage(&receiveMessage); |
tobyspark | 1:f9fca21102e0 | 1172 | osc->begin(kOSCMbedPort); |
tobyspark | 1:f9fca21102e0 | 1173 | |
tobyspark | 26:0299f8760715 | 1174 | snprintf(commsStatusBuffer, kStringBufferLength, "Listening on %i", kOSCMbedPort); |
tobyspark | 1:f9fca21102e0 | 1175 | } |
tobyspark | 23:909928cafb95 | 1176 | else if (commsMenu.selectedItem().payload.command[0] == commsArtNet) |
tobyspark | 1:f9fca21102e0 | 1177 | { |
tobyspark | 5:f8b285ca41ba | 1178 | commsMode = commsArtNet; |
tobyspark | 5:f8b285ca41ba | 1179 | commsTypeString = "ArtNet: "; |
tobyspark | 3:033d2b7768f3 | 1180 | |
tobyspark | 3:033d2b7768f3 | 1181 | artNet = new DmxArtNet(); |
tobyspark | 1:f9fca21102e0 | 1182 | |
tobyspark | 3:033d2b7768f3 | 1183 | artNet->BindIpAddress = IpAddr(kArtNetBindIPAddress); |
tobyspark | 3:033d2b7768f3 | 1184 | artNet->BCastAddress = IpAddr(kArtNetBroadcastAddress); |
tobyspark | 3:033d2b7768f3 | 1185 | |
tobyspark | 3:033d2b7768f3 | 1186 | artNet->InitArtPollReplyDefaults(); |
tobyspark | 3:033d2b7768f3 | 1187 | |
tobyspark | 33:e6672a9bd571 | 1188 | artNet->ArtPollReply.PortType[0] = 128; // Bit 7 = Set is this channel can output data from the Art-Net Network. |
tobyspark | 33:e6672a9bd571 | 1189 | artNet->ArtPollReply.GoodOutput[0] = 128; // Bit 7 = Set – Data is being transmitted. |
tobyspark | 33:e6672a9bd571 | 1190 | artNet->ArtPollReply.PortType[2] = 64; // Bit 6 = Set if this channel can input onto the Art-NetNetwork. |
tobyspark | 33:e6672a9bd571 | 1191 | artNet->ArtPollReply.GoodInput[2] = 128; // Bit 7 = Set – Data received. |
tobyspark | 3:033d2b7768f3 | 1192 | |
tobyspark | 3:033d2b7768f3 | 1193 | artNet->Init(); |
tobyspark | 3:033d2b7768f3 | 1194 | artNet->SendArtPollReply(); // announce to art-net nodes |
tobyspark | 3:033d2b7768f3 | 1195 | |
tobyspark | 26:0299f8760715 | 1196 | snprintf(commsStatusBuffer, kStringBufferLength, "Listening"); |
tobyspark | 1:f9fca21102e0 | 1197 | } |
tobyspark | 23:909928cafb95 | 1198 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXIn) |
tobyspark | 1:f9fca21102e0 | 1199 | { |
tobyspark | 5:f8b285ca41ba | 1200 | commsMode = commsDMXIn; |
tobyspark | 5:f8b285ca41ba | 1201 | commsTypeString = "DMX In: "; |
tobyspark | 1:f9fca21102e0 | 1202 | |
tobyspark | 5:f8b285ca41ba | 1203 | dmxDirectionDOUT = 0; |
tobyspark | 5:f8b285ca41ba | 1204 | |
tobyspark | 5:f8b285ca41ba | 1205 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 1:f9fca21102e0 | 1206 | } |
tobyspark | 23:909928cafb95 | 1207 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 1208 | { |
tobyspark | 5:f8b285ca41ba | 1209 | commsMode = commsDMXOut; |
tobyspark | 5:f8b285ca41ba | 1210 | commsTypeString = "DMX Out: "; |
tobyspark | 5:f8b285ca41ba | 1211 | |
tobyspark | 5:f8b285ca41ba | 1212 | dmxDirectionDOUT = 1; |
tobyspark | 5:f8b285ca41ba | 1213 | |
tobyspark | 5:f8b285ca41ba | 1214 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 5:f8b285ca41ba | 1215 | } |
tobyspark | 5:f8b285ca41ba | 1216 | |
tobyspark | 1:f9fca21102e0 | 1217 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 25:3b519ef70341 | 1218 | screen.textToBuffer(commsTypeString + commsStatusBuffer, kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 1219 | } |
tobyspark | 12:c270870bdd23 | 1220 | else if (selectedMenu == &advancedMenu) |
tobyspark | 12:c270870bdd23 | 1221 | { |
tobyspark | 23:909928cafb95 | 1222 | if (advancedMenu.selectedItem().payload.command[0] == advancedHDCPOff) |
tobyspark | 12:c270870bdd23 | 1223 | { |
tobyspark | 31:01845a2347ff | 1224 | bool ok; |
tobyspark | 12:c270870bdd23 | 1225 | |
tobyspark | 15:4b394c64b461 | 1226 | ok = tvOne.setHDCPOn(false); |
tobyspark | 12:c270870bdd23 | 1227 | |
tobyspark | 12:c270870bdd23 | 1228 | std::string sendOK = ok ? "Sent: HDCP Off" : "Send Error: HDCP Off"; |
tobyspark | 12:c270870bdd23 | 1229 | |
tobyspark | 12:c270870bdd23 | 1230 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 12:c270870bdd23 | 1231 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 12:c270870bdd23 | 1232 | } |
tobyspark | 23:909928cafb95 | 1233 | else if (advancedMenu.selectedItem().payload.command[0] == advancedHDCPOn) |
tobyspark | 15:4b394c64b461 | 1234 | { |
tobyspark | 31:01845a2347ff | 1235 | bool ok; |
tobyspark | 15:4b394c64b461 | 1236 | |
tobyspark | 15:4b394c64b461 | 1237 | ok = tvOne.setHDCPOn(true); |
tobyspark | 15:4b394c64b461 | 1238 | |
tobyspark | 15:4b394c64b461 | 1239 | std::string sendOK = ok ? "Sent: HDCP On" : "Send Error: HDCP On"; |
tobyspark | 15:4b394c64b461 | 1240 | |
tobyspark | 15:4b394c64b461 | 1241 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 15:4b394c64b461 | 1242 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 15:4b394c64b461 | 1243 | } |
tobyspark | 31:01845a2347ff | 1244 | else if (advancedMenu.selectedItem().payload.command[0] == advancedEDIDPassthrough) |
tobyspark | 31:01845a2347ff | 1245 | { |
tobyspark | 31:01845a2347ff | 1246 | tvOneEDIDPassthrough = true; |
tobyspark | 31:01845a2347ff | 1247 | |
tobyspark | 31:01845a2347ff | 1248 | bool ok = true; |
tobyspark | 31:01845a2347ff | 1249 | |
tobyspark | 31:01845a2347ff | 1250 | int32_t slot = tvOneEDIDPassthrough ? EDIDPassthroughSlot : resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 31:01845a2347ff | 1251 | |
tobyspark | 31:01845a2347ff | 1252 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 31:01845a2347ff | 1253 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 31:01845a2347ff | 1254 | |
tobyspark | 31:01845a2347ff | 1255 | std::string sendOK = ok ? "Sent: EDID. Next:conform?" : "Send Error: EDID"; |
tobyspark | 31:01845a2347ff | 1256 | |
tobyspark | 31:01845a2347ff | 1257 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 31:01845a2347ff | 1258 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 31:01845a2347ff | 1259 | } |
tobyspark | 31:01845a2347ff | 1260 | else if (advancedMenu.selectedItem().payload.command[0] == advancedEDIDInternal) |
tobyspark | 31:01845a2347ff | 1261 | { |
tobyspark | 31:01845a2347ff | 1262 | tvOneEDIDPassthrough = false; |
tobyspark | 31:01845a2347ff | 1263 | |
tobyspark | 31:01845a2347ff | 1264 | bool ok = true; |
tobyspark | 31:01845a2347ff | 1265 | |
tobyspark | 31:01845a2347ff | 1266 | int32_t slot = tvOneEDIDPassthrough ? EDIDPassthroughSlot : resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 31:01845a2347ff | 1267 | |
tobyspark | 31:01845a2347ff | 1268 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 31:01845a2347ff | 1269 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, slot); |
tobyspark | 31:01845a2347ff | 1270 | |
tobyspark | 31:01845a2347ff | 1271 | std::string sendOK = ok ? "Sent: EDID. Next:conform?" : "Send Error: EDID"; |
tobyspark | 31:01845a2347ff | 1272 | |
tobyspark | 31:01845a2347ff | 1273 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 31:01845a2347ff | 1274 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 31:01845a2347ff | 1275 | } |
tobyspark | 30:873979018850 | 1276 | else if (advancedMenu.selectedItem().payload.command[0] == advancedTestSources) |
tobyspark | 34:69dfe64e7e6b | 1277 | { |
tobyspark | 34:69dfe64e7e6b | 1278 | tvOneRGB1Stable = false; |
tobyspark | 34:69dfe64e7e6b | 1279 | tvOneRGB2Stable = false; |
tobyspark | 34:69dfe64e7e6b | 1280 | handleTVOneSources(); |
tobyspark | 29:95a7efe30527 | 1281 | } |
tobyspark | 23:909928cafb95 | 1282 | else if (advancedMenu.selectedItem().payload.command[0] == advancedConformProcessor) |
tobyspark | 17:fc68d40b8b1f | 1283 | { |
tobyspark | 20:8b92d7922c48 | 1284 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1285 | screen.textToBuffer("Reverting...", kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1286 | screen.sendBuffer(); |
tobyspark | 41:00d1cd3b2af2 | 1287 | |
tobyspark | 41:00d1cd3b2af2 | 1288 | bool ok = conformProcessor(); |
tobyspark | 41:00d1cd3b2af2 | 1289 | |
tobyspark | 41:00d1cd3b2af2 | 1290 | std::string sendOK = ok ? "Reverting success" : "Send Error: Revert"; |
tobyspark | 41:00d1cd3b2af2 | 1291 | |
tobyspark | 41:00d1cd3b2af2 | 1292 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1293 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1294 | } |
tobyspark | 41:00d1cd3b2af2 | 1295 | else if (advancedMenu.selectedItem().payload.command[0] == advancedConformUploadProcessor) |
tobyspark | 41:00d1cd3b2af2 | 1296 | { |
tobyspark | 41:00d1cd3b2af2 | 1297 | bool ok = true; |
tobyspark | 41:00d1cd3b2af2 | 1298 | |
tobyspark | 41:00d1cd3b2af2 | 1299 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1300 | screen.textToBuffer("Uploading...", kTVOneStatusLine); |
tobyspark | 41:00d1cd3b2af2 | 1301 | screen.sendBuffer(); |
tobyspark | 41:00d1cd3b2af2 | 1302 | |
tobyspark | 41:00d1cd3b2af2 | 1303 | ok = ok && uploadToProcessor(); |
tobyspark | 41:00d1cd3b2af2 | 1304 | |
tobyspark | 41:00d1cd3b2af2 | 1305 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 1306 | screen.textToBuffer("Conforming...", kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 1307 | screen.sendBuffer(); |
tobyspark | 20:8b92d7922c48 | 1308 | |
tobyspark | 41:00d1cd3b2af2 | 1309 | ok = ok && conformProcessor(); |
tobyspark | 17:fc68d40b8b1f | 1310 | |
tobyspark | 17:fc68d40b8b1f | 1311 | std::string sendOK = ok ? "Conform success" : "Send Error: Conform"; |
tobyspark | 17:fc68d40b8b1f | 1312 | |
tobyspark | 17:fc68d40b8b1f | 1313 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 17:fc68d40b8b1f | 1314 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 17:fc68d40b8b1f | 1315 | } |
tobyspark | 23:909928cafb95 | 1316 | else if (advancedMenu.selectedItem().payload.command[0] == advancedLoadDefaults) |
tobyspark | 16:52484666b323 | 1317 | { |
tobyspark | 16:52484666b323 | 1318 | settings.loadDefaults(); |
tobyspark | 27:27851d3d2bba | 1319 | setMixModeMenuItems(); |
tobyspark | 27:27851d3d2bba | 1320 | setResolutionMenuItems(); |
tobyspark | 16:52484666b323 | 1321 | |
tobyspark | 16:52484666b323 | 1322 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 16:52484666b323 | 1323 | screen.textToBuffer("Controller reverted", kTVOneStatusLine); |
tobyspark | 16:52484666b323 | 1324 | } |
tobyspark | 23:909928cafb95 | 1325 | else if (advancedMenu.selectedItem().payload.command[0] == advancedSetResolutions) |
tobyspark | 21:f9d63cb7cedb | 1326 | { |
tobyspark | 21:f9d63cb7cedb | 1327 | bool ok; |
tobyspark | 44:723e65413ebe | 1328 | ok = tvOne.uploadCustomResolutions(); |
tobyspark | 21:f9d63cb7cedb | 1329 | |
tobyspark | 21:f9d63cb7cedb | 1330 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 21:f9d63cb7cedb | 1331 | screen.textToBuffer(ok ? "Resolutions set" : "Res' could not be set", kTVOneStatusLine); |
tobyspark | 21:f9d63cb7cedb | 1332 | } |
tobyspark | 12:c270870bdd23 | 1333 | } |
tobyspark | 0:87aab40d5806 | 1334 | else |
tobyspark | 0:87aab40d5806 | 1335 | { |
tobyspark | 0:87aab40d5806 | 1336 | if (debug) { debug->printf("Warning: No action identified"); } |
tobyspark | 0:87aab40d5806 | 1337 | } |
tobyspark | 0:87aab40d5806 | 1338 | } |
tobyspark | 0:87aab40d5806 | 1339 | |
tobyspark | 34:69dfe64e7e6b | 1340 | // Send any updates to the display |
tobyspark | 34:69dfe64e7e6b | 1341 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 1342 | |
tobyspark | 5:f8b285ca41ba | 1343 | //// MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIXMIX MIX MIXMIX MIX MIX MIX MIX MIXMIX MIX MIX |
tobyspark | 0:87aab40d5806 | 1344 | |
tobyspark | 0:87aab40d5806 | 1345 | bool updateFade = false; |
tobyspark | 3:033d2b7768f3 | 1346 | float xFade = 0; |
tobyspark | 3:033d2b7768f3 | 1347 | float fadeUp = 1; |
tobyspark | 3:033d2b7768f3 | 1348 | |
tobyspark | 3:033d2b7768f3 | 1349 | //// TASK: Process control surface |
tobyspark | 3:033d2b7768f3 | 1350 | |
tobyspark | 0:87aab40d5806 | 1351 | // Get new states of tap buttons, remembering at end of loop() assign these current values to the previous variables |
tobyspark | 5:f8b285ca41ba | 1352 | const bool tapLeft = !tapLeftDIN; |
tobyspark | 5:f8b285ca41ba | 1353 | const bool tapRight = !tapRightDIN; |
tobyspark | 0:87aab40d5806 | 1354 | |
tobyspark | 17:fc68d40b8b1f | 1355 | // We're taking a further median of the AINs on top of mbed libs v29. |
tobyspark | 17:fc68d40b8b1f | 1356 | // This takes some values from last passes and most from now. With debug off, seem to need median size > 5 |
tobyspark | 17:fc68d40b8b1f | 1357 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1358 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1359 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1360 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1361 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1362 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1363 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1364 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1365 | const float xFadeAINCached = xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 1366 | const float fadeUpAINCached = fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 1367 | |
tobyspark | 0:87aab40d5806 | 1368 | // When a tap is depressed, we can ignore any move of the crossfader but not fade to black |
tobyspark | 0:87aab40d5806 | 1369 | if (tapLeft || tapRight) |
tobyspark | 0:87aab40d5806 | 1370 | { |
tobyspark | 5:f8b285ca41ba | 1371 | // If both are pressed, take to the one that is new, ie. not the first pressed. |
tobyspark | 0:87aab40d5806 | 1372 | if (tapLeft && tapRight) |
tobyspark | 0:87aab40d5806 | 1373 | { |
tobyspark | 5:f8b285ca41ba | 1374 | xFade = tapLeftWasFirstPressed ? 1 : 0; |
tobyspark | 0:87aab40d5806 | 1375 | } |
tobyspark | 5:f8b285ca41ba | 1376 | // If just one is pressed, take to that and remember which is pressed |
tobyspark | 5:f8b285ca41ba | 1377 | else if (tapLeft) |
tobyspark | 5:f8b285ca41ba | 1378 | { |
tobyspark | 5:f8b285ca41ba | 1379 | xFade = 0; |
tobyspark | 5:f8b285ca41ba | 1380 | tapLeftWasFirstPressed = 1; |
tobyspark | 5:f8b285ca41ba | 1381 | } |
tobyspark | 5:f8b285ca41ba | 1382 | else if (tapRight) |
tobyspark | 5:f8b285ca41ba | 1383 | { |
tobyspark | 5:f8b285ca41ba | 1384 | xFade = 1; |
tobyspark | 5:f8b285ca41ba | 1385 | tapLeftWasFirstPressed = 0; |
tobyspark | 5:f8b285ca41ba | 1386 | } |
tobyspark | 5:f8b285ca41ba | 1387 | } |
tobyspark | 18:ebe5da639a6a | 1388 | else xFade = 1.0 - fadeCalc(xFadeAINCached, xFadeTolerance); |
tobyspark | 0:87aab40d5806 | 1389 | |
tobyspark | 0:87aab40d5806 | 1390 | fadeUp = 1.0 - fadeCalc(fadeUpAINCached, fadeUpTolerance); |
tobyspark | 0:87aab40d5806 | 1391 | |
tobyspark | 33:e6672a9bd571 | 1392 | //// TASK: Process Network Comms In, ie. modify TVOne state |
tobyspark | 5:f8b285ca41ba | 1393 | if (commsMode == commsOSC) |
tobyspark | 3:033d2b7768f3 | 1394 | { |
tobyspark | 3:033d2b7768f3 | 1395 | if (osc->newMessage) |
tobyspark | 3:033d2b7768f3 | 1396 | { |
tobyspark | 3:033d2b7768f3 | 1397 | osc->newMessage = false; // fixme! |
tobyspark | 33:e6672a9bd571 | 1398 | processOSCIn(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 1399 | } |
tobyspark | 3:033d2b7768f3 | 1400 | } |
tobyspark | 3:033d2b7768f3 | 1401 | |
tobyspark | 5:f8b285ca41ba | 1402 | if (commsMode == commsArtNet) |
tobyspark | 3:033d2b7768f3 | 1403 | { |
tobyspark | 33:e6672a9bd571 | 1404 | if (artNet->Work()) processArtNetIn(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 1405 | } |
tobyspark | 3:033d2b7768f3 | 1406 | |
tobyspark | 5:f8b285ca41ba | 1407 | if (commsMode == commsDMXIn) |
tobyspark | 5:f8b285ca41ba | 1408 | { |
tobyspark | 5:f8b285ca41ba | 1409 | processDMXIn(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 1410 | } |
tobyspark | 5:f8b285ca41ba | 1411 | |
tobyspark | 5:f8b285ca41ba | 1412 | if (commsMode == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 1413 | { |
tobyspark | 5:f8b285ca41ba | 1414 | processDMXOut(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 1415 | } |
tobyspark | 0:87aab40d5806 | 1416 | |
tobyspark | 0:87aab40d5806 | 1417 | // Calculate new A&B fade percents |
tobyspark | 0:87aab40d5806 | 1418 | int newFadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 1419 | int newFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 1420 | |
tobyspark | 30:873979018850 | 1421 | if (mixMode == mixBlend) |
tobyspark | 11:0783cfbeb746 | 1422 | { |
tobyspark | 30:873979018850 | 1423 | if (fadeUp < 1.0) |
tobyspark | 30:873979018850 | 1424 | { |
tobyspark | 30:873979018850 | 1425 | // we need to set fade level of both windows as there is no way AFAIK to implement fade to black as a further window on top of A&B |
tobyspark | 30:873979018850 | 1426 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 30:873979018850 | 1427 | newFadeBPercent = xFade * fadeUp * 100.0; |
tobyspark | 30:873979018850 | 1428 | } |
tobyspark | 30:873979018850 | 1429 | else |
tobyspark | 30:873979018850 | 1430 | { |
tobyspark | 30:873979018850 | 1431 | // we can optimise and just fade A in and out over a fully up B, doubling the rate of fadeA commands sent. |
tobyspark | 30:873979018850 | 1432 | newFadeAPercent = (1.0-xFade) * 100.0; |
tobyspark | 30:873979018850 | 1433 | newFadeBPercent = 100.0; |
tobyspark | 30:873979018850 | 1434 | } |
tobyspark | 11:0783cfbeb746 | 1435 | } |
tobyspark | 15:4b394c64b461 | 1436 | else if (mixMode == mixAdditive) |
tobyspark | 11:0783cfbeb746 | 1437 | { |
tobyspark | 22:90054fe6d86c | 1438 | // we need to set fade level of both windows according to the fade curve profile |
tobyspark | 22:90054fe6d86c | 1439 | float newFadeA = (1.0-xFade) * (1.0 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 1440 | float newFadeB = xFade * (1 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 1441 | if (newFadeA > 1.0) newFadeA = 1.0; |
tobyspark | 22:90054fe6d86c | 1442 | if (newFadeB > 1.0) newFadeB = 1.0; |
tobyspark | 22:90054fe6d86c | 1443 | |
tobyspark | 22:90054fe6d86c | 1444 | newFadeAPercent = newFadeA * fadeUp * 100.0; |
tobyspark | 22:90054fe6d86c | 1445 | newFadeBPercent = newFadeB * fadeUp * 100.0; |
tobyspark | 11:0783cfbeb746 | 1446 | } |
tobyspark | 36:8b5c75c8bc23 | 1447 | else if (mixMode >= mixKeyStartIndex) |
tobyspark | 11:0783cfbeb746 | 1448 | { |
tobyspark | 0:87aab40d5806 | 1449 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 1450 | newFadeBPercent = fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 1451 | } |
tobyspark | 0:87aab40d5806 | 1452 | |
tobyspark | 17:fc68d40b8b1f | 1453 | //// TASK: Send to TVOne if percents have changed |
tobyspark | 17:fc68d40b8b1f | 1454 | |
tobyspark | 17:fc68d40b8b1f | 1455 | // No amount of median filtering is stopping flipflopping between two adjacent percents, so... |
tobyspark | 17:fc68d40b8b1f | 1456 | bool fadeAPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 1457 | bool fadeBPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 1458 | if (oldFadeAPercent == newFadeAPercent && (newFadeAPercent == fadeAPercent - 1 || newFadeAPercent == fadeAPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 1459 | fadeAPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 1460 | else |
tobyspark | 17:fc68d40b8b1f | 1461 | fadeAPercentHasChanged = newFadeAPercent != fadeAPercent; |
tobyspark | 17:fc68d40b8b1f | 1462 | if (oldFadeBPercent == newFadeBPercent && (newFadeBPercent == fadeBPercent - 1 || newFadeBPercent == fadeBPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 1463 | fadeBPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 1464 | else |
tobyspark | 17:fc68d40b8b1f | 1465 | fadeBPercentHasChanged = newFadeBPercent != fadeBPercent; |
tobyspark | 17:fc68d40b8b1f | 1466 | |
tobyspark | 35:d5d9f0838f99 | 1467 | // If changing mixMode from additive, we want to do this before updating fade values |
tobyspark | 35:d5d9f0838f99 | 1468 | if (updateMixMode && mixMode != mixAdditive) actionMixMode(); |
tobyspark | 35:d5d9f0838f99 | 1469 | |
tobyspark | 9:f83eadd8917a | 1470 | // We want to send the higher first, otherwise black flashes can happen on taps |
tobyspark | 17:fc68d40b8b1f | 1471 | if (fadeAPercentHasChanged && newFadeAPercent >= newFadeBPercent) |
tobyspark | 8:d46cc49f0f37 | 1472 | { |
tobyspark | 17:fc68d40b8b1f | 1473 | oldFadeAPercent = fadeAPercent; |
tobyspark | 0:87aab40d5806 | 1474 | fadeAPercent = newFadeAPercent; |
tobyspark | 0:87aab40d5806 | 1475 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1476 | |
tobyspark | 0:87aab40d5806 | 1477 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1478 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 0:87aab40d5806 | 1479 | } |
tobyspark | 17:fc68d40b8b1f | 1480 | if (fadeBPercentHasChanged) |
tobyspark | 8:d46cc49f0f37 | 1481 | { |
tobyspark | 17:fc68d40b8b1f | 1482 | oldFadeBPercent = fadeBPercent; |
tobyspark | 0:87aab40d5806 | 1483 | fadeBPercent = newFadeBPercent; |
tobyspark | 0:87aab40d5806 | 1484 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1485 | |
tobyspark | 0:87aab40d5806 | 1486 | fadeBPO = fadeBPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1487 | tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 0:87aab40d5806 | 1488 | } |
tobyspark | 17:fc68d40b8b1f | 1489 | if (fadeAPercentHasChanged && newFadeAPercent < newFadeBPercent) |
tobyspark | 9:f83eadd8917a | 1490 | { |
tobyspark | 17:fc68d40b8b1f | 1491 | oldFadeAPercent = fadeAPercent; |
tobyspark | 9:f83eadd8917a | 1492 | fadeAPercent = newFadeAPercent; |
tobyspark | 9:f83eadd8917a | 1493 | updateFade = true; |
tobyspark | 9:f83eadd8917a | 1494 | |
tobyspark | 9:f83eadd8917a | 1495 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 9:f83eadd8917a | 1496 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 9:f83eadd8917a | 1497 | } |
tobyspark | 8:d46cc49f0f37 | 1498 | if (updateFade && debug) |
tobyspark | 8:d46cc49f0f37 | 1499 | { |
tobyspark | 0:87aab40d5806 | 1500 | //debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAIN.read(), fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 1501 | debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAINCached, fadeUpAINCached); |
tobyspark | 0:87aab40d5806 | 1502 | debug->printf("xFade = %3f fadeUp = %3f fadeA% = %i fadeB% = %i \r\n", xFade, fadeUp, fadeAPercent, fadeBPercent); |
tobyspark | 18:ebe5da639a6a | 1503 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 1504 | } |
tobyspark | 30:873979018850 | 1505 | |
tobyspark | 35:d5d9f0838f99 | 1506 | // If changing mixMode to additive, we want to do this before updating fade values |
tobyspark | 35:d5d9f0838f99 | 1507 | if (updateMixMode && mixMode == mixAdditive) actionMixMode(); |
tobyspark | 35:d5d9f0838f99 | 1508 | |
tobyspark | 33:e6672a9bd571 | 1509 | //// TASK: Process Network Comms Out, ie. send out any fade updates |
tobyspark | 33:e6672a9bd571 | 1510 | if (commsMode == commsOSC && updateFade) |
tobyspark | 33:e6672a9bd571 | 1511 | { |
tobyspark | 33:e6672a9bd571 | 1512 | processOSCOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1513 | } |
tobyspark | 33:e6672a9bd571 | 1514 | |
tobyspark | 33:e6672a9bd571 | 1515 | if (commsMode == commsArtNet && updateFade) |
tobyspark | 33:e6672a9bd571 | 1516 | { |
tobyspark | 33:e6672a9bd571 | 1517 | processArtNetOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1518 | } |
tobyspark | 33:e6672a9bd571 | 1519 | |
tobyspark | 33:e6672a9bd571 | 1520 | if (commsMode == commsDMXOut && updateFade) |
tobyspark | 33:e6672a9bd571 | 1521 | { |
tobyspark | 33:e6672a9bd571 | 1522 | processDMXOut(xFade, fadeUp); |
tobyspark | 33:e6672a9bd571 | 1523 | } |
tobyspark | 33:e6672a9bd571 | 1524 | |
tobyspark | 45:cf8c2400be5c | 1525 | //// TASK: Housekeeping |
tobyspark | 45:cf8c2400be5c | 1526 | |
tobyspark | 45:cf8c2400be5c | 1527 | // We want to check every second or so, but not overwrite any messages from action by user. |
tobyspark | 45:cf8c2400be5c | 1528 | // There's no sensible way to do this, so the following is a kludge, checking more frequently when its important. |
tobyspark | 45:cf8c2400be5c | 1529 | int housekeepingPeriod = (!tvOneRGB1Stable || !tvOneRGB2Stable) ? 1500 : 5000; |
tobyspark | 45:cf8c2400be5c | 1530 | if (tvOne.millisSinceLastCommandSent() > housekeepingPeriod) |
tobyspark | 30:873979018850 | 1531 | { |
tobyspark | 45:cf8c2400be5c | 1532 | // Lets check on our sources |
tobyspark | 45:cf8c2400be5c | 1533 | handleTVOneSources(); |
tobyspark | 30:873979018850 | 1534 | } |
tobyspark | 0:87aab40d5806 | 1535 | } |
tobyspark | 30:873979018850 | 1536 | } |