adc invert for highz (#59)

This commit is contained in:
Dhanya Thattil
2019-08-29 10:12:10 +02:00
committed by GitHub
parent 1980a7d80c
commit 4f0634fe62
4 changed files with 84 additions and 13 deletions

View File

@ -416,6 +416,11 @@ void qDrawPlot::EnableGainPlot(bool enable) {
hasGainData = enable;
}
void qDrawPlot::EnableADCInvert(bool enable) {
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " ADC Invert";
isADCInvert = enable;
}
void qDrawPlot::SetSaveFileName(QString val) {
FILE_LOG(logDEBUG) << "Setting Clone/Save File Name to " << val.toAscii().constData();
fileSaveName = val;
@ -895,25 +900,62 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
// show gain plot
if (gaindest != NULL) {
for (ichan = 0; ichan < size; ++ichan) {
if ((*((u_int16_t *)source)) == 0xFFFF) {
gaindest[ichan] = 0xFFFF;
dest[ichan] = 0xFFFF;
} else {
gaindest[ichan] =
(((*((u_int16_t *)source)) & 0xC000) >> 14);
dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF);
// adcinvert
if (isADCInvert) {
for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source));
if (temp == 0xFFFF) {
gaindest[ichan] = 0xFFFF;
dest[ichan] = 0xFFFF;
} else {
gaindest[ichan] = ((temp & 0xC000) >> 14);
dest[ichan] = 0x4000 - (temp & 0x3FFF);
}
source += 2;
}
}
// normal
else {
for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source));
if (temp == 0xFFFF) {
gaindest[ichan] = 0xFFFF;
dest[ichan] = 0xFFFF;
} else {
gaindest[ichan] = ((temp & 0xC000) >> 14);
dest[ichan] = (temp & 0x3FFF);
}
source += 2;
}
source += 2;
}
}
// only data plot
else {
for (ichan = 0; ichan < size; ++ichan) {
dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF);
source += 2;
// adcinvert
if (isADCInvert) {
for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source));
if (temp == 0xFFFF) {
dest[ichan] = 0xFFFF;
} else {
dest[ichan] = 0x4000 - (temp & 0x3FFF);
}
source += 2;
}
}
// normal
else {
for (ichan = 0; ichan < size; ++ichan) {
uint16_t temp = (*((u_int16_t *)source));
if (temp == 0xFFFF) {
dest[ichan] = 0xFFFF;
} else {
dest[ichan] = (temp & 0x3FFF);
}
source += 2;
}
}
}
break;
}