]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: properly set encoding digits
authorAurelien Jacobs <redacted>
Fri, 19 Aug 2016 22:56:23 +0000 (00:56 +0200)
committerUwe Hermann <redacted>
Tue, 23 Aug 2016 10:58:05 +0000 (12:58 +0200)
src/hardware/rigol-ds/protocol.c

index 98570ff0d7e6e0208b24cadc826fbd4bebec91b8..df72307d411b3924e4d43361240a87034665168f 100644 (file)
@@ -672,7 +672,9 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                else
                        for (i = 0; i < len; i++)
                                devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset;
-               sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+               float vdivlog = log10f(vdiv);
+               int digits = -(int)vdivlog + (vdivlog < 0.0);
+               sr_analog_init(&analog, &encoding, &meaning, &spec, digits);
                analog.meaning->channels = g_slist_append(NULL, ch);
                analog.num_samples = len;
                analog.data = devc->data;