Extend timebase range @ dso mode

This commit is contained in:
DreamSourceLab 2019-11-24 00:17:48 -08:00
parent 84a7e6a33e
commit c5c12248c0
9 changed files with 76 additions and 10 deletions

View File

@ -441,7 +441,7 @@ void MainWindow::update_device_list()
// USB device speed check
if (!selected_device->name().contains("virtual")) {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);

View File

@ -375,6 +375,18 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
fprintf(meta, "hDiv = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE);
if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
fprintf(meta, "hDiv max = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
fprintf(meta, "hDiv min = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
if (gvar != NULL) {
uint8_t tmp_u8 = g_variant_get_byte(gvar);

View File

@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "samplingbar.h"
#include <extdef.h>
#include <assert.h>
#include <boost/foreach.hpp>
@ -30,7 +32,6 @@
#include <QAbstractItemView>
#include <QApplication>
#include "samplingbar.h"
#include "../devicemanager.h"
#include "../device/devinst.h"
#include "../dialogs/deviceoptions.h"
@ -156,7 +157,7 @@ void SamplingBar::retranslateUi()
else if (dev_inst->name().contains("virtual"))
_device_type.setText(tr("File"));
else {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
@ -203,7 +204,7 @@ void SamplingBar::reStyle()
else if (dev_inst->name().contains("virtual"))
_device_type.setIcon(QIcon(":/icons/data.png"));
else {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
@ -521,6 +522,7 @@ void SamplingBar::update_sample_count_selector()
uint64_t sw_depth;
uint64_t rle_depth = 0;
uint64_t max_timebase = 0;
uint64_t min_timebase = SR_NS(10);
double pre_duration = SR_SEC(1);
double duration;
bool rle_support = false;
@ -574,6 +576,11 @@ void SamplingBar::update_sample_count_selector()
max_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL) {
min_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
}
if (0 != _sample_count.count())
@ -626,7 +633,7 @@ void SamplingBar::update_sample_count_selector()
unit == SR_MIN(1) ? SR_SEC(50) : duration * 0.5);
if (dev_inst->dev_inst()->mode == DSO)
not_last = duration >= SR_NS(10);
not_last = duration >= min_timebase;
else if (dev_inst->dev_inst()->mode == ANALOG)
not_last = (duration >= SR_MS(100)) &&
(duration / SR_SEC(1) * samplerate >= SR_KB(1));
@ -957,6 +964,11 @@ void SamplingBar::enable_toggle(bool enable)
_sample_count.setDisabled(true);
_sample_rate.setDisabled(true);
}
if (_session.get_device()->name() == "virtual-session") {
_sample_count.setDisabled(true);
_sample_rate.setDisabled(true);
}
}
void SamplingBar::enable_run_stop(bool enable)
@ -1005,6 +1017,7 @@ void SamplingBar::reload()
_instant_action->setVisible(true);
enable_toggle(true);
}
retranslateUi();
reStyle();
update();

View File

@ -23,6 +23,8 @@
#ifndef DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H
#define DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H
#include "../sigsession.h"
#include <stdint.h>
#include <list>
#include <map>
@ -35,8 +37,6 @@
#include <QAction>
#include <QMenu>
#include "../sigsession.h"
struct st_dev_inst;
class QAction;
@ -67,7 +67,7 @@ private:
static const uint64_t AnalogMaxSWDepth = SR_Mn(100);
static const QString RLEString;
static const QString DIVString;
static const uint64_t ZeroTimeBase = SR_US(10);
static const uint64_t ZeroTimeBase = SR_US(2);
public:
SamplingBar(SigSession &session, QWidget *parent);

View File

@ -1248,6 +1248,11 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
channel_modes[devc->ch_mode].min_samplerate /
DS_CONF_DSO_HDIVS));
break;
case SR_CONF_MIN_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(SR_SEC(1) / channel_modes[devc->ch_mode].hw_max_samplerate);
break;
case SR_CONF_PROBE_COUPLING:
if (!ch)
return SR_ERR;

View File

@ -347,6 +347,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_MIN_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(MIN_TIMEBASE);
break;
case SR_CONF_PROBE_COUPLING:
*data = g_variant_new_byte(ch->coupling);
break;

View File

@ -129,6 +129,7 @@ enum {
* Oscilloscope
*/
#define MAX_TIMEBASE SR_SEC(10)
#define MIN_TIMEBASE SR_NS(10)
extern char DS_RES_PATH[256];
@ -842,6 +843,7 @@ enum {
/** Time base. */
SR_CONF_MAX_TIMEBASE,
SR_CONF_MIN_TIMEBASE,
SR_CONF_TIMEBASE,
/** Filter. */

View File

@ -85,6 +85,8 @@ struct session_vdev {
int num_probes;
int enabled_probes;
uint64_t timebase;
uint64_t max_timebase;
uint64_t min_timebase;
uint8_t unit_bits;
uint32_t ref_min;
uint32_t ref_max;
@ -364,6 +366,8 @@ static int dev_open(struct sr_dev_inst *sdi)
vdev->unit_bits = 1;
vdev->ref_min = 0;
vdev->ref_max = 0;
vdev->max_timebase = MAX_TIMEBASE;
vdev->min_timebase = MIN_TIMEBASE;
vdev->max_height = 0;
vdev->mstatus.measure_valid = TRUE;
@ -431,9 +435,18 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR;
break;
case SR_CONF_MAX_TIMEBASE:
if (!sdi)
if (sdi) {
vdev = sdi->priv;
*data = g_variant_new_uint64(vdev->max_timebase);
} else
return SR_ERR;
break;
case SR_CONF_MIN_TIMEBASE:
if (sdi) {
vdev = sdi->priv;
*data = g_variant_new_uint64(vdev->min_timebase);
} else
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_UNIT_BITS:
if (sdi) {
@ -593,6 +606,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
vdev->timebase = g_variant_get_uint64(data);
sr_info("Setting timebase to %" PRIu64 ".", vdev->timebase);
break;
case SR_CONF_MAX_TIMEBASE:
vdev->max_timebase = g_variant_get_uint64(data);
sr_info("Setting max timebase to %" PRIu64 ".", vdev->max_timebase);
break;
case SR_CONF_MIN_TIMEBASE:
vdev->min_timebase = g_variant_get_uint64(data);
sr_info("Setting min timebase to %" PRIu64 ".", vdev->min_timebase);
break;
case SR_CONF_UNIT_BITS:
vdev->unit_bits = g_variant_get_byte(data);
sr_info("Setting unit bits to %d.", vdev->unit_bits);

View File

@ -220,6 +220,14 @@ SR_API int sr_session_load(const char *filename)
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "hDiv min")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_MIN_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "hDiv max")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_MAX_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "bits")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_UNIT_BITS,