The codebase to run the *spark d-fuser controller www.sparkav.co.uk/dvimixer

Dependencies:   SPK-TVOne DMX DmxArtNet NetServicesMin OSC PinDetect mRotaryEncoder iniparser mbed spk_oled_ssd1305 filter

Committer:
tobyspark
Date:
Sun Sep 30 13:41:06 2012 +0000
Revision:
15:4b394c64b461
Parent:
13:3796bde6ba8f
Child:
16:52484666b323
Self Test part implemented

Who changed what in which revision?

UserRevisionLine numberNew 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 0:87aab40d5806 58
tobyspark 0:87aab40d5806 59 #include <sstream>
tobyspark 0:87aab40d5806 60
tobyspark 13:3796bde6ba8f 61 #define kSPKDFSoftwareVersion "beta.19"
tobyspark 13:3796bde6ba8f 62
tobyspark 5:f8b285ca41ba 63 // MBED PINS
tobyspark 5:f8b285ca41ba 64
tobyspark 5:f8b285ca41ba 65 #define kMBED_AIN_XFADE p20
tobyspark 5:f8b285ca41ba 66 #define kMBED_AIN_FADEUP p19
tobyspark 5:f8b285ca41ba 67 #define kMBED_DIN_TAP_L p24
tobyspark 5:f8b285ca41ba 68 #define kMBED_DIN_TAP_R p23
tobyspark 5:f8b285ca41ba 69 #define kMBED_ENC_SW p15
tobyspark 5:f8b285ca41ba 70 #define kMBED_ENC_A p16
tobyspark 5:f8b285ca41ba 71 #define kMBED_ENC_B p17
tobyspark 5:f8b285ca41ba 72
tobyspark 5:f8b285ca41ba 73 #define kMBED_RS232_TTLTX p13
tobyspark 5:f8b285ca41ba 74 #define kMBED_RS232_TTLRX p14
tobyspark 5:f8b285ca41ba 75
tobyspark 5:f8b285ca41ba 76 #define kMBED_OLED_MOSI p5
tobyspark 5:f8b285ca41ba 77 #define kMBED_OLED_SCK p7
tobyspark 5:f8b285ca41ba 78 #define kMBED_OLED_CS p8
tobyspark 5:f8b285ca41ba 79 #define kMBED_OLED_RES p9
tobyspark 5:f8b285ca41ba 80 #define kMBED_OLED_DC p10
tobyspark 5:f8b285ca41ba 81
tobyspark 5:f8b285ca41ba 82 #define kMBED_DIN_ETHLO_DMXHI p30
tobyspark 5:f8b285ca41ba 83 #define kMBED_DOUT_RS485_TXHI_RXLO p29
tobyspark 5:f8b285ca41ba 84 #define kMBED_RS485_TTLTX p28
tobyspark 5:f8b285ca41ba 85 #define kMBED_RS485_TTLRX p27
tobyspark 5:f8b285ca41ba 86
tobyspark 5:f8b285ca41ba 87 // DISPLAY
tobyspark 5:f8b285ca41ba 88
tobyspark 1:f9fca21102e0 89 #define kMenuLine1 3
tobyspark 1:f9fca21102e0 90 #define kMenuLine2 4
tobyspark 1:f9fca21102e0 91 #define kCommsStatusLine 6
tobyspark 1:f9fca21102e0 92 #define kTVOneStatusLine 7
tobyspark 1:f9fca21102e0 93
tobyspark 5:f8b285ca41ba 94 // NETWORKING
tobyspark 5:f8b285ca41ba 95
tobyspark 1:f9fca21102e0 96 #define kOSCMbedPort 10000
tobyspark 1:f9fca21102e0 97 #define kOSCMbedIPAddress 10,0,0,2
tobyspark 1:f9fca21102e0 98 #define kOSCMbedSubnetMask 255,255,255,0
tobyspark 1:f9fca21102e0 99 #define kOSCMbedGateway 10,0,0,1
tobyspark 1:f9fca21102e0 100 #define kOSCMbedDNS 10,0,0,1
tobyspark 0:87aab40d5806 101
tobyspark 3:033d2b7768f3 102 #define kArtNetBindIPAddress 2,0,0,100
tobyspark 3:033d2b7768f3 103 #define kArtNetBroadcastAddress 2,255,255,255
tobyspark 3:033d2b7768f3 104
tobyspark 5:f8b285ca41ba 105 #define kDMXInChannelXFade 0
tobyspark 5:f8b285ca41ba 106 #define kDMXInChannelFadeUp 1
tobyspark 5:f8b285ca41ba 107 #define kDMXOutChannelXFade 0
tobyspark 5:f8b285ca41ba 108 #define kDMXOutChannelFadeUp 1
tobyspark 5:f8b285ca41ba 109
tobyspark 13:3796bde6ba8f 110 // 8.3 format filename only, no subdirs
tobyspark 13:3796bde6ba8f 111 #define kSPKDFSettingsFilename "SPKDF.ini"
tobyspark 11:0783cfbeb746 112
tobyspark 0:87aab40d5806 113 //// DEBUG
tobyspark 0:87aab40d5806 114
tobyspark 0:87aab40d5806 115 // Comment out one or the other...
tobyspark 5:f8b285ca41ba 116 //Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial
tobyspark 5:f8b285ca41ba 117 Serial *debug = NULL; // For release (no debugging)
tobyspark 0:87aab40d5806 118
tobyspark 15:4b394c64b461 119 //// SOFT RESET
tobyspark 15:4b394c64b461 120
tobyspark 15:4b394c64b461 121 extern "C" void mbed_reset();
tobyspark 15:4b394c64b461 122
tobyspark 0:87aab40d5806 123 //// mBED PIN ASSIGNMENTS
tobyspark 0:87aab40d5806 124
tobyspark 0:87aab40d5806 125 // Inputs
tobyspark 5:f8b285ca41ba 126 AnalogIn xFadeAIN(kMBED_AIN_XFADE);
tobyspark 5:f8b285ca41ba 127 AnalogIn fadeUpAIN(kMBED_AIN_FADEUP);
tobyspark 5:f8b285ca41ba 128 DigitalIn tapLeftDIN(kMBED_DIN_TAP_L);
tobyspark 5:f8b285ca41ba 129 DigitalIn tapRightDIN(kMBED_DIN_TAP_R);
tobyspark 0:87aab40d5806 130
tobyspark 5:f8b285ca41ba 131 SPKRotaryEncoder menuEnc(kMBED_ENC_A, kMBED_ENC_B, kMBED_ENC_SW);
tobyspark 5:f8b285ca41ba 132
tobyspark 5:f8b285ca41ba 133 DigitalIn rj45ModeDIN(kMBED_DIN_ETHLO_DMXHI);
tobyspark 0:87aab40d5806 134
tobyspark 0:87aab40d5806 135 // Outputs
tobyspark 0:87aab40d5806 136 PwmOut fadeAPO(LED1);
tobyspark 0:87aab40d5806 137 PwmOut fadeBPO(LED2);
tobyspark 0:87aab40d5806 138
tobyspark 5:f8b285ca41ba 139 DigitalOut dmxDirectionDOUT(kMBED_DOUT_RS485_TXHI_RXLO);
tobyspark 5:f8b285ca41ba 140
tobyspark 0:87aab40d5806 141 // SPKTVOne(PinName txPin, PinName rxPin, PinName signWritePin, PinName signErrorPin, Serial *debugSerial)
tobyspark 5:f8b285ca41ba 142 SPKTVOne tvOne(kMBED_RS232_TTLTX, kMBED_RS232_TTLRX, LED3, LED4, debug);
tobyspark 0:87aab40d5806 143
tobyspark 0:87aab40d5806 144 // SPKDisplay(PinName mosi, PinName clk, PinName cs, PinName dc, PinName res, Serial *debugSerial = NULL);
tobyspark 5:f8b285ca41ba 145 SPKDisplay screen(kMBED_OLED_MOSI, kMBED_OLED_SCK, kMBED_OLED_CS, kMBED_OLED_DC, kMBED_OLED_RES, debug);
tobyspark 0:87aab40d5806 146
tobyspark 11:0783cfbeb746 147 // Saved Settings
tobyspark 11:0783cfbeb746 148 SPKSettings settings;
tobyspark 11:0783cfbeb746 149
tobyspark 0:87aab40d5806 150 // Menu
tobyspark 0:87aab40d5806 151 SPKMenu *selectedMenu;
tobyspark 0:87aab40d5806 152 SPKMenu *lastSelectedMenu;
tobyspark 0:87aab40d5806 153 SPKMenuOfMenus mainMenu;
tobyspark 0:87aab40d5806 154 SPKMenuPayload resolutionMenu;
tobyspark 0:87aab40d5806 155 SPKMenuPayload mixModeMenu;
tobyspark 12:c270870bdd23 156 SPKMenuPayload advancedMenu;
tobyspark 12:c270870bdd23 157
tobyspark 15:4b394c64b461 158 enum { mixBlend, mixAdditive, mixKey }; // additive will require custom TVOne firmware.
tobyspark 15:4b394c64b461 159 int mixMode = mixBlend;
tobyspark 1:f9fca21102e0 160 SPKMenuPayload commsMenu;
tobyspark 5:f8b285ca41ba 161 enum { commsNone, commsOSC, commsArtNet, commsDMXIn, commsDMXOut};
tobyspark 5:f8b285ca41ba 162 int commsMode = commsNone;
tobyspark 15:4b394c64b461 163 enum { advancedHDCPOn, advancedHDCPOff, advancedSelfTest };
tobyspark 1:f9fca21102e0 164
tobyspark 5:f8b285ca41ba 165 // RJ45 Comms
tobyspark 5:f8b285ca41ba 166 enum { rj45Ethernet = 0, rj45DMX = 1}; // These values from circuit
tobyspark 5:f8b285ca41ba 167 int rj45Mode = -1;
tobyspark 1:f9fca21102e0 168 EthernetNetIf *ethernet = NULL;
tobyspark 1:f9fca21102e0 169 OSCClass *osc = NULL;
tobyspark 3:033d2b7768f3 170 OSCMessage recMessage;
tobyspark 3:033d2b7768f3 171 DmxArtNet *artNet = NULL;
tobyspark 5:f8b285ca41ba 172 DMX *dmx = NULL;
tobyspark 0:87aab40d5806 173
tobyspark 3:033d2b7768f3 174 // Fade logic constants
tobyspark 0:87aab40d5806 175 const float xFadeTolerance = 0.05;
tobyspark 0:87aab40d5806 176 const float fadeUpTolerance = 0.05;
tobyspark 0:87aab40d5806 177
tobyspark 0:87aab40d5806 178 // A&B Fade as resolved percent
tobyspark 0:87aab40d5806 179 int fadeAPercent = 0;
tobyspark 0:87aab40d5806 180 int fadeBPercent = 0;
tobyspark 0:87aab40d5806 181
tobyspark 0:87aab40d5806 182 // Tap button states
tobyspark 5:f8b285ca41ba 183 bool tapLeftWasFirstPressed = false;
tobyspark 0:87aab40d5806 184
tobyspark 0:87aab40d5806 185 // Key mode parameters
tobyspark 0:87aab40d5806 186 int keyerParamsSet = -1; // last keyParams index uploaded to unit
tobyspark 0:87aab40d5806 187
tobyspark 3:033d2b7768f3 188 void processOSC(float &xFade, float &fadeUp) {
tobyspark 3:033d2b7768f3 189 std::stringstream statusMessage;
tobyspark 3:033d2b7768f3 190 statusMessage.setf(ios::fixed,ios::floatfield);
tobyspark 3:033d2b7768f3 191 statusMessage.precision(2);
tobyspark 3:033d2b7768f3 192
tobyspark 3:033d2b7768f3 193 if (!strcmp( recMessage.getTopAddress() , "dvimxr" ))
tobyspark 3:033d2b7768f3 194 {
tobyspark 3:033d2b7768f3 195 statusMessage << "OSC: /dvimxr";
tobyspark 3:033d2b7768f3 196 if (!strcmp( recMessage.getSubAddress() , "xFade" ))
tobyspark 3:033d2b7768f3 197 if (recMessage.getArgNum() == 1)
tobyspark 3:033d2b7768f3 198 if (recMessage.getTypeTag(0) == 'f')
tobyspark 3:033d2b7768f3 199 {
tobyspark 3:033d2b7768f3 200 double newXFade = recMessage.getArgFloat(0);
tobyspark 3:033d2b7768f3 201 statusMessage << "/xFade " << newXFade;
tobyspark 3:033d2b7768f3 202 xFade = newXFade;
tobyspark 3:033d2b7768f3 203 }
tobyspark 3:033d2b7768f3 204 else if (!strcmp( recMessage.getSubAddress() , "fadeUp" ))
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 newFadeUp = recMessage.getArgFloat(0);
tobyspark 3:033d2b7768f3 209 statusMessage << "/fadeUp " << newFadeUp;
tobyspark 3:033d2b7768f3 210 xFade = newFadeUp;
tobyspark 3:033d2b7768f3 211 }
tobyspark 3:033d2b7768f3 212 else statusMessage << recMessage.getSubAddress() << " - Ignoring";
tobyspark 3:033d2b7768f3 213 }
tobyspark 3:033d2b7768f3 214 else
tobyspark 3:033d2b7768f3 215 {
tobyspark 3:033d2b7768f3 216 statusMessage << "OSC: " << recMessage.getTopAddress() << " - Ignoring";
tobyspark 3:033d2b7768f3 217 }
tobyspark 3:033d2b7768f3 218
tobyspark 3:033d2b7768f3 219 screen.clearBufferRow(kCommsStatusLine);
tobyspark 3:033d2b7768f3 220 screen.textToBuffer(statusMessage.str(), kCommsStatusLine);
tobyspark 3:033d2b7768f3 221 screen.sendBuffer();
tobyspark 3:033d2b7768f3 222 if (debug) debug->printf("%s \r\n", statusMessage.str().c_str());
tobyspark 3:033d2b7768f3 223
tobyspark 3:033d2b7768f3 224 }
tobyspark 3:033d2b7768f3 225
tobyspark 8:d46cc49f0f37 226 void processArtNet(float &xFade, float &fadeUp)
tobyspark 8:d46cc49f0f37 227 {
tobyspark 3:033d2b7768f3 228 screen.clearBufferRow(kCommsStatusLine);
tobyspark 3:033d2b7768f3 229 screen.textToBuffer("ArtNet activity", kCommsStatusLine);
tobyspark 3:033d2b7768f3 230 screen.sendBuffer();
tobyspark 3:033d2b7768f3 231 if (debug) debug->printf("ArtNet activity");
tobyspark 3:033d2b7768f3 232 }
tobyspark 0:87aab40d5806 233
tobyspark 8:d46cc49f0f37 234 void processDMXIn(float &xFade, float &fadeUp)
tobyspark 8:d46cc49f0f37 235 {
tobyspark 5:f8b285ca41ba 236 std::stringstream statusMessage;
tobyspark 5:f8b285ca41ba 237
tobyspark 5:f8b285ca41ba 238 int xFadeDMX = dmx->get(kDMXInChannelXFade);
tobyspark 7:e6717468c18d 239 int fadeUpDMX = dmx->get(kDMXInChannelFadeUp);
tobyspark 5:f8b285ca41ba 240
tobyspark 5:f8b285ca41ba 241 xFade = (float)xFadeDMX/255;
tobyspark 5:f8b285ca41ba 242 fadeUp = (float)fadeUpDMX/255;
tobyspark 5:f8b285ca41ba 243
tobyspark 5:f8b285ca41ba 244 screen.clearBufferRow(kCommsStatusLine);
tobyspark 5:f8b285ca41ba 245 statusMessage << "DMX In: xF " << xFadeDMX << " fUp " << fadeUpDMX;
tobyspark 5:f8b285ca41ba 246 screen.textToBuffer(statusMessage.str(), kCommsStatusLine);
tobyspark 5:f8b285ca41ba 247 screen.sendBuffer();
tobyspark 5:f8b285ca41ba 248 if (debug) debug->printf(statusMessage.str().c_str());
tobyspark 5:f8b285ca41ba 249 }
tobyspark 5:f8b285ca41ba 250
tobyspark 8:d46cc49f0f37 251 void processDMXOut(float &xFade, float &fadeUp)
tobyspark 8:d46cc49f0f37 252 {
tobyspark 5:f8b285ca41ba 253 std::stringstream statusMessage;
tobyspark 5:f8b285ca41ba 254
tobyspark 5:f8b285ca41ba 255 int xFadeDMX = xFade*255;
tobyspark 5:f8b285ca41ba 256 int fadeUpDMX = fadeUp*255;
tobyspark 5:f8b285ca41ba 257
tobyspark 5:f8b285ca41ba 258 dmx->put(kDMXOutChannelXFade, xFadeDMX);
tobyspark 5:f8b285ca41ba 259 dmx->put(kDMXOutChannelFadeUp, fadeUpDMX);
tobyspark 5:f8b285ca41ba 260
tobyspark 5:f8b285ca41ba 261 screen.clearBufferRow(kCommsStatusLine);
tobyspark 5:f8b285ca41ba 262 statusMessage << "DMX Out: xF " << xFadeDMX << " fUp " << fadeUpDMX;
tobyspark 5:f8b285ca41ba 263 screen.textToBuffer(statusMessage.str(), kCommsStatusLine);
tobyspark 5:f8b285ca41ba 264 screen.sendBuffer();
tobyspark 5:f8b285ca41ba 265 if (debug) debug->printf(statusMessage.str().c_str());
tobyspark 5:f8b285ca41ba 266 }
tobyspark 0:87aab40d5806 267
tobyspark 8:d46cc49f0f37 268 inline float fadeCalc (const float AIN, const float tolerance)
tobyspark 8:d46cc49f0f37 269 {
tobyspark 0:87aab40d5806 270 float pos ;
tobyspark 0:87aab40d5806 271 if (AIN < tolerance) pos = 0;
tobyspark 0:87aab40d5806 272 else if (AIN > 1.0 - tolerance) pos = 1;
tobyspark 0:87aab40d5806 273 else pos = (AIN - tolerance) / (1 - 2*tolerance);
tobyspark 0:87aab40d5806 274 if (debug && false) debug->printf("fadeCalc in: %f out: %f \r\n", AIN, pos);
tobyspark 0:87aab40d5806 275 return pos;
tobyspark 0:87aab40d5806 276 }
tobyspark 0:87aab40d5806 277
tobyspark 8:d46cc49f0f37 278 bool setKeyParamsTo(int index)
tobyspark 8:d46cc49f0f37 279 {
tobyspark 0:87aab40d5806 280 // Only spend the time uploading six parameters if we need to
tobyspark 0:87aab40d5806 281 // Might want to bounds check here
tobyspark 0:87aab40d5806 282
tobyspark 9:f83eadd8917a 283 bool ok;
tobyspark 0:87aab40d5806 284
tobyspark 0:87aab40d5806 285 if (index != keyerParamsSet)
tobyspark 0:87aab40d5806 286 {
tobyspark 11:0783cfbeb746 287 ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinY, settings.keyerParamSet(index)[0]);
tobyspark 11:0783cfbeb746 288 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxY, settings.keyerParamSet(index)[1]);
tobyspark 11:0783cfbeb746 289 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinU, settings.keyerParamSet(index)[2]);
tobyspark 11:0783cfbeb746 290 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxU, settings.keyerParamSet(index)[3]);
tobyspark 11:0783cfbeb746 291 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMinV, settings.keyerParamSet(index)[4]);
tobyspark 11:0783cfbeb746 292 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, settings.keyerParamSet(index)[5]);
tobyspark 0:87aab40d5806 293
tobyspark 0:87aab40d5806 294 keyerParamsSet = index;
tobyspark 9:f83eadd8917a 295 }
tobyspark 9:f83eadd8917a 296 else
tobyspark 9:f83eadd8917a 297 {
tobyspark 9:f83eadd8917a 298 ok = true;
tobyspark 9:f83eadd8917a 299 }
tobyspark 0:87aab40d5806 300
tobyspark 0:87aab40d5806 301 return ok;
tobyspark 0:87aab40d5806 302 }
tobyspark 0:87aab40d5806 303
tobyspark 0:87aab40d5806 304 int main()
tobyspark 0:87aab40d5806 305 {
tobyspark 0:87aab40d5806 306 if (debug)
tobyspark 0:87aab40d5806 307 {
tobyspark 0:87aab40d5806 308 debug->printf("\r\n\r\n");
tobyspark 0:87aab40d5806 309 debug->printf("*spark d-fuser -----------\r\n");
tobyspark 0:87aab40d5806 310 debug->printf(" debug channel\r\n");
tobyspark 0:87aab40d5806 311 }
tobyspark 2:50043054e4f7 312
tobyspark 2:50043054e4f7 313 // Set display font
tobyspark 2:50043054e4f7 314 screen.fontStartCharacter = &characterBytesStartChar;
tobyspark 2:50043054e4f7 315 screen.fontEndCharacter = &characterBytesEndChar;
tobyspark 2:50043054e4f7 316 screen.fontCharacters = characterBytes;
tobyspark 2:50043054e4f7 317
tobyspark 0:87aab40d5806 318 // Splash screen
tobyspark 2:50043054e4f7 319 screen.imageToBuffer(spkDisplayLogo);
tobyspark 0:87aab40d5806 320 screen.textToBuffer("SPK:D-Fuser",0);
tobyspark 13:3796bde6ba8f 321 screen.textToBuffer(string("SW ") + kSPKDFSoftwareVersion,1);
tobyspark 5:f8b285ca41ba 322 screen.sendBuffer();
tobyspark 0:87aab40d5806 323
tobyspark 11:0783cfbeb746 324 // Load saved settings
tobyspark 13:3796bde6ba8f 325 /* CRAZY, see note in spk_settings.h
tobyspark 13:3796bde6ba8f 326 if (settings.load(kSPKDFSettingsFilename))
tobyspark 13:3796bde6ba8f 327 {screen.textToBuffer("Settings Read",2); screen.sendBuffer();}
tobyspark 13:3796bde6ba8f 328 else
tobyspark 13:3796bde6ba8f 329 {screen.textToBuffer("Settings NOT Read",2); screen.sendBuffer();}
tobyspark 13:3796bde6ba8f 330 */
tobyspark 0:87aab40d5806 331 // Set menu structure
tobyspark 0:87aab40d5806 332 mixModeMenu.title = "Mix Mode";
tobyspark 15:4b394c64b461 333 mixModeMenu.addMenuItem("Blend", mixBlend, 0);
tobyspark 11:0783cfbeb746 334 for (int i=0; i < settings.keyerSetCount(); i++)
tobyspark 11:0783cfbeb746 335 {
tobyspark 15:4b394c64b461 336 mixModeMenu.addMenuItem(settings.keyerParamName(i), mixKey+i, 0);
tobyspark 11:0783cfbeb746 337 }
tobyspark 0:87aab40d5806 338
tobyspark 0:87aab40d5806 339 resolutionMenu.title = "Resolution";
tobyspark 0:87aab40d5806 340 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionVGA, kTV1ResolutionVGA, 5);
tobyspark 0:87aab40d5806 341 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionSVGA, kTV1ResolutionSVGA, 5);
tobyspark 0:87aab40d5806 342 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionXGAp60, kTV1ResolutionXGAp60, 5);
tobyspark 0:87aab40d5806 343 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionWSXGAPLUSp60, kTV1ResolutionWSXGAPLUSp60, 5);
tobyspark 0:87aab40d5806 344 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionWUXGAp60, kTV1ResolutionWUXGAp60, 5);
tobyspark 0:87aab40d5806 345 resolutionMenu.addMenuItem(kTV1ResolutionDescription720p60, kTV1Resolution720p60, 5);
tobyspark 0:87aab40d5806 346 resolutionMenu.addMenuItem(kTV1ResolutionDescription1080p60, kTV1Resolution1080p60, 5);
tobyspark 0:87aab40d5806 347 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionDualHeadSVGAp60, kTV1ResolutionDualHeadSVGAp60, 0);
tobyspark 0:87aab40d5806 348 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionDualHeadXGAp60, kTV1ResolutionDualHeadXGAp60, 0);
tobyspark 0:87aab40d5806 349 resolutionMenu.addMenuItem(kTV1ResolutionDescriptionTripleHeadVGAp60, kTV1ResolutionTripleHeadVGAp60, 0);
tobyspark 0:87aab40d5806 350
tobyspark 5:f8b285ca41ba 351 commsMenu.title = "Network Mode";
tobyspark 1:f9fca21102e0 352 commsMenu.addMenuItem("None", commsNone, 0);
tobyspark 1:f9fca21102e0 353 commsMenu.addMenuItem("OSC", commsOSC, 0);
tobyspark 1:f9fca21102e0 354 commsMenu.addMenuItem("ArtNet", commsArtNet, 0);
tobyspark 5:f8b285ca41ba 355 commsMenu.addMenuItem("DMX In", commsDMXIn, 0);
tobyspark 5:f8b285ca41ba 356 commsMenu.addMenuItem("DMX Out", commsDMXOut, 0);
tobyspark 1:f9fca21102e0 357
tobyspark 15:4b394c64b461 358 advancedMenu.title = "Troubleshooting";
tobyspark 12:c270870bdd23 359 advancedMenu.addMenuItem("HDCP Off", advancedHDCPOff, 0);
tobyspark 15:4b394c64b461 360 advancedMenu.addMenuItem("HDCP On", advancedHDCPOn, 0);
tobyspark 15:4b394c64b461 361 advancedMenu.addMenuItem("Start Self-Test", advancedSelfTest, 0);
tobyspark 12:c270870bdd23 362
tobyspark 0:87aab40d5806 363 mainMenu.title = "Main Menu";
tobyspark 0:87aab40d5806 364 mainMenu.addMenuItem(&mixModeMenu);
tobyspark 0:87aab40d5806 365 mainMenu.addMenuItem(&resolutionMenu);
tobyspark 1:f9fca21102e0 366 mainMenu.addMenuItem(&commsMenu);
tobyspark 12:c270870bdd23 367 mainMenu.addMenuItem(&advancedMenu);
tobyspark 0:87aab40d5806 368
tobyspark 0:87aab40d5806 369 selectedMenu = &mainMenu;
tobyspark 0:87aab40d5806 370 lastSelectedMenu = &mainMenu;
tobyspark 0:87aab40d5806 371
tobyspark 0:87aab40d5806 372 // Misc I/O stuff
tobyspark 0:87aab40d5806 373
tobyspark 0:87aab40d5806 374 fadeAPO.period(0.001);
tobyspark 0:87aab40d5806 375 fadeBPO.period(0.001);
tobyspark 0:87aab40d5806 376
tobyspark 12:c270870bdd23 377 // TODO: Test for TVOne connectivity here and display in status line
tobyspark 0:87aab40d5806 378
tobyspark 12:c270870bdd23 379 // Display menu and framing lines
tobyspark 0:87aab40d5806 380 screen.horizLineToBuffer(kMenuLine1*pixInPage - 1);
tobyspark 0:87aab40d5806 381 screen.clearBufferRow(kMenuLine1);
tobyspark 0:87aab40d5806 382 screen.textToBuffer(selectedMenu->title, kMenuLine1);
tobyspark 0:87aab40d5806 383 screen.clearBufferRow(kMenuLine2);
tobyspark 0:87aab40d5806 384 screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2);
tobyspark 0:87aab40d5806 385 screen.horizLineToBuffer(kMenuLine2*pixInPage + pixInPage);
tobyspark 1:f9fca21102e0 386 screen.horizLineToBuffer(kCommsStatusLine*pixInPage - 1);
tobyspark 1:f9fca21102e0 387 screen.clearBufferRow(kCommsStatusLine);
tobyspark 1:f9fca21102e0 388 screen.textToBuffer(commsMenu.selectedString(), kCommsStatusLine);
tobyspark 1:f9fca21102e0 389 screen.clearBufferRow(kTVOneStatusLine);
tobyspark 0:87aab40d5806 390 screen.sendBuffer();
tobyspark 0:87aab40d5806 391
tobyspark 0:87aab40d5806 392
tobyspark 0:87aab40d5806 393 //// CONTROLS TEST
tobyspark 0:87aab40d5806 394
tobyspark 0:87aab40d5806 395 while (0) {
tobyspark 0:87aab40d5806 396 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 397 }
tobyspark 0:87aab40d5806 398
tobyspark 0:87aab40d5806 399 //// MIXER RUN
tobyspark 0:87aab40d5806 400
tobyspark 8:d46cc49f0f37 401 while (1)
tobyspark 8:d46cc49f0f37 402 {
tobyspark 1:f9fca21102e0 403 //// Task background things
tobyspark 5:f8b285ca41ba 404 if (ethernet && rj45Mode == rj45Ethernet)
tobyspark 5:f8b285ca41ba 405 {
tobyspark 5:f8b285ca41ba 406 if (debug) debug->printf("net poll");
tobyspark 5:f8b285ca41ba 407 Net::poll();
tobyspark 5:f8b285ca41ba 408 }
tobyspark 5:f8b285ca41ba 409
tobyspark 5:f8b285ca41ba 410 //// RJ45 SWITCH
tobyspark 5:f8b285ca41ba 411
tobyspark 5:f8b285ca41ba 412 if (rj45ModeDIN != rj45Mode)
tobyspark 1:f9fca21102e0 413 {
tobyspark 5:f8b285ca41ba 414 // update state
tobyspark 5:f8b285ca41ba 415 rj45Mode = rj45ModeDIN;
tobyspark 5:f8b285ca41ba 416 if (rj45Mode == rj45Ethernet) commsMenu.title = "Network Mode [Ethernet]";
tobyspark 5:f8b285ca41ba 417 if (rj45Mode == rj45DMX) commsMenu.title = "Network Mode [DMX]";
tobyspark 5:f8b285ca41ba 418
tobyspark 5:f8b285ca41ba 419 // cancel old comms
tobyspark 5:f8b285ca41ba 420 commsMode = commsNone;
tobyspark 5:f8b285ca41ba 421 commsMenu = commsMode;
tobyspark 5:f8b285ca41ba 422
tobyspark 5:f8b285ca41ba 423 // refresh display
tobyspark 5:f8b285ca41ba 424 if (selectedMenu == &commsMenu) screen.textToBuffer(selectedMenu->title, kMenuLine1);
tobyspark 5:f8b285ca41ba 425 if (rj45Mode == rj45Ethernet) screen.textToBuffer("RJ45: Ethernet Engaged", kCommsStatusLine);
tobyspark 5:f8b285ca41ba 426 if (rj45Mode == rj45DMX) screen.textToBuffer("RJ45: DMX Engaged", kCommsStatusLine);
tobyspark 1:f9fca21102e0 427 }
tobyspark 1:f9fca21102e0 428
tobyspark 0:87aab40d5806 429 //// MENU
tobyspark 0:87aab40d5806 430
tobyspark 0:87aab40d5806 431 int menuChange = menuEnc.getChange();
tobyspark 0:87aab40d5806 432
tobyspark 0:87aab40d5806 433 // Update GUI
tobyspark 0:87aab40d5806 434 if (menuChange != 0)
tobyspark 0:87aab40d5806 435 {
tobyspark 0:87aab40d5806 436 if (debug) debug->printf("Menu changed by %i\r\n", menuChange);
tobyspark 0:87aab40d5806 437
tobyspark 0:87aab40d5806 438 *selectedMenu = selectedMenu->selectedIndex() + menuChange;
tobyspark 0:87aab40d5806 439
tobyspark 0:87aab40d5806 440 // update OLED line 2 here
tobyspark 0:87aab40d5806 441 screen.clearBufferRow(kMenuLine2);
tobyspark 0:87aab40d5806 442 screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2);
tobyspark 0:87aab40d5806 443
tobyspark 0:87aab40d5806 444 if (debug) debug->printf("%s \r\n", selectedMenu->selectedString().c_str());
tobyspark 0:87aab40d5806 445 }
tobyspark 0:87aab40d5806 446
tobyspark 0:87aab40d5806 447 // Action menu item
tobyspark 0:87aab40d5806 448 if (menuEnc.hasPressed())
tobyspark 0:87aab40d5806 449 {
tobyspark 0:87aab40d5806 450 if (debug) debug->printf("Action Menu Item!\r\n");
tobyspark 0:87aab40d5806 451
tobyspark 0:87aab40d5806 452 // Are we changing menus?
tobyspark 0:87aab40d5806 453 if (selectedMenu->type() == menuOfMenus)
tobyspark 0:87aab40d5806 454 {
tobyspark 0:87aab40d5806 455 // point selected menu to the new menu
tobyspark 0:87aab40d5806 456 // FIXME. Make this function abstract virtual of base class or get dynamic_cast working. BTW: C++ sucks / Obj-c rocks / Right now.
tobyspark 0:87aab40d5806 457 if (selectedMenu == &mainMenu) selectedMenu = mainMenu.selectedMenu();
tobyspark 0:87aab40d5806 458 else if (debug) debug->printf("FIXME: You've missed a SPKMenuOfMenus");
tobyspark 0:87aab40d5806 459
tobyspark 0:87aab40d5806 460 // reset the selection within that menu to the first position
tobyspark 0:87aab40d5806 461 (*selectedMenu) = 0;
tobyspark 0:87aab40d5806 462
tobyspark 0:87aab40d5806 463 // update OLED lines 1&2
tobyspark 0:87aab40d5806 464 screen.clearBufferRow(kMenuLine1);
tobyspark 0:87aab40d5806 465 screen.clearBufferRow(kMenuLine2);
tobyspark 0:87aab40d5806 466 screen.textToBuffer(selectedMenu->title, kMenuLine1);
tobyspark 0:87aab40d5806 467 screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2);
tobyspark 0:87aab40d5806 468
tobyspark 0:87aab40d5806 469 if (debug)
tobyspark 0:87aab40d5806 470 {
tobyspark 0:87aab40d5806 471 debug->printf("\r\n");
tobyspark 0:87aab40d5806 472 debug->printf("%s \r\n", selectedMenu->title.c_str());
tobyspark 0:87aab40d5806 473 debug->printf("%s \r\n", selectedMenu->selectedString().c_str());
tobyspark 0:87aab40d5806 474 }
tobyspark 0:87aab40d5806 475 }
tobyspark 0:87aab40d5806 476 // Are we cancelling?
tobyspark 0:87aab40d5806 477 else if (selectedMenu->type() == payload && selectedMenu->selectedIndex() == 0)
tobyspark 0:87aab40d5806 478 {
tobyspark 0:87aab40d5806 479 selectedMenu = lastSelectedMenu;
tobyspark 0:87aab40d5806 480
tobyspark 0:87aab40d5806 481 // update OLED lines 1&2
tobyspark 0:87aab40d5806 482 screen.clearBufferRow(kMenuLine1);
tobyspark 0:87aab40d5806 483 screen.clearBufferRow(kMenuLine2);
tobyspark 0:87aab40d5806 484 screen.textToBuffer(selectedMenu->title, kMenuLine1);
tobyspark 0:87aab40d5806 485 screen.textToBuffer(selectedMenu->selectedString(), kMenuLine2);
tobyspark 0:87aab40d5806 486
tobyspark 0:87aab40d5806 487 if (debug)
tobyspark 0:87aab40d5806 488 {
tobyspark 0:87aab40d5806 489 debug->printf("\r\n");
tobyspark 0:87aab40d5806 490 debug->printf("%s \r\n", selectedMenu->title.c_str());
tobyspark 0:87aab40d5806 491 debug->printf("%s \r\n", selectedMenu->selectedString().c_str());
tobyspark 0:87aab40d5806 492 }
tobyspark 0:87aab40d5806 493 }
tobyspark 0:87aab40d5806 494 // With that out of the way, we should be actioning a specific menu's payload?
tobyspark 0:87aab40d5806 495 else if (selectedMenu == &mixModeMenu)
tobyspark 0:87aab40d5806 496 {
tobyspark 5:f8b285ca41ba 497 mixMode = mixModeMenu.selectedPayload1();
tobyspark 5:f8b285ca41ba 498
tobyspark 9:f83eadd8917a 499 bool ok = true;
tobyspark 0:87aab40d5806 500 std::string sentOK;
tobyspark 0:87aab40d5806 501 std::stringstream sentMSG;
tobyspark 0:87aab40d5806 502
tobyspark 11:0783cfbeb746 503 // Set Keyer
tobyspark 15:4b394c64b461 504 if (mixModeMenu.selectedPayload1() < mixKey)
tobyspark 11:0783cfbeb746 505 {
tobyspark 11:0783cfbeb746 506 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, false);
tobyspark 11:0783cfbeb746 507 sentMSG << "Keyer Off";
tobyspark 11:0783cfbeb746 508 }
tobyspark 11:0783cfbeb746 509 else
tobyspark 11:0783cfbeb746 510 {
tobyspark 11:0783cfbeb746 511 ok = ok && tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerEnable, true);
tobyspark 11:0783cfbeb746 512 sentMSG << "Keyer On";
tobyspark 11:0783cfbeb746 513
tobyspark 15:4b394c64b461 514 int index = mixModeMenu.selectedPayload1() - mixKey;
tobyspark 11:0783cfbeb746 515 ok = ok && setKeyParamsTo(index);
tobyspark 11:0783cfbeb746 516 sentMSG << " with " << index;
tobyspark 0:87aab40d5806 517 }
tobyspark 0:87aab40d5806 518
tobyspark 0:87aab40d5806 519 if (ok) sentOK = "Sent:";
tobyspark 0:87aab40d5806 520 else sentOK = "Send Error:";
tobyspark 0:87aab40d5806 521
tobyspark 1:f9fca21102e0 522 screen.clearBufferRow(kTVOneStatusLine);
tobyspark 1:f9fca21102e0 523 screen.textToBuffer(sentOK + sentMSG.str(), kTVOneStatusLine);
tobyspark 0:87aab40d5806 524
tobyspark 0:87aab40d5806 525 if (debug) { debug->printf("Changing mix mode"); }
tobyspark 0:87aab40d5806 526 }
tobyspark 0:87aab40d5806 527 else if (selectedMenu == &resolutionMenu)
tobyspark 0:87aab40d5806 528 {
tobyspark 9:f83eadd8917a 529 bool ok = true;
tobyspark 0:87aab40d5806 530
tobyspark 0:87aab40d5806 531 ok = tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustOutputsOutputResolution, resolutionMenu.selectedPayload1());
tobyspark 0:87aab40d5806 532 ok = ok && tvOne.command(kTV1SourceRGB1, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, resolutionMenu.selectedPayload2());
tobyspark 0:87aab40d5806 533 ok = ok && tvOne.command(kTV1SourceRGB2, kTV1WindowIDA, kTV1FunctionAdjustSourceEDID, resolutionMenu.selectedPayload2());
tobyspark 0:87aab40d5806 534
tobyspark 0:87aab40d5806 535 std::string sentOK;
tobyspark 0:87aab40d5806 536 if (ok) sentOK = "Sent: ";
tobyspark 0:87aab40d5806 537 else sentOK = "Send Error: ";
tobyspark 0:87aab40d5806 538
tobyspark 0:87aab40d5806 539 std::stringstream sentMSG;
tobyspark 0:87aab40d5806 540 sentMSG << "Res " << resolutionMenu.selectedPayload1() << ", EDID " << resolutionMenu.selectedPayload2();
tobyspark 0:87aab40d5806 541
tobyspark 1:f9fca21102e0 542 screen.clearBufferRow(kTVOneStatusLine);
tobyspark 1:f9fca21102e0 543 screen.textToBuffer(sentOK + sentMSG.str(), kTVOneStatusLine);
tobyspark 0:87aab40d5806 544
tobyspark 0:87aab40d5806 545 if (debug) { debug->printf("Changing resolution"); }
tobyspark 0:87aab40d5806 546 }
tobyspark 1:f9fca21102e0 547 else if (selectedMenu == &commsMenu)
tobyspark 1:f9fca21102e0 548 {
tobyspark 5:f8b285ca41ba 549 std::string commsTypeString = "Network: --";
tobyspark 1:f9fca21102e0 550 std::stringstream commsStatus;
tobyspark 1:f9fca21102e0 551
tobyspark 1:f9fca21102e0 552 // Tear down any existing comms
tobyspark 1:f9fca21102e0 553 // This is the action of commsNone
tobyspark 1:f9fca21102e0 554 // And also clears the way for other comms actions
tobyspark 5:f8b285ca41ba 555 if (osc) {delete osc; osc = NULL;}
tobyspark 5:f8b285ca41ba 556 if (ethernet) {delete ethernet; ethernet = NULL;}
tobyspark 5:f8b285ca41ba 557 if (artNet) {delete artNet; artNet = NULL;}
tobyspark 5:f8b285ca41ba 558 if (dmx) {delete dmx; dmx = NULL;}
tobyspark 5:f8b285ca41ba 559
tobyspark 5:f8b285ca41ba 560 // Ensure we can't change to comms modes the hardware isn't switched to
tobyspark 5:f8b285ca41ba 561 if (rj45Mode == rj45DMX && (commsMenu.selectedPayload1() == commsOSC || commsMenu.selectedPayload1() == commsArtNet))
tobyspark 1:f9fca21102e0 562 {
tobyspark 5:f8b285ca41ba 563 commsTypeString = "RJ45 not in Ethernet mode";
tobyspark 5:f8b285ca41ba 564 }
tobyspark 5:f8b285ca41ba 565 else if (rj45Mode == rj45Ethernet && (commsMenu.selectedPayload1() == commsDMXIn || commsMenu.selectedPayload1() == commsDMXOut))
tobyspark 5:f8b285ca41ba 566 {
tobyspark 5:f8b285ca41ba 567 commsTypeString = "RJ45 not in DMX mode";
tobyspark 5:f8b285ca41ba 568 }
tobyspark 5:f8b285ca41ba 569 // Action!
tobyspark 5:f8b285ca41ba 570 else if (commsMenu.selectedPayload1() == commsOSC)
tobyspark 5:f8b285ca41ba 571 {
tobyspark 5:f8b285ca41ba 572 commsMode = commsOSC;
tobyspark 5:f8b285ca41ba 573 commsTypeString = "OSC: ";
tobyspark 1:f9fca21102e0 574
tobyspark 1:f9fca21102e0 575 ethernet = new EthernetNetIf(
tobyspark 1:f9fca21102e0 576 IpAddr(kOSCMbedIPAddress),
tobyspark 1:f9fca21102e0 577 IpAddr(kOSCMbedSubnetMask),
tobyspark 1:f9fca21102e0 578 IpAddr(kOSCMbedGateway),
tobyspark 1:f9fca21102e0 579 IpAddr(kOSCMbedDNS)
tobyspark 1:f9fca21102e0 580 );
tobyspark 3:033d2b7768f3 581
tobyspark 1:f9fca21102e0 582 EthernetErr ethError = ethernet->setup();
tobyspark 1:f9fca21102e0 583 if(ethError)
tobyspark 1:f9fca21102e0 584 {
tobyspark 1:f9fca21102e0 585 if (debug) debug->printf("Ethernet setup error, %d", ethError);
tobyspark 1:f9fca21102e0 586 commsStatus << "Ethernet setup failed";
tobyspark 5:f8b285ca41ba 587 commsMenu = commsNone;
tobyspark 1:f9fca21102e0 588 // break out of here. this setup should be a function that returns a boolean
tobyspark 1:f9fca21102e0 589 }
tobyspark 1:f9fca21102e0 590
tobyspark 1:f9fca21102e0 591 osc = new OSCClass();
tobyspark 3:033d2b7768f3 592 osc->setReceiveMessage(&recMessage);
tobyspark 1:f9fca21102e0 593 osc->begin(kOSCMbedPort);
tobyspark 1:f9fca21102e0 594
tobyspark 3:033d2b7768f3 595 commsStatus << "Listening on " << kOSCMbedPort;
tobyspark 1:f9fca21102e0 596 }
tobyspark 1:f9fca21102e0 597 else if (commsMenu.selectedPayload1() == commsArtNet)
tobyspark 1:f9fca21102e0 598 {
tobyspark 5:f8b285ca41ba 599 commsMode = commsArtNet;
tobyspark 5:f8b285ca41ba 600 commsTypeString = "ArtNet: ";
tobyspark 3:033d2b7768f3 601
tobyspark 3:033d2b7768f3 602 artNet = new DmxArtNet();
tobyspark 1:f9fca21102e0 603
tobyspark 3:033d2b7768f3 604 artNet->BindIpAddress = IpAddr(kArtNetBindIPAddress);
tobyspark 3:033d2b7768f3 605 artNet->BCastAddress = IpAddr(kArtNetBroadcastAddress);
tobyspark 3:033d2b7768f3 606
tobyspark 3:033d2b7768f3 607 artNet->InitArtPollReplyDefaults();
tobyspark 3:033d2b7768f3 608
tobyspark 3:033d2b7768f3 609 artNet->ArtPollReply.PortType[0] = 128; // output
tobyspark 3:033d2b7768f3 610 artNet->ArtPollReply.PortType[2] = 64; // input
tobyspark 3:033d2b7768f3 611 artNet->ArtPollReply.GoodInput[2] = 4;
tobyspark 3:033d2b7768f3 612
tobyspark 3:033d2b7768f3 613 artNet->Init();
tobyspark 3:033d2b7768f3 614 artNet->SendArtPollReply(); // announce to art-net nodes
tobyspark 3:033d2b7768f3 615
tobyspark 3:033d2b7768f3 616 commsStatus << "Listening";
tobyspark 1:f9fca21102e0 617 }
tobyspark 5:f8b285ca41ba 618 else if (commsMenu.selectedPayload1() == commsDMXIn)
tobyspark 1:f9fca21102e0 619 {
tobyspark 5:f8b285ca41ba 620 commsMode = commsDMXIn;
tobyspark 5:f8b285ca41ba 621 commsTypeString = "DMX In: ";
tobyspark 1:f9fca21102e0 622
tobyspark 5:f8b285ca41ba 623 dmxDirectionDOUT = 0;
tobyspark 5:f8b285ca41ba 624
tobyspark 5:f8b285ca41ba 625 dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX);
tobyspark 1:f9fca21102e0 626 }
tobyspark 5:f8b285ca41ba 627 else if (commsMenu.selectedPayload1() == commsDMXOut)
tobyspark 5:f8b285ca41ba 628 {
tobyspark 5:f8b285ca41ba 629 commsMode = commsDMXOut;
tobyspark 5:f8b285ca41ba 630 commsTypeString = "DMX Out: ";
tobyspark 5:f8b285ca41ba 631
tobyspark 5:f8b285ca41ba 632 dmxDirectionDOUT = 1;
tobyspark 5:f8b285ca41ba 633
tobyspark 5:f8b285ca41ba 634 dmx = new DMX(kMBED_RS485_TTLTX, kMBED_RS485_TTLRX);
tobyspark 5:f8b285ca41ba 635 }
tobyspark 5:f8b285ca41ba 636
tobyspark 1:f9fca21102e0 637 screen.clearBufferRow(kCommsStatusLine);
tobyspark 5:f8b285ca41ba 638 screen.textToBuffer(commsTypeString + commsStatus.str(), kCommsStatusLine);
tobyspark 1:f9fca21102e0 639 }
tobyspark 12:c270870bdd23 640 else if (selectedMenu == &advancedMenu)
tobyspark 12:c270870bdd23 641 {
tobyspark 12:c270870bdd23 642 if (advancedMenu.selectedPayload1() == advancedHDCPOff)
tobyspark 12:c270870bdd23 643 {
tobyspark 12:c270870bdd23 644 bool ok = false;
tobyspark 12:c270870bdd23 645
tobyspark 15:4b394c64b461 646 ok = tvOne.setHDCPOn(false);
tobyspark 12:c270870bdd23 647
tobyspark 12:c270870bdd23 648 std::string sendOK = ok ? "Sent: HDCP Off" : "Send Error: HDCP Off";
tobyspark 12:c270870bdd23 649
tobyspark 12:c270870bdd23 650 screen.clearBufferRow(kTVOneStatusLine);
tobyspark 12:c270870bdd23 651 screen.textToBuffer(sendOK, kTVOneStatusLine);
tobyspark 12:c270870bdd23 652 }
tobyspark 15:4b394c64b461 653 else if (advancedMenu.selectedPayload1() == advancedHDCPOn)
tobyspark 15:4b394c64b461 654 {
tobyspark 15:4b394c64b461 655 bool ok = false;
tobyspark 15:4b394c64b461 656
tobyspark 15:4b394c64b461 657 ok = tvOne.setHDCPOn(true);
tobyspark 15:4b394c64b461 658
tobyspark 15:4b394c64b461 659 std::string sendOK = ok ? "Sent: HDCP On" : "Send Error: HDCP On";
tobyspark 15:4b394c64b461 660
tobyspark 15:4b394c64b461 661 screen.clearBufferRow(kTVOneStatusLine);
tobyspark 15:4b394c64b461 662 screen.textToBuffer(sendOK, kTVOneStatusLine);
tobyspark 15:4b394c64b461 663 }
tobyspark 15:4b394c64b461 664 else if (advancedMenu.selectedPayload1() == advancedSelfTest)
tobyspark 15:4b394c64b461 665 {
tobyspark 15:4b394c64b461 666 /* SELF TEST - Pixels
tobyspark 15:4b394c64b461 667 * Clicking ‘self-test’ menu will display a solid lit screen. Check all pixels lit.
tobyspark 15:4b394c64b461 668 * Verified: Display
tobyspark 15:4b394c64b461 669 */
tobyspark 15:4b394c64b461 670
tobyspark 15:4b394c64b461 671 screen.imageToBuffer(spkDisplayAllPixelsOn);
tobyspark 15:4b394c64b461 672 screen.sendBuffer();
tobyspark 15:4b394c64b461 673
tobyspark 15:4b394c64b461 674 while(!menuEnc.hasPressed())
tobyspark 15:4b394c64b461 675 {
tobyspark 15:4b394c64b461 676 // do nothing, wait for press
tobyspark 15:4b394c64b461 677 }
tobyspark 15:4b394c64b461 678
tobyspark 15:4b394c64b461 679 /* SELF TEST - Mixing Controls
tobyspark 15:4b394c64b461 680 * 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 15:4b394c64b461 681 * Verified: Mixing controls.
tobyspark 15:4b394c64b461 682 */
tobyspark 15:4b394c64b461 683
tobyspark 15:4b394c64b461 684 screen.clearBuffer();
tobyspark 15:4b394c64b461 685 screen.textToBuffer("Self test - Mixing Controls", 0);
tobyspark 15:4b394c64b461 686
tobyspark 15:4b394c64b461 687 while(!menuEnc.hasPressed())
tobyspark 15:4b394c64b461 688 {
tobyspark 15:4b394c64b461 689 stringstream xFadeReadOut;
tobyspark 15:4b394c64b461 690 stringstream fadeToBlackReadOut;
tobyspark 15:4b394c64b461 691 stringstream tapsReadOut;
tobyspark 15:4b394c64b461 692
tobyspark 15:4b394c64b461 693 xFadeReadOut.precision(2);
tobyspark 15:4b394c64b461 694 fadeToBlackReadOut.precision(2);
tobyspark 15:4b394c64b461 695 tapsReadOut.precision(1);
tobyspark 15:4b394c64b461 696
tobyspark 15:4b394c64b461 697 xFadeReadOut << "Crossfade: " << xFadeAIN.read();
tobyspark 15:4b394c64b461 698 fadeToBlackReadOut << "Fade to black: " << fadeUpAIN.read();
tobyspark 15:4b394c64b461 699 tapsReadOut << "Tap left: " << tapLeftDIN.read() << " right: " << tapRightDIN.read();
tobyspark 15:4b394c64b461 700
tobyspark 15:4b394c64b461 701 screen.clearBufferRow(1);
tobyspark 15:4b394c64b461 702 screen.clearBufferRow(2);
tobyspark 15:4b394c64b461 703 screen.clearBufferRow(3);
tobyspark 15:4b394c64b461 704
tobyspark 15:4b394c64b461 705 screen.textToBuffer(xFadeReadOut.str(), 1);
tobyspark 15:4b394c64b461 706 screen.textToBuffer(fadeToBlackReadOut.str(), 2);
tobyspark 15:4b394c64b461 707 screen.textToBuffer(tapsReadOut.str(), 3);
tobyspark 15:4b394c64b461 708 screen.sendBuffer();
tobyspark 15:4b394c64b461 709 }
tobyspark 15:4b394c64b461 710
tobyspark 15:4b394c64b461 711 /* SELF TEST - RS232
tobyspark 15:4b394c64b461 712 * Click the controller menu control. Should see ‘RS232 test’ prompt and test message. Ensure PC is displaying the test message.
tobyspark 15:4b394c64b461 713 * Verified: RS232 connection.
tobyspark 15:4b394c64b461 714 */
tobyspark 15:4b394c64b461 715
tobyspark 15:4b394c64b461 716 screen.clearBuffer();
tobyspark 15:4b394c64b461 717 screen.textToBuffer("Self test - RS232", 0);
tobyspark 15:4b394c64b461 718 screen.sendBuffer();
tobyspark 15:4b394c64b461 719
tobyspark 15:4b394c64b461 720 while(!menuEnc.hasPressed())
tobyspark 15:4b394c64b461 721 {
tobyspark 15:4b394c64b461 722 screen.textToBuffer("TODO!", 1);
tobyspark 15:4b394c64b461 723 screen.sendBuffer();
tobyspark 15:4b394c64b461 724 }
tobyspark 15:4b394c64b461 725
tobyspark 15:4b394c64b461 726 /* SELF TEST - DMX
tobyspark 15:4b394c64b461 727 * Click the controller menu control. Should see ‘DMX test’ prompt and test message. Ensure PC is displaying the test message.
tobyspark 15:4b394c64b461 728 * Verified: RS485 connection and DMX library.
tobyspark 15:4b394c64b461 729 */
tobyspark 15:4b394c64b461 730
tobyspark 15:4b394c64b461 731 screen.clearBuffer();
tobyspark 15:4b394c64b461 732 screen.textToBuffer("Self test - DMX", 0);
tobyspark 15:4b394c64b461 733 screen.sendBuffer();
tobyspark 15:4b394c64b461 734
tobyspark 15:4b394c64b461 735 while(!menuEnc.hasPressed())
tobyspark 15:4b394c64b461 736 {
tobyspark 15:4b394c64b461 737 screen.textToBuffer("TODO!", 1);
tobyspark 15:4b394c64b461 738 screen.sendBuffer();
tobyspark 15:4b394c64b461 739 }
tobyspark 15:4b394c64b461 740
tobyspark 15:4b394c64b461 741 /* SELF TEST - OSC
tobyspark 15:4b394c64b461 742 * Click the controller menu control. Should see ‘OSC test’ prompt and test message. Ensure PC is displaying the test message.
tobyspark 15:4b394c64b461 743 * Verified: Ethernet connection and OSC library.
tobyspark 15:4b394c64b461 744 */
tobyspark 15:4b394c64b461 745
tobyspark 15:4b394c64b461 746 screen.clearBuffer();
tobyspark 15:4b394c64b461 747 screen.textToBuffer("Self test - DMX", 0);
tobyspark 15:4b394c64b461 748 screen.sendBuffer();
tobyspark 15:4b394c64b461 749
tobyspark 15:4b394c64b461 750 while(!menuEnc.hasPressed())
tobyspark 15:4b394c64b461 751 {
tobyspark 15:4b394c64b461 752 screen.textToBuffer("TODO!", 1);
tobyspark 15:4b394c64b461 753 screen.sendBuffer();
tobyspark 15:4b394c64b461 754 }
tobyspark 15:4b394c64b461 755
tobyspark 15:4b394c64b461 756 /* SELF TEST - Exit!
tobyspark 15:4b394c64b461 757 * To do this, we could just do nothing but we'd need to recreate screen and comms as they were.
tobyspark 15:4b394c64b461 758 * Instead, lets just restart the mbed
tobyspark 15:4b394c64b461 759 */
tobyspark 15:4b394c64b461 760
tobyspark 15:4b394c64b461 761 screen.clearBuffer();
tobyspark 15:4b394c64b461 762 screen.textToBuffer("Self test complete", 0);
tobyspark 15:4b394c64b461 763 screen.textToBuffer("Press to restart controller", 1);
tobyspark 15:4b394c64b461 764 screen.sendBuffer();
tobyspark 15:4b394c64b461 765
tobyspark 15:4b394c64b461 766 while(!menuEnc.hasPressed()) {}
tobyspark 15:4b394c64b461 767
tobyspark 15:4b394c64b461 768 mbed_reset();
tobyspark 15:4b394c64b461 769 }
tobyspark 12:c270870bdd23 770 }
tobyspark 0:87aab40d5806 771 else
tobyspark 0:87aab40d5806 772 {
tobyspark 0:87aab40d5806 773 if (debug) { debug->printf("Warning: No action identified"); }
tobyspark 0:87aab40d5806 774 }
tobyspark 0:87aab40d5806 775 }
tobyspark 0:87aab40d5806 776
tobyspark 2:50043054e4f7 777 // Send any updates to the display
tobyspark 2:50043054e4f7 778 screen.sendBuffer();
tobyspark 5:f8b285ca41ba 779
tobyspark 0:87aab40d5806 780
tobyspark 5:f8b285ca41ba 781 //// MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIX MIXMIX MIX MIXMIX MIX MIX MIX MIX MIXMIX MIX MIX
tobyspark 0:87aab40d5806 782
tobyspark 0:87aab40d5806 783 bool updateFade = false;
tobyspark 3:033d2b7768f3 784 float xFade = 0;
tobyspark 3:033d2b7768f3 785 float fadeUp = 1;
tobyspark 3:033d2b7768f3 786
tobyspark 3:033d2b7768f3 787 //// TASK: Process control surface
tobyspark 3:033d2b7768f3 788
tobyspark 0:87aab40d5806 789 // Get new states of tap buttons, remembering at end of loop() assign these current values to the previous variables
tobyspark 5:f8b285ca41ba 790 const bool tapLeft = !tapLeftDIN;
tobyspark 5:f8b285ca41ba 791 const bool tapRight = !tapRightDIN;
tobyspark 0:87aab40d5806 792
tobyspark 0:87aab40d5806 793 // We're going to cache the analog in reads, as have seen wierdness otherwise
tobyspark 5:f8b285ca41ba 794 const float xFadeAINCached = 1-xFadeAIN.read();
tobyspark 0:87aab40d5806 795 const float fadeUpAINCached = fadeUpAIN.read();
tobyspark 0:87aab40d5806 796
tobyspark 0:87aab40d5806 797 // When a tap is depressed, we can ignore any move of the crossfader but not fade to black
tobyspark 0:87aab40d5806 798 if (tapLeft || tapRight)
tobyspark 0:87aab40d5806 799 {
tobyspark 5:f8b285ca41ba 800 // If both are pressed, take to the one that is new, ie. not the first pressed.
tobyspark 0:87aab40d5806 801 if (tapLeft && tapRight)
tobyspark 0:87aab40d5806 802 {
tobyspark 5:f8b285ca41ba 803 xFade = tapLeftWasFirstPressed ? 1 : 0;
tobyspark 0:87aab40d5806 804 }
tobyspark 5:f8b285ca41ba 805 // If just one is pressed, take to that and remember which is pressed
tobyspark 5:f8b285ca41ba 806 else if (tapLeft)
tobyspark 5:f8b285ca41ba 807 {
tobyspark 5:f8b285ca41ba 808 xFade = 0;
tobyspark 5:f8b285ca41ba 809 tapLeftWasFirstPressed = 1;
tobyspark 5:f8b285ca41ba 810 }
tobyspark 5:f8b285ca41ba 811 else if (tapRight)
tobyspark 5:f8b285ca41ba 812 {
tobyspark 5:f8b285ca41ba 813 xFade = 1;
tobyspark 5:f8b285ca41ba 814 tapLeftWasFirstPressed = 0;
tobyspark 5:f8b285ca41ba 815 }
tobyspark 5:f8b285ca41ba 816 }
tobyspark 0:87aab40d5806 817 else xFade = fadeCalc(xFadeAINCached, xFadeTolerance);
tobyspark 0:87aab40d5806 818
tobyspark 0:87aab40d5806 819 fadeUp = 1.0 - fadeCalc(fadeUpAINCached, fadeUpTolerance);
tobyspark 0:87aab40d5806 820
tobyspark 3:033d2b7768f3 821 //// TASK: Process Network Comms
tobyspark 5:f8b285ca41ba 822 if (commsMode == commsOSC)
tobyspark 3:033d2b7768f3 823 {
tobyspark 3:033d2b7768f3 824 if (osc->newMessage)
tobyspark 3:033d2b7768f3 825 {
tobyspark 3:033d2b7768f3 826 osc->newMessage = false; // fixme!
tobyspark 3:033d2b7768f3 827 processOSC(xFade, fadeUp);
tobyspark 3:033d2b7768f3 828 }
tobyspark 3:033d2b7768f3 829 }
tobyspark 3:033d2b7768f3 830
tobyspark 5:f8b285ca41ba 831 if (commsMode == commsArtNet)
tobyspark 3:033d2b7768f3 832 {
tobyspark 3:033d2b7768f3 833 if (artNet->Work()) processArtNet(xFade, fadeUp);
tobyspark 3:033d2b7768f3 834 }
tobyspark 3:033d2b7768f3 835
tobyspark 5:f8b285ca41ba 836 if (commsMode == commsDMXIn)
tobyspark 5:f8b285ca41ba 837 {
tobyspark 5:f8b285ca41ba 838 processDMXIn(xFade, fadeUp);
tobyspark 5:f8b285ca41ba 839 }
tobyspark 5:f8b285ca41ba 840
tobyspark 5:f8b285ca41ba 841 if (commsMode == commsDMXOut)
tobyspark 5:f8b285ca41ba 842 {
tobyspark 5:f8b285ca41ba 843 processDMXOut(xFade, fadeUp);
tobyspark 5:f8b285ca41ba 844 }
tobyspark 0:87aab40d5806 845
tobyspark 0:87aab40d5806 846 // Calculate new A&B fade percents
tobyspark 0:87aab40d5806 847 int newFadeAPercent = 0;
tobyspark 0:87aab40d5806 848 int newFadeBPercent = 0;
tobyspark 0:87aab40d5806 849
tobyspark 15:4b394c64b461 850 if (mixMode == mixBlend)
tobyspark 11:0783cfbeb746 851 {
tobyspark 9:f83eadd8917a 852 if (fadeUp < 1.0)
tobyspark 9:f83eadd8917a 853 {
tobyspark 9:f83eadd8917a 854 // 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 855 newFadeAPercent = (1.0-xFade) * fadeUp * 100.0;
tobyspark 9:f83eadd8917a 856 newFadeBPercent = xFade * fadeUp * 100.0;
tobyspark 9:f83eadd8917a 857 }
tobyspark 9:f83eadd8917a 858 else
tobyspark 9:f83eadd8917a 859 {
tobyspark 9:f83eadd8917a 860 // 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 861 newFadeAPercent = (1.0-xFade) * 100.0;
tobyspark 9:f83eadd8917a 862 newFadeBPercent = 100.0;
tobyspark 9:f83eadd8917a 863 }
tobyspark 11:0783cfbeb746 864 }
tobyspark 15:4b394c64b461 865 else if (mixMode == mixAdditive)
tobyspark 11:0783cfbeb746 866 {
tobyspark 9:f83eadd8917a 867 // we need to set fade level of both windows according to the fade curve profile (yet to implement - to do when tvone supply additive capability)
tobyspark 0:87aab40d5806 868 newFadeAPercent = (1.0-xFade) * fadeUp * 100.0;
tobyspark 0:87aab40d5806 869 newFadeBPercent = xFade * fadeUp * 100.0;
tobyspark 11:0783cfbeb746 870 }
tobyspark 15:4b394c64b461 871 else if (mixMode >= mixKey)
tobyspark 11:0783cfbeb746 872 {
tobyspark 0:87aab40d5806 873 newFadeAPercent = (1.0-xFade) * fadeUp * 100.0;
tobyspark 0:87aab40d5806 874 newFadeBPercent = fadeUp * 100.0;
tobyspark 0:87aab40d5806 875 }
tobyspark 0:87aab40d5806 876
tobyspark 0:87aab40d5806 877 // Send to TVOne if percents have changed
tobyspark 9:f83eadd8917a 878 // We want to send the higher first, otherwise black flashes can happen on taps
tobyspark 9:f83eadd8917a 879 if (newFadeAPercent != fadeAPercent && newFadeAPercent >= newFadeBPercent)
tobyspark 8:d46cc49f0f37 880 {
tobyspark 0:87aab40d5806 881 fadeAPercent = newFadeAPercent;
tobyspark 0:87aab40d5806 882 updateFade = true;
tobyspark 0:87aab40d5806 883
tobyspark 0:87aab40d5806 884 fadeAPO = fadeAPercent / 100.0;
tobyspark 0:87aab40d5806 885 tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent);
tobyspark 0:87aab40d5806 886 }
tobyspark 0:87aab40d5806 887
tobyspark 8:d46cc49f0f37 888 if (newFadeBPercent != fadeBPercent)
tobyspark 8:d46cc49f0f37 889 {
tobyspark 0:87aab40d5806 890 fadeBPercent = newFadeBPercent;
tobyspark 0:87aab40d5806 891 updateFade = true;
tobyspark 0:87aab40d5806 892
tobyspark 0:87aab40d5806 893 fadeBPO = fadeBPercent / 100.0;
tobyspark 0:87aab40d5806 894 tvOne.command(0, kTV1WindowIDB, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeBPercent);
tobyspark 0:87aab40d5806 895 }
tobyspark 0:87aab40d5806 896
tobyspark 9:f83eadd8917a 897 if (newFadeAPercent != fadeAPercent && newFadeAPercent < newFadeBPercent)
tobyspark 9:f83eadd8917a 898 {
tobyspark 9:f83eadd8917a 899 fadeAPercent = newFadeAPercent;
tobyspark 9:f83eadd8917a 900 updateFade = true;
tobyspark 9:f83eadd8917a 901
tobyspark 9:f83eadd8917a 902 fadeAPO = fadeAPercent / 100.0;
tobyspark 9:f83eadd8917a 903 tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustWindowsMaxFadeLevel, fadeAPercent);
tobyspark 9:f83eadd8917a 904 }
tobyspark 9:f83eadd8917a 905
tobyspark 8:d46cc49f0f37 906 if (updateFade && debug)
tobyspark 8:d46cc49f0f37 907 {
tobyspark 0:87aab40d5806 908 debug->printf("\r\n");
tobyspark 0:87aab40d5806 909 //debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAIN.read(), fadeUpAIN.read());
tobyspark 0:87aab40d5806 910 debug->printf("xFade = %3f fadeUp = %3f \r\n", xFadeAINCached, fadeUpAINCached);
tobyspark 0:87aab40d5806 911 debug->printf("xFade = %3f fadeUp = %3f fadeA% = %i fadeB% = %i \r\n", xFade, fadeUp, fadeAPercent, fadeBPercent);
tobyspark 0:87aab40d5806 912 }
tobyspark 5:f8b285ca41ba 913
tobyspark 0:87aab40d5806 914 }
tobyspark 0:87aab40d5806 915 }