ctb: power regulators (set dac, get dac, get adc of voltage and current) works

This commit is contained in:
2019-02-20 08:45:34 +01:00
parent c93f88b7e5
commit 69f361468e
10 changed files with 286 additions and 104 deletions

View File

@ -12,7 +12,7 @@
*/
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax,
int inputValue, int* outputValue) {
FILE_LOG(logDEBUG1, ("Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
FILE_LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
inputValue, inputMin, inputMax, outputMin, outputMax));
// validate within bounds
@ -29,7 +29,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outpu
return FAIL;
}
double value = (double)((inputValue - inputMin) * (outputMax - outputMin))
double value = ((double)(inputValue - inputMin) * (double)(outputMax - outputMin))
/ (double)(inputMax - inputMin) + outputMin;
// double to integer conversion (if decimal places, round to integer)
@ -38,7 +38,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outpu
}
*outputValue = value;
FILE_LOG(logDEBUG1, ("Converted Ouput Value: %d\n", *outputValue));
FILE_LOG(logDEBUG1, (" Converted Ouput Value: %d\n", *outputValue));
return OK;
}