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