SR_CONF_LIMIT_FRAMES | SR_CONF_SET,
SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_NUM_HDIV | SR_CONF_GET,
- SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET,
SR_CONF_BUFFERSIZE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
devc->framesize = DEFAULT_FRAMESIZE;
devc->triggerslope = SLOPE_POSITIVE;
devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
- devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
+ devc->capture_ratio = DEFAULT_CAPTURE_RATIO;
sdi->priv = devc;
return sdi;
s = (devc->triggerslope == SLOPE_POSITIVE) ? "r" : "f";
*data = g_variant_new_string(s);
break;
- case SR_CONF_HORIZ_TRIGGERPOS:
- *data = g_variant_new_double(devc->triggerposition);
+ case SR_CONF_CAPTURE_RATIO:
+ *data = g_variant_new_uint64(devc->capture_ratio);
break;
default:
return SR_ERR_NA;
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- double tmp_double;
+ int rat;
int ch_idx, idx;
devc = sdi->priv;
return SR_ERR_ARG;
devc->triggerslope = idx;
break;
- case SR_CONF_HORIZ_TRIGGERPOS:
- tmp_double = g_variant_get_double(data);
- if (tmp_double < 0.0 || tmp_double > 1.0) {
- sr_err("Trigger position should be between 0.0 and 1.0.");
+ case SR_CONF_CAPTURE_RATIO:
+ rat = g_variant_get_uint64(data);
+ if (rat < 0 || rat > 100) {
+ sr_err("Capture ratio must be in [0,100].");
return SR_ERR_ARG;
} else
- devc->triggerposition = tmp_double;
+ devc->capture_ratio = rat;
break;
case SR_CONF_BUFFERSIZE:
if ((idx = std_u64_idx(data, devc->profile->buffersizes, NUM_BUFFER_SIZES)) < 0)
devc->samplerate = samplerates[idx];
if (dso_set_trigger_samplerate(sdi) != SR_OK)
return SR_ERR;
+ sr_dbg("got new sample rate %d, idx %d", devc->samplerate, idx);
break;
case SR_CONF_TRIGGER_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0)
return SR_OK;
}
+
+static void dso2250_set_triggerpos(int value, int long_buffer, uint8_t dest[], int offset)
+{
+ uint32_t min, max;
+ uint32_t tmp, diff;
+
+ min = long_buffer ? 0 : 0x7d7ff;
+ max = 0x7ffff;
+
+ diff = max - min;
+ tmp = min + diff * value / 100;
+ sr_dbg("2250 trigger pos: %3d%% * [0x%x,0x%x] == 0x%x", value, min, max, tmp);
+
+ dest[offset + 0] = tmp & 0xff;
+ dest[offset + 1] = (tmp >> 8) & 0xff;
+ dest[offset + 2] = (tmp >> 16) & 0x7;
+}
+
+
/* See http://openhantek.sourceforge.net/doc/namespaceHantek.html#ac1cd181814cf3da74771c29800b39028 */
static int dso2250_set_trigger_samplerate(const struct sr_dev_inst *sdi)
{
int ret, tmp;
int base;
uint8_t cmdstring[12];
+ int trig;
devc = sdi->priv;
memset(cmdstring, 0, sizeof(cmdstring));
cmdstring[0] = CMD_2250_SET_TRIGGERPOS_AND_BUFFER;
- /* TODO for big buffer */
- sr_dbg("Trigger position: %3.2f.", devc->triggerposition);
-// tmp = 0x77fff + 0x8000 * devc->triggerposition;
-// cmdstring[6] = tmp & 0xff;
-// cmdstring[7] = (tmp >> 8) & 0xff;
-// cmdstring[10] = (tmp >> 16) & 0xff;
-
- cmdstring[2]=0xff;
- cmdstring[3]=0xff;
- cmdstring[4]=0x07;
-
- cmdstring[6]=0xff;
- cmdstring[7]=0xd7;
- cmdstring[8]=0x07;
+ sr_dbg("Capture ratio: %d.", devc->capture_ratio);
+ trig = devc->capture_ratio;
+ dso2250_set_triggerpos(trig,
+ devc->framesize != FRAMESIZE_SMALL, cmdstring, 2);
+ dso2250_set_triggerpos(100 - trig,
+ devc->framesize != FRAMESIZE_SMALL, cmdstring, 6);
if (send_begin(sdi) != SR_OK)
return SR_ERR;
cmdstring[5] = (tmp >> 8) & 0xff;
/* Horizontal trigger position */
- sr_dbg("Trigger position: %3.2f.", devc->triggerposition);
- tmp = 0x77fff + 0x8000 * devc->triggerposition;
+ sr_dbg("Capture ratio: %d.", devc->capture_ratio);
+ tmp = 0x77fff + 0x8000 * devc->capture_ratio / 100;
cmdstring[6] = tmp & 0xff;
cmdstring[7] = (tmp >> 8) & 0xff;
cmdstring[10] = (tmp >> 16) & 0xff;
#define DEFAULT_SAMPLERATE SR_KHZ(10)
#define DEFAULT_TRIGGER_SOURCE "CH1"
#define DEFAULT_COUPLING COUPLING_DC
-#define DEFAULT_HORIZ_TRIGGERPOS 0.5
+#define DEFAULT_CAPTURE_RATIO 100
#define DEFAULT_VERT_OFFSET 0.5
#define DEFAULT_VERT_TRIGGERPOS 0.5
gboolean filter[2];
int triggerslope;
char *triggersource;
- float triggerposition;
+ int capture_ratio;
int triggermode;
/* Frame transfer */