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