Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPK-TVOne DMX DmxArtNet NetServicesMin OSC PinDetect mRotaryEncoder iniparser mbed spk_oled_ssd1305 filter
spk_settings.h@43:328d851c429a, 2012-12-02 (annotated)
- Committer:
- tobyspark
- Date:
- Sun Dec 02 16:13:31 2012 +0000
- Revision:
- 43:328d851c429a
- Parent:
- 36:8b5c75c8bc23
Code to save keyer parameter changes back to .ini. However iniparser hangs on reading the ini despite this part of save code being identical to load code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 11:0783cfbeb746 | 1 | #include "mbed.h" |
tobyspark | 13:3796bde6ba8f | 2 | #include <string> |
tobyspark | 13:3796bde6ba8f | 3 | #include <vector> |
tobyspark | 13:3796bde6ba8f | 4 | |
tobyspark | 13:3796bde6ba8f | 5 | extern "C" |
tobyspark | 13:3796bde6ba8f | 6 | { |
tobyspark | 13:3796bde6ba8f | 7 | #include "iniparser.h" |
tobyspark | 13:3796bde6ba8f | 8 | } |
tobyspark | 11:0783cfbeb746 | 9 | |
tobyspark | 11:0783cfbeb746 | 10 | class SPKSettings { |
tobyspark | 11:0783cfbeb746 | 11 | public: |
tobyspark | 36:8b5c75c8bc23 | 12 | enum keyerParameterType {minY = 0, maxY, minU, maxU, minV, maxV}; |
tobyspark | 36:8b5c75c8bc23 | 13 | |
tobyspark | 36:8b5c75c8bc23 | 14 | int editingKeyerSetIndex; |
tobyspark | 31:01845a2347ff | 15 | |
tobyspark | 11:0783cfbeb746 | 16 | SPKSettings() |
tobyspark | 11:0783cfbeb746 | 17 | { |
tobyspark | 36:8b5c75c8bc23 | 18 | editingKeyerSetIndex = -1; |
tobyspark | 16:52484666b323 | 19 | loadDefaults(); |
tobyspark | 16:52484666b323 | 20 | } |
tobyspark | 16:52484666b323 | 21 | |
tobyspark | 16:52484666b323 | 22 | void loadDefaults() |
tobyspark | 16:52484666b323 | 23 | { |
tobyspark | 16:52484666b323 | 24 | //// KEYS |
tobyspark | 16:52484666b323 | 25 | |
tobyspark | 27:27851d3d2bba | 26 | keyerParamNames.clear(); |
tobyspark | 27:27851d3d2bba | 27 | keyerParamSets.clear(); |
tobyspark | 31:01845a2347ff | 28 | vector<int> paramSet(6); |
tobyspark | 27:27851d3d2bba | 29 | |
tobyspark | 31:01845a2347ff | 30 | paramSet[minY] = 0; |
tobyspark | 31:01845a2347ff | 31 | paramSet[maxY] = 18; |
tobyspark | 31:01845a2347ff | 32 | paramSet[minU] = 128; |
tobyspark | 31:01845a2347ff | 33 | paramSet[maxU] = 129; |
tobyspark | 31:01845a2347ff | 34 | paramSet[minV] = 128; |
tobyspark | 31:01845a2347ff | 35 | paramSet[maxV] = 129; |
tobyspark | 31:01845a2347ff | 36 | keyerParamSets.push_back(paramSet); |
tobyspark | 16:52484666b323 | 37 | keyerParamNames.push_back("Lumakey"); |
tobyspark | 11:0783cfbeb746 | 38 | |
tobyspark | 31:01845a2347ff | 39 | paramSet[minY] = 30; |
tobyspark | 31:01845a2347ff | 40 | paramSet[maxY] = 35; |
tobyspark | 31:01845a2347ff | 41 | paramSet[minU] = 237; |
tobyspark | 31:01845a2347ff | 42 | paramSet[maxU] = 242; |
tobyspark | 31:01845a2347ff | 43 | paramSet[minV] = 114; |
tobyspark | 31:01845a2347ff | 44 | paramSet[maxV] = 121; |
tobyspark | 31:01845a2347ff | 45 | keyerParamSets.push_back(paramSet); |
tobyspark | 16:52484666b323 | 46 | keyerParamNames.push_back("Chromakey - Blue"); |
tobyspark | 16:52484666b323 | 47 | |
tobyspark | 16:52484666b323 | 48 | //// RESOLUTIONS |
tobyspark | 16:52484666b323 | 49 | |
tobyspark | 27:27851d3d2bba | 50 | resolutionNames.clear(); |
tobyspark | 27:27851d3d2bba | 51 | resolutionIndexes.clear(); |
tobyspark | 27:27851d3d2bba | 52 | resolutionEDIDIndexes.clear(); |
tobyspark | 27:27851d3d2bba | 53 | |
tobyspark | 16:52484666b323 | 54 | resolutionNames.push_back(kTV1ResolutionDescriptionVGA); |
tobyspark | 16:52484666b323 | 55 | resolutionIndexes.push_back(kTV1ResolutionVGA); |
tobyspark | 34:69dfe64e7e6b | 56 | resolutionEDIDIndexes.push_back(6); |
tobyspark | 16:52484666b323 | 57 | |
tobyspark | 16:52484666b323 | 58 | resolutionNames.push_back(kTV1ResolutionDescriptionSVGA); |
tobyspark | 16:52484666b323 | 59 | resolutionIndexes.push_back(kTV1ResolutionSVGA); |
tobyspark | 34:69dfe64e7e6b | 60 | resolutionEDIDIndexes.push_back(6); |
tobyspark | 16:52484666b323 | 61 | |
tobyspark | 16:52484666b323 | 62 | resolutionNames.push_back(kTV1ResolutionDescriptionXGAp60); |
tobyspark | 16:52484666b323 | 63 | resolutionIndexes.push_back(kTV1ResolutionXGAp60); |
tobyspark | 34:69dfe64e7e6b | 64 | resolutionEDIDIndexes.push_back(6); |
tobyspark | 16:52484666b323 | 65 | |
tobyspark | 16:52484666b323 | 66 | resolutionNames.push_back(kTV1ResolutionDescriptionWSXGAPLUSp60); |
tobyspark | 16:52484666b323 | 67 | resolutionIndexes.push_back(kTV1ResolutionWSXGAPLUSp60); |
tobyspark | 34:69dfe64e7e6b | 68 | resolutionEDIDIndexes.push_back(6); |
tobyspark | 16:52484666b323 | 69 | |
tobyspark | 16:52484666b323 | 70 | resolutionNames.push_back(kTV1ResolutionDescriptionWUXGAp60); |
tobyspark | 16:52484666b323 | 71 | resolutionIndexes.push_back(kTV1ResolutionWUXGAp60); |
tobyspark | 34:69dfe64e7e6b | 72 | resolutionEDIDIndexes.push_back(6); |
tobyspark | 16:52484666b323 | 73 | |
tobyspark | 16:52484666b323 | 74 | resolutionNames.push_back(kTV1ResolutionDescription720p60); |
tobyspark | 16:52484666b323 | 75 | resolutionIndexes.push_back(kTV1Resolution720p60); |
tobyspark | 16:52484666b323 | 76 | resolutionEDIDIndexes.push_back(5); |
tobyspark | 16:52484666b323 | 77 | |
tobyspark | 16:52484666b323 | 78 | resolutionNames.push_back(kTV1ResolutionDescription1080p60); |
tobyspark | 16:52484666b323 | 79 | resolutionIndexes.push_back(kTV1Resolution1080p60); |
tobyspark | 16:52484666b323 | 80 | resolutionEDIDIndexes.push_back(5); |
tobyspark | 16:52484666b323 | 81 | |
tobyspark | 16:52484666b323 | 82 | resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadSVGAp60); |
tobyspark | 16:52484666b323 | 83 | resolutionIndexes.push_back(kTV1ResolutionDualHeadSVGAp60); |
tobyspark | 34:69dfe64e7e6b | 84 | resolutionEDIDIndexes.push_back(4); |
tobyspark | 16:52484666b323 | 85 | |
tobyspark | 16:52484666b323 | 86 | resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadXGAp60); |
tobyspark | 16:52484666b323 | 87 | resolutionIndexes.push_back(kTV1ResolutionDualHeadXGAp60); |
tobyspark | 34:69dfe64e7e6b | 88 | resolutionEDIDIndexes.push_back(4); |
tobyspark | 16:52484666b323 | 89 | |
tobyspark | 16:52484666b323 | 90 | resolutionNames.push_back(kTV1ResolutionDescriptionTripleHeadVGAp60); |
tobyspark | 16:52484666b323 | 91 | resolutionIndexes.push_back(kTV1ResolutionTripleHeadVGAp60); |
tobyspark | 34:69dfe64e7e6b | 92 | resolutionEDIDIndexes.push_back(4); |
tobyspark | 11:0783cfbeb746 | 93 | } |
tobyspark | 11:0783cfbeb746 | 94 | |
tobyspark | 13:3796bde6ba8f | 95 | string keyerParamName (int index) |
tobyspark | 11:0783cfbeb746 | 96 | { |
tobyspark | 11:0783cfbeb746 | 97 | // TODO: Bounds check and return out of bounds name |
tobyspark | 11:0783cfbeb746 | 98 | return keyerParamNames[index]; |
tobyspark | 11:0783cfbeb746 | 99 | } |
tobyspark | 11:0783cfbeb746 | 100 | |
tobyspark | 31:01845a2347ff | 101 | vector<int> keyerParamSet(int index) |
tobyspark | 11:0783cfbeb746 | 102 | { |
tobyspark | 11:0783cfbeb746 | 103 | return keyerParamSets[index]; |
tobyspark | 11:0783cfbeb746 | 104 | } |
tobyspark | 11:0783cfbeb746 | 105 | |
tobyspark | 11:0783cfbeb746 | 106 | int keyerSetCount() |
tobyspark | 11:0783cfbeb746 | 107 | { |
tobyspark | 11:0783cfbeb746 | 108 | return keyerParamSets.size(); |
tobyspark | 11:0783cfbeb746 | 109 | } |
tobyspark | 11:0783cfbeb746 | 110 | |
tobyspark | 36:8b5c75c8bc23 | 111 | int editingKeyerSetValue(keyerParameterType parameter) |
tobyspark | 36:8b5c75c8bc23 | 112 | { |
tobyspark | 36:8b5c75c8bc23 | 113 | int value = -1; |
tobyspark | 36:8b5c75c8bc23 | 114 | if (editingKeyerSetIndex >= 0 && editingKeyerSetIndex < keyerSetCount()) |
tobyspark | 36:8b5c75c8bc23 | 115 | { |
tobyspark | 36:8b5c75c8bc23 | 116 | value = keyerParamSets[editingKeyerSetIndex][parameter]; |
tobyspark | 36:8b5c75c8bc23 | 117 | } |
tobyspark | 36:8b5c75c8bc23 | 118 | return value; |
tobyspark | 36:8b5c75c8bc23 | 119 | } |
tobyspark | 36:8b5c75c8bc23 | 120 | |
tobyspark | 36:8b5c75c8bc23 | 121 | void setEditingKeyerSetValue(keyerParameterType parameter, int value) |
tobyspark | 36:8b5c75c8bc23 | 122 | { |
tobyspark | 36:8b5c75c8bc23 | 123 | if (editingKeyerSetIndex >= 0 && editingKeyerSetIndex < keyerSetCount()) |
tobyspark | 36:8b5c75c8bc23 | 124 | { |
tobyspark | 36:8b5c75c8bc23 | 125 | keyerParamSets[editingKeyerSetIndex][parameter] = value; |
tobyspark | 36:8b5c75c8bc23 | 126 | } |
tobyspark | 36:8b5c75c8bc23 | 127 | } |
tobyspark | 36:8b5c75c8bc23 | 128 | |
tobyspark | 36:8b5c75c8bc23 | 129 | string resolutionName (int index) |
tobyspark | 16:52484666b323 | 130 | { |
tobyspark | 16:52484666b323 | 131 | // TODO: Bounds check and return out of bounds name |
tobyspark | 16:52484666b323 | 132 | return resolutionNames[index]; |
tobyspark | 16:52484666b323 | 133 | } |
tobyspark | 16:52484666b323 | 134 | |
tobyspark | 16:52484666b323 | 135 | int32_t resolutionIndex(int index) |
tobyspark | 16:52484666b323 | 136 | { |
tobyspark | 16:52484666b323 | 137 | return resolutionIndexes[index]; |
tobyspark | 16:52484666b323 | 138 | } |
tobyspark | 16:52484666b323 | 139 | |
tobyspark | 16:52484666b323 | 140 | int32_t resolutionEDIDIndex(int index) |
tobyspark | 16:52484666b323 | 141 | { |
tobyspark | 16:52484666b323 | 142 | return resolutionEDIDIndexes[index]; |
tobyspark | 16:52484666b323 | 143 | } |
tobyspark | 16:52484666b323 | 144 | |
tobyspark | 16:52484666b323 | 145 | int resolutionsCount() |
tobyspark | 16:52484666b323 | 146 | { |
tobyspark | 16:52484666b323 | 147 | return resolutionNames.size(); |
tobyspark | 16:52484666b323 | 148 | } |
tobyspark | 16:52484666b323 | 149 | |
tobyspark | 13:3796bde6ba8f | 150 | bool load(string filename) |
tobyspark | 11:0783cfbeb746 | 151 | { |
tobyspark | 11:0783cfbeb746 | 152 | bool success = false; |
tobyspark | 13:3796bde6ba8f | 153 | |
tobyspark | 43:328d851c429a | 154 | LocalFileSystem local("local"); |
tobyspark | 13:3796bde6ba8f | 155 | string filePath("/local/"); |
tobyspark | 13:3796bde6ba8f | 156 | filePath += filename; |
tobyspark | 13:3796bde6ba8f | 157 | |
tobyspark | 13:3796bde6ba8f | 158 | dictionary* settings = iniparser_load(filePath.c_str()); |
tobyspark | 13:3796bde6ba8f | 159 | |
tobyspark | 13:3796bde6ba8f | 160 | // KEYER |
tobyspark | 13:3796bde6ba8f | 161 | { |
tobyspark | 13:3796bde6ba8f | 162 | int counter = 1; |
tobyspark | 13:3796bde6ba8f | 163 | |
tobyspark | 13:3796bde6ba8f | 164 | bool keyParamReadOK = true; |
tobyspark | 13:3796bde6ba8f | 165 | bool keyParamCleared = false; |
tobyspark | 13:3796bde6ba8f | 166 | |
tobyspark | 28:67269c2d042b | 167 | char* const failString = "Failed to read"; |
tobyspark | 28:67269c2d042b | 168 | const int failInt = -1; |
tobyspark | 28:67269c2d042b | 169 | const int stringLength = 11; |
tobyspark | 13:3796bde6ba8f | 170 | |
tobyspark | 13:3796bde6ba8f | 171 | // Loop through [Key1,2,...,99] sections |
tobyspark | 13:3796bde6ba8f | 172 | while(keyParamReadOK) |
tobyspark | 13:3796bde6ba8f | 173 | { |
tobyspark | 31:01845a2347ff | 174 | vector<int> paramSet(6); |
tobyspark | 31:01845a2347ff | 175 | char* paramName; |
tobyspark | 13:3796bde6ba8f | 176 | |
tobyspark | 28:67269c2d042b | 177 | char key[stringLength]; |
tobyspark | 11:0783cfbeb746 | 178 | |
tobyspark | 28:67269c2d042b | 179 | snprintf(key, stringLength, "Key%i:Name", counter); |
tobyspark | 13:3796bde6ba8f | 180 | paramName = iniparser_getstring(settings, key, failString); |
tobyspark | 13:3796bde6ba8f | 181 | keyParamReadOK = keyParamReadOK && strcmp(paramName, failString); |
tobyspark | 13:3796bde6ba8f | 182 | |
tobyspark | 28:67269c2d042b | 183 | snprintf(key, stringLength, "Key%i:MinY", counter); |
tobyspark | 31:01845a2347ff | 184 | paramSet[minY] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 185 | keyParamReadOK = keyParamReadOK && (paramSet[minY] != failInt); |
tobyspark | 13:3796bde6ba8f | 186 | |
tobyspark | 28:67269c2d042b | 187 | snprintf(key, stringLength, "Key%i:MaxY", counter); |
tobyspark | 31:01845a2347ff | 188 | paramSet[maxY] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 189 | keyParamReadOK = keyParamReadOK && (paramSet[maxY] != failInt); |
tobyspark | 13:3796bde6ba8f | 190 | |
tobyspark | 28:67269c2d042b | 191 | snprintf(key, stringLength, "Key%i:MinU", counter); |
tobyspark | 31:01845a2347ff | 192 | paramSet[minU] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 193 | keyParamReadOK = keyParamReadOK && (paramSet[minU] != failInt); |
tobyspark | 13:3796bde6ba8f | 194 | |
tobyspark | 28:67269c2d042b | 195 | snprintf(key, stringLength, "Key%i:MaxU", counter); |
tobyspark | 31:01845a2347ff | 196 | paramSet[maxU] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 197 | keyParamReadOK = keyParamReadOK && (paramSet[maxU] != failInt); |
tobyspark | 13:3796bde6ba8f | 198 | |
tobyspark | 28:67269c2d042b | 199 | snprintf(key, stringLength, "Key%i:MinV", counter); |
tobyspark | 31:01845a2347ff | 200 | paramSet[minV] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 201 | keyParamReadOK = keyParamReadOK && (paramSet[minV] != failInt); |
tobyspark | 13:3796bde6ba8f | 202 | |
tobyspark | 28:67269c2d042b | 203 | snprintf(key, stringLength, "Key%i:MaxV", counter); |
tobyspark | 31:01845a2347ff | 204 | paramSet[maxV] = iniparser_getint(settings, key, failInt); |
tobyspark | 31:01845a2347ff | 205 | keyParamReadOK = keyParamReadOK && (paramSet[maxV] != failInt); |
tobyspark | 13:3796bde6ba8f | 206 | |
tobyspark | 13:3796bde6ba8f | 207 | // If all parameters have been read successfully |
tobyspark | 13:3796bde6ba8f | 208 | if (keyParamReadOK) |
tobyspark | 13:3796bde6ba8f | 209 | { |
tobyspark | 13:3796bde6ba8f | 210 | |
tobyspark | 13:3796bde6ba8f | 211 | // If this is the first time through, clear old values |
tobyspark | 13:3796bde6ba8f | 212 | if (!keyParamCleared) |
tobyspark | 13:3796bde6ba8f | 213 | { |
tobyspark | 13:3796bde6ba8f | 214 | keyerParamNames.clear(); |
tobyspark | 13:3796bde6ba8f | 215 | keyerParamSets.clear(); |
tobyspark | 13:3796bde6ba8f | 216 | keyParamCleared = true; |
tobyspark | 13:3796bde6ba8f | 217 | } |
tobyspark | 13:3796bde6ba8f | 218 | |
tobyspark | 13:3796bde6ba8f | 219 | // Apply settings |
tobyspark | 13:3796bde6ba8f | 220 | keyerParamNames.push_back(paramName); |
tobyspark | 13:3796bde6ba8f | 221 | keyerParamSets.push_back(paramSet); |
tobyspark | 13:3796bde6ba8f | 222 | |
tobyspark | 13:3796bde6ba8f | 223 | // We've successfully read a keyer param set, so should return true; |
tobyspark | 31:01845a2347ff | 224 | success = true; |
tobyspark | 13:3796bde6ba8f | 225 | } |
tobyspark | 13:3796bde6ba8f | 226 | |
tobyspark | 13:3796bde6ba8f | 227 | counter++; |
tobyspark | 13:3796bde6ba8f | 228 | } |
tobyspark | 13:3796bde6ba8f | 229 | } |
tobyspark | 13:3796bde6ba8f | 230 | |
tobyspark | 16:52484666b323 | 231 | // RESOLUTIONS |
tobyspark | 16:52484666b323 | 232 | { |
tobyspark | 16:52484666b323 | 233 | int counter = 1; |
tobyspark | 16:52484666b323 | 234 | |
tobyspark | 16:52484666b323 | 235 | bool resolutionReadOK = true; |
tobyspark | 16:52484666b323 | 236 | bool resolutionCleared = false; |
tobyspark | 16:52484666b323 | 237 | |
tobyspark | 28:67269c2d042b | 238 | char* const failString = "Failed to read"; |
tobyspark | 28:67269c2d042b | 239 | const int failInt = -1; |
tobyspark | 28:67269c2d042b | 240 | const int stringLength = 25; |
tobyspark | 16:52484666b323 | 241 | |
tobyspark | 16:52484666b323 | 242 | // Loop through [Key1,2,...,99] sections |
tobyspark | 16:52484666b323 | 243 | while(resolutionReadOK) |
tobyspark | 16:52484666b323 | 244 | { |
tobyspark | 16:52484666b323 | 245 | char* resolutionName; |
tobyspark | 16:52484666b323 | 246 | int resolutionIndex; |
tobyspark | 16:52484666b323 | 247 | int resolutionEDIDIndex; |
tobyspark | 16:52484666b323 | 248 | |
tobyspark | 28:67269c2d042b | 249 | char key[stringLength]; |
tobyspark | 16:52484666b323 | 250 | |
tobyspark | 28:67269c2d042b | 251 | snprintf(key, stringLength, "Resolution%i:Name", counter); |
tobyspark | 16:52484666b323 | 252 | resolutionName = iniparser_getstring(settings, key, failString); |
tobyspark | 16:52484666b323 | 253 | resolutionReadOK = resolutionReadOK && strcmp(resolutionName, failString); |
tobyspark | 16:52484666b323 | 254 | |
tobyspark | 28:67269c2d042b | 255 | snprintf(key, stringLength, "Resolution%i:Number", counter); |
tobyspark | 16:52484666b323 | 256 | resolutionIndex = iniparser_getint(settings, key, failInt); |
tobyspark | 16:52484666b323 | 257 | resolutionReadOK = resolutionReadOK && (resolutionIndex != failInt); |
tobyspark | 16:52484666b323 | 258 | |
tobyspark | 28:67269c2d042b | 259 | snprintf(key, stringLength, "Resolution%i:EDIDNumber", counter); |
tobyspark | 16:52484666b323 | 260 | resolutionEDIDIndex = iniparser_getint(settings, key, failInt); |
tobyspark | 16:52484666b323 | 261 | resolutionReadOK = resolutionReadOK && (resolutionEDIDIndex != failInt); |
tobyspark | 16:52484666b323 | 262 | |
tobyspark | 16:52484666b323 | 263 | // If all parameters have been read successfully |
tobyspark | 16:52484666b323 | 264 | if (resolutionReadOK) |
tobyspark | 16:52484666b323 | 265 | { |
tobyspark | 16:52484666b323 | 266 | // If this is the first time through, clear old values |
tobyspark | 16:52484666b323 | 267 | if (!resolutionCleared) |
tobyspark | 16:52484666b323 | 268 | { |
tobyspark | 16:52484666b323 | 269 | resolutionNames.clear(); |
tobyspark | 16:52484666b323 | 270 | resolutionIndexes.clear(); |
tobyspark | 16:52484666b323 | 271 | resolutionEDIDIndexes.clear(); |
tobyspark | 16:52484666b323 | 272 | resolutionCleared = true; |
tobyspark | 16:52484666b323 | 273 | } |
tobyspark | 16:52484666b323 | 274 | |
tobyspark | 16:52484666b323 | 275 | // Apply settings |
tobyspark | 16:52484666b323 | 276 | resolutionNames.push_back(resolutionName); |
tobyspark | 16:52484666b323 | 277 | resolutionIndexes.push_back(resolutionIndex); |
tobyspark | 16:52484666b323 | 278 | resolutionEDIDIndexes.push_back(resolutionEDIDIndex); |
tobyspark | 16:52484666b323 | 279 | |
tobyspark | 16:52484666b323 | 280 | // We've successfully read a resolution, so should return true; |
tobyspark | 16:52484666b323 | 281 | success = true; |
tobyspark | 16:52484666b323 | 282 | } |
tobyspark | 16:52484666b323 | 283 | |
tobyspark | 16:52484666b323 | 284 | counter++; |
tobyspark | 16:52484666b323 | 285 | } |
tobyspark | 16:52484666b323 | 286 | } |
tobyspark | 16:52484666b323 | 287 | |
tobyspark | 13:3796bde6ba8f | 288 | iniparser_freedict(settings); |
tobyspark | 13:3796bde6ba8f | 289 | |
tobyspark | 43:328d851c429a | 290 | return success; |
tobyspark | 43:328d851c429a | 291 | } |
tobyspark | 43:328d851c429a | 292 | |
tobyspark | 43:328d851c429a | 293 | |
tobyspark | 43:328d851c429a | 294 | bool saveEditingKeyerSet(string filename) |
tobyspark | 43:328d851c429a | 295 | { |
tobyspark | 43:328d851c429a | 296 | int success = 0; |
tobyspark | 43:328d851c429a | 297 | |
tobyspark | 43:328d851c429a | 298 | LocalFileSystem local("local"); |
tobyspark | 43:328d851c429a | 299 | string filePath("/local/"); |
tobyspark | 43:328d851c429a | 300 | filePath += filename; |
tobyspark | 43:328d851c429a | 301 | |
tobyspark | 43:328d851c429a | 302 | dictionary* settings = iniparser_load(filePath.c_str()); |
tobyspark | 43:328d851c429a | 303 | |
tobyspark | 43:328d851c429a | 304 | const int keyLength = 11; |
tobyspark | 43:328d851c429a | 305 | const int valueLength = 3; |
tobyspark | 43:328d851c429a | 306 | |
tobyspark | 43:328d851c429a | 307 | char keyMinY[keyLength]; |
tobyspark | 43:328d851c429a | 308 | char valueMinY[valueLength]; |
tobyspark | 43:328d851c429a | 309 | snprintf(keyMinY, keyLength, "Key%i:MinY", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 310 | snprintf(valueMinY, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minY]); |
tobyspark | 43:328d851c429a | 311 | success += iniparser_set(settings, keyMinY, valueMinY); |
tobyspark | 43:328d851c429a | 312 | |
tobyspark | 43:328d851c429a | 313 | char keyMaxY[keyLength]; |
tobyspark | 43:328d851c429a | 314 | char valueMaxY[valueLength]; |
tobyspark | 43:328d851c429a | 315 | snprintf(keyMaxY, keyLength, "Key%i:MaxY", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 316 | snprintf(valueMaxY, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxY]); |
tobyspark | 43:328d851c429a | 317 | success += iniparser_set(settings, keyMaxY, valueMaxY); |
tobyspark | 11:0783cfbeb746 | 318 | |
tobyspark | 43:328d851c429a | 319 | char keyMinU[keyLength]; |
tobyspark | 43:328d851c429a | 320 | char valueMinU[valueLength]; |
tobyspark | 43:328d851c429a | 321 | snprintf(keyMinU, keyLength, "Key%i:MinU", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 322 | snprintf(valueMinU, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minU]); |
tobyspark | 43:328d851c429a | 323 | success += iniparser_set(settings, keyMinU, valueMinU); |
tobyspark | 43:328d851c429a | 324 | |
tobyspark | 43:328d851c429a | 325 | char keyMaxU[keyLength]; |
tobyspark | 43:328d851c429a | 326 | char valueMaxU[valueLength]; |
tobyspark | 43:328d851c429a | 327 | snprintf(keyMaxU, keyLength, "Key%i:MaxU", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 328 | snprintf(valueMaxU, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxU]); |
tobyspark | 43:328d851c429a | 329 | success += iniparser_set(settings, keyMaxU, valueMaxU); |
tobyspark | 43:328d851c429a | 330 | |
tobyspark | 43:328d851c429a | 331 | char keyMinV[keyLength]; |
tobyspark | 43:328d851c429a | 332 | char valueMinV[valueLength]; |
tobyspark | 43:328d851c429a | 333 | snprintf(keyMinV, keyLength, "Key%i:MinV", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 334 | snprintf(valueMinV, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minV]); |
tobyspark | 43:328d851c429a | 335 | success += iniparser_set(settings, keyMinV, valueMinV); |
tobyspark | 43:328d851c429a | 336 | |
tobyspark | 43:328d851c429a | 337 | char keyMaxV[keyLength]; |
tobyspark | 43:328d851c429a | 338 | char valueMaxV[valueLength]; |
tobyspark | 43:328d851c429a | 339 | snprintf(keyMaxV, keyLength, "Key%i:MaxV", editingKeyerSetIndex); |
tobyspark | 43:328d851c429a | 340 | snprintf(valueMaxV, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxV]); |
tobyspark | 43:328d851c429a | 341 | success += iniparser_set(settings, keyMaxV, valueMaxV); |
tobyspark | 43:328d851c429a | 342 | |
tobyspark | 43:328d851c429a | 343 | FILE* file = fopen(filePath.c_str(), "w"); |
tobyspark | 43:328d851c429a | 344 | if (file) |
tobyspark | 43:328d851c429a | 345 | { |
tobyspark | 43:328d851c429a | 346 | iniparser_dump_ini(settings, file); |
tobyspark | 43:328d851c429a | 347 | fclose(file); |
tobyspark | 43:328d851c429a | 348 | } |
tobyspark | 43:328d851c429a | 349 | |
tobyspark | 43:328d851c429a | 350 | iniparser_freedict(settings); |
tobyspark | 43:328d851c429a | 351 | |
tobyspark | 43:328d851c429a | 352 | return (success == 0); |
tobyspark | 11:0783cfbeb746 | 353 | } |
tobyspark | 11:0783cfbeb746 | 354 | |
tobyspark | 11:0783cfbeb746 | 355 | protected: |
tobyspark | 11:0783cfbeb746 | 356 | LocalFileSystem *local; |
tobyspark | 31:01845a2347ff | 357 | vector< vector<int> > keyerParamSets; |
tobyspark | 31:01845a2347ff | 358 | vector<string> keyerParamNames; |
tobyspark | 31:01845a2347ff | 359 | vector<string> resolutionNames; |
tobyspark | 31:01845a2347ff | 360 | vector<int32_t> resolutionIndexes; |
tobyspark | 31:01845a2347ff | 361 | vector<int32_t> resolutionEDIDIndexes; |
tobyspark | 16:52484666b323 | 362 | }; |