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
Revision 43:328d851c429a, committed 2012-12-02
- Comitter:
- tobyspark
- Date:
- Sun Dec 02 16:13:31 2012 +0000
- Parent:
- 41:00d1cd3b2af2
- Commit message:
- 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.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
spk_settings.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Dec 02 01:08:34 2012 +0000 +++ b/main.cpp Sun Dec 02 16:13:31 2012 +0000 @@ -931,7 +931,7 @@ value); screen.textToBuffer(paramLine, kMenuLine2); - tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, value); + tvOne.command(0, kTV1WindowIDA, kTV1FunctionAdjustKeyerMaxV, value); } } else @@ -1070,6 +1070,14 @@ settings.editingKeyerSetValue(SPKSettings::maxV)); screen.textToBuffer(paramLine, kMenuLine2); } + else if (selectedMenu == &mixModeMenu) + { + // We should save the keyer parameter set if it was updated + if (settings.editingKeyerSetIndex != -1) + { + settings.saveEditingKeyerSet(kSPKDFSettingsFilename); + } + } } // With that out of the way, we should be actioning a specific menu's payload? else if (selectedMenu == &resolutionMenu)
--- a/spk_settings.h Sun Dec 02 01:08:34 2012 +0000 +++ b/spk_settings.h Sun Dec 02 16:13:31 2012 +0000 @@ -151,7 +151,7 @@ { bool success = false; - local = new LocalFileSystem("local"); + LocalFileSystem local("local"); string filePath("/local/"); filePath += filename; @@ -287,9 +287,69 @@ iniparser_freedict(settings); - delete local; + return success; + } + + + bool saveEditingKeyerSet(string filename) + { + int success = 0; + + LocalFileSystem local("local"); + string filePath("/local/"); + filePath += filename; + + dictionary* settings = iniparser_load(filePath.c_str()); + + const int keyLength = 11; + const int valueLength = 3; + + char keyMinY[keyLength]; + char valueMinY[valueLength]; + snprintf(keyMinY, keyLength, "Key%i:MinY", editingKeyerSetIndex); + snprintf(valueMinY, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minY]); + success += iniparser_set(settings, keyMinY, valueMinY); + + char keyMaxY[keyLength]; + char valueMaxY[valueLength]; + snprintf(keyMaxY, keyLength, "Key%i:MaxY", editingKeyerSetIndex); + snprintf(valueMaxY, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxY]); + success += iniparser_set(settings, keyMaxY, valueMaxY); - return success; + char keyMinU[keyLength]; + char valueMinU[valueLength]; + snprintf(keyMinU, keyLength, "Key%i:MinU", editingKeyerSetIndex); + snprintf(valueMinU, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minU]); + success += iniparser_set(settings, keyMinU, valueMinU); + + char keyMaxU[keyLength]; + char valueMaxU[valueLength]; + snprintf(keyMaxU, keyLength, "Key%i:MaxU", editingKeyerSetIndex); + snprintf(valueMaxU, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxU]); + success += iniparser_set(settings, keyMaxU, valueMaxU); + + char keyMinV[keyLength]; + char valueMinV[valueLength]; + snprintf(keyMinV, keyLength, "Key%i:MinV", editingKeyerSetIndex); + snprintf(valueMinV, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][minV]); + success += iniparser_set(settings, keyMinV, valueMinV); + + char keyMaxV[keyLength]; + char valueMaxV[valueLength]; + snprintf(keyMaxV, keyLength, "Key%i:MaxV", editingKeyerSetIndex); + snprintf(valueMaxV, valueLength, "%i", keyerParamSets[editingKeyerSetIndex][maxV]); + success += iniparser_set(settings, keyMaxV, valueMaxV); + + FILE* file = fopen(filePath.c_str(), "w"); + if (file) + { + iniparser_dump_ini(settings, file); + fclose(file); + } + + iniparser_freedict(settings); + + return (success == 0); } protected: