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