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

Committer:
tobyspark
Date:
Sat Jul 27 14:53:57 2013 +0000
Revision:
67:6ce9fb62b17c
Parent:
66:02845e02a758
Child:
68:c26478f42ca4
Removed possibility of crash by selecting different network mode once OSC or ArtNet active. Without hardware debug impossible to tell what is crashing on being destroyed... so working round it GUI-wise.

Who changed what in which revision?

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