]> sigrok.org Git - libsigrok.git/commitdiff
global: Treat SR_CONF_OUTPUT_FREQUENCY as float instead of uint64_t
authorAlexandru Gagniuc <redacted>
Wed, 29 Apr 2015 23:58:24 +0000 (16:58 -0700)
committerAlexandru Gagniuc <redacted>
Wed, 6 May 2015 17:25:16 +0000 (10:25 -0700)
This makes 'output_frequency' symmetrical with 'output_current' and
'output_voltage'. On a more fundamental level, there's no reason why
frequency should be treated as a discrete quantity, other than
"es51919 used it this way".

src/hwdriver.c
src/lcr/es51919.c

index ec0c706e97279ee431d516b9a19d4ba81d9d412d..c6c5645659e44a50d81c230f0b1dcc70a97722a0 100644 (file)
@@ -157,7 +157,7 @@ static struct sr_config_info sr_config_info_data[] = {
                "Output channel regulation", NULL},
        {SR_CONF_OVER_TEMPERATURE_PROTECTION, SR_T_BOOL, "otp",
                "Over-temperature protection", NULL},
-       {SR_CONF_OUTPUT_FREQUENCY, SR_T_UINT64, "output_frequency",
+       {SR_CONF_OUTPUT_FREQUENCY, SR_T_FLOAT, "output_frequency",
                "Output frequency", NULL},
        {SR_CONF_MEASURED_QUANTITY, SR_T_STRING, "measured_quantity",
                "Measured quantity", NULL},
index d7290c76dafcec6a191be7fe75a37010a179f37c..06d05d0ff22e2fec3357c16904fedf6bedf0d05c 100644 (file)
@@ -402,7 +402,7 @@ static int send_config_update_key(struct sr_dev_inst *sdi, uint32_t key,
 
 #define PACKET_SIZE 17
 
-static const uint64_t frequencies[] = {
+static const double frequencies[] = {
        100, 120, 1000, 10000, 100000, 0,
 };
 
@@ -636,7 +636,7 @@ static int do_config_update(struct sr_dev_inst *sdi, uint32_t key,
 static int send_freq_update(struct sr_dev_inst *sdi, unsigned int freq)
 {
        return do_config_update(sdi, SR_CONF_OUTPUT_FREQUENCY,
-                               g_variant_new_uint64(frequencies[freq]));
+                               g_variant_new_double(frequencies[freq]));
 }
 
 static int send_quant1_update(struct sr_dev_inst *sdi, unsigned int quant)
@@ -877,7 +877,7 @@ SR_PRIV int es51919_serial_config_get(uint32_t key, GVariant **data,
 
        switch (key) {
        case SR_CONF_OUTPUT_FREQUENCY:
-               *data = g_variant_new_uint64(frequencies[devc->freq]);
+               *data = g_variant_new_double(frequencies[devc->freq]);
                break;
        case SR_CONF_MEASURED_QUANTITY:
                *data = g_variant_new_string(quantities1[devc->quant1]);
@@ -960,8 +960,8 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
 
        switch (key) {
        case SR_CONF_OUTPUT_FREQUENCY:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
-                       frequencies, ARRAY_SIZE(frequencies), sizeof(uint64_t));
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_DOUBLE,
+                       frequencies, ARRAY_SIZE(frequencies), sizeof(double));
                break;
        case SR_CONF_MEASURED_QUANTITY:
                *data = g_variant_new_strv(list_quantities1,