X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhung-chang-dso-2100%2Fprotocol.c;h=69efb14d3c332b125334490b4ebc901ed25794be;hb=ebcd1aba011ba6e1082e96be3cd7e47374a516b4;hp=88c47e0ae811a938101570af66774eef18fe66df;hpb=99f8fa25194aca21ec400353902e90eb425bd620;p=libsigrok.git diff --git a/src/hardware/hung-chang-dso-2100/protocol.c b/src/hardware/hung-chang-dso-2100/protocol.c index 88c47e0a..69efb14d 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" @@ -78,11 +79,11 @@ * trigger on (rising or falling) * The next state is 0x0C * 0x0C Same as state 0x0F but expects the calibration - * value for the first channel's position + * value for the first channel's position * (POS1 in the schematics) * The next state is 0x0D * 0x0D Same as state 0x0F but expects the calibration - * value for the second channel's position + * value for the second channel's position * (POS2 in the schematics) * The next state is 0x0E * 0x0E Same as state 0x0F but expects the trigger level @@ -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; @@ -416,7 +420,7 @@ static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf) SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data) { struct sr_datafeed_packet packet = { .type = SR_DF_FRAME_BEGIN }; - const struct sr_dev_inst *sdi; + struct sr_dev_inst *sdi; struct dev_context *devc; uint8_t state, buf[1000]; @@ -460,7 +464,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data) sr_session_send(sdi, &packet); if (++devc->frame >= devc->frame_limit) - hung_chang_dso_2100_dev_acquisition_stop(sdi); + sr_dev_acquisition_stop(sdi); else hung_chang_dso_2100_move_to(sdi, 0x21);