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

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

Committer:
tobyspark
Date:
Sat Jul 27 18:27:11 2013 +0000
Revision:
68:c26478f42ca4
Parent:
61:f0a42bfca816
Child:
70:5be3966a8a0b
Read network settings in from SPKDF.ini

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tobyspark 11:0783cfbeb746 1 #include "mbed.h"
tobyspark 68:c26478f42ca4 2 #include "ipaddr.h"
tobyspark 13:3796bde6ba8f 3 #include <string>
tobyspark 13:3796bde6ba8f 4 #include <vector>
tobyspark 13:3796bde6ba8f 5
tobyspark 13:3796bde6ba8f 6 extern "C"
tobyspark 13:3796bde6ba8f 7 {
tobyspark 13:3796bde6ba8f 8 #include "iniparser.h"
tobyspark 13:3796bde6ba8f 9 }
tobyspark 11:0783cfbeb746 10
tobyspark 11:0783cfbeb746 11 class SPKSettings {
tobyspark 11:0783cfbeb746 12 public:
tobyspark 36:8b5c75c8bc23 13 enum keyerParameterType {minY = 0, maxY, minU, maxU, minV, maxV};
tobyspark 36:8b5c75c8bc23 14
tobyspark 36:8b5c75c8bc23 15 int editingKeyerSetIndex;
tobyspark 68:c26478f42ca4 16
tobyspark 68:c26478f42ca4 17 struct {
tobyspark 68:c26478f42ca4 18 bool DHCP;
tobyspark 68:c26478f42ca4 19 IpAddr controllerAddress;
tobyspark 68:c26478f42ca4 20 int controllerPort;
tobyspark 68:c26478f42ca4 21 IpAddr controllerSubnetMask;
tobyspark 68:c26478f42ca4 22 IpAddr controllerGateway;
tobyspark 68:c26478f42ca4 23 IpAddr controllerDNS;
tobyspark 68:c26478f42ca4 24
tobyspark 68:c26478f42ca4 25 IpAddr sendAddress;
tobyspark 68:c26478f42ca4 26 int sendPort;
tobyspark 68:c26478f42ca4 27 } osc;
tobyspark 68:c26478f42ca4 28
tobyspark 68:c26478f42ca4 29 struct {
tobyspark 68:c26478f42ca4 30 IpAddr controllerAddress;
tobyspark 68:c26478f42ca4 31 IpAddr broadcastAddress;
tobyspark 68:c26478f42ca4 32 } artNet;
tobyspark 68:c26478f42ca4 33
tobyspark 68:c26478f42ca4 34 struct {
tobyspark 68:c26478f42ca4 35 int inChannelXFade;
tobyspark 68:c26478f42ca4 36 int inChannelFadeUp;
tobyspark 68:c26478f42ca4 37 int outChannelXFade;
tobyspark 68:c26478f42ca4 38 int outChannelFadeUp;
tobyspark 68:c26478f42ca4 39 } dmx;
tobyspark 68:c26478f42ca4 40
tobyspark 11:0783cfbeb746 41 SPKSettings()
tobyspark 11:0783cfbeb746 42 {
tobyspark 36:8b5c75c8bc23 43 editingKeyerSetIndex = -1;
tobyspark 16:52484666b323 44 loadDefaults();
tobyspark 16:52484666b323 45 }
tobyspark 16:52484666b323 46
tobyspark 16:52484666b323 47 void loadDefaults()
tobyspark 16:52484666b323 48 {
tobyspark 68:c26478f42ca4 49 // NETWORK
tobyspark 68:c26478f42ca4 50
tobyspark 68:c26478f42ca4 51 osc.DHCP = false;
tobyspark 68:c26478f42ca4 52 osc.controllerAddress = IpAddr(10,0,0,2);
tobyspark 68:c26478f42ca4 53 osc.controllerPort = 10000;
tobyspark 68:c26478f42ca4 54 osc.controllerSubnetMask = IpAddr(255,255,255,0);
tobyspark 68:c26478f42ca4 55 osc.controllerGateway = IpAddr(10,0,0,1);
tobyspark 68:c26478f42ca4 56 osc.controllerDNS = IpAddr(10,0,0,1);
tobyspark 68:c26478f42ca4 57
tobyspark 68:c26478f42ca4 58 osc.sendAddress = IpAddr(255,255,255,255);
tobyspark 68:c26478f42ca4 59 osc.sendPort = 10000;
tobyspark 68:c26478f42ca4 60
tobyspark 68:c26478f42ca4 61 artNet.controllerAddress = IpAddr(2,0,0,100);
tobyspark 68:c26478f42ca4 62 artNet.broadcastAddress = IpAddr(2,255,255,255);
tobyspark 68:c26478f42ca4 63
tobyspark 68:c26478f42ca4 64 dmx.inChannelXFade = 0;
tobyspark 68:c26478f42ca4 65 dmx.inChannelFadeUp = 1;
tobyspark 68:c26478f42ca4 66 dmx.outChannelXFade = 0;
tobyspark 68:c26478f42ca4 67 dmx.outChannelFadeUp = 1;
tobyspark 68:c26478f42ca4 68
tobyspark 16:52484666b323 69 //// KEYS
tobyspark 16:52484666b323 70
tobyspark 27:27851d3d2bba 71 keyerParamNames.clear();
tobyspark 27:27851d3d2bba 72 keyerParamSets.clear();
tobyspark 31:01845a2347ff 73 vector<int> paramSet(6);
tobyspark 27:27851d3d2bba 74
tobyspark 31:01845a2347ff 75 paramSet[minY] = 0;
tobyspark 31:01845a2347ff 76 paramSet[maxY] = 18;
tobyspark 31:01845a2347ff 77 paramSet[minU] = 128;
tobyspark 31:01845a2347ff 78 paramSet[maxU] = 129;
tobyspark 31:01845a2347ff 79 paramSet[minV] = 128;
tobyspark 31:01845a2347ff 80 paramSet[maxV] = 129;
tobyspark 31:01845a2347ff 81 keyerParamSets.push_back(paramSet);
tobyspark 61:f0a42bfca816 82 keyerParamNames.push_back("Key - Current");
tobyspark 61:f0a42bfca816 83
tobyspark 61:f0a42bfca816 84 paramSet[minY] = 0;
tobyspark 61:f0a42bfca816 85 paramSet[maxY] = 18;
tobyspark 61:f0a42bfca816 86 paramSet[minU] = 128;
tobyspark 61:f0a42bfca816 87 paramSet[maxU] = 129;
tobyspark 61:f0a42bfca816 88 paramSet[minV] = 128;
tobyspark 61:f0a42bfca816 89 paramSet[maxV] = 129;
tobyspark 61:f0a42bfca816 90 keyerParamSets.push_back(paramSet);
tobyspark 16:52484666b323 91 keyerParamNames.push_back("Lumakey");
tobyspark 11:0783cfbeb746 92
tobyspark 31:01845a2347ff 93 paramSet[minY] = 30;
tobyspark 31:01845a2347ff 94 paramSet[maxY] = 35;
tobyspark 31:01845a2347ff 95 paramSet[minU] = 237;
tobyspark 31:01845a2347ff 96 paramSet[maxU] = 242;
tobyspark 31:01845a2347ff 97 paramSet[minV] = 114;
tobyspark 31:01845a2347ff 98 paramSet[maxV] = 121;
tobyspark 31:01845a2347ff 99 keyerParamSets.push_back(paramSet);
tobyspark 16:52484666b323 100 keyerParamNames.push_back("Chromakey - Blue");
tobyspark 16:52484666b323 101
tobyspark 16:52484666b323 102 //// RESOLUTIONS
tobyspark 16:52484666b323 103
tobyspark 27:27851d3d2bba 104 resolutionNames.clear();
tobyspark 27:27851d3d2bba 105 resolutionIndexes.clear();
tobyspark 27:27851d3d2bba 106 resolutionEDIDIndexes.clear();
tobyspark 27:27851d3d2bba 107
tobyspark 16:52484666b323 108 resolutionNames.push_back(kTV1ResolutionDescriptionVGA);
tobyspark 16:52484666b323 109 resolutionIndexes.push_back(kTV1ResolutionVGA);
tobyspark 34:69dfe64e7e6b 110 resolutionEDIDIndexes.push_back(6);
tobyspark 16:52484666b323 111
tobyspark 16:52484666b323 112 resolutionNames.push_back(kTV1ResolutionDescriptionSVGA);
tobyspark 16:52484666b323 113 resolutionIndexes.push_back(kTV1ResolutionSVGA);
tobyspark 34:69dfe64e7e6b 114 resolutionEDIDIndexes.push_back(6);
tobyspark 16:52484666b323 115
tobyspark 16:52484666b323 116 resolutionNames.push_back(kTV1ResolutionDescriptionXGAp60);
tobyspark 16:52484666b323 117 resolutionIndexes.push_back(kTV1ResolutionXGAp60);
tobyspark 34:69dfe64e7e6b 118 resolutionEDIDIndexes.push_back(6);
tobyspark 16:52484666b323 119
tobyspark 16:52484666b323 120 resolutionNames.push_back(kTV1ResolutionDescriptionWSXGAPLUSp60);
tobyspark 16:52484666b323 121 resolutionIndexes.push_back(kTV1ResolutionWSXGAPLUSp60);
tobyspark 34:69dfe64e7e6b 122 resolutionEDIDIndexes.push_back(6);
tobyspark 16:52484666b323 123
tobyspark 16:52484666b323 124 resolutionNames.push_back(kTV1ResolutionDescriptionWUXGAp60);
tobyspark 16:52484666b323 125 resolutionIndexes.push_back(kTV1ResolutionWUXGAp60);
tobyspark 34:69dfe64e7e6b 126 resolutionEDIDIndexes.push_back(6);
tobyspark 16:52484666b323 127
tobyspark 16:52484666b323 128 resolutionNames.push_back(kTV1ResolutionDescription720p60);
tobyspark 16:52484666b323 129 resolutionIndexes.push_back(kTV1Resolution720p60);
tobyspark 16:52484666b323 130 resolutionEDIDIndexes.push_back(5);
tobyspark 16:52484666b323 131
tobyspark 16:52484666b323 132 resolutionNames.push_back(kTV1ResolutionDescription1080p60);
tobyspark 16:52484666b323 133 resolutionIndexes.push_back(kTV1Resolution1080p60);
tobyspark 16:52484666b323 134 resolutionEDIDIndexes.push_back(5);
tobyspark 16:52484666b323 135
tobyspark 16:52484666b323 136 resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadSVGAp60);
tobyspark 16:52484666b323 137 resolutionIndexes.push_back(kTV1ResolutionDualHeadSVGAp60);
tobyspark 34:69dfe64e7e6b 138 resolutionEDIDIndexes.push_back(4);
tobyspark 16:52484666b323 139
tobyspark 16:52484666b323 140 resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadXGAp60);
tobyspark 16:52484666b323 141 resolutionIndexes.push_back(kTV1ResolutionDualHeadXGAp60);
tobyspark 34:69dfe64e7e6b 142 resolutionEDIDIndexes.push_back(4);
tobyspark 16:52484666b323 143
tobyspark 16:52484666b323 144 resolutionNames.push_back(kTV1ResolutionDescriptionTripleHeadVGAp60);
tobyspark 16:52484666b323 145 resolutionIndexes.push_back(kTV1ResolutionTripleHeadVGAp60);
tobyspark 34:69dfe64e7e6b 146 resolutionEDIDIndexes.push_back(4);
tobyspark 11:0783cfbeb746 147 }
tobyspark 11:0783cfbeb746 148
tobyspark 13:3796bde6ba8f 149 string keyerParamName (int index)
tobyspark 11:0783cfbeb746 150 {
tobyspark 11:0783cfbeb746 151 // TODO: Bounds check and return out of bounds name
tobyspark 11:0783cfbeb746 152 return keyerParamNames[index];
tobyspark 11:0783cfbeb746 153 }
tobyspark 11:0783cfbeb746 154
tobyspark 31:01845a2347ff 155 vector<int> keyerParamSet(int index)
tobyspark 11:0783cfbeb746 156 {
tobyspark 11:0783cfbeb746 157 return keyerParamSets[index];
tobyspark 11:0783cfbeb746 158 }
tobyspark 11:0783cfbeb746 159
tobyspark 11:0783cfbeb746 160 int keyerSetCount()
tobyspark 11:0783cfbeb746 161 {
tobyspark 11:0783cfbeb746 162 return keyerParamSets.size();
tobyspark 11:0783cfbeb746 163 }
tobyspark 11:0783cfbeb746 164
tobyspark 36:8b5c75c8bc23 165 int editingKeyerSetValue(keyerParameterType parameter)
tobyspark 36:8b5c75c8bc23 166 {
tobyspark 36:8b5c75c8bc23 167 int value = -1;
tobyspark 36:8b5c75c8bc23 168 if (editingKeyerSetIndex >= 0 && editingKeyerSetIndex < keyerSetCount())
tobyspark 36:8b5c75c8bc23 169 {
tobyspark 36:8b5c75c8bc23 170 value = keyerParamSets[editingKeyerSetIndex][parameter];
tobyspark 36:8b5c75c8bc23 171 }
tobyspark 36:8b5c75c8bc23 172 return value;
tobyspark 36:8b5c75c8bc23 173 }
tobyspark 36:8b5c75c8bc23 174
tobyspark 36:8b5c75c8bc23 175 void setEditingKeyerSetValue(keyerParameterType parameter, int value)
tobyspark 36:8b5c75c8bc23 176 {
tobyspark 36:8b5c75c8bc23 177 if (editingKeyerSetIndex >= 0 && editingKeyerSetIndex < keyerSetCount())
tobyspark 36:8b5c75c8bc23 178 {
tobyspark 36:8b5c75c8bc23 179 keyerParamSets[editingKeyerSetIndex][parameter] = value;
tobyspark 36:8b5c75c8bc23 180 }
tobyspark 36:8b5c75c8bc23 181 }
tobyspark 36:8b5c75c8bc23 182
tobyspark 36:8b5c75c8bc23 183 string resolutionName (int index)
tobyspark 16:52484666b323 184 {
tobyspark 16:52484666b323 185 // TODO: Bounds check and return out of bounds name
tobyspark 16:52484666b323 186 return resolutionNames[index];
tobyspark 16:52484666b323 187 }
tobyspark 16:52484666b323 188
tobyspark 16:52484666b323 189 int32_t resolutionIndex(int index)
tobyspark 16:52484666b323 190 {
tobyspark 16:52484666b323 191 return resolutionIndexes[index];
tobyspark 16:52484666b323 192 }
tobyspark 16:52484666b323 193
tobyspark 16:52484666b323 194 int32_t resolutionEDIDIndex(int index)
tobyspark 16:52484666b323 195 {
tobyspark 16:52484666b323 196 return resolutionEDIDIndexes[index];
tobyspark 16:52484666b323 197 }
tobyspark 16:52484666b323 198
tobyspark 16:52484666b323 199 int resolutionsCount()
tobyspark 16:52484666b323 200 {
tobyspark 16:52484666b323 201 return resolutionNames.size();
tobyspark 16:52484666b323 202 }
tobyspark 16:52484666b323 203
tobyspark 13:3796bde6ba8f 204 bool load(string filename)
tobyspark 11:0783cfbeb746 205 {
tobyspark 11:0783cfbeb746 206 bool success = false;
tobyspark 13:3796bde6ba8f 207
tobyspark 13:3796bde6ba8f 208 local = new LocalFileSystem("local");
tobyspark 13:3796bde6ba8f 209 string filePath("/local/");
tobyspark 13:3796bde6ba8f 210 filePath += filename;
tobyspark 13:3796bde6ba8f 211
tobyspark 68:c26478f42ca4 212 char* const failString = "Failed to read";
tobyspark 68:c26478f42ca4 213 const int failInt = -1;
tobyspark 68:c26478f42ca4 214
tobyspark 13:3796bde6ba8f 215 dictionary* settings = iniparser_load(filePath.c_str());
tobyspark 68:c26478f42ca4 216
tobyspark 68:c26478f42ca4 217 // NETWORK
tobyspark 68:c26478f42ca4 218 {
tobyspark 68:c26478f42ca4 219 bool netReadOK = true;
tobyspark 68:c26478f42ca4 220
tobyspark 68:c26478f42ca4 221 int DHCP = iniparser_getboolean(settings, "OSC:DHCP", failInt);
tobyspark 68:c26478f42ca4 222 netReadOK = netReadOK && DHCP != failInt;
tobyspark 68:c26478f42ca4 223
tobyspark 68:c26478f42ca4 224 IpAddr controllerAddress = ipAddrWithString(iniparser_getstring(settings, "OSC:ControllerAddress", failString));
tobyspark 68:c26478f42ca4 225 netReadOK = netReadOK && !controllerAddress.isNull();
tobyspark 68:c26478f42ca4 226
tobyspark 68:c26478f42ca4 227 int controllerPort = iniparser_getboolean(settings, "OSC:ControllerPort", failInt);
tobyspark 68:c26478f42ca4 228 netReadOK = netReadOK && controllerPort != failInt;
tobyspark 68:c26478f42ca4 229
tobyspark 68:c26478f42ca4 230 IpAddr controllerSubnetMask = ipAddrWithString(iniparser_getstring(settings, "OSC:ControllerSubnetMask", failString));
tobyspark 68:c26478f42ca4 231 netReadOK = netReadOK && !controllerSubnetMask.isNull();
tobyspark 68:c26478f42ca4 232
tobyspark 68:c26478f42ca4 233 IpAddr controllerGateway = ipAddrWithString(iniparser_getstring(settings, "OSC:ControllerGateway", failString));
tobyspark 68:c26478f42ca4 234 netReadOK = netReadOK && !controllerGateway.isNull();
tobyspark 68:c26478f42ca4 235
tobyspark 68:c26478f42ca4 236 IpAddr controllerDNS = ipAddrWithString(iniparser_getstring(settings, "OSC:ControllerDNS", failString));
tobyspark 68:c26478f42ca4 237 netReadOK = netReadOK && !controllerDNS.isNull();
tobyspark 68:c26478f42ca4 238
tobyspark 68:c26478f42ca4 239 IpAddr sendAddress = ipAddrWithString(iniparser_getstring(settings, "OSC:SendAddress", failString));
tobyspark 68:c26478f42ca4 240 netReadOK = netReadOK && !sendAddress.isNull();
tobyspark 68:c26478f42ca4 241
tobyspark 68:c26478f42ca4 242 int sendPort = iniparser_getboolean(settings, "OSC:SendPort", failInt);
tobyspark 68:c26478f42ca4 243 netReadOK = netReadOK && sendPort != failInt;
tobyspark 68:c26478f42ca4 244
tobyspark 68:c26478f42ca4 245 IpAddr artNetControllerAddress = ipAddrWithString(iniparser_getstring(settings, "ArtNet:ControllerAddress", failString));
tobyspark 68:c26478f42ca4 246 netReadOK = netReadOK && !artNetControllerAddress.isNull();
tobyspark 68:c26478f42ca4 247
tobyspark 68:c26478f42ca4 248 IpAddr artNetBroadcastAddress = ipAddrWithString(iniparser_getstring(settings, "ArtNet:BroadcastAddress", failString));
tobyspark 68:c26478f42ca4 249 netReadOK = netReadOK && !artNetBroadcastAddress.isNull();
tobyspark 68:c26478f42ca4 250
tobyspark 68:c26478f42ca4 251 int inChannelXFade = iniparser_getboolean(settings, "DMX:InChannelXFade", failInt);
tobyspark 68:c26478f42ca4 252 netReadOK = netReadOK && inChannelXFade != failInt;
tobyspark 68:c26478f42ca4 253
tobyspark 68:c26478f42ca4 254 int inChannelFadeUp = iniparser_getboolean(settings, "DMX:InChannelFadeUp", failInt);
tobyspark 68:c26478f42ca4 255 netReadOK = netReadOK && inChannelFadeUp != failInt;
tobyspark 68:c26478f42ca4 256
tobyspark 68:c26478f42ca4 257 int outChannelXFade = iniparser_getboolean(settings, "DMX:OutChannelXFade", failInt);
tobyspark 68:c26478f42ca4 258 netReadOK = netReadOK && outChannelXFade != failInt;
tobyspark 68:c26478f42ca4 259
tobyspark 68:c26478f42ca4 260 int outChannelFadeUp = iniparser_getboolean(settings, "DMX:OutChannelFadeUp", failInt);
tobyspark 68:c26478f42ca4 261 netReadOK = netReadOK && outChannelFadeUp != failInt;
tobyspark 68:c26478f42ca4 262
tobyspark 68:c26478f42ca4 263 if (netReadOK)
tobyspark 68:c26478f42ca4 264 {
tobyspark 68:c26478f42ca4 265 osc.DHCP = DHCP;
tobyspark 68:c26478f42ca4 266 osc.controllerAddress = controllerAddress;
tobyspark 68:c26478f42ca4 267 osc.controllerPort = controllerPort;
tobyspark 68:c26478f42ca4 268 osc.controllerSubnetMask = controllerSubnetMask;
tobyspark 68:c26478f42ca4 269 osc.controllerGateway = controllerGateway;
tobyspark 68:c26478f42ca4 270 osc.controllerDNS = controllerDNS;
tobyspark 68:c26478f42ca4 271
tobyspark 68:c26478f42ca4 272 osc.sendAddress = sendAddress;
tobyspark 68:c26478f42ca4 273 osc.sendPort = sendPort;
tobyspark 68:c26478f42ca4 274
tobyspark 68:c26478f42ca4 275 artNet.controllerAddress = artNetControllerAddress;
tobyspark 68:c26478f42ca4 276 artNet.broadcastAddress = artNetBroadcastAddress;
tobyspark 68:c26478f42ca4 277
tobyspark 68:c26478f42ca4 278 dmx.inChannelXFade = inChannelXFade;
tobyspark 68:c26478f42ca4 279 dmx.inChannelFadeUp = inChannelFadeUp;
tobyspark 68:c26478f42ca4 280 dmx.outChannelXFade = outChannelXFade;
tobyspark 68:c26478f42ca4 281 dmx.outChannelFadeUp = outChannelFadeUp;
tobyspark 68:c26478f42ca4 282
tobyspark 68:c26478f42ca4 283 success = true;
tobyspark 68:c26478f42ca4 284 }
tobyspark 68:c26478f42ca4 285 }
tobyspark 13:3796bde6ba8f 286
tobyspark 13:3796bde6ba8f 287 // KEYER
tobyspark 13:3796bde6ba8f 288 {
tobyspark 13:3796bde6ba8f 289 int counter = 1;
tobyspark 13:3796bde6ba8f 290
tobyspark 13:3796bde6ba8f 291 bool keyParamReadOK = true;
tobyspark 13:3796bde6ba8f 292 bool keyParamCleared = false;
tobyspark 68:c26478f42ca4 293
tobyspark 28:67269c2d042b 294 const int stringLength = 11;
tobyspark 13:3796bde6ba8f 295
tobyspark 13:3796bde6ba8f 296 // Loop through [Key1,2,...,99] sections
tobyspark 13:3796bde6ba8f 297 while(keyParamReadOK)
tobyspark 13:3796bde6ba8f 298 {
tobyspark 31:01845a2347ff 299 vector<int> paramSet(6);
tobyspark 31:01845a2347ff 300 char* paramName;
tobyspark 13:3796bde6ba8f 301
tobyspark 28:67269c2d042b 302 char key[stringLength];
tobyspark 11:0783cfbeb746 303
tobyspark 28:67269c2d042b 304 snprintf(key, stringLength, "Key%i:Name", counter);
tobyspark 13:3796bde6ba8f 305 paramName = iniparser_getstring(settings, key, failString);
tobyspark 13:3796bde6ba8f 306 keyParamReadOK = keyParamReadOK && strcmp(paramName, failString);
tobyspark 13:3796bde6ba8f 307
tobyspark 28:67269c2d042b 308 snprintf(key, stringLength, "Key%i:MinY", counter);
tobyspark 31:01845a2347ff 309 paramSet[minY] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 310 keyParamReadOK = keyParamReadOK && (paramSet[minY] != failInt);
tobyspark 13:3796bde6ba8f 311
tobyspark 28:67269c2d042b 312 snprintf(key, stringLength, "Key%i:MaxY", counter);
tobyspark 31:01845a2347ff 313 paramSet[maxY] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 314 keyParamReadOK = keyParamReadOK && (paramSet[maxY] != failInt);
tobyspark 13:3796bde6ba8f 315
tobyspark 28:67269c2d042b 316 snprintf(key, stringLength, "Key%i:MinU", counter);
tobyspark 31:01845a2347ff 317 paramSet[minU] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 318 keyParamReadOK = keyParamReadOK && (paramSet[minU] != failInt);
tobyspark 13:3796bde6ba8f 319
tobyspark 28:67269c2d042b 320 snprintf(key, stringLength, "Key%i:MaxU", counter);
tobyspark 31:01845a2347ff 321 paramSet[maxU] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 322 keyParamReadOK = keyParamReadOK && (paramSet[maxU] != failInt);
tobyspark 13:3796bde6ba8f 323
tobyspark 28:67269c2d042b 324 snprintf(key, stringLength, "Key%i:MinV", counter);
tobyspark 31:01845a2347ff 325 paramSet[minV] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 326 keyParamReadOK = keyParamReadOK && (paramSet[minV] != failInt);
tobyspark 13:3796bde6ba8f 327
tobyspark 28:67269c2d042b 328 snprintf(key, stringLength, "Key%i:MaxV", counter);
tobyspark 31:01845a2347ff 329 paramSet[maxV] = iniparser_getint(settings, key, failInt);
tobyspark 31:01845a2347ff 330 keyParamReadOK = keyParamReadOK && (paramSet[maxV] != failInt);
tobyspark 13:3796bde6ba8f 331
tobyspark 13:3796bde6ba8f 332 // If all parameters have been read successfully
tobyspark 13:3796bde6ba8f 333 if (keyParamReadOK)
tobyspark 13:3796bde6ba8f 334 {
tobyspark 13:3796bde6ba8f 335
tobyspark 13:3796bde6ba8f 336 // If this is the first time through, clear old values
tobyspark 13:3796bde6ba8f 337 if (!keyParamCleared)
tobyspark 13:3796bde6ba8f 338 {
tobyspark 13:3796bde6ba8f 339 keyerParamNames.clear();
tobyspark 13:3796bde6ba8f 340 keyerParamSets.clear();
tobyspark 13:3796bde6ba8f 341 keyParamCleared = true;
tobyspark 61:f0a42bfca816 342
tobyspark 61:f0a42bfca816 343 vector<int> paramSet(6);
tobyspark 61:f0a42bfca816 344 paramSet[minY] = 0;
tobyspark 61:f0a42bfca816 345 paramSet[maxY] = 18;
tobyspark 61:f0a42bfca816 346 paramSet[minU] = 128;
tobyspark 61:f0a42bfca816 347 paramSet[maxU] = 129;
tobyspark 61:f0a42bfca816 348 paramSet[minV] = 128;
tobyspark 61:f0a42bfca816 349 paramSet[maxV] = 129;
tobyspark 61:f0a42bfca816 350 keyerParamSets.push_back(paramSet);
tobyspark 61:f0a42bfca816 351 keyerParamNames.push_back("Key - Current");
tobyspark 13:3796bde6ba8f 352 }
tobyspark 13:3796bde6ba8f 353
tobyspark 13:3796bde6ba8f 354 // Apply settings
tobyspark 13:3796bde6ba8f 355 keyerParamNames.push_back(paramName);
tobyspark 13:3796bde6ba8f 356 keyerParamSets.push_back(paramSet);
tobyspark 13:3796bde6ba8f 357
tobyspark 13:3796bde6ba8f 358 // We've successfully read a keyer param set, so should return true;
tobyspark 31:01845a2347ff 359 success = true;
tobyspark 13:3796bde6ba8f 360 }
tobyspark 13:3796bde6ba8f 361
tobyspark 13:3796bde6ba8f 362 counter++;
tobyspark 13:3796bde6ba8f 363 }
tobyspark 13:3796bde6ba8f 364 }
tobyspark 13:3796bde6ba8f 365
tobyspark 16:52484666b323 366 // RESOLUTIONS
tobyspark 16:52484666b323 367 {
tobyspark 16:52484666b323 368 int counter = 1;
tobyspark 16:52484666b323 369
tobyspark 16:52484666b323 370 bool resolutionReadOK = true;
tobyspark 16:52484666b323 371 bool resolutionCleared = false;
tobyspark 16:52484666b323 372
tobyspark 28:67269c2d042b 373 const int stringLength = 25;
tobyspark 16:52484666b323 374
tobyspark 16:52484666b323 375 // Loop through [Key1,2,...,99] sections
tobyspark 16:52484666b323 376 while(resolutionReadOK)
tobyspark 16:52484666b323 377 {
tobyspark 16:52484666b323 378 char* resolutionName;
tobyspark 16:52484666b323 379 int resolutionIndex;
tobyspark 16:52484666b323 380 int resolutionEDIDIndex;
tobyspark 16:52484666b323 381
tobyspark 28:67269c2d042b 382 char key[stringLength];
tobyspark 16:52484666b323 383
tobyspark 28:67269c2d042b 384 snprintf(key, stringLength, "Resolution%i:Name", counter);
tobyspark 16:52484666b323 385 resolutionName = iniparser_getstring(settings, key, failString);
tobyspark 16:52484666b323 386 resolutionReadOK = resolutionReadOK && strcmp(resolutionName, failString);
tobyspark 16:52484666b323 387
tobyspark 28:67269c2d042b 388 snprintf(key, stringLength, "Resolution%i:Number", counter);
tobyspark 16:52484666b323 389 resolutionIndex = iniparser_getint(settings, key, failInt);
tobyspark 16:52484666b323 390 resolutionReadOK = resolutionReadOK && (resolutionIndex != failInt);
tobyspark 16:52484666b323 391
tobyspark 28:67269c2d042b 392 snprintf(key, stringLength, "Resolution%i:EDIDNumber", counter);
tobyspark 16:52484666b323 393 resolutionEDIDIndex = iniparser_getint(settings, key, failInt);
tobyspark 16:52484666b323 394 resolutionReadOK = resolutionReadOK && (resolutionEDIDIndex != failInt);
tobyspark 16:52484666b323 395
tobyspark 16:52484666b323 396 // If all parameters have been read successfully
tobyspark 16:52484666b323 397 if (resolutionReadOK)
tobyspark 16:52484666b323 398 {
tobyspark 16:52484666b323 399 // If this is the first time through, clear old values
tobyspark 16:52484666b323 400 if (!resolutionCleared)
tobyspark 16:52484666b323 401 {
tobyspark 16:52484666b323 402 resolutionNames.clear();
tobyspark 16:52484666b323 403 resolutionIndexes.clear();
tobyspark 16:52484666b323 404 resolutionEDIDIndexes.clear();
tobyspark 16:52484666b323 405 resolutionCleared = true;
tobyspark 16:52484666b323 406 }
tobyspark 16:52484666b323 407
tobyspark 16:52484666b323 408 // Apply settings
tobyspark 16:52484666b323 409 resolutionNames.push_back(resolutionName);
tobyspark 16:52484666b323 410 resolutionIndexes.push_back(resolutionIndex);
tobyspark 16:52484666b323 411 resolutionEDIDIndexes.push_back(resolutionEDIDIndex);
tobyspark 16:52484666b323 412
tobyspark 16:52484666b323 413 // We've successfully read a resolution, so should return true;
tobyspark 16:52484666b323 414 success = true;
tobyspark 16:52484666b323 415 }
tobyspark 16:52484666b323 416
tobyspark 16:52484666b323 417 counter++;
tobyspark 16:52484666b323 418 }
tobyspark 16:52484666b323 419 }
tobyspark 16:52484666b323 420
tobyspark 13:3796bde6ba8f 421 iniparser_freedict(settings);
tobyspark 13:3796bde6ba8f 422
tobyspark 13:3796bde6ba8f 423 delete local;
tobyspark 11:0783cfbeb746 424
tobyspark 11:0783cfbeb746 425 return success;
tobyspark 11:0783cfbeb746 426 }
tobyspark 11:0783cfbeb746 427
tobyspark 11:0783cfbeb746 428 protected:
tobyspark 11:0783cfbeb746 429 LocalFileSystem *local;
tobyspark 31:01845a2347ff 430 vector< vector<int> > keyerParamSets;
tobyspark 31:01845a2347ff 431 vector<string> keyerParamNames;
tobyspark 31:01845a2347ff 432 vector<string> resolutionNames;
tobyspark 31:01845a2347ff 433 vector<int32_t> resolutionIndexes;
tobyspark 31:01845a2347ff 434 vector<int32_t> resolutionEDIDIndexes;
tobyspark 68:c26478f42ca4 435
tobyspark 68:c26478f42ca4 436 IpAddr ipAddrWithString(const char* ipAsString)
tobyspark 68:c26478f42ca4 437 {
tobyspark 68:c26478f42ca4 438 int ip0, ip1, ip2, ip3;
tobyspark 68:c26478f42ca4 439
tobyspark 68:c26478f42ca4 440 int parsedNum = sscanf(ipAsString, "%u.%u.%u.%u", &ip0, &ip1, &ip2, &ip3);
tobyspark 68:c26478f42ca4 441
tobyspark 68:c26478f42ca4 442 if (parsedNum == 4)
tobyspark 68:c26478f42ca4 443 {
tobyspark 68:c26478f42ca4 444 return IpAddr(ip0, ip1, ip2, ip3);
tobyspark 68:c26478f42ca4 445 }
tobyspark 68:c26478f42ca4 446
tobyspark 68:c26478f42ca4 447 return IpAddr();
tobyspark 68:c26478f42ca4 448 }
tobyspark 16:52484666b323 449 };