New scope: implemented trace delay

pull/27/head
f4exb 2017-02-17 01:54:55 +01:00
rodzic eaffa127b8
commit 06dc97c91c
5 zmienionych plików z 104 dodań i 29 usunięć

Wyświetl plik

@ -88,7 +88,8 @@ void ScopeVisNG::changeTrace(const TraceData& traceData, uint32_t traceIndex)
qDebug() << "ScopeVisNG::changeTrace:" qDebug() << "ScopeVisNG::changeTrace:"
<< " trace: " << traceIndex << " trace: " << traceIndex
<< " m_amp: " << traceData.m_amp << " m_amp: " << traceData.m_amp
<< " m_ofs: " << traceData.m_ofs; << " m_ofs: " << traceData.m_ofs
<< " m_traceDelay: " << traceData.m_traceDelay;
Message* cmd = MsgScopeVisNGChangeTrace::create(traceData, traceIndex); Message* cmd = MsgScopeVisNGChangeTrace::create(traceData, traceIndex);
getInputMessageQueue()->push(cmd); getInputMessageQueue()->push(cmd);
} }

Wyświetl plik

@ -57,7 +57,8 @@ public:
int m_ofsCoarse; //!< Coarse offset slider value int m_ofsCoarse; //!< Coarse offset slider value
int m_ofsFine; //!< Fine offset slider value int m_ofsFine; //!< Fine offset slider value
int m_traceDelay; //!< Trace delay in number of samples int m_traceDelay; //!< Trace delay in number of samples
int m_traceDelayValue; //!< Trace delay slider value int m_traceDelayCoarse; //!< Coarse delay slider value
int m_traceDelayFine; //!< Fine delay slider value
float m_triggerDisplayLevel; //!< Displayable trigger display level in -1:+1 scale. Off scale if not displayable. float m_triggerDisplayLevel; //!< Displayable trigger display level in -1:+1 scale. Off scale if not displayable.
QColor m_traceColor; //!< Trace display color QColor m_traceColor; //!< Trace display color
float m_traceColorR; //!< Trace display color - red shortcut float m_traceColorR; //!< Trace display color - red shortcut
@ -73,7 +74,8 @@ public:
m_ofsCoarse(0), m_ofsCoarse(0),
m_ofsFine(0), m_ofsFine(0),
m_traceDelay(0), m_traceDelay(0),
m_traceDelayValue(0), m_traceDelayCoarse(0),
m_traceDelayFine(0),
m_triggerDisplayLevel(2.0), // OVer scale by default (2.0) m_triggerDisplayLevel(2.0), // OVer scale by default (2.0)
m_traceColor(255,255,64) m_traceColor(255,255,64)
{ {

Wyświetl plik

@ -113,6 +113,7 @@ void GLScopeNGGUI::setBuddies(MessageQueue* messageQueue, ScopeVisNG* scopeVis,
setTimeOfsDisplay(); setTimeOfsDisplay();
setAmpScaleDisplay(); setAmpScaleDisplay();
setAmpOfsDisplay(); setAmpOfsDisplay();
setTraceDelayDisplay();
} }
void GLScopeNGGUI::setSampleRate(int sampleRate) void GLScopeNGGUI::setSampleRate(int sampleRate)
@ -128,6 +129,7 @@ void GLScopeNGGUI::on_scope_sampleRateChanged(int sampleRate)
setTraceLenDisplay(); setTraceLenDisplay();
setTimeScaleDisplay(); setTimeScaleDisplay();
setTimeOfsDisplay(); setTimeOfsDisplay();
setTraceDelayDisplay();
} }
void GLScopeNGGUI::resetToDefaults() void GLScopeNGGUI::resetToDefaults()
@ -236,6 +238,7 @@ void GLScopeNGGUI::on_time_valueChanged(int value)
{ {
m_timeBase = value; m_timeBase = value;
setTimeScaleDisplay(); setTimeScaleDisplay();
setTraceDelayDisplay();
m_glScope->setTimeBase(m_timeBase); m_glScope->setTimeBase(m_timeBase);
} }
@ -395,9 +398,16 @@ void GLScopeNGGUI::on_ofsFine_valueChanged(int value)
changeCurrentTrace(); changeCurrentTrace();
} }
void GLScopeNGGUI::on_traceDelay_valueChanged(int value) void GLScopeNGGUI::on_traceDelayCoarse_valueChanged(int value)
{ {
// TODO setTraceDelayDisplay();
changeCurrentTrace();
}
void GLScopeNGGUI::on_traceDelayFine_valueChanged(int value)
{
setTraceDelayDisplay();
changeCurrentTrace();
} }
void GLScopeNGGUI::on_traceColor_clicked() void GLScopeNGGUI::on_traceColor_clicked()
@ -671,6 +681,29 @@ void GLScopeNGGUI::setAmpOfsDisplay()
} }
} }
void GLScopeNGGUI::setTraceDelayDisplay()
{
int n_samples = ui->traceDelayCoarse->value()*100 + ui->traceDelayFine->value();
double t = ((double) n_samples) / m_sampleRate;
if (n_samples < 1000) {
ui->traceDelayText->setToolTip(tr("%1 S").arg(n_samples));
} else if (n_samples < 1000000) {
ui->traceDelayText->setToolTip(tr("%1 kS").arg(n_samples/1000.0));
} else {
ui->traceDelayText->setToolTip(tr("%1 MS").arg(n_samples/1000000.0));
}
if(t < 0.000001)
ui->traceDelayText->setText(tr("%1\nns").arg(t * 1000000000.0, 0, 'f', 2));
else if(t < 0.001)
ui->traceDelayText->setText(tr("%1\nµs").arg(t * 1000000.0, 0, 'f', 2));
else if(t < 1.0)
ui->traceDelayText->setText(tr("%1\nms").arg(t * 1000.0, 0, 'f', 2));
else
ui->traceDelayText->setText(tr("%1\ns").arg(t * 1.0, 0, 'f', 2));
}
void GLScopeNGGUI::setTrigIndexDisplay() void GLScopeNGGUI::setTrigIndexDisplay()
{ {
ui->trigText->setText(tr("%1").arg(ui->trig->value())); ui->trigText->setText(tr("%1").arg(ui->trig->value()));
@ -782,8 +815,6 @@ void GLScopeNGGUI::fillTraceData(ScopeVisNG::TraceData& traceData)
traceData.m_inputIndex = 0; traceData.m_inputIndex = 0;
traceData.m_amp = 0.2 / amps[ui->amp->value()]; traceData.m_amp = 0.2 / amps[ui->amp->value()];
traceData.m_ampIndex = ui->amp->value(); traceData.m_ampIndex = ui->amp->value();
traceData.m_traceDelay = 0; // TODO
traceData.m_traceDelayValue = 0; // TODO
traceData.m_ofsCoarse = ui->ofsCoarse->value(); traceData.m_ofsCoarse = ui->ofsCoarse->value();
traceData.m_ofsFine = ui->ofsFine->value(); traceData.m_ofsFine = ui->ofsFine->value();
@ -794,6 +825,10 @@ void GLScopeNGGUI::fillTraceData(ScopeVisNG::TraceData& traceData)
traceData.m_ofs = ((10.0 * ui->ofsCoarse->value()) + (ui->ofsFine->value() / 20.0)) / 1000.0f; traceData.m_ofs = ((10.0 * ui->ofsCoarse->value()) + (ui->ofsFine->value() / 20.0)) / 1000.0f;
} }
traceData.m_traceDelayCoarse = ui->traceDelayCoarse->value();
traceData.m_traceDelayFine = ui->traceDelayFine->value();
traceData.m_traceDelay = traceData.m_traceDelayCoarse * 100 + traceData.m_traceDelayFine;
traceData.setColor(m_focusedTraceColor); traceData.setColor(m_focusedTraceColor);
} }
@ -816,14 +851,15 @@ void GLScopeNGGUI::fillTriggerData(ScopeVisNG::TriggerData& triggerData)
void GLScopeNGGUI::setTraceUI(ScopeVisNG::TraceData& traceData) void GLScopeNGGUI::setTraceUI(ScopeVisNG::TraceData& traceData)
{ {
bool oldStateTraceMode = ui->traceMode->blockSignals(true); bool oldStateTraceMode = ui->traceMode->blockSignals(true);
bool oldStateAmp = ui->amp->blockSignals(true); bool oldStateAmp = ui->amp->blockSignals(true);
bool oldStateOfsCoarse = ui->ofsCoarse->blockSignals(true); bool oldStateOfsCoarse = ui->ofsCoarse->blockSignals(true);
bool oldStateOfsFine = ui->ofsFine->blockSignals(true); bool oldStateOfsFine = ui->ofsFine->blockSignals(true);
bool oldStateTraceDelay = ui->traceDelay->blockSignals(true); bool oldStateTraceDelayCoarse = ui->traceDelayCoarse->blockSignals(true);
bool oldStateZSelect = ui->zSelect->blockSignals(true); bool oldStateTraceDelayFine = ui->traceDelayFine->blockSignals(true);
bool oldStateZTraceMode = ui->zTraceMode->blockSignals(true); bool oldStateZSelect = ui->zSelect->blockSignals(true);
bool oldStateTraceColor = ui->traceColor->blockSignals(true); bool oldStateZTraceMode = ui->zTraceMode->blockSignals(true);
bool oldStateTraceColor = ui->traceColor->blockSignals(true);
ui->traceMode->setCurrentIndex((int) traceData.m_projectionType); ui->traceMode->setCurrentIndex((int) traceData.m_projectionType);
ui->amp->setValue(traceData.m_ampIndex); ui->amp->setValue(traceData.m_ampIndex);
@ -833,8 +869,9 @@ void GLScopeNGGUI::setTraceUI(ScopeVisNG::TraceData& traceData)
ui->ofsFine->setValue(traceData.m_ofsFine); ui->ofsFine->setValue(traceData.m_ofsFine);
setAmpOfsDisplay(); setAmpOfsDisplay();
ui->traceDelay->setValue(traceData.m_traceDelayValue); ui->traceDelayCoarse->setValue(traceData.m_traceDelayCoarse);
// TODO: set trace delay display ui->traceDelayFine->setValue(traceData.m_traceDelayFine);
setTraceDelayDisplay();
m_focusedTraceColor = traceData.m_traceColor; m_focusedTraceColor = traceData.m_traceColor;
int r, g, b, a; int r, g, b, a;
@ -845,7 +882,8 @@ void GLScopeNGGUI::setTraceUI(ScopeVisNG::TraceData& traceData)
ui->amp->blockSignals(oldStateAmp); ui->amp->blockSignals(oldStateAmp);
ui->ofsCoarse->blockSignals(oldStateOfsCoarse); ui->ofsCoarse->blockSignals(oldStateOfsCoarse);
ui->ofsFine->blockSignals(oldStateOfsFine); ui->ofsFine->blockSignals(oldStateOfsFine);
ui->traceDelay->blockSignals(oldStateTraceDelay); ui->traceDelayCoarse->blockSignals(oldStateTraceDelayCoarse);
ui->traceDelayFine->blockSignals(oldStateTraceDelayFine);
ui->zSelect->blockSignals(oldStateZSelect); ui->zSelect->blockSignals(oldStateZSelect);
ui->zTraceMode->blockSignals(oldStateZTraceMode); ui->zTraceMode->blockSignals(oldStateZTraceMode);
ui->traceColor->blockSignals(oldStateTraceColor); ui->traceColor->blockSignals(oldStateTraceColor);

Wyświetl plik

@ -74,6 +74,7 @@ private:
// Second row // Second row
void setAmpScaleDisplay(); void setAmpScaleDisplay();
void setAmpOfsDisplay(); void setAmpOfsDisplay();
void setTraceDelayDisplay();
// Third row // Third row
void setTrigIndexDisplay(); void setTrigIndexDisplay();
void setTrigCountDisplay(); void setTrigCountDisplay();
@ -112,7 +113,8 @@ private slots:
void on_amp_valueChanged(int value); void on_amp_valueChanged(int value);
void on_ofsCoarse_valueChanged(int value); void on_ofsCoarse_valueChanged(int value);
void on_ofsFine_valueChanged(int value); void on_ofsFine_valueChanged(int value);
void on_traceDelay_valueChanged(int value); void on_traceDelayCoarse_valueChanged(int value);
void on_traceDelayFine_valueChanged(int value);
void on_traceColor_clicked(); void on_traceColor_clicked();
// Third row // Third row
void on_trig_valueChanged(int value); void on_trig_valueChanged(int value);

Wyświetl plik

@ -407,7 +407,7 @@
<number>1</number> <number>1</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>100</number> <number>20</number>
</property> </property>
<property name="pageStep"> <property name="pageStep">
<number>1</number> <number>1</number>
@ -833,7 +833,7 @@ kS/s</string>
<widget class="QLabel" name="traceDelayText"> <widget class="QLabel" name="traceDelayText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>32</width> <width>40</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -846,17 +846,49 @@ kS/s</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSlider" name="traceDelay"> <layout class="QVBoxLayout" name="traceDelayLayout">
<property name="maximum"> <property name="spacing">
<number>100</number> <number>2</number>
</property> </property>
<property name="pageStep"> <property name="leftMargin">
<number>1</number> <number>0</number>
</property> </property>
<property name="orientation"> <property name="topMargin">
<enum>Qt::Horizontal</enum> <number>0</number>
</property> </property>
</widget> <property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSlider" name="traceDelayCoarse">
<property name="maximum">
<number>48</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="traceDelayFine">
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="Line" name="line_17"> <widget class="Line" name="line_17">