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