drivers: Factor out std_gvar_tuple_double().
This commit is contained in:
parent
a162eeb2e8
commit
43995cda36
|
@ -383,7 +383,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
GVariant *range[2];
|
|
||||||
unsigned int i, voltage_range;
|
unsigned int i, voltage_range;
|
||||||
char str[128];
|
char str[128];
|
||||||
|
|
||||||
|
@ -415,16 +414,11 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
voltage_range = i;
|
voltage_range = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*data = std_gvar_tuple_double(voltage_thresholds[voltage_range].low,
|
||||||
range[0] = g_variant_new_double(
|
|
||||||
voltage_thresholds[voltage_range].low);
|
|
||||||
range[1] = g_variant_new_double(
|
|
||||||
voltage_thresholds[voltage_range].high);
|
voltage_thresholds[voltage_range].high);
|
||||||
} else {
|
} else {
|
||||||
range[0] = g_variant_new_double(devc->cur_threshold);
|
*data = std_gvar_tuple_double(devc->cur_threshold, devc->cur_threshold);
|
||||||
range[1] = g_variant_new_double(devc->cur_threshold);
|
|
||||||
}
|
}
|
||||||
*data = g_variant_new_tuple(range, 2);
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
*data = g_variant_new_uint64(devc->limit_samples);
|
*data = g_variant_new_uint64(devc->limit_samples);
|
||||||
|
|
|
@ -400,7 +400,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
GVariant *range[2];
|
|
||||||
char str[128];
|
char str[128];
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -441,9 +440,7 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
if (devc->selected_voltage_range !=
|
if (devc->selected_voltage_range !=
|
||||||
volt_thresholds[i].range)
|
volt_thresholds[i].range)
|
||||||
continue;
|
continue;
|
||||||
range[0] = g_variant_new_double(volt_thresholds[i].low);
|
*data = std_gvar_tuple_double(volt_thresholds[i].low, volt_thresholds[i].high);
|
||||||
range[1] = g_variant_new_double(volt_thresholds[i].high);
|
|
||||||
*data = g_variant_new_tuple(range, 2);
|
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,6 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *range[2];
|
|
||||||
|
|
||||||
(void)cg;
|
(void)cg;
|
||||||
|
|
||||||
|
@ -348,9 +347,7 @@ static int config_get(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_new_uint64(devc->capture_ratio);
|
*data = g_variant_new_uint64(devc->capture_ratio);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
range[0] = g_variant_new_double(devc->cur_threshold);
|
*data = std_gvar_tuple_double(devc->cur_threshold, devc->cur_threshold);
|
||||||
range[1] = g_variant_new_double(devc->cur_threshold);
|
|
||||||
*data = g_variant_new_tuple(range, 2);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -965,6 +965,7 @@ SR_PRIV GVariant *std_gvar_min_max_step_array(const double a[3]);
|
||||||
SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double dmin, const double dmax, const double dstep);
|
SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double dmin, const double dmax, const double dstep);
|
||||||
|
|
||||||
SR_PRIV GVariant *std_gvar_tuple_u64(uint64_t low, uint64_t high);
|
SR_PRIV GVariant *std_gvar_tuple_u64(uint64_t low, uint64_t high);
|
||||||
|
SR_PRIV GVariant *std_gvar_tuple_double(double low, double high);
|
||||||
|
|
||||||
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n);
|
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n);
|
||||||
SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n);
|
SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n);
|
||||||
|
|
10
src/std.c
10
src/std.c
|
@ -657,6 +657,16 @@ SR_PRIV GVariant *std_gvar_tuple_u64(uint64_t low, uint64_t high)
|
||||||
return g_variant_new_tuple(range, 2);
|
return g_variant_new_tuple(range, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SR_PRIV GVariant *std_gvar_tuple_double(double low, double high)
|
||||||
|
{
|
||||||
|
GVariant *range[2];
|
||||||
|
|
||||||
|
range[0] = g_variant_new_double(low);
|
||||||
|
range[1] = g_variant_new_double(high);
|
||||||
|
|
||||||
|
return g_variant_new_tuple(range, 2);
|
||||||
|
}
|
||||||
|
|
||||||
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n)
|
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n)
|
||||||
{
|
{
|
||||||
return g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
return g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
|
Loading…
Reference in New Issue