]> sigrok.org Git - libsigrok.git/commitdiff
cem-dt-885x: Hold off measurements in max/min hold mode
authorBert Vermeulen <redacted>
Wed, 12 Jun 2013 13:45:37 +0000 (15:45 +0200)
committerBert Vermeulen <redacted>
Wed, 12 Jun 2013 16:34:42 +0000 (18:34 +0200)
hardware/cem-dt-885x/protocol.c
hardware/cem-dt-885x/protocol.h

index 8b09d3242eeec0bb58f775924522a356e6c37313..b727ada9c4f796c7087d02c1f0f7925cad59c1d3 100644 (file)
@@ -117,13 +117,26 @@ static void process_mset(const struct sr_dev_inst *sdi)
                fvalue += (devc->buf[0] & 0x0f) * 10;
                fvalue += ((devc->buf[1] & 0xf0) >> 4);
                fvalue += (devc->buf[1] & 0x0f) / 10.0;
+               devc->last_spl = fvalue;
+               break;
+       case TOKEN_MEAS_WAS_READOUT:
+       case TOKEN_MEAS_WAS_BARGRAPH:
+               if (devc->cur_mqflags & (SR_MQFLAG_MAX | SR_MQFLAG_MIN)) {
+                       if (devc->token == TOKEN_MEAS_WAS_BARGRAPH) {
+                               /* The device still sends bargraph measurements even
+                                * when in max/min hold mode. Suppress them here, unless
+                                * they're readout values. This duplicates the behavior
+                                * of the device display exactly. */
+                               break;
+                       }
+               }
                memset(&analog, 0, sizeof(struct sr_datafeed_analog));
                analog.mq = SR_MQ_SOUND_PRESSURE_LEVEL;
                analog.mqflags = devc->cur_mqflags;
                analog.unit = SR_UNIT_DECIBEL_SPL;
                analog.probes = sdi->probes;
                analog.num_samples = 1;
-               analog.data = &fvalue;
+               analog.data = &devc->last_spl;
                packet.type = SR_DF_ANALOG;
                packet.payload = &analog;
                sr_session_send(devc->cb_data, &packet);
@@ -138,8 +151,6 @@ static void process_mset(const struct sr_dev_inst *sdi)
        case TOKEN_STORE_FULL:
        case TOKEN_RECORDING_ON:
        case TOKEN_RECORDING_OFF:
-       case TOKEN_MEAS_WAS_READOUT:
-       case TOKEN_MEAS_WAS_BARGRAPH:
        case TOKEN_BATTERY_OK:
        case TOKEN_BATTERY_LOW:
        case TOKEN_MEAS_RANGE_OK:
index 7f296e83dc3cf4422c004ba4d24eb25d5569ca93..f3809fc27d37d53da25f20fb1f45375dc03d8d41 100644 (file)
@@ -79,6 +79,7 @@ struct dev_context {
        unsigned char token;
        int buf_len;
        unsigned char buf[BUF_SIZE];
+       float last_spl;
 
 };