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