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 13:16:55 2013 +0000
Revision:
65:24ee1bf3061c
Parent:
63:33d7fa825c4f
Child:
66:02845e02a758
Network in fix - applying xFade in would inadvertently set fadeUp to 0 and vice versa.

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