![](/media/cache/profiles/89a26a363b87a87ac6a94277e841b7f4.50x50_q85.jpg)
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
Diff: spk_settings.h
- Revision:
- 28:67269c2d042b
- Parent:
- 27:27851d3d2bba
- Child:
- 31:01845a2347ff
diff -r 27851d3d2bba -r 67269c2d042b spk_settings.h --- a/spk_settings.h Sun Oct 28 16:19:04 2012 +0000 +++ b/spk_settings.h Sun Oct 28 17:21:19 2012 +0000 @@ -131,8 +131,9 @@ bool keyParamReadOK = true; bool keyParamCleared = false; - char* failString = "Failed to read"; - int failInt = -1; + char* const failString = "Failed to read"; + const int failInt = -1; + const int stringLength = 11; // Loop through [Key1,2,...,99] sections while(keyParamReadOK) @@ -140,33 +141,33 @@ int paramSet[6]; char* paramName; - char key[11]; + char key[stringLength]; - sprintf(key, "Key%i:Name", counter); + snprintf(key, stringLength, "Key%i:Name", counter); paramName = iniparser_getstring(settings, key, failString); keyParamReadOK = keyParamReadOK && strcmp(paramName, failString); - sprintf(key, "Key%i:MinY", counter); + snprintf(key, stringLength, "Key%i:MinY", counter); paramSet[0] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[0] != failInt); - sprintf(key, "Key%i:MaxY", counter); + snprintf(key, stringLength, "Key%i:MaxY", counter); paramSet[1] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[1] != failInt); - sprintf(key, "Key%i:MinU", counter); + snprintf(key, stringLength, "Key%i:MinU", counter); paramSet[2] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[2] != failInt); - sprintf(key, "Key%i:MaxU", counter); + snprintf(key, stringLength, "Key%i:MaxU", counter); paramSet[3] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[3] != failInt); - sprintf(key, "Key%i:MinV", counter); + snprintf(key, stringLength, "Key%i:MinV", counter); paramSet[4] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[4] != failInt); - sprintf(key, "Key%i:MaxV", counter); + snprintf(key, stringLength, "Key%i:MaxV", counter); paramSet[5] = iniparser_getint(settings, key, failInt); keyParamReadOK = keyParamReadOK && (paramSet[5] != failInt); @@ -201,8 +202,9 @@ bool resolutionReadOK = true; bool resolutionCleared = false; - char* failString = "Failed to read"; - int failInt = -1; + char* const failString = "Failed to read"; + const int failInt = -1; + const int stringLength = 25; // Loop through [Key1,2,...,99] sections while(resolutionReadOK) @@ -211,17 +213,17 @@ int resolutionIndex; int resolutionEDIDIndex; - char key[18]; + char key[stringLength]; - sprintf(key, "Resolution%i:Name", counter); + snprintf(key, stringLength, "Resolution%i:Name", counter); resolutionName = iniparser_getstring(settings, key, failString); resolutionReadOK = resolutionReadOK && strcmp(resolutionName, failString); - sprintf(key, "Resolution%i:Number", counter); + snprintf(key, stringLength, "Resolution%i:Number", counter); resolutionIndex = iniparser_getint(settings, key, failInt); resolutionReadOK = resolutionReadOK && (resolutionIndex != failInt); - sprintf(key, "Resolution%i:EDIDNumber", counter); + snprintf(key, stringLength, "Resolution%i:EDIDNumber", counter); resolutionEDIDIndex = iniparser_getint(settings, key, failInt); resolutionReadOK = resolutionReadOK && (resolutionEDIDIndex != failInt);