Commit ba611bec authored by David Košenina's avatar David Košenina

measure precision

parent 53d3f0b6
......@@ -1088,18 +1088,17 @@ void DoubleToString(char* buffer, int size, double value, char* unit)
{
FORMAT_BUFFER();
double cmp = fabs(value);
if(value >= MAX_DOUBLE) FORMAT("max %s", unit)
else if(value <= -MAX_DOUBLE) FORMAT("min %s", unit)
else if(value == 0.0) FORMAT("zero %s", unit)
else if(cmp <= DOUBLE_PIKO) FORMAT("%.3f pico %s", value * DOUBLE_TERA, unit)
else if(cmp <= DOUBLE_NANO) FORMAT("%.3f nano %s", value * DOUBLE_GIGA, unit)
else if(cmp <= DOUBLE_MICRO) FORMAT("%.3f micro %s", value * DOUBLE_MEGA, unit)
else if(cmp <= DOUBLE_MILI) FORMAT("%.3f mili %s", value * DOUBLE_KILO, unit)
else if(cmp >= DOUBLE_TERA) FORMAT("%.3f tera %s", value / DOUBLE_TERA, unit)
else if(cmp >= DOUBLE_GIGA) FORMAT("%.3f giga %s", value / DOUBLE_GIGA, unit)
else if(cmp >= DOUBLE_MEGA) FORMAT("%.3f mega %s", value / DOUBLE_MEGA, unit)
else if(cmp >= DOUBLE_KILO) FORMAT("%.3f kilo %s", value / DOUBLE_KILO, unit)
else { FORMAT("%.3f %s", value, unit); }
if(value >= MAX_DOUBLE/100) FORMAT("max %s", unit)
else if(value <= -MAX_DOUBLE/100) FORMAT("min %s", unit)
else if(value == 0.0) FORMAT("0%s", unit)
else if(cmp < 100*DOUBLE_GIGA && cmp >= 100*DOUBLE_MEGA) FORMAT("%.3f G%s", value / DOUBLE_GIGA, unit)
else if(cmp < 100*DOUBLE_MEGA && cmp >= 100*DOUBLE_KILO) FORMAT("%.3f M%s", value / DOUBLE_MEGA, unit)
else if(cmp < 100*DOUBLE_KILO && cmp >= 100) FORMAT("%.3f k%s", value / DOUBLE_KILO, unit)
else if(cmp < 100 && cmp >= 0.1) FORMAT("%.3f %s", value, unit)
else if(cmp < 100*DOUBLE_MILI && cmp >= 100*DOUBLE_MICRO) FORMAT("%.3f m%s", value*DOUBLE_KILO, unit)
else if(cmp < 100*DOUBLE_MICRO && cmp >= 100*DOUBLE_NANO) FORMAT("%.3f u%s", value*DOUBLE_MEGA, unit)
else if(cmp < 100*DOUBLE_NANO && cmp >= 100*DOUBLE_PIKO) FORMAT("%.3f n%s", value*DOUBLE_GIGA, unit)
else FORMAT("%.3f n%s", value*DOUBLE_GIGA, unit);
memcpy(buffer, formatBuffer, FORMAT_BUFFER_SIZE);
}
......
......@@ -1876,8 +1876,8 @@ bool OsciloscopeManager::onApplicationIdle()
renderData.shadowCoolingShader = shadowCoolingShader;
renderData.analogChannelYVoltageStep0 = settings.getHardware()->getAnalogStep(window.horizontal.Capture, 0, window.channel01.Capture);
renderData.analogChannelYVoltageStep1 = settings.getHardware()->getAnalogStep(window.horizontal.Capture, 1, window.channel02.Capture);
renderData.analogChannelOffsets0 = settings.getHardware()->getAnalogOffset(window.horizontal.Capture, 0, window.channel01.Capture);
renderData.analogChannelOffsets1 = settings.getHardware()->getAnalogOffset(window.horizontal.Capture, 1, window.channel02.Capture);
renderData.analogChannelOffsets0 = settings.getHardware()->getAnalogOffsetDouble(window.horizontal.Capture, 0, window.channel01.Capture);
renderData.analogChannelOffsets1 = settings.getHardware()->getAnalogOffsetDouble(window.horizontal.Capture, 1, window.channel02.Capture);
renderData.analogChannelPositin0 = control.getYPositionA();
renderData.analogChannelPositin1 = control.getYPositionB();
renderData.colorBackground = settings.getColors()->renderBackground;
......
......@@ -980,9 +980,9 @@ void OsciloscopeThreadRenderer::measureSignal(uint threadId, OsciloscopeThreadDa
{
periodF += timeF[i];
}
period0 /= (time0.getCount() / 2);
period1 /= (time1.getCount() / 2);
periodF /= (timeF.getCount() / 2);
period0 /= max(1,(time0.getCount() / 2));
period1 /= max(1,(time1.getCount() / 2));
periodF /= max(1,(timeF.getCount() / 2));
current.row[Ch0Tperiod] = period0;
current.row[Ch1Tperiod] = period1;
current.row[FunTperiod] = periodF;
......
......@@ -303,6 +303,14 @@ int OscHardware::getAnalogOffset(float time, int ch, float volt)
return callibratedOffsets[type][ch][index];
}
double OscHardware::getAnalogOffsetDouble(float time, int ch, float volt)
{
ECallibrationType type = getCallibrationType(time);
uint index = captureVoltFromValue(volt);
int offset = callibratedOffsets[type][ch][index];
double koeficient = 10*double( captureVoltFromEnum(index) ) / 1024.0;
return koeficient*offset;
}
double OscHardware::getAnalogStep(float time, int ch, float volt)
{
ECallibrationType type = getCallibrationType(time);
......
......@@ -73,6 +73,7 @@ public:
SUsb getUSB();
public:
int getAnalogOffset(float time, int ch, float volt);
double getAnalogOffsetDouble(float time, int ch, float volt);
double getAnalogStep(float time, int ch, float volt);
ushort getAnalogGain(float time, int ch, float volt);
int getGeneratorOffset(float time, int ch);
......
......@@ -649,7 +649,7 @@ void ToolText::Time(char* buffer, int size, double value)
}
else if(absvalue >= DOUBLE_MILI)
{
pFormat->formatString(buffer, size, "%.3f ms", value * DOUBLE_KILO);
pFormat->formatString(buffer, size, "%.3f ms", value*DOUBLE_KILO);
}
else if(absvalue >= DOUBLE_MICRO)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment