diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index a3fc6163..6dcb24f2 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -48,7 +48,9 @@ DsoSnapshot::DsoSnapshot() : _envelope_en = false; _envelope_done = false; _instant = false; - _threshold = 0; + _threshold = 0; + _measure_voltage_factor1 = 0; + _measure_voltage_factor2 = 0; memset(_envelope_levels, 0, sizeof(_envelope_levels)); } diff --git a/DSView/pv/data/dsosnapshot.h b/DSView/pv/data/dsosnapshot.h index 0d9725e0..1e2cd8f0 100644 --- a/DSView/pv/data/dsosnapshot.h +++ b/DSView/pv/data/dsosnapshot.h @@ -111,6 +111,22 @@ public: return _threshold; } + inline void set_measure_voltage_factor1(uint64_t v){ + _measure_voltage_factor1 = v; + } + + inline uint64_t get_measure_voltage_factor1(){ + return _measure_voltage_factor1; + } + + inline void set_measure_voltage_factor2(uint64_t v){ + _measure_voltage_factor2 = v; + } + + inline uint64_t get_measure_voltage_factor2(){ + return _measure_voltage_factor2; + } + private: void append_data(void *data, uint64_t samples, bool instant); void free_envelop(); @@ -126,6 +142,8 @@ private: bool _instant; std::vector _ch_data; float _threshold; + uint64_t _measure_voltage_factor1; + uint64_t _measure_voltage_factor2; friend class DsoSnapshotTest::Basic; }; diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 2605f6a5..192cd7ae 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -375,6 +375,21 @@ namespace pv _capture_data->get_logic()->set_samplerate(samplerate); _capture_data->get_analog()->set_samplerate(samplerate); _capture_data->get_dso()->set_samplerate(samplerate); + + if (_device_agent.get_work_mode() == DSO) + { + for(auto s : _signals){ + if (s->get_type() == SR_CHANNEL_DSO){ + view::DsoSignal *ch = (view::DsoSignal*)s; + uint64_t k = ch->get_vDial()->get_value() * ch->get_vDial()->get_factor(); + + if (ch->get_index() == 0) + _capture_data->get_dso()->set_measure_voltage_factor1(k); + else + _capture_data->get_dso()->set_measure_voltage_factor2(k); + } + } + } // DecoderStack for (auto d : _decode_traces) diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index 0920cdba..e6dfef62 100644 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -1494,12 +1494,14 @@ double DsoSignal::get_voltage(uint64_t index) if (index >= _data->get_sample_count()) return 1; + + assert(_data); const double value = *_data->get_samples(index, index, get_index()); const int hw_offset = get_hw_offset(); + uint64_t k = get_index() == 0 ? _data->get_measure_voltage_factor1() : _data->get_measure_voltage_factor2(); - return (hw_offset - value) * _scale * - _vDial->get_value() * _vDial->get_factor() * + return (hw_offset - value) * _scale * k * DS_CONF_DSO_VDIVS / get_view_rect().height(); } @@ -1513,10 +1515,14 @@ QString DsoSignal::get_voltage(double v, int p, bool scaled) assert(false); } + assert(_data); + + uint64_t k = get_index() == 0 ? _data->get_measure_voltage_factor1() : _data->get_measure_voltage_factor2(); + if (scaled) - v = v * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height(); + v = v * k * DS_CONF_DSO_VDIVS / get_view_rect().height(); else - v = v * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height(); + v = v * _scale * k * DS_CONF_DSO_VDIVS / get_view_rect().height(); return abs(v) >= 1000 ? QString::number(v/1000.0, 'f', p) + "V" : QString::number(v, 'f', p) + "mV"; }