Updated menu. Can now preview presets and preset number is shown when selected and when repair is in process

Fixed negative value handling in DAConverter and ADConverter 

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@267 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-26 12:08:32 +00:00
parent 9a0d6a2288
commit a50a10995f
8 changed files with 153 additions and 45 deletions

View File

@@ -107,9 +107,10 @@ static uint32_t calculateDACValue(const struct DAConverter* self, int voltage)
uint32_t dacValue;
if (self->initialized)
{
uint32_t maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
dacValue = (abs(voltage) - abs(self->minVoltage)) * maxDacValue;
dacValue/= (abs(self->maxVoltage) - abs(self->minVoltage));
int maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
int tempValue = (voltage - self->minVoltage) * maxDacValue;
tempValue /= (self->maxVoltage - self->minVoltage);
dacValue = abs(tempValue);
if (dacValue > maxDacValue)
{
dacValue = maxDacValue;