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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user