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@23:909928cafb95, 2012-10-26 (annotated)
- Committer:
- tobyspark
- Date:
- Fri Oct 26 16:51:28 2012 +0000
- Revision:
- 23:909928cafb95
- Parent:
- 22:90054fe6d86c
- Child:
- 24:49c6624119ae
SPKMenu redux
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 8:d46cc49f0f37 | 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 | 8:d46cc49f0f37 | 39 | * vxx - TODO: Keying values load from USB mass storage |
tobyspark | 10:c011b0e5c17e | 40 | * vxx - TODO: Set keying values from controller, requires a guided, step-through process for user |
tobyspark | 8:d46cc49f0f37 | 41 | * vxx - TODO: Defaults load/save from USB mass storage |
tobyspark | 8:d46cc49f0f37 | 42 | * vxx - TODO: EDID upload from USB mass storage |
tobyspark | 8:d46cc49f0f37 | 43 | * vxx - TODO: EDID creation from resolution |
tobyspark | 8:d46cc49f0f37 | 44 | */ |
tobyspark | 8:d46cc49f0f37 | 45 | |
tobyspark | 0:87aab40d5806 | 46 | #include "mbed.h" |
tobyspark | 0:87aab40d5806 | 47 | |
tobyspark | 0:87aab40d5806 | 48 | #include "spk_tvone_mbed.h" |
tobyspark | 0:87aab40d5806 | 49 | #include "spk_utils.h" |
tobyspark | 0:87aab40d5806 | 50 | #include "spk_mRotaryEncoder.h" |
tobyspark | 0:87aab40d5806 | 51 | #include "spk_oled_ssd1305.h" |
tobyspark | 2:50043054e4f7 | 52 | #include "spk_oled_gfx.h" |
tobyspark | 11:0783cfbeb746 | 53 | #include "spk_settings.h" |
tobyspark | 1:f9fca21102e0 | 54 | #include "EthernetNetIf.h" |
tobyspark | 1:f9fca21102e0 | 55 | #include "mbedOSC.h" |
tobyspark | 3:033d2b7768f3 | 56 | #include "DmxArtNet.h" |
tobyspark | 5:f8b285ca41ba | 57 | #include "DMX.h" |
tobyspark | 17:fc68d40b8b1f | 58 | #include "filter.h" |
tobyspark | 0:87aab40d5806 | 59 | |
tobyspark | 0:87aab40d5806 | 60 | #include <sstream> |
tobyspark | 0:87aab40d5806 | 61 | |
tobyspark | 13:3796bde6ba8f | 62 | #define kSPKDFSoftwareVersion "beta.19" |
tobyspark | 13:3796bde6ba8f | 63 | |
tobyspark | 5:f8b285ca41ba | 64 | // MBED PINS |
tobyspark | 5:f8b285ca41ba | 65 | |
tobyspark | 5:f8b285ca41ba | 66 | #define kMBED_AIN_XFADE p20 |
tobyspark | 5:f8b285ca41ba | 67 | #define kMBED_AIN_FADEUP p19 |
tobyspark | 5:f8b285ca41ba | 68 | #define kMBED_DIN_TAP_L p24 |
tobyspark | 5:f8b285ca41ba | 69 | #define kMBED_DIN_TAP_R p23 |
tobyspark | 5:f8b285ca41ba | 70 | #define kMBED_ENC_SW p15 |
tobyspark | 5:f8b285ca41ba | 71 | #define kMBED_ENC_A p16 |
tobyspark | 5:f8b285ca41ba | 72 | #define kMBED_ENC_B p17 |
tobyspark | 5:f8b285ca41ba | 73 | |
tobyspark | 5:f8b285ca41ba | 74 | #define kMBED_RS232_TTLTX p13 |
tobyspark | 5:f8b285ca41ba | 75 | #define kMBED_RS232_TTLRX p14 |
tobyspark | 5:f8b285ca41ba | 76 | |
tobyspark | 5:f8b285ca41ba | 77 | #define kMBED_OLED_MOSI p5 |
tobyspark | 5:f8b285ca41ba | 78 | #define kMBED_OLED_SCK p7 |
tobyspark | 5:f8b285ca41ba | 79 | #define kMBED_OLED_CS p8 |
tobyspark | 5:f8b285ca41ba | 80 | #define kMBED_OLED_RES p9 |
tobyspark | 5:f8b285ca41ba | 81 | #define kMBED_OLED_DC p10 |
tobyspark | 5:f8b285ca41ba | 82 | |
tobyspark | 5:f8b285ca41ba | 83 | #define kMBED_DIN_ETHLO_DMXHI p30 |
tobyspark | 5:f8b285ca41ba | 84 | #define kMBED_DOUT_RS485_TXHI_RXLO p29 |
tobyspark | 5:f8b285ca41ba | 85 | #define kMBED_RS485_TTLTX p28 |
tobyspark | 5:f8b285ca41ba | 86 | #define kMBED_RS485_TTLRX p27 |
tobyspark | 5:f8b285ca41ba | 87 | |
tobyspark | 5:f8b285ca41ba | 88 | // DISPLAY |
tobyspark | 5:f8b285ca41ba | 89 | |
tobyspark | 1:f9fca21102e0 | 90 | #define kMenuLine1 3 |
tobyspark | 1:f9fca21102e0 | 91 | #define kMenuLine2 4 |
tobyspark | 1:f9fca21102e0 | 92 | #define kCommsStatusLine 6 |
tobyspark | 1:f9fca21102e0 | 93 | #define kTVOneStatusLine 7 |
tobyspark | 1:f9fca21102e0 | 94 | |
tobyspark | 5:f8b285ca41ba | 95 | // NETWORKING |
tobyspark | 5:f8b285ca41ba | 96 | |
tobyspark | 1:f9fca21102e0 | 97 | #define kOSCMbedPort 10000 |
tobyspark | 1:f9fca21102e0 | 98 | #define kOSCMbedIPAddress 10,0,0,2 |
tobyspark | 1:f9fca21102e0 | 99 | #define kOSCMbedSubnetMask 255,255,255,0 |
tobyspark | 1:f9fca21102e0 | 100 | #define kOSCMbedGateway 10,0,0,1 |
tobyspark | 1:f9fca21102e0 | 101 | #define kOSCMbedDNS 10,0,0,1 |
tobyspark | 0:87aab40d5806 | 102 | |
tobyspark | 3:033d2b7768f3 | 103 | #define kArtNetBindIPAddress 2,0,0,100 |
tobyspark | 3:033d2b7768f3 | 104 | #define kArtNetBroadcastAddress 2,255,255,255 |
tobyspark | 3:033d2b7768f3 | 105 | |
tobyspark | 5:f8b285ca41ba | 106 | #define kDMXInChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 107 | #define kDMXInChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 108 | #define kDMXOutChannelXFade 0 |
tobyspark | 5:f8b285ca41ba | 109 | #define kDMXOutChannelFadeUp 1 |
tobyspark | 5:f8b285ca41ba | 110 | |
tobyspark | 13:3796bde6ba8f | 111 | // 8.3 format filename only, no subdirs |
tobyspark | 13:3796bde6ba8f | 112 | #define kSPKDFSettingsFilename "SPKDF.ini" |
tobyspark | 11:0783cfbeb746 | 113 | |
tobyspark | 0:87aab40d5806 | 114 | //// DEBUG |
tobyspark | 0:87aab40d5806 | 115 | |
tobyspark | 0:87aab40d5806 | 116 | // Comment out one or the other... |
tobyspark | 23:909928cafb95 | 117 | Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial |
tobyspark | 23:909928cafb95 | 118 | //Serial *debug = NULL; // For release (no debugging) |
tobyspark | 0:87aab40d5806 | 119 | |
tobyspark | 15:4b394c64b461 | 120 | //// SOFT RESET |
tobyspark | 15:4b394c64b461 | 121 | |
tobyspark | 15:4b394c64b461 | 122 | extern "C" void mbed_reset(); |
tobyspark | 15:4b394c64b461 | 123 | |
tobyspark | 0:87aab40d5806 | 124 | //// mBED PIN ASSIGNMENTS |
tobyspark | 0:87aab40d5806 | 125 | |
tobyspark | 0:87aab40d5806 | 126 | // Inputs |
tobyspark | 5:f8b285ca41ba | 127 | AnalogIn xFadeAIN(kMBED_AIN_XFADE); |
tobyspark | 5:f8b285ca41ba | 128 | AnalogIn fadeUpAIN(kMBED_AIN_FADEUP); |
tobyspark | 5:f8b285ca41ba | 129 | DigitalIn tapLeftDIN(kMBED_DIN_TAP_L); |
tobyspark | 5:f8b285ca41ba | 130 | DigitalIn tapRightDIN(kMBED_DIN_TAP_R); |
tobyspark | 17:fc68d40b8b1f | 131 | medianFilter xFadeFilter(9); |
tobyspark | 17:fc68d40b8b1f | 132 | medianFilter fadeUpFilter(9); |
tobyspark | 0:87aab40d5806 | 133 | |
tobyspark | 5:f8b285ca41ba | 134 | SPKRotaryEncoder menuEnc(kMBED_ENC_A, kMBED_ENC_B, kMBED_ENC_SW); |
tobyspark | 5:f8b285ca41ba | 135 | |
tobyspark | 5:f8b285ca41ba | 136 | DigitalIn rj45ModeDIN(kMBED_DIN_ETHLO_DMXHI); |
tobyspark | 0:87aab40d5806 | 137 | |
tobyspark | 0:87aab40d5806 | 138 | // Outputs |
tobyspark | 0:87aab40d5806 | 139 | PwmOut fadeAPO(LED1); |
tobyspark | 0:87aab40d5806 | 140 | PwmOut fadeBPO(LED2); |
tobyspark | 0:87aab40d5806 | 141 | |
tobyspark | 5:f8b285ca41ba | 142 | DigitalOut dmxDirectionDOUT(kMBED_DOUT_RS485_TXHI_RXLO); |
tobyspark | 5:f8b285ca41ba | 143 | |
tobyspark | 0:87aab40d5806 | 144 | // SPKTVOne(PinName txPin, PinName rxPin, PinName signWritePin, PinName signErrorPin, Serial *debugSerial) |
tobyspark | 5:f8b285ca41ba | 145 | SPKTVOne tvOne(kMBED_RS232_TTLTX, kMBED_RS232_TTLRX, LED3, LED4, debug); |
tobyspark | 0:87aab40d5806 | 146 | |
tobyspark | 0:87aab40d5806 | 147 | // SPKDisplay(PinName mosi, PinName clk, PinName cs, PinName dc, PinName res, Serial *debugSerial = NULL); |
tobyspark | 5:f8b285ca41ba | 148 | SPKDisplay screen(kMBED_OLED_MOSI, kMBED_OLED_SCK, kMBED_OLED_CS, kMBED_OLED_DC, kMBED_OLED_RES, debug); |
tobyspark | 0:87aab40d5806 | 149 | |
tobyspark | 11:0783cfbeb746 | 150 | // Saved Settings |
tobyspark | 11:0783cfbeb746 | 151 | SPKSettings settings; |
tobyspark | 11:0783cfbeb746 | 152 | |
tobyspark | 0:87aab40d5806 | 153 | // Menu |
tobyspark | 0:87aab40d5806 | 154 | SPKMenu *selectedMenu; |
tobyspark | 0:87aab40d5806 | 155 | SPKMenu *lastSelectedMenu; |
tobyspark | 23:909928cafb95 | 156 | SPKMenu mainMenu; |
tobyspark | 23:909928cafb95 | 157 | SPKMenu resolutionMenu; |
tobyspark | 12:c270870bdd23 | 158 | |
tobyspark | 23:909928cafb95 | 159 | SPKMenu mixModeMenu; |
tobyspark | 15:4b394c64b461 | 160 | enum { mixBlend, mixAdditive, mixKey }; // additive will require custom TVOne firmware. |
tobyspark | 15:4b394c64b461 | 161 | int mixMode = mixBlend; |
tobyspark | 22:90054fe6d86c | 162 | float fadeCurve = 0; // 0 = "X", 1 = "/\" <-- pictograms! |
tobyspark | 22:90054fe6d86c | 163 | |
tobyspark | 23:909928cafb95 | 164 | SPKMenu commsMenu; |
tobyspark | 5:f8b285ca41ba | 165 | enum { commsNone, commsOSC, commsArtNet, commsDMXIn, commsDMXOut}; |
tobyspark | 5:f8b285ca41ba | 166 | int commsMode = commsNone; |
tobyspark | 22:90054fe6d86c | 167 | |
tobyspark | 23:909928cafb95 | 168 | SPKMenu advancedMenu; |
tobyspark | 21:f9d63cb7cedb | 169 | enum { advancedHDCPOn, advancedHDCPOff, advancedConformProcessor, advancedLoadDefaults, advancedSelfTest, advancedSetResolutions }; |
tobyspark | 1:f9fca21102e0 | 170 | |
tobyspark | 5:f8b285ca41ba | 171 | // RJ45 Comms |
tobyspark | 5:f8b285ca41ba | 172 | enum { rj45Ethernet = 0, rj45DMX = 1}; // These values from circuit |
tobyspark | 5:f8b285ca41ba | 173 | int rj45Mode = -1; |
tobyspark | 1:f9fca21102e0 | 174 | EthernetNetIf *ethernet = NULL; |
tobyspark | 1:f9fca21102e0 | 175 | OSCClass *osc = NULL; |
tobyspark | 3:033d2b7768f3 | 176 | OSCMessage recMessage; |
tobyspark | 3:033d2b7768f3 | 177 | DmxArtNet *artNet = NULL; |
tobyspark | 5:f8b285ca41ba | 178 | DMX *dmx = NULL; |
tobyspark | 0:87aab40d5806 | 179 | |
tobyspark | 3:033d2b7768f3 | 180 | // Fade logic constants |
tobyspark | 0:87aab40d5806 | 181 | const float xFadeTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 182 | const float fadeUpTolerance = 0.05; |
tobyspark | 0:87aab40d5806 | 183 | |
tobyspark | 0:87aab40d5806 | 184 | // A&B Fade as resolved percent |
tobyspark | 0:87aab40d5806 | 185 | int fadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 186 | int fadeBPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 187 | int oldFadeAPercent = 0; |
tobyspark | 17:fc68d40b8b1f | 188 | int oldFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 189 | |
tobyspark | 0:87aab40d5806 | 190 | // Tap button states |
tobyspark | 5:f8b285ca41ba | 191 | bool tapLeftWasFirstPressed = false; |
tobyspark | 0:87aab40d5806 | 192 | |
tobyspark | 0:87aab40d5806 | 193 | // Key mode parameters |
tobyspark | 0:87aab40d5806 | 194 | int keyerParamsSet = -1; // last keyParams index uploaded to unit |
tobyspark | 0:87aab40d5806 | 195 | |
tobyspark | 3:033d2b7768f3 | 196 | void processOSC(float &xFade, float &fadeUp) { |
tobyspark | 3:033d2b7768f3 | 197 | std::stringstream statusMessage; |
tobyspark | 3:033d2b7768f3 | 198 | statusMessage.setf(ios::fixed,ios::floatfield); |
tobyspark | 3:033d2b7768f3 | 199 | statusMessage.precision(2); |
tobyspark | 3:033d2b7768f3 | 200 | |
tobyspark | 3:033d2b7768f3 | 201 | if (!strcmp( recMessage.getTopAddress() , "dvimxr" )) |
tobyspark | 3:033d2b7768f3 | 202 | { |
tobyspark | 3:033d2b7768f3 | 203 | statusMessage << "OSC: /dvimxr"; |
tobyspark | 3:033d2b7768f3 | 204 | if (!strcmp( recMessage.getSubAddress() , "xFade" )) |
tobyspark | 3:033d2b7768f3 | 205 | if (recMessage.getArgNum() == 1) |
tobyspark | 3:033d2b7768f3 | 206 | if (recMessage.getTypeTag(0) == 'f') |
tobyspark | 3:033d2b7768f3 | 207 | { |
tobyspark | 3:033d2b7768f3 | 208 | double newXFade = recMessage.getArgFloat(0); |
tobyspark | 3:033d2b7768f3 | 209 | statusMessage << "/xFade " << newXFade; |
tobyspark | 3:033d2b7768f3 | 210 | xFade = newXFade; |
tobyspark | 3:033d2b7768f3 | 211 | } |
tobyspark | 3:033d2b7768f3 | 212 | else if (!strcmp( recMessage.getSubAddress() , "fadeUp" )) |
tobyspark | 3:033d2b7768f3 | 213 | if (recMessage.getArgNum() == 1) |
tobyspark | 3:033d2b7768f3 | 214 | if (recMessage.getTypeTag(0) == 'f') |
tobyspark | 3:033d2b7768f3 | 215 | { |
tobyspark | 3:033d2b7768f3 | 216 | double newFadeUp = recMessage.getArgFloat(0); |
tobyspark | 3:033d2b7768f3 | 217 | statusMessage << "/fadeUp " << newFadeUp; |
tobyspark | 3:033d2b7768f3 | 218 | xFade = newFadeUp; |
tobyspark | 3:033d2b7768f3 | 219 | } |
tobyspark | 3:033d2b7768f3 | 220 | else statusMessage << recMessage.getSubAddress() << " - Ignoring"; |
tobyspark | 3:033d2b7768f3 | 221 | } |
tobyspark | 3:033d2b7768f3 | 222 | else |
tobyspark | 3:033d2b7768f3 | 223 | { |
tobyspark | 3:033d2b7768f3 | 224 | statusMessage << "OSC: " << recMessage.getTopAddress() << " - Ignoring"; |
tobyspark | 3:033d2b7768f3 | 225 | } |
tobyspark | 3:033d2b7768f3 | 226 | |
tobyspark | 3:033d2b7768f3 | 227 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 228 | screen.textToBuffer(statusMessage.str(), kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 229 | screen.sendBuffer(); |
tobyspark | 3:033d2b7768f3 | 230 | if (debug) debug->printf("%s \r\n", statusMessage.str().c_str()); |
tobyspark | 3:033d2b7768f3 | 231 | |
tobyspark | 3:033d2b7768f3 | 232 | } |
tobyspark | 3:033d2b7768f3 | 233 | |
tobyspark | 8:d46cc49f0f37 | 234 | void processArtNet(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 235 | { |
tobyspark | 3:033d2b7768f3 | 236 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 237 | screen.textToBuffer("ArtNet activity", kCommsStatusLine); |
tobyspark | 3:033d2b7768f3 | 238 | screen.sendBuffer(); |
tobyspark | 3:033d2b7768f3 | 239 | if (debug) debug->printf("ArtNet activity"); |
tobyspark | 3:033d2b7768f3 | 240 | } |
tobyspark | 0:87aab40d5806 | 241 | |
tobyspark | 8:d46cc49f0f37 | 242 | void processDMXIn(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 243 | { |
tobyspark | 5:f8b285ca41ba | 244 | std::stringstream statusMessage; |
tobyspark | 5:f8b285ca41ba | 245 | |
tobyspark | 5:f8b285ca41ba | 246 | int xFadeDMX = dmx->get(kDMXInChannelXFade); |
tobyspark | 7:e6717468c18d | 247 | int fadeUpDMX = dmx->get(kDMXInChannelFadeUp); |
tobyspark | 5:f8b285ca41ba | 248 | |
tobyspark | 5:f8b285ca41ba | 249 | xFade = (float)xFadeDMX/255; |
tobyspark | 5:f8b285ca41ba | 250 | fadeUp = (float)fadeUpDMX/255; |
tobyspark | 5:f8b285ca41ba | 251 | |
tobyspark | 5:f8b285ca41ba | 252 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 253 | statusMessage << "DMX In: xF " << xFadeDMX << " fUp " << fadeUpDMX; |
tobyspark | 5:f8b285ca41ba | 254 | screen.textToBuffer(statusMessage.str(), kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 255 | screen.sendBuffer(); |
tobyspark | 5:f8b285ca41ba | 256 | if (debug) debug->printf(statusMessage.str().c_str()); |
tobyspark | 5:f8b285ca41ba | 257 | } |
tobyspark | 5:f8b285ca41ba | 258 | |
tobyspark | 8:d46cc49f0f37 | 259 | void processDMXOut(float &xFade, float &fadeUp) |
tobyspark | 8:d46cc49f0f37 | 260 | { |
tobyspark | 5:f8b285ca41ba | 261 | std::stringstream statusMessage; |
tobyspark | 5:f8b285ca41ba | 262 | |
tobyspark | 5:f8b285ca41ba | 263 | int xFadeDMX = xFade*255; |
tobyspark | 5:f8b285ca41ba | 264 | int fadeUpDMX = fadeUp*255; |
tobyspark | 5:f8b285ca41ba | 265 | |
tobyspark | 5:f8b285ca41ba | 266 | dmx->put(kDMXOutChannelXFade, xFadeDMX); |
tobyspark | 5:f8b285ca41ba | 267 | dmx->put(kDMXOutChannelFadeUp, fadeUpDMX); |
tobyspark | 5:f8b285ca41ba | 268 | |
tobyspark | 5:f8b285ca41ba | 269 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 270 | statusMessage << "DMX Out: xF " << xFadeDMX << " fUp " << fadeUpDMX; |
tobyspark | 5:f8b285ca41ba | 271 | screen.textToBuffer(statusMessage.str(), kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 272 | screen.sendBuffer(); |
tobyspark | 5:f8b285ca41ba | 273 | if (debug) debug->printf(statusMessage.str().c_str()); |
tobyspark | 5:f8b285ca41ba | 274 | } |
tobyspark | 0:87aab40d5806 | 275 | |
tobyspark | 8:d46cc49f0f37 | 276 | inline float fadeCalc (const float AIN, const float tolerance) |
tobyspark | 8:d46cc49f0f37 | 277 | { |
tobyspark | 0:87aab40d5806 | 278 | float pos ; |
tobyspark | 0:87aab40d5806 | 279 | if (AIN < tolerance) pos = 0; |
tobyspark | 0:87aab40d5806 | 280 | else if (AIN > 1.0 - tolerance) pos = 1; |
tobyspark | 0:87aab40d5806 | 281 | else pos = (AIN - tolerance) / (1 - 2*tolerance); |
tobyspark | 0:87aab40d5806 | 282 | if (debug && false) debug->printf("fadeCalc in: %f out: %f \r\n", AIN, pos); |
tobyspark | 0:87aab40d5806 | 283 | return pos; |
tobyspark | 0:87aab40d5806 | 284 | } |
tobyspark | 0:87aab40d5806 | 285 | |
tobyspark | 8:d46cc49f0f37 | 286 | bool setKeyParamsTo(int index) |
tobyspark | 8:d46cc49f0f37 | 287 | { |
tobyspark | 0:87aab40d5806 | 288 | // Only spend the time uploading six parameters if we need to |
tobyspark | 0:87aab40d5806 | 289 | // Might want to bounds check here |
tobyspark | 0:87aab40d5806 | 290 | |
tobyspark | 9:f83eadd8917a | 291 | bool ok; |
tobyspark | 0:87aab40d5806 | 292 | |
tobyspark | 0:87aab40d5806 | 293 | if (index != keyerParamsSet) |
tobyspark | 0:87aab40d5806 | 294 | { |
tobyspark | 11:0783cfbeb746 | 295 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, settings.keyerParamSet(index)[0]); |
tobyspark | 11:0783cfbeb746 | 296 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, settings.keyerParamSet(index)[1]); |
tobyspark | 11:0783cfbeb746 | 297 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, settings.keyerParamSet(index)[2]); |
tobyspark | 11:0783cfbeb746 | 298 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, settings.keyerParamSet(index)[3]); |
tobyspark | 11:0783cfbeb746 | 299 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, settings.keyerParamSet(index)[4]); |
tobyspark | 11:0783cfbeb746 | 300 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, settings.keyerParamSet(index)[5]); |
tobyspark | 0:87aab40d5806 | 301 | |
tobyspark | 0:87aab40d5806 | 302 | keyerParamsSet = index; |
tobyspark | 9:f83eadd8917a | 303 | } |
tobyspark | 9:f83eadd8917a | 304 | else |
tobyspark | 9:f83eadd8917a | 305 | { |
tobyspark | 9:f83eadd8917a | 306 | ok = true; |
tobyspark | 9:f83eadd8917a | 307 | } |
tobyspark | 0:87aab40d5806 | 308 | |
tobyspark | 0:87aab40d5806 | 309 | return ok; |
tobyspark | 0:87aab40d5806 | 310 | } |
tobyspark | 0:87aab40d5806 | 311 | |
tobyspark | 17:fc68d40b8b1f | 312 | bool conformProcessor() |
tobyspark | 17:fc68d40b8b1f | 313 | { |
tobyspark | 17:fc68d40b8b1f | 314 | bool ok = true; |
tobyspark | 17:fc68d40b8b1f | 315 | |
tobyspark | 17:fc68d40b8b1f | 316 | int32_t on = 1; |
tobyspark | 17:fc68d40b8b1f | 317 | int32_t off = 0; |
tobyspark | 20:8b92d7922c48 | 318 | |
tobyspark | 20:8b92d7922c48 | 319 | // Independent output |
tobyspark | 20:8b92d7922c48 | 320 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsOutputEnable, on); |
tobyspark | 20:8b92d7922c48 | 321 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsLockMethod, off); |
tobyspark | 17:fc68d40b8b1f | 322 | |
tobyspark | 17:fc68d40b8b1f | 323 | // Make sure our windows exist |
tobyspark | 17:fc68d40b8b1f | 324 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 17:fc68d40b8b1f | 325 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsEnable, on); |
tobyspark | 18:ebe5da639a6a | 326 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsLayerPriority, 0); |
tobyspark | 18:ebe5da639a6a | 327 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsLayerPriority, 1); |
tobyspark | 17:fc68d40b8b1f | 328 | |
tobyspark | 17:fc68d40b8b1f | 329 | // Assign inputs to windows, so that left on the crossfader is left on the processor viewed from front |
tobyspark | 17:fc68d40b8b1f | 330 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB2); |
tobyspark | 17:fc68d40b8b1f | 331 | ok = ok && tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsWindowSource, kTV1SourceRGB1); |
tobyspark | 17:fc68d40b8b1f | 332 | |
tobyspark | 17:fc68d40b8b1f | 333 | // Set scaling to fit source within output, maintaining aspect ratio |
tobyspark | 17:fc68d40b8b1f | 334 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 17:fc68d40b8b1f | 335 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDB, kTV1FunctionAdjustWindowsZoomLevel, 100); |
tobyspark | 17:fc68d40b8b1f | 336 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 17:fc68d40b8b1f | 337 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDB, kTV1FunctionAdjustWindowsShrinkEnable, off); |
tobyspark | 17:fc68d40b8b1f | 338 | int32_t fit = 1; |
tobyspark | 17:fc68d40b8b1f | 339 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 17:fc68d40b8b1f | 340 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceAspectCorrect, fit); |
tobyspark | 17:fc68d40b8b1f | 341 | |
tobyspark | 17:fc68d40b8b1f | 342 | // On source loss, hold on the last frame received. |
tobyspark | 17:fc68d40b8b1f | 343 | int32_t freeze = 1; |
tobyspark | 17:fc68d40b8b1f | 344 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 17:fc68d40b8b1f | 345 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceOnSourceLoss, freeze); |
tobyspark | 17:fc68d40b8b1f | 346 | |
tobyspark | 17:fc68d40b8b1f | 347 | // Finally, autoset to sources? |
tobyspark | 17:fc68d40b8b1f | 348 | //int32_t start = 1; |
tobyspark | 17:fc68d40b8b1f | 349 | //ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceAutoSet, start); |
tobyspark | 17:fc68d40b8b1f | 350 | //ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceAutoSet, start); |
tobyspark | 17:fc68d40b8b1f | 351 | |
tobyspark | 17:fc68d40b8b1f | 352 | return ok; |
tobyspark | 17:fc68d40b8b1f | 353 | } |
tobyspark | 17:fc68d40b8b1f | 354 | |
tobyspark | 17:fc68d40b8b1f | 355 | void selfTest() |
tobyspark | 17:fc68d40b8b1f | 356 | { |
tobyspark | 17:fc68d40b8b1f | 357 | /* SELF TEST - Pixels |
tobyspark | 17:fc68d40b8b1f | 358 | * Clicking �self-test� menu will display a solid lit screen. Check all pixels lit. |
tobyspark | 17:fc68d40b8b1f | 359 | * Verified: Display |
tobyspark | 17:fc68d40b8b1f | 360 | */ |
tobyspark | 17:fc68d40b8b1f | 361 | |
tobyspark | 17:fc68d40b8b1f | 362 | screen.imageToBuffer(spkDisplayAllPixelsOn); |
tobyspark | 17:fc68d40b8b1f | 363 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 364 | |
tobyspark | 17:fc68d40b8b1f | 365 | while(!menuEnc.hasPressed()) |
tobyspark | 17:fc68d40b8b1f | 366 | { |
tobyspark | 17:fc68d40b8b1f | 367 | // do nothing, wait for press |
tobyspark | 17:fc68d40b8b1f | 368 | } |
tobyspark | 17:fc68d40b8b1f | 369 | |
tobyspark | 17:fc68d40b8b1f | 370 | /* SELF TEST - Mixing Controls |
tobyspark | 17:fc68d40b8b1f | 371 | * Clicking again will prompt to check crossfader, fade to black and tap buttons. Check movement of physical controls against 0.0-1.0 values on- screen. |
tobyspark | 17:fc68d40b8b1f | 372 | * Verified: Mixing controls. |
tobyspark | 17:fc68d40b8b1f | 373 | */ |
tobyspark | 17:fc68d40b8b1f | 374 | |
tobyspark | 17:fc68d40b8b1f | 375 | screen.clearBuffer(); |
tobyspark | 17:fc68d40b8b1f | 376 | screen.textToBuffer("Self test - Mixing Controls", 0); |
tobyspark | 17:fc68d40b8b1f | 377 | |
tobyspark | 17:fc68d40b8b1f | 378 | while(!menuEnc.hasPressed()) |
tobyspark | 17:fc68d40b8b1f | 379 | { |
tobyspark | 17:fc68d40b8b1f | 380 | stringstream xFadeReadOut; |
tobyspark | 17:fc68d40b8b1f | 381 | stringstream fadeToBlackReadOut; |
tobyspark | 17:fc68d40b8b1f | 382 | stringstream tapsReadOut; |
tobyspark | 17:fc68d40b8b1f | 383 | |
tobyspark | 17:fc68d40b8b1f | 384 | xFadeReadOut.precision(2); |
tobyspark | 17:fc68d40b8b1f | 385 | fadeToBlackReadOut.precision(2); |
tobyspark | 17:fc68d40b8b1f | 386 | tapsReadOut.precision(1); |
tobyspark | 17:fc68d40b8b1f | 387 | |
tobyspark | 17:fc68d40b8b1f | 388 | xFadeReadOut << "Crossfade: " << xFadeAIN.read(); |
tobyspark | 17:fc68d40b8b1f | 389 | fadeToBlackReadOut << "Fade to black: " << fadeUpAIN.read(); |
tobyspark | 17:fc68d40b8b1f | 390 | tapsReadOut << "Tap left: " << tapLeftDIN.read() << " right: " << tapRightDIN.read(); |
tobyspark | 17:fc68d40b8b1f | 391 | |
tobyspark | 17:fc68d40b8b1f | 392 | screen.clearBufferRow(1); |
tobyspark | 17:fc68d40b8b1f | 393 | screen.clearBufferRow(2); |
tobyspark | 17:fc68d40b8b1f | 394 | screen.clearBufferRow(3); |
tobyspark | 17:fc68d40b8b1f | 395 | |
tobyspark | 17:fc68d40b8b1f | 396 | screen.textToBuffer(xFadeReadOut.str(), 1); |
tobyspark | 17:fc68d40b8b1f | 397 | screen.textToBuffer(fadeToBlackReadOut.str(), 2); |
tobyspark | 17:fc68d40b8b1f | 398 | screen.textToBuffer(tapsReadOut.str(), 3); |
tobyspark | 17:fc68d40b8b1f | 399 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 400 | } |
tobyspark | 17:fc68d40b8b1f | 401 | |
tobyspark | 17:fc68d40b8b1f | 402 | /* SELF TEST - RS232 |
tobyspark | 17:fc68d40b8b1f | 403 | * Click the controller menu control. Should see �RS232 test� prompt and test message. Ensure PC is displaying the test message. |
tobyspark | 17:fc68d40b8b1f | 404 | * Verified: RS232 connection. |
tobyspark | 17:fc68d40b8b1f | 405 | */ |
tobyspark | 17:fc68d40b8b1f | 406 | |
tobyspark | 17:fc68d40b8b1f | 407 | screen.clearBuffer(); |
tobyspark | 17:fc68d40b8b1f | 408 | screen.textToBuffer("Self test - RS232", 0); |
tobyspark | 17:fc68d40b8b1f | 409 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 410 | |
tobyspark | 17:fc68d40b8b1f | 411 | while(!menuEnc.hasPressed()) |
tobyspark | 17:fc68d40b8b1f | 412 | { |
tobyspark | 17:fc68d40b8b1f | 413 | screen.textToBuffer("TODO!", 1); |
tobyspark | 17:fc68d40b8b1f | 414 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 415 | } |
tobyspark | 17:fc68d40b8b1f | 416 | |
tobyspark | 17:fc68d40b8b1f | 417 | /* SELF TEST - DMX |
tobyspark | 17:fc68d40b8b1f | 418 | * Click the controller menu control. Should see �DMX test� prompt and test message. Ensure PC is displaying the test message. |
tobyspark | 17:fc68d40b8b1f | 419 | * Verified: RS485 connection and DMX library. |
tobyspark | 17:fc68d40b8b1f | 420 | */ |
tobyspark | 17:fc68d40b8b1f | 421 | |
tobyspark | 17:fc68d40b8b1f | 422 | screen.clearBuffer(); |
tobyspark | 17:fc68d40b8b1f | 423 | screen.textToBuffer("Self test - DMX", 0); |
tobyspark | 17:fc68d40b8b1f | 424 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 425 | |
tobyspark | 17:fc68d40b8b1f | 426 | while(!menuEnc.hasPressed()) |
tobyspark | 17:fc68d40b8b1f | 427 | { |
tobyspark | 17:fc68d40b8b1f | 428 | screen.textToBuffer("TODO!", 1); |
tobyspark | 17:fc68d40b8b1f | 429 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 430 | } |
tobyspark | 17:fc68d40b8b1f | 431 | |
tobyspark | 17:fc68d40b8b1f | 432 | /* SELF TEST - OSC |
tobyspark | 17:fc68d40b8b1f | 433 | * Click the controller menu control. Should see �OSC test� prompt and test message. Ensure PC is displaying the test message. |
tobyspark | 17:fc68d40b8b1f | 434 | * Verified: Ethernet connection and OSC library. |
tobyspark | 17:fc68d40b8b1f | 435 | */ |
tobyspark | 17:fc68d40b8b1f | 436 | |
tobyspark | 17:fc68d40b8b1f | 437 | screen.clearBuffer(); |
tobyspark | 17:fc68d40b8b1f | 438 | screen.textToBuffer("Self test - DMX", 0); |
tobyspark | 17:fc68d40b8b1f | 439 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 440 | |
tobyspark | 17:fc68d40b8b1f | 441 | while(!menuEnc.hasPressed()) |
tobyspark | 17:fc68d40b8b1f | 442 | { |
tobyspark | 17:fc68d40b8b1f | 443 | screen.textToBuffer("TODO!", 1); |
tobyspark | 17:fc68d40b8b1f | 444 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 445 | } |
tobyspark | 17:fc68d40b8b1f | 446 | |
tobyspark | 17:fc68d40b8b1f | 447 | /* SELF TEST - Exit! |
tobyspark | 17:fc68d40b8b1f | 448 | * To do this, we could just do nothing but we'd need to recreate screen and comms as they were. |
tobyspark | 17:fc68d40b8b1f | 449 | * Instead, lets just restart the mbed |
tobyspark | 17:fc68d40b8b1f | 450 | */ |
tobyspark | 17:fc68d40b8b1f | 451 | |
tobyspark | 17:fc68d40b8b1f | 452 | screen.clearBuffer(); |
tobyspark | 17:fc68d40b8b1f | 453 | screen.textToBuffer("Self test complete", 0); |
tobyspark | 17:fc68d40b8b1f | 454 | screen.textToBuffer("Press to restart controller", 1); |
tobyspark | 17:fc68d40b8b1f | 455 | screen.sendBuffer(); |
tobyspark | 17:fc68d40b8b1f | 456 | |
tobyspark | 17:fc68d40b8b1f | 457 | while(!menuEnc.hasPressed()) {} |
tobyspark | 17:fc68d40b8b1f | 458 | |
tobyspark | 17:fc68d40b8b1f | 459 | mbed_reset(); |
tobyspark | 17:fc68d40b8b1f | 460 | } |
tobyspark | 17:fc68d40b8b1f | 461 | |
tobyspark | 0:87aab40d5806 | 462 | int main() |
tobyspark | 0:87aab40d5806 | 463 | { |
tobyspark | 0:87aab40d5806 | 464 | if (debug) |
tobyspark | 0:87aab40d5806 | 465 | { |
tobyspark | 0:87aab40d5806 | 466 | debug->printf("\r\n\r\n"); |
tobyspark | 0:87aab40d5806 | 467 | debug->printf("*spark d-fuser -----------\r\n"); |
tobyspark | 0:87aab40d5806 | 468 | debug->printf(" debug channel\r\n"); |
tobyspark | 0:87aab40d5806 | 469 | } |
tobyspark | 2:50043054e4f7 | 470 | |
tobyspark | 2:50043054e4f7 | 471 | // Set display font |
tobyspark | 2:50043054e4f7 | 472 | screen.fontStartCharacter = &characterBytesStartChar; |
tobyspark | 2:50043054e4f7 | 473 | screen.fontEndCharacter = &characterBytesEndChar; |
tobyspark | 2:50043054e4f7 | 474 | screen.fontCharacters = characterBytes; |
tobyspark | 2:50043054e4f7 | 475 | |
tobyspark | 0:87aab40d5806 | 476 | // Splash screen |
tobyspark | 2:50043054e4f7 | 477 | screen.imageToBuffer(spkDisplayLogo); |
tobyspark | 0:87aab40d5806 | 478 | screen.textToBuffer("SPK:D-Fuser",0); |
tobyspark | 13:3796bde6ba8f | 479 | screen.textToBuffer(string("SW ") + kSPKDFSoftwareVersion,1); |
tobyspark | 5:f8b285ca41ba | 480 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 481 | |
tobyspark | 11:0783cfbeb746 | 482 | // Load saved settings |
tobyspark | 16:52484666b323 | 483 | bool settingsAreCustom = false; |
tobyspark | 13:3796bde6ba8f | 484 | /* CRAZY, see note in spk_settings.h |
tobyspark | 16:52484666b323 | 485 | settingsAreCustom = settings.load(kSPKDFSettingsFilename); |
tobyspark | 16:52484666b323 | 486 | if (settingsAreCustom) |
tobyspark | 13:3796bde6ba8f | 487 | {screen.textToBuffer("Settings Read",2); screen.sendBuffer();} |
tobyspark | 13:3796bde6ba8f | 488 | else |
tobyspark | 13:3796bde6ba8f | 489 | {screen.textToBuffer("Settings NOT Read",2); screen.sendBuffer();} |
tobyspark | 13:3796bde6ba8f | 490 | */ |
tobyspark | 0:87aab40d5806 | 491 | // Set menu structure |
tobyspark | 0:87aab40d5806 | 492 | mixModeMenu.title = "Mix Mode"; |
tobyspark | 23:909928cafb95 | 493 | mixModeMenu.addMenuItem(SPKMenuItem("Blend", mixBlend)); |
tobyspark | 23:909928cafb95 | 494 | if (true) mixModeMenu.addMenuItem(SPKMenuItem("Additive", mixAdditive)); // TODO: Detect whether SPKDF custom firmware |
tobyspark | 22:90054fe6d86c | 495 | // TODO: Set fadecurve parameter menuitem |
tobyspark | 11:0783cfbeb746 | 496 | for (int i=0; i < settings.keyerSetCount(); i++) |
tobyspark | 11:0783cfbeb746 | 497 | { |
tobyspark | 23:909928cafb95 | 498 | mixModeMenu.addMenuItem(SPKMenuItem(settings.keyerParamName(i), mixKey+i)); |
tobyspark | 11:0783cfbeb746 | 499 | } |
tobyspark | 23:909928cafb95 | 500 | mixModeMenu.addMenuItem(SPKMenuItem("< Main Menu", &mainMenu)); |
tobyspark | 0:87aab40d5806 | 501 | |
tobyspark | 0:87aab40d5806 | 502 | resolutionMenu.title = "Resolution"; |
tobyspark | 16:52484666b323 | 503 | for (int i=0; i < settings.resolutionsCount(); i++) |
tobyspark | 16:52484666b323 | 504 | { |
tobyspark | 23:909928cafb95 | 505 | resolutionMenu.addMenuItem(SPKMenuItem(settings.resolutionName(i), settings.resolutionIndex(i), settings.resolutionEDIDIndex(i))); |
tobyspark | 16:52484666b323 | 506 | } |
tobyspark | 23:909928cafb95 | 507 | resolutionMenu.addMenuItem(SPKMenuItem("< Main Menu", &mainMenu)); |
tobyspark | 0:87aab40d5806 | 508 | |
tobyspark | 5:f8b285ca41ba | 509 | commsMenu.title = "Network Mode"; |
tobyspark | 23:909928cafb95 | 510 | // commsMenu is built in mixer's run loop, depending on RJ45 mode. |
tobyspark | 23:909928cafb95 | 511 | |
tobyspark | 15:4b394c64b461 | 512 | advancedMenu.title = "Troubleshooting"; |
tobyspark | 23:909928cafb95 | 513 | advancedMenu.addMenuItem(SPKMenuItem("HDCP Off", advancedHDCPOff)); |
tobyspark | 23:909928cafb95 | 514 | advancedMenu.addMenuItem(SPKMenuItem("HDCP On", advancedHDCPOn)); |
tobyspark | 23:909928cafb95 | 515 | advancedMenu.addMenuItem(SPKMenuItem("Conform Processor", advancedConformProcessor)); |
tobyspark | 23:909928cafb95 | 516 | if (settingsAreCustom) advancedMenu.addMenuItem(SPKMenuItem("Revert to defaults", advancedLoadDefaults)); |
tobyspark | 23:909928cafb95 | 517 | advancedMenu.addMenuItem(SPKMenuItem("Start Self-Test", advancedSelfTest)); |
tobyspark | 23:909928cafb95 | 518 | advancedMenu.addMenuItem(SPKMenuItem("< Main Menu", &mainMenu)); |
tobyspark | 23:909928cafb95 | 519 | |
tobyspark | 0:87aab40d5806 | 520 | mainMenu.title = "Main Menu"; |
tobyspark | 23:909928cafb95 | 521 | mainMenu.addMenuItem(SPKMenuItem("> " + mixModeMenu.title, &mixModeMenu)); |
tobyspark | 23:909928cafb95 | 522 | mainMenu.addMenuItem(SPKMenuItem("> " + resolutionMenu.title, &resolutionMenu)); |
tobyspark | 23:909928cafb95 | 523 | mainMenu.addMenuItem(SPKMenuItem("> " + commsMenu.title, &commsMenu)); |
tobyspark | 23:909928cafb95 | 524 | mainMenu.addMenuItem(SPKMenuItem("> " + advancedMenu.title, &advancedMenu)); |
tobyspark | 23:909928cafb95 | 525 | |
tobyspark | 0:87aab40d5806 | 526 | selectedMenu = &mainMenu; |
tobyspark | 23:909928cafb95 | 527 | |
tobyspark | 0:87aab40d5806 | 528 | // Misc I/O stuff |
tobyspark | 0:87aab40d5806 | 529 | |
tobyspark | 0:87aab40d5806 | 530 | fadeAPO.period(0.001); |
tobyspark | 0:87aab40d5806 | 531 | fadeBPO.period(0.001); |
tobyspark | 0:87aab40d5806 | 532 | |
tobyspark | 20:8b92d7922c48 | 533 | // Test for TV One connectivity and determine unit type |
tobyspark | 21:f9d63cb7cedb | 534 | int32_t testConnectionPayload = 0; |
tobyspark | 21:f9d63cb7cedb | 535 | |
tobyspark | 21:f9d63cb7cedb | 536 | // kTV1FunctionReadSoftwareVersion |
tobyspark | 21:f9d63cb7cedb | 537 | // kTV1FunctionReadProductType |
tobyspark | 21:f9d63cb7cedb | 538 | // kTV1FunctionReadBoardType |
tobyspark | 21:f9d63cb7cedb | 539 | bool ok = tvOne.readCommand(0, kTV1WindowIDA, kTV1FunctionReadSoftwareVersion, testConnectionPayload); |
tobyspark | 21:f9d63cb7cedb | 540 | |
tobyspark | 21:f9d63cb7cedb | 541 | string tvOneDetectString = ok ? "TVOne link ok" : "TVOne link failed"; |
tobyspark | 21:f9d63cb7cedb | 542 | |
tobyspark | 21:f9d63cb7cedb | 543 | // TODO: Use software version to select resolution slots etc? |
tobyspark | 21:f9d63cb7cedb | 544 | // TODO: Use product / board type to select TVOne conform type? |
tobyspark | 23:909928cafb95 | 545 | |
tobyspark | 12:c270870bdd23 | 546 | // Display menu and framing lines |
tobyspark | 0:87aab40d5806 | 547 | screen.horizLineToBuffer(kMenuLine1*pixInPage - 1); |
tobyspark | 0:87aab40d5806 | 548 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 549 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 550 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 551 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 552 | screen.horizLineToBuffer(kMenuLine2*pixInPage + pixInPage); |
tobyspark | 1:f9fca21102e0 | 553 | screen.horizLineToBuffer(kCommsStatusLine*pixInPage - 1); |
tobyspark | 1:f9fca21102e0 | 554 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 21:f9d63cb7cedb | 555 | screen.textToBuffer(tvOneDetectString, kTVOneStatusLine); |
tobyspark | 0:87aab40d5806 | 556 | screen.sendBuffer(); |
tobyspark | 0:87aab40d5806 | 557 | |
tobyspark | 23:909928cafb95 | 558 | debug->printf("this far?"); |
tobyspark | 0:87aab40d5806 | 559 | |
tobyspark | 0:87aab40d5806 | 560 | //// CONTROLS TEST |
tobyspark | 0:87aab40d5806 | 561 | |
tobyspark | 0:87aab40d5806 | 562 | while (0) { |
tobyspark | 0:87aab40d5806 | 563 | 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 | 564 | } |
tobyspark | 0:87aab40d5806 | 565 | |
tobyspark | 0:87aab40d5806 | 566 | //// MIXER RUN |
tobyspark | 0:87aab40d5806 | 567 | |
tobyspark | 8:d46cc49f0f37 | 568 | while (1) |
tobyspark | 8:d46cc49f0f37 | 569 | { |
tobyspark | 1:f9fca21102e0 | 570 | //// Task background things |
tobyspark | 5:f8b285ca41ba | 571 | if (ethernet && rj45Mode == rj45Ethernet) |
tobyspark | 5:f8b285ca41ba | 572 | { |
tobyspark | 5:f8b285ca41ba | 573 | if (debug) debug->printf("net poll"); |
tobyspark | 5:f8b285ca41ba | 574 | Net::poll(); |
tobyspark | 5:f8b285ca41ba | 575 | } |
tobyspark | 5:f8b285ca41ba | 576 | |
tobyspark | 5:f8b285ca41ba | 577 | //// RJ45 SWITCH |
tobyspark | 5:f8b285ca41ba | 578 | |
tobyspark | 5:f8b285ca41ba | 579 | if (rj45ModeDIN != rj45Mode) |
tobyspark | 1:f9fca21102e0 | 580 | { |
tobyspark | 23:909928cafb95 | 581 | if (debug) debug->printf("Handling RJ45 mode change\r\n"); |
tobyspark | 5:f8b285ca41ba | 582 | // update state |
tobyspark | 5:f8b285ca41ba | 583 | rj45Mode = rj45ModeDIN; |
tobyspark | 23:909928cafb95 | 584 | if (rj45Mode == rj45Ethernet) |
tobyspark | 23:909928cafb95 | 585 | { |
tobyspark | 23:909928cafb95 | 586 | commsMenu.title = "Network Mode [Ethernet]"; |
tobyspark | 23:909928cafb95 | 587 | commsMenu.clearMenuItems(); |
tobyspark | 23:909928cafb95 | 588 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 23:909928cafb95 | 589 | commsMenu.addMenuItem(SPKMenuItem("OSC", commsOSC)); |
tobyspark | 23:909928cafb95 | 590 | commsMenu.addMenuItem(SPKMenuItem("ArtNet", commsArtNet)); |
tobyspark | 23:909928cafb95 | 591 | commsMenu.addMenuItem(SPKMenuItem("< Main Menu", &mainMenu)); |
tobyspark | 23:909928cafb95 | 592 | } |
tobyspark | 23:909928cafb95 | 593 | if (rj45Mode == rj45DMX) |
tobyspark | 23:909928cafb95 | 594 | { |
tobyspark | 23:909928cafb95 | 595 | commsMenu.title = "Network Mode [DMX]"; |
tobyspark | 23:909928cafb95 | 596 | commsMenu.clearMenuItems(); |
tobyspark | 23:909928cafb95 | 597 | commsMenu.addMenuItem(SPKMenuItem("None", commsNone)); |
tobyspark | 23:909928cafb95 | 598 | commsMenu.addMenuItem(SPKMenuItem("DMX In", commsDMXIn)); |
tobyspark | 23:909928cafb95 | 599 | commsMenu.addMenuItem(SPKMenuItem("DMX Out", commsDMXOut)); |
tobyspark | 23:909928cafb95 | 600 | commsMenu.addMenuItem(SPKMenuItem("< Main Menu", &mainMenu)); |
tobyspark | 23:909928cafb95 | 601 | } |
tobyspark | 5:f8b285ca41ba | 602 | |
tobyspark | 5:f8b285ca41ba | 603 | // cancel old comms |
tobyspark | 5:f8b285ca41ba | 604 | commsMode = commsNone; |
tobyspark | 5:f8b285ca41ba | 605 | commsMenu = commsMode; |
tobyspark | 5:f8b285ca41ba | 606 | |
tobyspark | 5:f8b285ca41ba | 607 | // refresh display |
tobyspark | 23:909928cafb95 | 608 | if (selectedMenu == &commsMenu) |
tobyspark | 23:909928cafb95 | 609 | { |
tobyspark | 23:909928cafb95 | 610 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 23:909928cafb95 | 611 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 23:909928cafb95 | 612 | } |
tobyspark | 5:f8b285ca41ba | 613 | if (rj45Mode == rj45Ethernet) screen.textToBuffer("RJ45: Ethernet Engaged", kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 614 | if (rj45Mode == rj45DMX) screen.textToBuffer("RJ45: DMX Engaged", kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 615 | } |
tobyspark | 1:f9fca21102e0 | 616 | |
tobyspark | 0:87aab40d5806 | 617 | //// MENU |
tobyspark | 0:87aab40d5806 | 618 | |
tobyspark | 0:87aab40d5806 | 619 | int menuChange = menuEnc.getChange(); |
tobyspark | 0:87aab40d5806 | 620 | |
tobyspark | 0:87aab40d5806 | 621 | // Update GUI |
tobyspark | 0:87aab40d5806 | 622 | if (menuChange != 0) |
tobyspark | 0:87aab40d5806 | 623 | { |
tobyspark | 0:87aab40d5806 | 624 | if (debug) debug->printf("Menu changed by %i\r\n", menuChange); |
tobyspark | 0:87aab40d5806 | 625 | |
tobyspark | 0:87aab40d5806 | 626 | *selectedMenu = selectedMenu->selectedIndex() + menuChange; |
tobyspark | 0:87aab40d5806 | 627 | |
tobyspark | 0:87aab40d5806 | 628 | // update OLED line 2 here |
tobyspark | 0:87aab40d5806 | 629 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 630 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 631 | |
tobyspark | 0:87aab40d5806 | 632 | if (debug) debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 0:87aab40d5806 | 633 | } |
tobyspark | 0:87aab40d5806 | 634 | |
tobyspark | 0:87aab40d5806 | 635 | // Action menu item |
tobyspark | 0:87aab40d5806 | 636 | if (menuEnc.hasPressed()) |
tobyspark | 0:87aab40d5806 | 637 | { |
tobyspark | 0:87aab40d5806 | 638 | if (debug) debug->printf("Action Menu Item!\r\n"); |
tobyspark | 21:f9d63cb7cedb | 639 | |
tobyspark | 0:87aab40d5806 | 640 | // Are we changing menus? |
tobyspark | 23:909928cafb95 | 641 | if (selectedMenu->selectedItem().type == SPKMenuItem::changesToMenu) |
tobyspark | 0:87aab40d5806 | 642 | { |
tobyspark | 0:87aab40d5806 | 643 | // point selected menu to the new menu |
tobyspark | 23:909928cafb95 | 644 | selectedMenu = selectedMenu->selectedItem().payload.menu; |
tobyspark | 0:87aab40d5806 | 645 | |
tobyspark | 0:87aab40d5806 | 646 | // reset the selection within that menu to the first position |
tobyspark | 0:87aab40d5806 | 647 | (*selectedMenu) = 0; |
tobyspark | 0:87aab40d5806 | 648 | |
tobyspark | 0:87aab40d5806 | 649 | // update OLED lines 1&2 |
tobyspark | 0:87aab40d5806 | 650 | screen.clearBufferRow(kMenuLine1); |
tobyspark | 0:87aab40d5806 | 651 | screen.clearBufferRow(kMenuLine2); |
tobyspark | 0:87aab40d5806 | 652 | screen.textToBuffer(selectedMenu->title, kMenuLine1); |
tobyspark | 0:87aab40d5806 | 653 | screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2); |
tobyspark | 0:87aab40d5806 | 654 | |
tobyspark | 0:87aab40d5806 | 655 | if (debug) |
tobyspark | 0:87aab40d5806 | 656 | { |
tobyspark | 0:87aab40d5806 | 657 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 658 | debug->printf("%s \r\n", selectedMenu->title.c_str()); |
tobyspark | 0:87aab40d5806 | 659 | debug->printf("%s \r\n", selectedMenu->selectedString().c_str()); |
tobyspark | 0:87aab40d5806 | 660 | } |
tobyspark | 0:87aab40d5806 | 661 | } |
tobyspark | 0:87aab40d5806 | 662 | // With that out of the way, we should be actioning a specific menu's payload? |
tobyspark | 0:87aab40d5806 | 663 | else if (selectedMenu == &mixModeMenu) |
tobyspark | 0:87aab40d5806 | 664 | { |
tobyspark | 23:909928cafb95 | 665 | mixMode = mixModeMenu.selectedItem().payload.command[0]; |
tobyspark | 5:f8b285ca41ba | 666 | |
tobyspark | 9:f83eadd8917a | 667 | bool ok = true; |
tobyspark | 0:87aab40d5806 | 668 | std::string sentOK; |
tobyspark | 0:87aab40d5806 | 669 | std::stringstream sentMSG; |
tobyspark | 0:87aab40d5806 | 670 | |
tobyspark | 11:0783cfbeb746 | 671 | // Set Keyer |
tobyspark | 23:909928cafb95 | 672 | if (mixMode < mixKey) |
tobyspark | 11:0783cfbeb746 | 673 | { |
tobyspark | 11:0783cfbeb746 | 674 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, false); |
tobyspark | 11:0783cfbeb746 | 675 | sentMSG << "Keyer Off"; |
tobyspark | 11:0783cfbeb746 | 676 | } |
tobyspark | 11:0783cfbeb746 | 677 | else |
tobyspark | 11:0783cfbeb746 | 678 | { |
tobyspark | 11:0783cfbeb746 | 679 | ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, true); |
tobyspark | 11:0783cfbeb746 | 680 | sentMSG << "Keyer On"; |
tobyspark | 11:0783cfbeb746 | 681 | |
tobyspark | 23:909928cafb95 | 682 | int index = mixMode - mixKey; |
tobyspark | 11:0783cfbeb746 | 683 | ok = ok && setKeyParamsTo(index); |
tobyspark | 11:0783cfbeb746 | 684 | sentMSG << " with " << index; |
tobyspark | 0:87aab40d5806 | 685 | } |
tobyspark | 0:87aab40d5806 | 686 | |
tobyspark | 0:87aab40d5806 | 687 | if (ok) sentOK = "Sent:"; |
tobyspark | 0:87aab40d5806 | 688 | else sentOK = "Send Error:"; |
tobyspark | 0:87aab40d5806 | 689 | |
tobyspark | 1:f9fca21102e0 | 690 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 1:f9fca21102e0 | 691 | screen.textToBuffer(sentOK + sentMSG.str(), kTVOneStatusLine); |
tobyspark | 0:87aab40d5806 | 692 | |
tobyspark | 0:87aab40d5806 | 693 | if (debug) { debug->printf("Changing mix mode"); } |
tobyspark | 0:87aab40d5806 | 694 | } |
tobyspark | 0:87aab40d5806 | 695 | else if (selectedMenu == &resolutionMenu) |
tobyspark | 0:87aab40d5806 | 696 | { |
tobyspark | 9:f83eadd8917a | 697 | bool ok = true; |
tobyspark | 0:87aab40d5806 | 698 | |
tobyspark | 23:909928cafb95 | 699 | ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsOutputResolution, resolutionMenu.selectedItem().payload.command[0]); |
tobyspark | 23:909928cafb95 | 700 | ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, resolutionMenu.selectedItem().payload.command[1]); |
tobyspark | 23:909928cafb95 | 701 | ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, resolutionMenu.selectedItem().payload.command[1]); |
tobyspark | 0:87aab40d5806 | 702 | |
tobyspark | 0:87aab40d5806 | 703 | std::string sentOK; |
tobyspark | 0:87aab40d5806 | 704 | if (ok) sentOK = "Sent: "; |
tobyspark | 0:87aab40d5806 | 705 | else sentOK = "Send Error: "; |
tobyspark | 0:87aab40d5806 | 706 | |
tobyspark | 0:87aab40d5806 | 707 | std::stringstream sentMSG; |
tobyspark | 23:909928cafb95 | 708 | sentMSG << "Res " << resolutionMenu.selectedItem().payload.command[0] << ", EDID " << resolutionMenu.selectedItem().payload.command[1]; |
tobyspark | 0:87aab40d5806 | 709 | |
tobyspark | 1:f9fca21102e0 | 710 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 1:f9fca21102e0 | 711 | screen.textToBuffer(sentOK + sentMSG.str(), kTVOneStatusLine); |
tobyspark | 0:87aab40d5806 | 712 | |
tobyspark | 0:87aab40d5806 | 713 | if (debug) { debug->printf("Changing resolution"); } |
tobyspark | 0:87aab40d5806 | 714 | } |
tobyspark | 1:f9fca21102e0 | 715 | else if (selectedMenu == &commsMenu) |
tobyspark | 1:f9fca21102e0 | 716 | { |
tobyspark | 5:f8b285ca41ba | 717 | std::string commsTypeString = "Network: --"; |
tobyspark | 1:f9fca21102e0 | 718 | std::stringstream commsStatus; |
tobyspark | 1:f9fca21102e0 | 719 | |
tobyspark | 1:f9fca21102e0 | 720 | // Tear down any existing comms |
tobyspark | 1:f9fca21102e0 | 721 | // This is the action of commsNone |
tobyspark | 1:f9fca21102e0 | 722 | // And also clears the way for other comms actions |
tobyspark | 5:f8b285ca41ba | 723 | if (osc) {delete osc; osc = NULL;} |
tobyspark | 5:f8b285ca41ba | 724 | if (ethernet) {delete ethernet; ethernet = NULL;} |
tobyspark | 5:f8b285ca41ba | 725 | if (artNet) {delete artNet; artNet = NULL;} |
tobyspark | 5:f8b285ca41ba | 726 | if (dmx) {delete dmx; dmx = NULL;} |
tobyspark | 5:f8b285ca41ba | 727 | |
tobyspark | 5:f8b285ca41ba | 728 | // Ensure we can't change to comms modes the hardware isn't switched to |
tobyspark | 23:909928cafb95 | 729 | if (rj45Mode == rj45DMX && (commsMenu.selectedItem().payload.command[0] == commsOSC || commsMenu.selectedItem().payload.command[0] == commsArtNet)) |
tobyspark | 1:f9fca21102e0 | 730 | { |
tobyspark | 5:f8b285ca41ba | 731 | commsTypeString = "RJ45 not in Ethernet mode"; |
tobyspark | 5:f8b285ca41ba | 732 | } |
tobyspark | 23:909928cafb95 | 733 | else if (rj45Mode == rj45Ethernet && (commsMenu.selectedItem().payload.command[0] == commsDMXIn || commsMenu.selectedItem().payload.command[0] == commsDMXOut)) |
tobyspark | 5:f8b285ca41ba | 734 | { |
tobyspark | 5:f8b285ca41ba | 735 | commsTypeString = "RJ45 not in DMX mode"; |
tobyspark | 5:f8b285ca41ba | 736 | } |
tobyspark | 5:f8b285ca41ba | 737 | // Action! |
tobyspark | 23:909928cafb95 | 738 | else if (commsMenu.selectedItem().payload.command[0] == commsOSC) |
tobyspark | 5:f8b285ca41ba | 739 | { |
tobyspark | 5:f8b285ca41ba | 740 | commsMode = commsOSC; |
tobyspark | 5:f8b285ca41ba | 741 | commsTypeString = "OSC: "; |
tobyspark | 1:f9fca21102e0 | 742 | |
tobyspark | 1:f9fca21102e0 | 743 | ethernet = new EthernetNetIf( |
tobyspark | 1:f9fca21102e0 | 744 | IpAddr(kOSCMbedIPAddress), |
tobyspark | 1:f9fca21102e0 | 745 | IpAddr(kOSCMbedSubnetMask), |
tobyspark | 1:f9fca21102e0 | 746 | IpAddr(kOSCMbedGateway), |
tobyspark | 1:f9fca21102e0 | 747 | IpAddr(kOSCMbedDNS) |
tobyspark | 1:f9fca21102e0 | 748 | ); |
tobyspark | 3:033d2b7768f3 | 749 | |
tobyspark | 1:f9fca21102e0 | 750 | EthernetErr ethError = ethernet->setup(); |
tobyspark | 1:f9fca21102e0 | 751 | if(ethError) |
tobyspark | 1:f9fca21102e0 | 752 | { |
tobyspark | 1:f9fca21102e0 | 753 | if (debug) debug->printf("Ethernet setup error, %d", ethError); |
tobyspark | 1:f9fca21102e0 | 754 | commsStatus << "Ethernet setup failed"; |
tobyspark | 5:f8b285ca41ba | 755 | commsMenu = commsNone; |
tobyspark | 1:f9fca21102e0 | 756 | // break out of here. this setup should be a function that returns a boolean |
tobyspark | 1:f9fca21102e0 | 757 | } |
tobyspark | 1:f9fca21102e0 | 758 | |
tobyspark | 1:f9fca21102e0 | 759 | osc = new OSCClass(); |
tobyspark | 3:033d2b7768f3 | 760 | osc->setReceiveMessage(&recMessage); |
tobyspark | 1:f9fca21102e0 | 761 | osc->begin(kOSCMbedPort); |
tobyspark | 1:f9fca21102e0 | 762 | |
tobyspark | 3:033d2b7768f3 | 763 | commsStatus << "Listening on " << kOSCMbedPort; |
tobyspark | 1:f9fca21102e0 | 764 | } |
tobyspark | 23:909928cafb95 | 765 | else if (commsMenu.selectedItem().payload.command[0] == commsArtNet) |
tobyspark | 1:f9fca21102e0 | 766 | { |
tobyspark | 5:f8b285ca41ba | 767 | commsMode = commsArtNet; |
tobyspark | 5:f8b285ca41ba | 768 | commsTypeString = "ArtNet: "; |
tobyspark | 3:033d2b7768f3 | 769 | |
tobyspark | 3:033d2b7768f3 | 770 | artNet = new DmxArtNet(); |
tobyspark | 1:f9fca21102e0 | 771 | |
tobyspark | 3:033d2b7768f3 | 772 | artNet->BindIpAddress = IpAddr(kArtNetBindIPAddress); |
tobyspark | 3:033d2b7768f3 | 773 | artNet->BCastAddress = IpAddr(kArtNetBroadcastAddress); |
tobyspark | 3:033d2b7768f3 | 774 | |
tobyspark | 3:033d2b7768f3 | 775 | artNet->InitArtPollReplyDefaults(); |
tobyspark | 3:033d2b7768f3 | 776 | |
tobyspark | 3:033d2b7768f3 | 777 | artNet->ArtPollReply.PortType[0] = 128; // output |
tobyspark | 3:033d2b7768f3 | 778 | artNet->ArtPollReply.PortType[2] = 64; // input |
tobyspark | 3:033d2b7768f3 | 779 | artNet->ArtPollReply.GoodInput[2] = 4; |
tobyspark | 3:033d2b7768f3 | 780 | |
tobyspark | 3:033d2b7768f3 | 781 | artNet->Init(); |
tobyspark | 3:033d2b7768f3 | 782 | artNet->SendArtPollReply(); // announce to art-net nodes |
tobyspark | 3:033d2b7768f3 | 783 | |
tobyspark | 3:033d2b7768f3 | 784 | commsStatus << "Listening"; |
tobyspark | 1:f9fca21102e0 | 785 | } |
tobyspark | 23:909928cafb95 | 786 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXIn) |
tobyspark | 1:f9fca21102e0 | 787 | { |
tobyspark | 5:f8b285ca41ba | 788 | commsMode = commsDMXIn; |
tobyspark | 5:f8b285ca41ba | 789 | commsTypeString = "DMX In: "; |
tobyspark | 1:f9fca21102e0 | 790 | |
tobyspark | 5:f8b285ca41ba | 791 | dmxDirectionDOUT = 0; |
tobyspark | 5:f8b285ca41ba | 792 | |
tobyspark | 5:f8b285ca41ba | 793 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 1:f9fca21102e0 | 794 | } |
tobyspark | 23:909928cafb95 | 795 | else if (commsMenu.selectedItem().payload.command[0] == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 796 | { |
tobyspark | 5:f8b285ca41ba | 797 | commsMode = commsDMXOut; |
tobyspark | 5:f8b285ca41ba | 798 | commsTypeString = "DMX Out: "; |
tobyspark | 5:f8b285ca41ba | 799 | |
tobyspark | 5:f8b285ca41ba | 800 | dmxDirectionDOUT = 1; |
tobyspark | 5:f8b285ca41ba | 801 | |
tobyspark | 5:f8b285ca41ba | 802 | dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX); |
tobyspark | 5:f8b285ca41ba | 803 | } |
tobyspark | 5:f8b285ca41ba | 804 | |
tobyspark | 1:f9fca21102e0 | 805 | screen.clearBufferRow(kCommsStatusLine); |
tobyspark | 5:f8b285ca41ba | 806 | screen.textToBuffer(commsTypeString + commsStatus.str(), kCommsStatusLine); |
tobyspark | 1:f9fca21102e0 | 807 | } |
tobyspark | 12:c270870bdd23 | 808 | else if (selectedMenu == &advancedMenu) |
tobyspark | 12:c270870bdd23 | 809 | { |
tobyspark | 23:909928cafb95 | 810 | if (advancedMenu.selectedItem().payload.command[0] == advancedHDCPOff) |
tobyspark | 12:c270870bdd23 | 811 | { |
tobyspark | 12:c270870bdd23 | 812 | bool ok = false; |
tobyspark | 12:c270870bdd23 | 813 | |
tobyspark | 15:4b394c64b461 | 814 | ok = tvOne.setHDCPOn(false); |
tobyspark | 12:c270870bdd23 | 815 | |
tobyspark | 12:c270870bdd23 | 816 | std::string sendOK = ok ? "Sent: HDCP Off" : "Send Error: HDCP Off"; |
tobyspark | 12:c270870bdd23 | 817 | |
tobyspark | 12:c270870bdd23 | 818 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 12:c270870bdd23 | 819 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 12:c270870bdd23 | 820 | } |
tobyspark | 23:909928cafb95 | 821 | else if (advancedMenu.selectedItem().payload.command[0] == advancedHDCPOn) |
tobyspark | 15:4b394c64b461 | 822 | { |
tobyspark | 15:4b394c64b461 | 823 | bool ok = false; |
tobyspark | 15:4b394c64b461 | 824 | |
tobyspark | 15:4b394c64b461 | 825 | ok = tvOne.setHDCPOn(true); |
tobyspark | 15:4b394c64b461 | 826 | |
tobyspark | 15:4b394c64b461 | 827 | std::string sendOK = ok ? "Sent: HDCP On" : "Send Error: HDCP On"; |
tobyspark | 15:4b394c64b461 | 828 | |
tobyspark | 15:4b394c64b461 | 829 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 15:4b394c64b461 | 830 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 15:4b394c64b461 | 831 | } |
tobyspark | 23:909928cafb95 | 832 | else if (advancedMenu.selectedItem().payload.command[0] == advancedConformProcessor) |
tobyspark | 17:fc68d40b8b1f | 833 | { |
tobyspark | 20:8b92d7922c48 | 834 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 835 | screen.textToBuffer("Conforming...", kTVOneStatusLine); |
tobyspark | 20:8b92d7922c48 | 836 | screen.sendBuffer(); |
tobyspark | 20:8b92d7922c48 | 837 | |
tobyspark | 17:fc68d40b8b1f | 838 | bool ok = conformProcessor(); |
tobyspark | 17:fc68d40b8b1f | 839 | |
tobyspark | 17:fc68d40b8b1f | 840 | std::string sendOK = ok ? "Conform success" : "Send Error: Conform"; |
tobyspark | 17:fc68d40b8b1f | 841 | |
tobyspark | 17:fc68d40b8b1f | 842 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 17:fc68d40b8b1f | 843 | screen.textToBuffer(sendOK, kTVOneStatusLine); |
tobyspark | 17:fc68d40b8b1f | 844 | } |
tobyspark | 23:909928cafb95 | 845 | else if (advancedMenu.selectedItem().payload.command[0] == advancedLoadDefaults) |
tobyspark | 16:52484666b323 | 846 | { |
tobyspark | 16:52484666b323 | 847 | settings.loadDefaults(); |
tobyspark | 16:52484666b323 | 848 | |
tobyspark | 16:52484666b323 | 849 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 16:52484666b323 | 850 | screen.textToBuffer("Controller reverted", kTVOneStatusLine); |
tobyspark | 16:52484666b323 | 851 | } |
tobyspark | 23:909928cafb95 | 852 | else if (advancedMenu.selectedItem().payload.command[0] == advancedSelfTest) |
tobyspark | 15:4b394c64b461 | 853 | { |
tobyspark | 17:fc68d40b8b1f | 854 | selfTest(); |
tobyspark | 15:4b394c64b461 | 855 | } |
tobyspark | 23:909928cafb95 | 856 | else if (advancedMenu.selectedItem().payload.command[0] == advancedSetResolutions) |
tobyspark | 21:f9d63cb7cedb | 857 | { |
tobyspark | 21:f9d63cb7cedb | 858 | bool ok; |
tobyspark | 21:f9d63cb7cedb | 859 | ok = tvOne.setCustomResolutions(); |
tobyspark | 21:f9d63cb7cedb | 860 | |
tobyspark | 21:f9d63cb7cedb | 861 | screen.clearBufferRow(kTVOneStatusLine); |
tobyspark | 21:f9d63cb7cedb | 862 | screen.textToBuffer(ok ? "Resolutions set" : "Res' could not be set", kTVOneStatusLine); |
tobyspark | 21:f9d63cb7cedb | 863 | } |
tobyspark | 12:c270870bdd23 | 864 | } |
tobyspark | 0:87aab40d5806 | 865 | else |
tobyspark | 0:87aab40d5806 | 866 | { |
tobyspark | 0:87aab40d5806 | 867 | if (debug) { debug->printf("Warning: No action identified"); } |
tobyspark | 0:87aab40d5806 | 868 | } |
tobyspark | 0:87aab40d5806 | 869 | } |
tobyspark | 0:87aab40d5806 | 870 | |
tobyspark | 2:50043054e4f7 | 871 | // Send any updates to the display |
tobyspark | 2:50043054e4f7 | 872 | screen.sendBuffer(); |
tobyspark | 5:f8b285ca41ba | 873 | |
tobyspark | 0:87aab40d5806 | 874 | |
tobyspark | 5:f8b285ca41ba | 875 | //// MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIXMIX MIX MIXMIX MIX MIX MIX MIX MIXMIX MIX MIX |
tobyspark | 0:87aab40d5806 | 876 | |
tobyspark | 0:87aab40d5806 | 877 | bool updateFade = false; |
tobyspark | 3:033d2b7768f3 | 878 | float xFade = 0; |
tobyspark | 3:033d2b7768f3 | 879 | float fadeUp = 1; |
tobyspark | 3:033d2b7768f3 | 880 | |
tobyspark | 3:033d2b7768f3 | 881 | //// TASK: Process control surface |
tobyspark | 3:033d2b7768f3 | 882 | |
tobyspark | 0:87aab40d5806 | 883 | // Get new states of tap buttons, remembering at end of loop() assign these current values to the previous variables |
tobyspark | 5:f8b285ca41ba | 884 | const bool tapLeft = !tapLeftDIN; |
tobyspark | 5:f8b285ca41ba | 885 | const bool tapRight = !tapRightDIN; |
tobyspark | 0:87aab40d5806 | 886 | |
tobyspark | 17:fc68d40b8b1f | 887 | // We're taking a further median of the AINs on top of mbed libs v29. |
tobyspark | 17:fc68d40b8b1f | 888 | // This takes some values from last passes and most from now. With debug off, seem to need median size > 5 |
tobyspark | 17:fc68d40b8b1f | 889 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 890 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 891 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 892 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 893 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 894 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 895 | xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 896 | fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 897 | const float xFadeAINCached = xFadeFilter.process(xFadeAIN.read()); |
tobyspark | 17:fc68d40b8b1f | 898 | const float fadeUpAINCached = fadeUpFilter.process(fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 899 | |
tobyspark | 0:87aab40d5806 | 900 | // When a tap is depressed, we can ignore any move of the crossfader but not fade to black |
tobyspark | 0:87aab40d5806 | 901 | if (tapLeft || tapRight) |
tobyspark | 0:87aab40d5806 | 902 | { |
tobyspark | 5:f8b285ca41ba | 903 | // If both are pressed, take to the one that is new, ie. not the first pressed. |
tobyspark | 0:87aab40d5806 | 904 | if (tapLeft && tapRight) |
tobyspark | 0:87aab40d5806 | 905 | { |
tobyspark | 5:f8b285ca41ba | 906 | xFade = tapLeftWasFirstPressed ? 1 : 0; |
tobyspark | 0:87aab40d5806 | 907 | } |
tobyspark | 5:f8b285ca41ba | 908 | // If just one is pressed, take to that and remember which is pressed |
tobyspark | 5:f8b285ca41ba | 909 | else if (tapLeft) |
tobyspark | 5:f8b285ca41ba | 910 | { |
tobyspark | 5:f8b285ca41ba | 911 | xFade = 0; |
tobyspark | 5:f8b285ca41ba | 912 | tapLeftWasFirstPressed = 1; |
tobyspark | 5:f8b285ca41ba | 913 | } |
tobyspark | 5:f8b285ca41ba | 914 | else if (tapRight) |
tobyspark | 5:f8b285ca41ba | 915 | { |
tobyspark | 5:f8b285ca41ba | 916 | xFade = 1; |
tobyspark | 5:f8b285ca41ba | 917 | tapLeftWasFirstPressed = 0; |
tobyspark | 5:f8b285ca41ba | 918 | } |
tobyspark | 5:f8b285ca41ba | 919 | } |
tobyspark | 18:ebe5da639a6a | 920 | else xFade = 1.0 - fadeCalc(xFadeAINCached, xFadeTolerance); |
tobyspark | 0:87aab40d5806 | 921 | |
tobyspark | 0:87aab40d5806 | 922 | fadeUp = 1.0 - fadeCalc(fadeUpAINCached, fadeUpTolerance); |
tobyspark | 0:87aab40d5806 | 923 | |
tobyspark | 3:033d2b7768f3 | 924 | //// TASK: Process Network Comms |
tobyspark | 5:f8b285ca41ba | 925 | if (commsMode == commsOSC) |
tobyspark | 3:033d2b7768f3 | 926 | { |
tobyspark | 3:033d2b7768f3 | 927 | if (osc->newMessage) |
tobyspark | 3:033d2b7768f3 | 928 | { |
tobyspark | 3:033d2b7768f3 | 929 | osc->newMessage = false; // fixme! |
tobyspark | 3:033d2b7768f3 | 930 | processOSC(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 931 | } |
tobyspark | 3:033d2b7768f3 | 932 | } |
tobyspark | 3:033d2b7768f3 | 933 | |
tobyspark | 5:f8b285ca41ba | 934 | if (commsMode == commsArtNet) |
tobyspark | 3:033d2b7768f3 | 935 | { |
tobyspark | 3:033d2b7768f3 | 936 | if (artNet->Work()) processArtNet(xFade, fadeUp); |
tobyspark | 3:033d2b7768f3 | 937 | } |
tobyspark | 3:033d2b7768f3 | 938 | |
tobyspark | 5:f8b285ca41ba | 939 | if (commsMode == commsDMXIn) |
tobyspark | 5:f8b285ca41ba | 940 | { |
tobyspark | 5:f8b285ca41ba | 941 | processDMXIn(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 942 | } |
tobyspark | 5:f8b285ca41ba | 943 | |
tobyspark | 5:f8b285ca41ba | 944 | if (commsMode == commsDMXOut) |
tobyspark | 5:f8b285ca41ba | 945 | { |
tobyspark | 5:f8b285ca41ba | 946 | processDMXOut(xFade, fadeUp); |
tobyspark | 5:f8b285ca41ba | 947 | } |
tobyspark | 0:87aab40d5806 | 948 | |
tobyspark | 0:87aab40d5806 | 949 | // Calculate new A&B fade percents |
tobyspark | 0:87aab40d5806 | 950 | int newFadeAPercent = 0; |
tobyspark | 0:87aab40d5806 | 951 | int newFadeBPercent = 0; |
tobyspark | 0:87aab40d5806 | 952 | |
tobyspark | 15:4b394c64b461 | 953 | if (mixMode == mixBlend) |
tobyspark | 11:0783cfbeb746 | 954 | { |
tobyspark | 22:90054fe6d86c | 955 | if (fadeUp < 1.0) // TODO: OR if a source is not valid |
tobyspark | 9:f83eadd8917a | 956 | { |
tobyspark | 9:f83eadd8917a | 957 | // we need to set fade level of both windows as there is no way AFAIK to implement fade to black as a further window on top of A&B |
tobyspark | 9:f83eadd8917a | 958 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 9:f83eadd8917a | 959 | newFadeBPercent = xFade * fadeUp * 100.0; |
tobyspark | 9:f83eadd8917a | 960 | } |
tobyspark | 9:f83eadd8917a | 961 | else |
tobyspark | 9:f83eadd8917a | 962 | { |
tobyspark | 9:f83eadd8917a | 963 | // we can optimise and just fade A in and out over a fully up B, doubling the rate of fadeA commands sent. |
tobyspark | 9:f83eadd8917a | 964 | newFadeAPercent = (1.0-xFade) * 100.0; |
tobyspark | 9:f83eadd8917a | 965 | newFadeBPercent = 100.0; |
tobyspark | 9:f83eadd8917a | 966 | } |
tobyspark | 11:0783cfbeb746 | 967 | } |
tobyspark | 15:4b394c64b461 | 968 | else if (mixMode == mixAdditive) |
tobyspark | 11:0783cfbeb746 | 969 | { |
tobyspark | 22:90054fe6d86c | 970 | // we need to set fade level of both windows according to the fade curve profile |
tobyspark | 22:90054fe6d86c | 971 | float newFadeA = (1.0-xFade) * (1.0 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 972 | float newFadeB = xFade * (1 + fadeCurve); |
tobyspark | 22:90054fe6d86c | 973 | if (newFadeA > 1.0) newFadeA = 1.0; |
tobyspark | 22:90054fe6d86c | 974 | if (newFadeB > 1.0) newFadeB = 1.0; |
tobyspark | 22:90054fe6d86c | 975 | |
tobyspark | 22:90054fe6d86c | 976 | newFadeAPercent = newFadeA * fadeUp * 100.0; |
tobyspark | 22:90054fe6d86c | 977 | newFadeBPercent = newFadeB * fadeUp * 100.0; |
tobyspark | 11:0783cfbeb746 | 978 | } |
tobyspark | 15:4b394c64b461 | 979 | else if (mixMode >= mixKey) |
tobyspark | 11:0783cfbeb746 | 980 | { |
tobyspark | 0:87aab40d5806 | 981 | newFadeAPercent = (1.0-xFade) * fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 982 | newFadeBPercent = fadeUp * 100.0; |
tobyspark | 0:87aab40d5806 | 983 | } |
tobyspark | 0:87aab40d5806 | 984 | |
tobyspark | 17:fc68d40b8b1f | 985 | //// TASK: Send to TVOne if percents have changed |
tobyspark | 17:fc68d40b8b1f | 986 | |
tobyspark | 17:fc68d40b8b1f | 987 | // No amount of median filtering is stopping flipflopping between two adjacent percents, so... |
tobyspark | 17:fc68d40b8b1f | 988 | bool fadeAPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 989 | bool fadeBPercentHasChanged; |
tobyspark | 17:fc68d40b8b1f | 990 | if (oldFadeAPercent == newFadeAPercent && (newFadeAPercent == fadeAPercent - 1 || newFadeAPercent == fadeAPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 991 | fadeAPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 992 | else |
tobyspark | 17:fc68d40b8b1f | 993 | fadeAPercentHasChanged = newFadeAPercent != fadeAPercent; |
tobyspark | 17:fc68d40b8b1f | 994 | if (oldFadeBPercent == newFadeBPercent && (newFadeBPercent == fadeBPercent - 1 || newFadeBPercent == fadeBPercent + 1)) |
tobyspark | 17:fc68d40b8b1f | 995 | fadeBPercentHasChanged = false; |
tobyspark | 17:fc68d40b8b1f | 996 | else |
tobyspark | 17:fc68d40b8b1f | 997 | fadeBPercentHasChanged = newFadeBPercent != fadeBPercent; |
tobyspark | 17:fc68d40b8b1f | 998 | |
tobyspark | 9:f83eadd8917a | 999 | // We want to send the higher first, otherwise black flashes can happen on taps |
tobyspark | 17:fc68d40b8b1f | 1000 | if (fadeAPercentHasChanged && newFadeAPercent >= newFadeBPercent) |
tobyspark | 8:d46cc49f0f37 | 1001 | { |
tobyspark | 17:fc68d40b8b1f | 1002 | oldFadeAPercent = fadeAPercent; |
tobyspark | 0:87aab40d5806 | 1003 | fadeAPercent = newFadeAPercent; |
tobyspark | 0:87aab40d5806 | 1004 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1005 | |
tobyspark | 0:87aab40d5806 | 1006 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1007 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 0:87aab40d5806 | 1008 | } |
tobyspark | 17:fc68d40b8b1f | 1009 | if (fadeBPercentHasChanged) |
tobyspark | 8:d46cc49f0f37 | 1010 | { |
tobyspark | 17:fc68d40b8b1f | 1011 | oldFadeBPercent = fadeBPercent; |
tobyspark | 0:87aab40d5806 | 1012 | fadeBPercent = newFadeBPercent; |
tobyspark | 0:87aab40d5806 | 1013 | updateFade = true; |
tobyspark | 0:87aab40d5806 | 1014 | |
tobyspark | 0:87aab40d5806 | 1015 | fadeBPO = fadeBPercent / 100.0; |
tobyspark | 0:87aab40d5806 | 1016 | tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent); |
tobyspark | 0:87aab40d5806 | 1017 | } |
tobyspark | 17:fc68d40b8b1f | 1018 | if (fadeAPercentHasChanged && newFadeAPercent < newFadeBPercent) |
tobyspark | 9:f83eadd8917a | 1019 | { |
tobyspark | 17:fc68d40b8b1f | 1020 | oldFadeAPercent = fadeAPercent; |
tobyspark | 9:f83eadd8917a | 1021 | fadeAPercent = newFadeAPercent; |
tobyspark | 9:f83eadd8917a | 1022 | updateFade = true; |
tobyspark | 9:f83eadd8917a | 1023 | |
tobyspark | 9:f83eadd8917a | 1024 | fadeAPO = fadeAPercent / 100.0; |
tobyspark | 9:f83eadd8917a | 1025 | tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent); |
tobyspark | 9:f83eadd8917a | 1026 | } |
tobyspark | 8:d46cc49f0f37 | 1027 | if (updateFade && debug) |
tobyspark | 8:d46cc49f0f37 | 1028 | { |
tobyspark | 0:87aab40d5806 | 1029 | //debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAIN.read(), fadeUpAIN.read()); |
tobyspark | 0:87aab40d5806 | 1030 | debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAINCached, fadeUpAINCached); |
tobyspark | 0:87aab40d5806 | 1031 | debug->printf("xFade = %3f fadeUp = %3f fadeA% = %i fadeB% = %i \r\n", xFade, fadeUp, fadeAPercent, fadeBPercent); |
tobyspark | 18:ebe5da639a6a | 1032 | debug->printf("\r\n"); |
tobyspark | 0:87aab40d5806 | 1033 | } |
tobyspark | 0:87aab40d5806 | 1034 | } |
tobyspark | 0:87aab40d5806 | 1035 | } |