From: Aurelien Jacobs Date: Tue, 23 Aug 2016 23:18:58 +0000 (+0200) Subject: hung-chang-dso-2100: properly set encoding digits X-Git-Tag: libsigrok-0.5.0~240 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=545101338ac4b283278f3922081428bc81a58810;p=libsigrok.git hung-chang-dso-2100: properly set encoding digits --- diff --git a/src/hardware/hung-chang-dso-2100/protocol.c b/src/hardware/hung-chang-dso-2100/protocol.c index 88c47e0a..cfe84f41 100644 --- a/src/hardware/hung-chang-dso-2100/protocol.c +++ b/src/hardware/hung-chang-dso-2100/protocol.c @@ -18,6 +18,7 @@ */ #include +#include #include #include "protocol.h" @@ -344,7 +345,10 @@ static void push_samples(const struct sr_dev_inst *sdi, uint8_t *buf, size_t num while (num--) data[num] = (buf[num] - 0x80) * factor; - sr_analog_init(&analog, &encoding, &meaning, &spec, 0); + float vdivlog = log10f(factor); + int digits = -(int)vdivlog + (vdivlog < 0.0); + + sr_analog_init(&analog, &encoding, &meaning, &spec, digits); analog.meaning->channels = devc->enabled_channel; analog.meaning->mq = SR_MQ_VOLTAGE; analog.meaning->unit = SR_UNIT_VOLT;