break;
case SR_CONF_TIMEBASE:
*data = g_variant_new("(tt)",
- model->timebases[state->timebase].p,
- model->timebases[state->timebase].q);
+ (*model->timebases)[state->timebase][0],
+ (*model->timebases)[state->timebase][1]);
break;
case SR_CONF_NUM_VDIV:
for (i = 0; i < model->analog_channels; i++) {
if (cg != devc->analog_groups[i])
continue;
*data = g_variant_new("(tt)",
- model->vdivs[state->analog_channels[i].vdiv].p,
- model->vdivs[state->analog_channels[i].vdiv].q);
+ (*model->vdivs)[state->analog_channels[i].vdiv][0],
+ (*model->vdivs)[state->analog_channels[i].vdiv][1]);
}
break;
case SR_CONF_TRIGGER_SOURCE:
const struct scope_config *model;
struct scope_state *state;
const char *tmp;
- int64_t p;
- uint64_t q;
+ uint64_t p, q;
double tmp_d;
gboolean update_sample_rate;
g_variant_get(data, "(tt)", &p, &q);
for (i = 0; i < model->num_vdivs; i++) {
- if (p != model->vdivs[i].p || q != model->vdivs[i].q)
+ if (p != (*model->vdivs)[i][0] || q != (*model->vdivs)[i][1])
continue;
for (j = 1; j <= model->analog_channels; j++) {
if (cg != devc->analog_groups[j - 1])
g_variant_get(data, "(tt)", &p, &q);
for (i = 0; i < model->num_timebases; i++) {
- if (p != model->timebases[i].p ||
- q != model->timebases[i].q)
+ if (p != (*model->timebases)[i][0] ||
+ q != (*model->timebases)[i][1])
continue;
state->timebase = i;
g_snprintf(command, sizeof(command),
state->horiz_triggerpos = tmp_d;
tmp_d = -(tmp_d - 0.5) *
- ((double)model->timebases[state->timebase].p /
- model->timebases[state->timebase].q)
+ ((double)(*model->timebases)[state->timebase][0] /
+ (*model->timebases)[state->timebase][1])
* model->num_xdivs;
g_snprintf(command, sizeof(command), "TRIG POS %e S", tmp_d);
case SR_CONF_TIMEBASE:
if (!model)
return SR_ERR_ARG;
- *data = std_gvar_tuple_rational(model->timebases, model->num_timebases);
+ *data = std_gvar_tuple_array(*model->timebases, model->num_timebases);
break;
case SR_CONF_VDIV:
if (!model)
return SR_ERR_ARG;
- *data = std_gvar_tuple_rational(model->vdivs, model->num_vdivs);
+ *data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs);
break;
default:
return SR_ERR_NA;
"C1", "C2", "C3", "C4", "LINE", "EXT",
};
-static const struct sr_rational timebases[] = {
+static const uint64_t timebases[][2] = {
/* picoseconds */
{ 20, 1000000000000 },
{ 50, 1000000000000 },
{ 1000, 1 },
};
-static const struct sr_rational vdivs[] = {
+static const uint64_t vdivs[][2] = {
/* millivolts */
{ 1, 1000 },
{ 2, 1000 },
.trigger_slopes = &scope_trigger_slopes,
.num_trigger_slopes = ARRAY_SIZE(scope_trigger_slopes),
- .timebases = timebases,
+ .timebases = &timebases,
.num_timebases = ARRAY_SIZE(timebases),
- .vdivs = vdivs,
+ .vdivs = &vdivs,
.num_vdivs = ARRAY_SIZE(vdivs),
.num_xdivs = 10,
char *tmp;
for (i = 0; i < config->analog_channels; i++) {
- tmp = sr_voltage_string(config->vdivs[state->analog_channels[i].vdiv].p,
- config->vdivs[state->analog_channels[i].vdiv].q);
+ tmp = sr_voltage_string((*config->vdivs)[state->analog_channels[i].vdiv][0],
+ (*config->vdivs)[state->analog_channels[i].vdiv][1]);
sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)",
i + 1, state->analog_channels[i].state ? "On" : "Off",
(*config->coupling_options)[state->analog_channels[i].coupling],
tmp, state->analog_channels[i].vertical_offset);
}
- tmp = sr_period_string(config->timebases[state->timebase].p,
- config->timebases[state->timebase].q);
+ tmp = sr_period_string((*config->timebases)[state->timebase][0],
+ (*config->timebases)[state->timebase][1]);
sr_info("Current timebase: %s", tmp);
g_free(tmp);
*
* @return SR_ERR on any parsing error, SR_OK otherwise.
*/
-static int array_float_get(gchar *value, const struct sr_rational *aval,
+static int array_float_get(gchar *value, const uint64_t array[][2],
int array_len, unsigned int *result)
{
struct sr_rational rval;
+ struct sr_rational aval;
if (sr_parse_rational(value, &rval) != SR_OK)
return SR_ERR;
for (int i = 0; i < array_len; i++) {
- if (sr_rational_eq(&rval, aval + i)) {
+ sr_rational_set(&aval, array[i][0], array[i][1]);
+ if (sr_rational_eq(&rval, &aval)) {
*result = i;
return SR_OK;
}
const char *(*trigger_slopes)[];
const uint8_t num_trigger_slopes;
- const struct sr_rational *timebases;
+ const uint64_t (*timebases)[][2];
const uint8_t num_timebases;
- const struct sr_rational *vdivs;
+ const uint64_t (*vdivs)[][2];
const uint8_t num_vdivs;
const uint8_t num_xdivs;